Skip to content

Commit 34e4376

Browse files
authored
ui: fix persist networks config in deploy vm form (#6994)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 889045f commit 34e4376

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

ui/src/views/compute/DeployVM.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,12 +1337,9 @@ export default {
13371337
}
13381338
this.zone = _.find(this.options.zones, (option) => option.id === instanceConfig.zoneid)
13391339
this.affinityGroups = _.filter(this.options.affinityGroups, (option) => _.includes(instanceConfig.affinitygroupids, option.id))
1340-
this.networks = _.filter(this.options.networks, (option) => _.includes(instanceConfig.networkids, option.id))
1340+
this.networks = this.getSelectedNetworksWithExistingConfig(_.filter(this.options.networks, (option) => _.includes(instanceConfig.networkids, option.id)))
13411341
13421342
this.diskOffering = _.find(this.options.diskOfferings, (option) => option.id === instanceConfig.diskofferingid)
1343-
this.zone = _.find(this.options.zones, (option) => option.id === instanceConfig.zoneid)
1344-
this.affinityGroups = _.filter(this.options.affinityGroups, (option) => _.includes(instanceConfig.affinitygroupids, option.id))
1345-
this.networks = _.filter(this.options.networks, (option) => _.includes(instanceConfig.networkids, option.id))
13461343
this.sshKeyPair = _.find(this.options.sshKeyPairs, (option) => option.name === instanceConfig.keypair)
13471344
13481345
if (this.zone) {
@@ -2594,6 +2591,19 @@ export default {
25942591
},
25952592
handleNicsNetworkSelection (nicToNetworkSelection) {
25962593
this.nicToNetworkSelection = nicToNetworkSelection
2594+
},
2595+
getSelectedNetworksWithExistingConfig (networks) {
2596+
for (var i in this.networks) {
2597+
var n = this.networks[i]
2598+
for (var c of this.networkConfig) {
2599+
if (n.id === c.key) {
2600+
n = { ...n, ...c }
2601+
networks[i] = n
2602+
break
2603+
}
2604+
}
2605+
}
2606+
return networks
25972607
}
25982608
}
25992609
}

ui/src/views/compute/wizard/NetworkConfiguration.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,20 @@ export default {
172172
const rules = {}
173173
174174
this.dataItems.forEach(record => {
175-
rules['ipAddress' + record.id] = [{
175+
const ipAddressKey = 'ipAddress' + record.id
176+
const macAddressKey = 'macAddress' + record.id
177+
rules[ipAddressKey] = [{
176178
validator: this.validatorIpAddress,
177179
cidr: record.cidr,
178180
networkType: record.type
179181
}]
180-
rules['macAddress' + record.id] = [{ validator: this.validatorMacAddress }]
182+
if (record.ipAddress) {
183+
form[ipAddressKey] = record.ipAddress
184+
}
185+
rules[macAddressKey] = [{ validator: this.validatorMacAddress }]
186+
if (record.macAddress) {
187+
form[macAddressKey] = record.macAddress
188+
}
181189
})
182190
this.form = reactive(form)
183191
this.rules = reactive(rules)
@@ -201,7 +209,7 @@ export default {
201209
202210
this.networks.filter((item, index) => {
203211
if (item.key === key) {
204-
this.networks[index].name = value
212+
this.networks[index][name] = value
205213
}
206214
})
207215
this.$emit('update-network-config', this.networks)

0 commit comments

Comments
 (0)