diff --git a/ui/src/components/view/DetailsTab.vue b/ui/src/components/view/DetailsTab.vue index 9800448b7977..2554ad233b89 100644 --- a/ui/src/components/view/DetailsTab.vue +++ b/ui/src/components/view/DetailsTab.vue @@ -49,6 +49,13 @@
{{ dataResource[item]? $t('message.egress.rules.allow') : $t('message.egress.rules.deny') }}
+
+
+ + {{ securityGroup.name }}   + +
+
{{ dataResource[item] }}
diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js index 955383b8d7c2..350c00d94927 100644 --- a/ui/src/config/section/compute.js +++ b/ui/src/config/section/compute.js @@ -67,7 +67,15 @@ export default { return fields }, searchFilters: ['name', 'zoneid', 'domainid', 'account', 'tags'], - details: ['displayname', 'name', 'id', 'state', 'ipaddress', 'ip6address', 'templatename', 'ostypename', 'serviceofferingname', 'isdynamicallyscalable', 'haenable', 'hypervisor', 'boottype', 'bootmode', 'account', 'domain', 'zonename'], + details: () => { + var fields = ['displayname', 'name', 'id', 'state', 'ipaddress', 'ip6address', 'templatename', 'ostypename', 'serviceofferingname', 'isdynamicallyscalable', 'haenable', 'hypervisor', 'boottype', 'bootmode', 'account', 'domain', 'zonename'] + const listZoneHaveSGEnabled = store.getters.zones.filter(zone => zone.securitygroupsenabled === true) + if (!listZoneHaveSGEnabled || listZoneHaveSGEnabled.length === 0) { + return fields + } + fields.push('securitygroup') + return fields + }, tabs: [{ component: shallowRef(defineAsyncComponent(() => import('@/views/compute/InstanceTab.vue'))) }], diff --git a/ui/src/views/compute/EditVM.vue b/ui/src/views/compute/EditVM.vue index ffd13e2459c1..87545c7e11c3 100644 --- a/ui/src/views/compute/EditVM.vue +++ b/ui/src/views/compute/EditVM.vue @@ -91,6 +91,25 @@ + + + +
+ {{ securitygroup.name || securitygroup.id }} +
+
+
+
{{ $t('label.cancel') }} @@ -124,8 +143,13 @@ export default { return { serviceOffering: {}, template: {}, + securityGroupsEnabled: false, dynamicScalingVmConfig: false, loading: false, + securitygroups: { + loading: false, + opts: [] + }, osTypes: { loading: false, opts: [] @@ -151,17 +175,48 @@ export default { displayname: this.resource.displayname, ostypeid: this.resource.ostypeid, isdynamicallyscalable: this.resource.isdynamicallyscalable, - group: this.resource.group + group: this.resource.group, + securitygroupids: this.resource.securitygroup.map(x => x.id) }) this.rules = reactive({}) }, fetchData () { + this.fetchZoneDetails() + this.fetchSecurityGroups() this.fetchOsTypes() this.fetchInstaceGroups() this.fetchServiceOfferingData() this.fetchTemplateData() this.fetchDynamicScalingVmConfig() }, + fetchZoneDetails () { + api('listZones', { + zoneid: this.resource.zoneid + }).then(response => { + const zone = response?.listzonesresponse?.zone || [] + this.securityGroupsEnabled = zone?.[0]?.securitygroupsenabled + }) + }, + fetchSecurityGroups () { + this.securitygroups.loading = true + api('listSecurityGroups', { + zoneid: this.resource.zoneid + }).then(json => { + const items = json.listsecuritygroupsresponse.securitygroup || [] + if (items && items.length > 0) { + for (let i = 0; i < items.length; i++) { + this.securitygroups.opts.push(items[i]) + } + this.securitygroups.opts.sort((a, b) => { + if (a.name < b.name) return -1 + if (a.name > b.name) return 1 + return 0 + }) + } + }).finally(() => { + this.securitygroups.loading = false + }) + }, fetchServiceOfferingData () { const params = {} params.id = this.resource.serviceofferingid @@ -242,6 +297,11 @@ export default { params.name = values.name params.displayname = values.displayname params.ostypeid = values.ostypeid + if (this.securityGroupsEnabled) { + if (values.securitygroupids) { + params.securitygroupids = values.securitygroupids + } + } if (values.isdynamicallyscalable !== undefined) { params.isdynamicallyscalable = values.isdynamicallyscalable }