Skip to content

Commit d8cd122

Browse files
authored
zone wizard: allow only one untagged physical network with guest traffic type (#8625)
1 parent 393f3d7 commit d8cd122

File tree

3 files changed

+56
-15
lines changed

3 files changed

+56
-15
lines changed

ui/public/locales/en.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,7 +2845,8 @@
28452845
"message.remove.vpc": "Please confirm that you want to remove the VPC",
28462846
"message.request.failed": "Request failed.",
28472847
"message.required.add.least.ip": "Please add at least 1 IP Range",
2848-
"message.required.traffic.type": "Error in configuration! All required traffic types should be added and with multiple physical networks each network should have a label.",
2848+
"message.required.traffic.type": "All required traffic types should be added and with multiple physical networks each network should have a label.",
2849+
"message.required.tagged.physical.network": "There can only be one untagged physical network with guest traffic type.",
28492850
"message.reset.vpn.connection": "Please confirm that you want to reset VPN connection.",
28502851
"message.resize.volume.failed": "Failed to resize volume.",
28512852
"message.resize.volume.processing": "Volume resize is in progress",
@@ -2881,7 +2882,7 @@
28812882
"message.set.default.nic": "Please confirm that you would like to make this NIC the default for this VM.",
28822883
"message.set.default.nic.manual": "Please manually update the default NIC on the VM now.",
28832884
"message.setting.updated": "Setting Updated:",
2884-
"message.setup.physical.network.during.zone.creation": "When adding a zone, you need to set up one or more physical networks. Each network corresponds to a NIC on the hypervisor. Each physical network can carry one or more types of traffic, with certain restrictions on how they may be combined. Add or remove one or more traffic types onto each physical network.",
2885+
"message.setup.physical.network.during.zone.creation": "When adding a zone, you need to set up one or more physical networks. Each physical network can carry one or more types of traffic, with certain restrictions on how they may be combined. Add or remove one or more traffic types onto each physical network.",
28852886
"message.setup.physical.network.during.zone.creation.basic": "When adding a basic zone, you can set up one physical network, which corresponds to a NIC on the hypervisor. The network carries several types of traffic.<br/><br/>You may also <strong>add</strong> other traffic types onto the physical network.",
28862887
"message.shared.network.offering.warning": "Domain admins and regular users can only create shared networks from network offering with the setting specifyvlan=false. Please contact an administrator to create a network offering if this list is empty.",
28872888
"message.specify.tag.key": "Please specify a tag key.",

ui/src/views/infra/zone/ZoneWizardLaunchZone.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ export default {
466466
if (physicalNetwork.isolationMethod) {
467467
params.isolationmethods = physicalNetwork.isolationMethod
468468
}
469+
if (physicalNetwork.tags) {
470+
params.tags = physicalNetwork.tags
471+
}
469472
470473
try {
471474
if (!this.stepData.stepMove.includes('createPhysicalNetwork' + index)) {

ui/src/views/infra/zone/ZoneWizardPhysicalNetworkSetupStep.vue

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,17 @@
7777
</template>
7878
<template #traffics="{ record, index }">
7979
<div v-for="traffic in record.traffics" :key="traffic.type">
80-
<a-tag
81-
:color="trafficColors[traffic.type]"
82-
style="margin:2px"
83-
>
84-
{{ traffic.type.toUpperCase() }}
80+
<a-tooltip :title="traffic.type.toUpperCase() + ' (' + traffic.label + ')'">
81+
<a-tag
82+
:color="trafficColors[traffic.type]"
83+
style="margin:2px"
84+
>
85+
{{ (traffic.type.toUpperCase() + ' (' + traffic.label + ')').slice(0, 20) }}
86+
{{ (traffic.type.toUpperCase() + ' (' + traffic.label + ')').length > 20 ? '...' : '' }}
8587
<edit-outlined class="traffic-type-action" @click="editTraffic(record.key, traffic, $event)"/>
8688
<delete-outlined class="traffic-type-action" @click="deleteTraffic(record.key, traffic, $event)"/>
8789
</a-tag>
90+
</a-tooltip>
8891
</div>
8992
<div v-if="isShowAddTraffic(record.traffics, index)">
9093
<div class="traffic-select-item" v-if="addingTrafficForKey === record.key">
@@ -133,6 +136,13 @@
133136
</a-tag>
134137
</div>
135138
</template>
139+
<template #tags="{ text, record, index }">
140+
<a-input
141+
:disabled="tungstenNetworkIndex > -1 && tungstenNetworkIndex !== index"
142+
:value="text"
143+
@change="e => onCellChange(record.key, 'tags', e.target.value)"
144+
/>
145+
</template>
136146
<template #actions="{ record, index }">
137147
<tooltip-button
138148
:tooltip="$t('label.delete')"
@@ -174,10 +184,18 @@
174184
@cancel="() => { showError = false }"
175185
centered
176186
>
177-
<div v-ctrl-enter="() => showError = false">
178-
<span>{{ $t('message.required.traffic.type') }}</span>
187+
<div v-ctrl-enter="() => showError = false" >
188+
<a-list item-layout="horizontal" :dataSource="errorList">
189+
<template #renderItem="{ item }">
190+
<a-list-item>
191+
<exclamation-circle-outlined
192+
:style="{ color: $config.theme['@error-color'], fontSize: '20px', marginRight: '10px' }"
193+
/>
194+
{{ item }}
195+
</a-list-item>
196+
</template>
197+
</a-list>
179198
<div :span="24" class="action-button">
180-
<a-button @click="showError = false">{{ $t('label.cancel') }}</a-button>
181199
<a-button type="primary" ref="submit" @click="showError = false">{{ $t('label.ok') }}</a-button>
182200
</div>
183201
</div>
@@ -282,6 +300,7 @@ export default {
282300
addingTrafficForKey: '-1',
283301
trafficLabelSelected: null,
284302
showError: false,
303+
errorList: [],
285304
defaultTrafficOptions: [],
286305
isChangeHyperv: false
287306
}
@@ -298,7 +317,7 @@ export default {
298317
columns.push({
299318
title: this.$t('label.isolation.method'),
300319
dataIndex: 'isolationMethod',
301-
width: 150,
320+
width: 125,
302321
slots: { customRender: 'isolationMethod' }
303322
})
304323
columns.push({
@@ -308,6 +327,13 @@ export default {
308327
width: 250,
309328
slots: { customRender: 'traffics' }
310329
})
330+
columns.push({
331+
title: this.$t('label.tags'),
332+
key: 'tags',
333+
dataIndex: 'tags',
334+
width: 175,
335+
slots: { customRender: 'tags' }
336+
})
311337
if (this.isAdvancedZone) {
312338
columns.push({
313339
title: '',
@@ -399,7 +425,7 @@ export default {
399425
return { type: item, label: '' }
400426
})
401427
this.count = 1
402-
this.physicalNetworks = [{ key: this.randomKeyTraffic(this.count), name: 'Physical Network 1', isolationMethod: 'VLAN', traffics: traffics }]
428+
this.physicalNetworks = [{ key: this.randomKeyTraffic(this.count), name: 'Physical Network 1', isolationMethod: 'VLAN', traffics: traffics, tags: null }]
403429
}
404430
if (this.isAdvancedZone) {
405431
this.availableTrafficToAdd.push('guest')
@@ -440,28 +466,32 @@ export default {
440466
key: this.randomKeyTraffic(count + 1),
441467
name: `Physical Network ${count + 1}`,
442468
isolationMethod: 'VLAN',
443-
traffics: []
469+
traffics: [],
470+
tags: null
444471
}
445472
this.physicalNetworks = [...physicalNetworks, newData]
446473
this.count = count + 1
447474
this.hasUnusedPhysicalNetwork = this.getHasUnusedPhysicalNetwork()
448475
},
449476
isValidSetup () {
477+
this.errorList = []
450478
let physicalNetworks = this.physicalNetworks
451479
if (this.tungstenNetworkIndex > -1) {
452480
physicalNetworks = [this.physicalNetworks[this.tungstenNetworkIndex]]
453481
}
454482
const shouldHaveLabels = physicalNetworks.length > 1
455483
let isValid = true
484+
let countPhysicalNetworkWithoutTags = 0
456485
this.requiredTrafficTypes.forEach(type => {
457-
if (!isValid) return false
458486
let foundType = false
459487
physicalNetworks.forEach(net => {
460488
net.traffics.forEach(traffic => {
461-
if (!isValid) return false
462489
if (traffic.type === type) {
463490
foundType = true
464491
}
492+
if (traffic.type === 'guest' && type === 'guest' && (!net.tags || net.tags.length === 0)) {
493+
countPhysicalNetworkWithoutTags++
494+
}
465495
if (this.hypervisor !== 'VMware') {
466496
if (shouldHaveLabels && (!traffic.label || traffic.label.length === 0)) {
467497
isValid = false
@@ -475,8 +505,15 @@ export default {
475505
})
476506
if (!foundType || !isValid) {
477507
isValid = false
508+
if (this.errorList.indexOf(this.$t('message.required.traffic.type')) === -1) {
509+
this.errorList.push(this.$t('message.required.traffic.type'))
510+
}
478511
}
479512
})
513+
if (countPhysicalNetworkWithoutTags > 1) {
514+
this.errorList.push(this.$t('message.required.tagged.physical.network'))
515+
isValid = false
516+
}
480517
return isValid
481518
},
482519
handleSubmit (e) {

0 commit comments

Comments
 (0)