From 79078ac472177205ceaf3400e29f5dc902c2f76b Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Tue, 28 Jul 2020 19:02:17 +0700 Subject: [PATCH] compute: Fix bug missing Security Group in Advanced Zone with SG enabled (#558) * Fix bug missing Security Group in Advanced Zone 1. Add a new step security group in a zone with SG enabled. 2. Fix error of displaying sshKeypair data incorrectly * remove `this.hypervisor!=='KVM'` condition. Signed-off-by: Rohit Yadav --- ui/src/views/compute/DeployVM.vue | 39 ++-- .../compute/wizard/SecurityGroupSelection.vue | 198 ++++++++++++++++++ .../compute/wizard/SshKeyPairSelection.vue | 42 ++-- 3 files changed, 243 insertions(+), 36 deletions(-) create mode 100644 ui/src/views/compute/wizard/SecurityGroupSelection.vue diff --git a/ui/src/views/compute/DeployVM.vue b/ui/src/views/compute/DeployVM.vue index 903cb6325b1..429de693a12 100644 --- a/ui/src/views/compute/DeployVM.vue +++ b/ui/src/views/compute/DeployVM.vue @@ -237,6 +237,19 @@ + + + @@ -448,6 +461,7 @@ import AffinityGroupSelection from '@views/compute/wizard/AffinityGroupSelection import NetworkSelection from '@views/compute/wizard/NetworkSelection' import NetworkConfiguration from '@views/compute/wizard/NetworkConfiguration' import SshKeyPairSelection from '@views/compute/wizard/SshKeyPairSelection' +import SecurityGroupSelection from '@views/compute/wizard/SecurityGroupSelection' export default { name: 'Wizard', @@ -461,7 +475,8 @@ export default { DiskOfferingSelection, InfoCard, ComputeOfferingSelection, - ComputeSelection + ComputeSelection, + SecurityGroupSelection }, props: { visible: { @@ -556,16 +571,6 @@ export default { 'selfexecutable', 'sharedexecutable' ], - steps: { - BASIC: 0, - TEMPLATE_ISO: 1, - COMPUTE: 2, - DISK_OFFERING: 3, - AFFINITY_GROUP: 4, - NETWORK: 5, - SSH_KEY_PAIR: 6, - ENABLE_SETUP: 7 - }, initDataConfig: {}, defaultNetwork: '', networkConfig: [], @@ -583,7 +588,8 @@ export default { tabKey: 'templateid', dataPreFill: {}, showDetails: false, - showRootDiskSizeChanger: false + showRootDiskSizeChanger: false, + securitygroupids: [] } }, computed: { @@ -774,6 +780,9 @@ export default { }, networkName () { return this.$route.query.name || null + }, + showSecurityGroupSection () { + return this.networks.length > 0 && this.zone.securitygroupsenabled } }, watch: { @@ -1060,6 +1069,9 @@ export default { keypair: name }) }, + updateSecurityGroups (securitygroupids) { + this.securitygroupids = securitygroupids + }, getText (option) { return _.get(option, 'displaytext', _.get(option, 'name')) }, @@ -1162,6 +1174,9 @@ export default { } } } + if (this.securitygroupids.length > 0) { + deployVmData.securitygroupids = this.securitygroupids.join(',') + } // step 7: select ssh key pair deployVmData.keypair = values.keypair deployVmData.name = values.name diff --git a/ui/src/views/compute/wizard/SecurityGroupSelection.vue b/ui/src/views/compute/wizard/SecurityGroupSelection.vue new file mode 100644 index 00000000000..0de773856f9 --- /dev/null +++ b/ui/src/views/compute/wizard/SecurityGroupSelection.vue @@ -0,0 +1,198 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + + + + diff --git a/ui/src/views/compute/wizard/SshKeyPairSelection.vue b/ui/src/views/compute/wizard/SshKeyPairSelection.vue index cd5e29ec21c..8f27a524be6 100644 --- a/ui/src/views/compute/wizard/SshKeyPairSelection.vue +++ b/ui/src/views/compute/wizard/SshKeyPairSelection.vue @@ -112,19 +112,29 @@ export default { } } }, - created () { - this.initDataItem() - }, computed: { tableSource () { - return this.dataItems.map((item) => { - return { + const dataItems = [] + + if (this.options.page === 1) { + dataItems.push({ + key: this.$t('label.noselect'), + name: this.$t('label.noselect'), + account: '-', + domain: '-' + }) + } + + this.items.map((item) => { + dataItems.push({ key: item.name, name: item.name, account: item.account, domain: item.domain - } + }) }) + + return dataItems }, rowSelection () { return { @@ -140,12 +150,6 @@ export default { this.selectedRowKeys = [newValue] } }, - items (newData, oldData) { - if (newData && newData.length > 0) { - this.initDataItem() - this.dataItems = this.dataItems.concat(newData) - } - }, loading () { if (!this.loading) { if (this.preFillContent.keypair) { @@ -156,23 +160,13 @@ export default { return } this.oldZoneId = this.zoneId - this.selectedRowKeys = [this.dataItems[0].name] - this.$emit('select-ssh-key-pair-item', this.dataItems[0].name) + this.selectedRowKeys = [this.$t('label.noselect')] + this.$emit('select-ssh-key-pair-item', this.$t('label.noselect')) } } } }, methods: { - initDataItem () { - this.dataItems = [] - if (this.options.page === 1) { - this.dataItems.push({ - name: this.$t('label.noselect'), - account: '-', - domain: '-' - }) - } - }, onSelectRow (value) { this.selectedRowKeys = value this.$emit('select-ssh-key-pair-item', value[0])