mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-17 07:16:46 +00:00
feat: 云管同步增加Azure模块 (#488)
* feat: 云管同步增加Azure模块 Co-authored-by: Orange <orangemtony@gmail.com>
This commit is contained in:
@@ -958,6 +958,12 @@
|
||||
"Username": "用户名"
|
||||
},
|
||||
"Cloud": {
|
||||
"Aliyun": "阿里云",
|
||||
"Qcloud": "腾讯云",
|
||||
"AWS_China": "AWS(中国)",
|
||||
"AWS_Int": "AWS(国际)",
|
||||
"HuaweiCloud": "华为云",
|
||||
"Azure":"Azure(中国)",
|
||||
"HostnameStrategy": "用于生成资产主机名。例如:1. 实例名称 (instanceDemo);2. 实例名称和部分IP(后两位) (instanceDemo-250.1)",
|
||||
"IsAlwaysUpdate": "资产信息保持最新",
|
||||
"AccountCreate": "创建账户",
|
||||
|
||||
@@ -945,6 +945,12 @@
|
||||
"Username": "Username"
|
||||
},
|
||||
"Cloud": {
|
||||
"Aliyun": "Ali Cloud",
|
||||
"Qcloud": "Tencent Cloud",
|
||||
"AWS_China": "AWS(China)",
|
||||
"AWS_Int": "AWS(International)",
|
||||
"HuaweiCloud": "Huawei Cloud",
|
||||
"Azure":"Azure(China)",
|
||||
"HostnameStrategy": "Used to produce the asset hostname. For example, 1. Instance name (instanceDemo);2. Instance name and Partial IP (instanceDemo-250.1)",
|
||||
"IsAlwaysUpdate": "Asset info is kept up-to-date",
|
||||
"AccountCreate": "Create account",
|
||||
|
||||
@@ -41,7 +41,6 @@ export default {
|
||||
url: '/api/v1/applications/applications/',
|
||||
getUrl() {
|
||||
const params = this.$route.params
|
||||
console.log(params)
|
||||
let url = `/api/v1/applications/applications/`
|
||||
const method = this.getMethod()
|
||||
if (params.id) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<GenericCreateUpdatePage v-bind="$data" />
|
||||
<GenericCreateUpdatePage v-bind="$data" :initial="initial" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -22,7 +22,10 @@ export default {
|
||||
url: '/api/v1/xpack/cloud/accounts/',
|
||||
fieldsMeta: {
|
||||
provider: {
|
||||
rules: [Required]
|
||||
rules: [Required],
|
||||
el: {
|
||||
disabled: true
|
||||
}
|
||||
},
|
||||
access_key_id: {
|
||||
rules: [
|
||||
@@ -41,6 +44,11 @@ export default {
|
||||
updateSuccessNextRoute: { name: 'CloudCenter' },
|
||||
createSuccessNextRoute: { name: 'CloudCenter' }
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
initial() {
|
||||
return this.$route.query
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ export default {
|
||||
ListTable
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
tableConfig: {
|
||||
url: '/api/v1/xpack/cloud/accounts/',
|
||||
@@ -32,7 +33,14 @@ export default {
|
||||
},
|
||||
actions: {
|
||||
formatterArgs: {
|
||||
updateRoute: 'AccountUpdate'
|
||||
updateRoute: 'AccountUpdate',
|
||||
onUpdate: ({ row, col }) => {
|
||||
if (row.provider === 'azure') {
|
||||
vm.$router.push({ name: 'AzureAccountUpdate', params: { id: row.id }})
|
||||
} else {
|
||||
vm.$router.push({ name: 'AccountUpdate', params: { id: row.id }})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
validity: {
|
||||
@@ -51,9 +59,71 @@ export default {
|
||||
headerActions: {
|
||||
hasBulkDelete: false,
|
||||
hasImport: false,
|
||||
createRoute: 'AccountCreate'
|
||||
hasCreate: false,
|
||||
moreActionsTitle: this.$t('common.Create'),
|
||||
moreActionsType: 'primary',
|
||||
extraMoreActions: [
|
||||
{
|
||||
name: 'aliyun',
|
||||
title: this.$t('xpack.Cloud.Aliyun'),
|
||||
type: 'primary',
|
||||
can: true,
|
||||
callback: this.createAliyun.bind(this)
|
||||
}, {
|
||||
name: 'qcloud',
|
||||
title: this.$t('xpack.Cloud.Qcloud'),
|
||||
type: 'primary',
|
||||
can: true,
|
||||
callback: this.createQcloud.bind(this)
|
||||
}, {
|
||||
name: 'AWS_China',
|
||||
title: this.$t('xpack.Cloud.AWS_China'),
|
||||
type: 'primary',
|
||||
can: true,
|
||||
callback: this.createAwsChina.bind(this)
|
||||
},
|
||||
{
|
||||
name: 'AWS_Int',
|
||||
title: this.$t('xpack.Cloud.AWS_Int'),
|
||||
type: 'primary',
|
||||
can: true,
|
||||
callback: this.createAwsInt.bind(this)
|
||||
}, {
|
||||
name: 'HuaweiCloud',
|
||||
title: this.$t('xpack.Cloud.HuaweiCloud'),
|
||||
type: 'primary',
|
||||
can: true,
|
||||
callback: this.createhuawei.bind(this)
|
||||
}, {
|
||||
name: 'Azure',
|
||||
title: this.$t('xpack.Cloud.Azure'),
|
||||
type: 'primary',
|
||||
can: true,
|
||||
callback: this.createAzure.bind(this)
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
createAzure() {
|
||||
this.$router.push({ name: 'AzureAccountCreate', query: { provider: 'azure' }})
|
||||
},
|
||||
createAliyun() {
|
||||
this.$router.push({ name: 'AccountCreate', query: { provider: 'aliyun' }})
|
||||
},
|
||||
createQcloud() {
|
||||
this.$router.push({ name: 'AccountCreate', query: { provider: 'qcloud' }})
|
||||
},
|
||||
createAwsChina() {
|
||||
this.$router.push({ name: 'AccountCreate', query: { provider: 'aws_china' }})
|
||||
},
|
||||
createAwsInt() {
|
||||
this.$router.push({ name: 'AccountCreate', query: { provider: 'aws_international' }})
|
||||
},
|
||||
createhuawei() {
|
||||
this.$router.push({ name: 'AccountCreate', query: { provider: 'huaweicloud' }})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
88
src/views/xpack/Cloud/Account/AzureAccountCreateUpdate.vue
Normal file
88
src/views/xpack/Cloud/Account/AzureAccountCreateUpdate.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<GenericCreateUpdatePage v-bind="$data" :initial="initial" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { GenericCreateUpdatePage } from '@/layout/components'
|
||||
import { Required } from '@/components/DataForm/rules'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
GenericCreateUpdatePage
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fields: [
|
||||
[
|
||||
'', [
|
||||
'name', 'provider', 'access_key_id', 'access_key_secret', 'attrs', 'comment'
|
||||
]
|
||||
]
|
||||
],
|
||||
url: '/api/v1/xpack/cloud/accounts/',
|
||||
fieldsMeta: {
|
||||
provider: {
|
||||
rules: [Required],
|
||||
el: {
|
||||
disabled: true
|
||||
}
|
||||
},
|
||||
access_key_id: {
|
||||
rules: [
|
||||
{ required: this.$route.meta.action === 'create', message: this.$t('common.fieldRequiredError') }
|
||||
]
|
||||
},
|
||||
access_key_secret: {
|
||||
el: {
|
||||
showPassword: true
|
||||
},
|
||||
rules: [
|
||||
{ required: this.$route.meta.action === 'create', message: this.$t('common.fieldRequiredError') }
|
||||
]
|
||||
}
|
||||
},
|
||||
updateSuccessNextRoute: { name: 'CloudCenter' },
|
||||
createSuccessNextRoute: { name: 'CloudCenter' },
|
||||
performSubmit(validValues) {
|
||||
const params = this.$route.params
|
||||
const baseUrl = `/api/v1/xpack/cloud/accounts/`
|
||||
const url = (params.id) ? `${baseUrl}${params.id}/` : baseUrl
|
||||
const method = this.getMethod()
|
||||
validValues.attrs = {
|
||||
subscription_id: validValues.subscription_id,
|
||||
tenant_id: validValues.tenant_id
|
||||
}
|
||||
return this.$axios[method](`${url}?provider=${validValues.provider}`, validValues)
|
||||
},
|
||||
getUrl() {
|
||||
const params = this.$route.params
|
||||
let url = `/api/v1/xpack/cloud/accounts/`
|
||||
const method = this.getMethod()
|
||||
if (params.id) {
|
||||
url = `${url}${params.id}/`
|
||||
}
|
||||
return method === 'post' ? `${url}?provider=${this.$route.query.provider}` : `${url}?provider=azure`
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
initial() {
|
||||
return this.$route.query
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getMethod() {
|
||||
const params = this.$route.params
|
||||
if (params.id) {
|
||||
return 'put'
|
||||
} else {
|
||||
return 'post'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
@@ -83,6 +83,19 @@ export default {
|
||||
name: 'AccountUpdate',
|
||||
hidden: true,
|
||||
meta: { title: i18n.t('xpack.Cloud.AccountUpdate'), action: 'update', activeMenu: '/xpack/cloud' }
|
||||
}, {
|
||||
path: 'azure/account/create',
|
||||
component: () => import('@/views/xpack/Cloud/Account/AzureAccountCreateUpdate'),
|
||||
name: 'AzureAccountCreate',
|
||||
hidden: true,
|
||||
meta: { title: i18n.t('xpack.Cloud.AccountCreate'), action: 'create', activeMenu: '/xpack/cloud' }
|
||||
},
|
||||
{
|
||||
path: 'azure/account/:id/update',
|
||||
component: () => import('@/views/xpack/Cloud/Account/AzureAccountCreateUpdate'),
|
||||
name: 'AzureAccountUpdate',
|
||||
hidden: true,
|
||||
meta: { title: i18n.t('xpack.Cloud.AccountUpdate'), action: 'update', activeMenu: '/xpack/cloud' }
|
||||
},
|
||||
{
|
||||
path: 'accounts/:id/',
|
||||
|
||||
Reference in New Issue
Block a user