Skip to content

Commit fdfd73f

Browse files
committed
ui: Allow IP range creation for Physical Network - Guest Traffic
1 parent 493d6a0 commit fdfd73f

3 files changed

Lines changed: 109 additions & 23 deletions

File tree

ui/src/views/infra/network/IpRangesTabGuest.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ export default {
149149
page: this.page,
150150
pagesize: this.pageSize
151151
}).then(response => {
152-
console.log(response)
153152
this.items = response.listnetworksresponse.network ? response.listnetworksresponse.network : []
154153
this.total = response.listnetworksresponse.count || 0
155154
}).catch(error => {

ui/src/views/infra/network/IpRangesTabPublic.vue

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@
3434
:rowKey="record => record.id"
3535
:pagination="false"
3636
>
37-
<template slot="account" slot-scope="record">
37+
<template slot="account" slot-scope="record" v-if="!basicGuestNetwork">
3838
<a-button @click="() => handleOpenAccountModal(record)">{{ `[${record.domain}] ${record.account === undefined ? '' : record.account}` }}</a-button>
3939
</template>
4040
<template slot="actions" slot-scope="record">
4141
<div class="actions">
4242
<tooltip-button
43-
v-if="record.account === 'system'"
43+
v-if="record.account === 'system' && !basicGuestNetwork"
4444
tooltipPlacement="bottom"
4545
:tooltip="$t('label.add.account')"
4646
icon="user-add"
4747
@click="() => handleOpenAddAccountModal(record)"
4848
:disabled="!('dedicatePublicIpRange' in $store.getters.apis)" />
4949
<tooltip-button
50-
v-else
50+
v-if="record.account !== 'system' && !basicGuestNetwork"
5151
tooltipPlacement="bottom"
5252
:tooltip="$t('label.release.account')"
5353
icon="user-delete"
@@ -137,6 +137,16 @@
137137
layout="vertical"
138138
class="form"
139139
>
140+
<a-form-item :label="$t('label.podid')" class="form__item" v-if="basicGuestNetwork">
141+
<a-select
142+
autoFocus
143+
v-decorator="['podid', {
144+
rules: [{ required: true, message: `${$t('label.required')}` }]
145+
}]"
146+
>
147+
<a-select-option v-for="pod in pods" :key="pod.id" :value="pod.id">{{ pod.name }}</a-select-option>
148+
</a-select>
149+
</a-form-item>
140150
<a-form-item :label="$t('label.gateway')" class="form__item">
141151
<a-input
142152
autoFocus
@@ -148,7 +158,7 @@
148158
v-decorator="['netmask', { rules: [{ required: true, message: `${$t('label.required')}` }] }]">
149159
</a-input>
150160
</a-form-item>
151-
<a-form-item :label="$t('label.vlan')" class="form__item">
161+
<a-form-item :label="$t('label.vlan')" class="form__item" v-if="!basicGuestNetwork">
152162
<a-input
153163
v-decorator="['vlan']">
154164
</a-input>
@@ -163,11 +173,11 @@
163173
v-decorator="['endip', { rules: [{ required: true, message: `${$t('label.required')}` }] }]">
164174
</a-input>
165175
</a-form-item>
166-
<div class="form__item">
176+
<div class="form__item" v-if="!basicGuestNetwork">
167177
<div style="color: black;">{{ $t('label.set.reservation') }}</div>
168178
<a-switch @change="handleShowAccountFields"></a-switch>
169179
</div>
170-
<div v-if="showAccountFields" style="margin-top: 20px;">
180+
<div v-if="showAccountFields && !basicGuestNetwork" style="margin-top: 20px;">
171181
<div v-html="$t('label.set.reservation.desc')"></div>
172182
<a-form-item :label="$t('label.system.vms')" class="form__item">
173183
<a-switch v-decorator="['forsystemvms']"></a-switch>
@@ -214,6 +224,10 @@ export default {
214224
network: {
215225
type: Object,
216226
required: true
227+
},
228+
basicGuestNetwork: {
229+
type: Boolean,
230+
required: true
217231
}
218232
},
219233
data () {
@@ -232,6 +246,8 @@ export default {
232246
domainsLoading: false,
233247
addIpRangeModal: false,
234248
showAccountFields: false,
249+
podsLoading: false,
250+
pods: [],
235251
page: 1,
236252
pageSize: 10,
237253
columns: [
@@ -255,10 +271,6 @@ export default {
255271
title: this.$t('label.endip'),
256272
dataIndex: 'endip'
257273
},
258-
{
259-
title: this.$t('label.account'),
260-
scopedSlots: { customRender: 'account' }
261-
},
262274
{
263275
title: this.$t('label.action'),
264276
scopedSlots: { customRender: 'actions' }
@@ -270,6 +282,19 @@ export default {
270282
this.form = this.$form.createForm(this)
271283
},
272284
created () {
285+
if (!this.basicGuestNetwork) {
286+
this.columns.splice(5, 0,
287+
{
288+
title: this.$t('label.account'),
289+
scopedSlots: { customRender: 'account' }
290+
}
291+
)
292+
} else {
293+
this.columns.unshift({
294+
title: this.$t('label.pod'),
295+
dataIndex: 'podname'
296+
})
297+
}
273298
this.fetchData()
274299
},
275300
watch: {
@@ -296,6 +321,7 @@ export default {
296321
}).finally(() => {
297322
this.componentLoading = false
298323
})
324+
this.fetchPods()
299325
},
300326
fetchDomains () {
301327
this.domainsLoading = true
@@ -314,6 +340,22 @@ export default {
314340
this.domainsLoading = false
315341
})
316342
},
343+
fetchPods () {
344+
this.podsLoading = true
345+
api('listPods', {
346+
zoneid: this.resource.zoneid,
347+
page: this.page,
348+
pagesize: this.pageSize
349+
}).then(response => {
350+
this.total = response.listpodsresponse.count || 0
351+
this.pods = response.listpodsresponse.pod ? response.listpodsresponse.pod : []
352+
}).catch(error => {
353+
console.log(error)
354+
this.$notifyError(error)
355+
}).finally(() => {
356+
this.podsLoading = false
357+
})
358+
},
317359
handleAddAccount () {
318360
this.domainsLoading = true
319361
@@ -384,18 +426,25 @@ export default {
384426
385427
this.componentLoading = true
386428
this.addIpRangeModal = false
387-
api('createVlanIpRange', {
388-
zoneId: this.resource.zoneid,
389-
vlan: values.vlan,
429+
var params = {
390430
gateway: values.gateway,
391431
netmask: values.netmask,
392432
startip: values.startip,
393-
endip: values.endip,
394-
forsystemvms: values.forsystemvms,
395-
account: values.forsystemvms ? null : values.account,
396-
domainid: values.forsystemvms ? null : values.domain,
397-
forvirtualnetwork: true
398-
}).then(() => {
433+
endip: values.endip
434+
}
435+
if (!this.basicGuestNetwork) {
436+
params.zoneId = this.resource.zoneid
437+
params.vlan = values.vlan
438+
params.forsystemvms = values.forsystemvms
439+
params.account = values.forsystemvms ? null : values.account
440+
params.domainid = values.forsystemvms ? null : values.domain
441+
params.forvirtualnetwork = true
442+
} else {
443+
params.forvirtualnetwork = false
444+
params.podid = values.podid
445+
params.networkid = this.network.id
446+
}
447+
api('createVlanIpRange', params).then(() => {
399448
this.$notification.success({
400449
message: this.$t('message.success.add.iprange')
401450
})

ui/src/views/infra/network/TrafficTypesTab.vue

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@
2626
<div><strong>{{ $t(type) }}</strong></div>
2727
<div>{{ item[type] || $t('label.network.label.display.for.blank.value') }}</div>
2828
</div>
29-
<div v-if="item.traffictype === 'Guest'">
29+
<div v-if="item.traffictype === 'Guest' && networkType === 'Advanced'">
3030
<a-divider />
31-
<IpRangesTabGuest :resource="resource" :loading="loading" />
31+
<IpRangesTabGuest :resource="resource" :loading="loading"/>
32+
</div>
33+
<div v-if="item.traffictype === 'Guest' && networkType === 'Basic'">
34+
<a-divider />
35+
<IpRangesTabPublic
36+
:resource="resource"
37+
:loading="loading"
38+
:network="guestNetwork"
39+
:basicGuestNetwork="networkType === 'Basic' && item.traffictype === 'Guest'"/>
3240
</div>
3341
<div v-if="item.traffictype === 'Public'">
3442
<div style="margin-bottom: 10px;">
@@ -40,7 +48,7 @@
4048
<div>{{ publicNetwork.broadcastdomaintype }}</div>
4149
</div>
4250
<a-divider />
43-
<IpRangesTabPublic :resource="resource" :loading="loading" :network="publicNetwork" />
51+
<IpRangesTabPublic :resource="resource" :loading="loading" :network="publicNetwork" :basicGuestNetwork="false" />
4452
</div>
4553
<div v-if="item.traffictype === 'Management'">
4654
<a-divider />
@@ -86,6 +94,8 @@ export default {
8694
return {
8795
traffictypes: [],
8896
publicNetwork: {},
97+
guestNetwork: {},
98+
networkType: 'Advanced',
8999
fetchLoading: false
90100
}
91101
},
@@ -104,6 +114,7 @@ export default {
104114
methods: {
105115
fetchData () {
106116
this.fetchLoading = true
117+
this.fetchGuestNetwork()
107118
api('listTrafficTypes', { physicalnetworkid: this.resource.id }).then(json => {
108119
this.traffictypes = json.listtraffictypesresponse.traffictype
109120
}).catch(error => {
@@ -129,6 +140,33 @@ export default {
129140
}).finally(() => {
130141
this.fetchLoading = false
131142
})
143+
144+
this.fetchLoading = true
145+
api('listZones', { id: this.resource.zoneid }).then(json => {
146+
const zone = json.listzonesresponse.zone || []
147+
this.networkType = zone[0].networktype
148+
}).catch(error => {
149+
this.$notifyError(error)
150+
}).finally(() => {
151+
this.fetchLoading = false
152+
})
153+
},
154+
fetchGuestNetwork () {
155+
api('listNetworks', {
156+
listAll: true,
157+
trafficType: 'Guest',
158+
zoneId: this.resource.zoneid
159+
}).then(json => {
160+
if (json.listnetworksresponse?.network?.length > 0) {
161+
this.guestNetwork = json.listnetworksresponse.network[0]
162+
} else {
163+
this.guestNetwork = {}
164+
}
165+
}).catch(error => {
166+
this.$notifyError(error)
167+
}).finally(() => {
168+
this.fetchLoading = false
169+
})
132170
}
133171
}
134172
}

0 commit comments

Comments
 (0)