ui: fix persist networks config in deploy vm form (#6994)

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
Abhishek Kumar 2022-12-20 20:54:23 +05:30 committed by GitHub
parent 889045fba5
commit 34e4376c16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View File

@ -1337,12 +1337,9 @@ export default {
}
this.zone = _.find(this.options.zones, (option) => option.id === instanceConfig.zoneid)
this.affinityGroups = _.filter(this.options.affinityGroups, (option) => _.includes(instanceConfig.affinitygroupids, option.id))
this.networks = _.filter(this.options.networks, (option) => _.includes(instanceConfig.networkids, option.id))
this.networks = this.getSelectedNetworksWithExistingConfig(_.filter(this.options.networks, (option) => _.includes(instanceConfig.networkids, option.id)))
this.diskOffering = _.find(this.options.diskOfferings, (option) => option.id === instanceConfig.diskofferingid)
this.zone = _.find(this.options.zones, (option) => option.id === instanceConfig.zoneid)
this.affinityGroups = _.filter(this.options.affinityGroups, (option) => _.includes(instanceConfig.affinitygroupids, option.id))
this.networks = _.filter(this.options.networks, (option) => _.includes(instanceConfig.networkids, option.id))
this.sshKeyPair = _.find(this.options.sshKeyPairs, (option) => option.name === instanceConfig.keypair)
if (this.zone) {
@ -2594,6 +2591,19 @@ export default {
},
handleNicsNetworkSelection (nicToNetworkSelection) {
this.nicToNetworkSelection = nicToNetworkSelection
},
getSelectedNetworksWithExistingConfig (networks) {
for (var i in this.networks) {
var n = this.networks[i]
for (var c of this.networkConfig) {
if (n.id === c.key) {
n = { ...n, ...c }
networks[i] = n
break
}
}
}
return networks
}
}
}

View File

@ -172,12 +172,20 @@ export default {
const rules = {}
this.dataItems.forEach(record => {
rules['ipAddress' + record.id] = [{
const ipAddressKey = 'ipAddress' + record.id
const macAddressKey = 'macAddress' + record.id
rules[ipAddressKey] = [{
validator: this.validatorIpAddress,
cidr: record.cidr,
networkType: record.type
}]
rules['macAddress' + record.id] = [{ validator: this.validatorMacAddress }]
if (record.ipAddress) {
form[ipAddressKey] = record.ipAddress
}
rules[macAddressKey] = [{ validator: this.validatorMacAddress }]
if (record.macAddress) {
form[macAddressKey] = record.macAddress
}
})
this.form = reactive(form)
this.rules = reactive(rules)
@ -201,7 +209,7 @@ export default {
this.networks.filter((item, index) => {
if (item.key === key) {
this.networks[index].name = value
this.networks[index][name] = value
}
})
this.$emit('update-network-config', this.networks)