Skip to content

Commit fd3b829

Browse files
Hoang NguyenGutoVeronezi
authored andcommitted
ui: add a provider for primary storage when adding zone wizard (#6429)
Fixes #6088 * add provider in creating primary storage when adding new zone * add custom protocol for SolidFire/PowerFlex provider * set the custom protocol option available with the rest of the protocol options * fixes indexOf error & auto-select protocol * set server=localhost with SharedMountPoint protocol
1 parent 27ae923 commit fd3b829

File tree

3 files changed

+163
-14
lines changed

3 files changed

+163
-14
lines changed

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

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
:name="field.key"
3636
:ref="field.key"
3737
:label="$t(field.title)"
38-
v-if="isDisplayInput(field.display)"
38+
v-if="isDisplayInput(field)"
3939
v-bind="formItemLayout"
4040
:has-feedback="field.switch ? false : true">
4141
<a-select
@@ -61,6 +61,11 @@
6161
v-model:checked="form[field.key]"
6262
v-focus="index === 0"
6363
/>
64+
<a-checkbox
65+
v-else-if="field.checkbox"
66+
v-model:checked="form[field.key]"
67+
v-focus="index === 0">
68+
</a-checkbox>
6469
<a-input
6570
v-else-if="field.password"
6671
type="password"
@@ -137,6 +142,11 @@ export default {
137142
const fieldsChanged = toRaw(changedFields)
138143
this.$emit('fieldsChanged', fieldsChanged)
139144
}
145+
},
146+
'prefillContent.provider' (val) {
147+
if (['SolidFire', 'PowerFlex'].includes(val)) {
148+
this.form.primaryStorageProtocol = 'custom'
149+
}
140150
}
141151
},
142152
methods: {
@@ -148,17 +158,17 @@ export default {
148158
fillValue () {
149159
this.fields.forEach(field => {
150160
this.setRules(field)
151-
const fieldExists = this.isDisplayInput(field.display)
161+
const fieldExists = this.isDisplayInput(field)
152162
if (!fieldExists) {
153163
return
154164
}
155-
if (field.key === 'agentUserName' && !this.getPrefilled(field.key)) {
165+
if (field.key === 'agentUserName' && !this.getPrefilled(field)) {
156166
this.form[field.key] = 'Oracle'
157167
} else {
158-
if (field.switch) {
168+
if (field.switch || field.checkbox) {
159169
this.form[field.key] = this.isChecked(field)
160170
} else {
161-
this.form[field.key] = this.getPrefilled(field.key)
171+
this.form[field.key] = this.getPrefilled(field)
162172
}
163173
}
164174
})
@@ -179,8 +189,8 @@ export default {
179189
})
180190
}
181191
},
182-
getPrefilled (key) {
183-
return this.prefillContent?.[key] || null
192+
getPrefilled (field) {
193+
return this.prefillContent?.[field.key] || field.value || undefined
184194
},
185195
handleSubmit () {
186196
this.formRef.value.validate().then(() => {
@@ -207,7 +217,11 @@ export default {
207217
return Promise.resolve()
208218
}
209219
},
210-
isDisplayInput (conditions) {
220+
isDisplayInput (field) {
221+
if (!field.display && !field.hidden) {
222+
return true
223+
}
224+
const conditions = field.display || field.hidden
211225
if (!conditions || Object.keys(conditions).length === 0) {
212226
return true
213227
}
@@ -218,10 +232,19 @@ export default {
218232
const fieldVal = this.form[key]
219233
? this.form[key]
220234
: (this.prefillContent?.[key] || null)
221-
if (Array.isArray(condition) && !condition.includes(fieldVal)) {
222-
isShow = false
223-
} else if (!Array.isArray(condition) && fieldVal !== condition) {
224-
isShow = false
235+
236+
if (field.hidden) {
237+
if (Array.isArray(condition) && condition.includes(fieldVal)) {
238+
isShow = false
239+
} else if (!Array.isArray(condition) && fieldVal === condition) {
240+
isShow = false
241+
}
242+
} else if (field.display) {
243+
if (Array.isArray(condition) && !condition.includes(fieldVal)) {
244+
isShow = false
245+
} else if (!Array.isArray(condition) && fieldVal !== condition) {
246+
isShow = false
247+
}
225248
}
226249
}
227250
})

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

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,81 @@ export default {
499499
primaryStorageProtocol: 'Linstor'
500500
}
501501
},
502+
{
503+
title: 'label.provider',
504+
key: 'provider',
505+
placeHolder: 'message.error.select',
506+
value: 'DefaultPrimary',
507+
select: true,
508+
required: true,
509+
options: this.primaryStorageProviders
510+
},
511+
{
512+
title: 'label.ismanaged',
513+
key: 'managed',
514+
checkbox: true,
515+
hidden: {
516+
provider: ['DefaultPrimary', 'PowerFlex', 'Linstor']
517+
}
518+
},
519+
{
520+
title: 'label.capacitybytes',
521+
key: 'capacityBytes',
522+
hidden: {
523+
provider: ['DefaultPrimary', 'PowerFlex', 'Linstor']
524+
}
525+
},
526+
{
527+
title: 'label.capacityiops',
528+
key: 'capacityIops',
529+
hidden: {
530+
provider: ['DefaultPrimary', 'PowerFlex', 'Linstor']
531+
}
532+
},
533+
{
534+
title: 'label.url',
535+
key: 'url',
536+
hidden: {
537+
provider: ['DefaultPrimary', 'PowerFlex', 'Linstor']
538+
}
539+
},
540+
{
541+
title: 'label.powerflex.gateway',
542+
key: 'powerflexGateway',
543+
required: true,
544+
placeHolder: 'message.error.input.value',
545+
display: {
546+
provider: 'PowerFlex'
547+
}
548+
},
549+
{
550+
title: 'label.powerflex.gateway.username',
551+
key: 'powerflexGatewayUsername',
552+
required: true,
553+
placeHolder: 'message.error.input.value',
554+
display: {
555+
provider: 'PowerFlex'
556+
}
557+
},
558+
{
559+
title: 'label.powerflex.gateway.password',
560+
key: 'powerflexGatewayPassword',
561+
required: true,
562+
placeHolder: 'message.error.input.value',
563+
password: true,
564+
display: {
565+
provider: 'PowerFlex'
566+
}
567+
},
568+
{
569+
title: 'label.powerflex.storage.pool',
570+
key: 'powerflexStoragePool',
571+
required: true,
572+
placeHolder: 'message.error.input.value',
573+
display: {
574+
provider: 'PowerFlex'
575+
}
576+
},
502577
{
503578
title: 'label.storage.tags',
504579
key: 'primaryStorageTags',
@@ -721,9 +796,10 @@ export default {
721796
currentHypervisor: null,
722797
primaryStorageScopes: [],
723798
primaryStorageProtocols: [],
799+
primaryStorageProviders: [],
724800
storageProviders: [],
725801
currentStep: null,
726-
options: ['primaryStorageScope', 'primaryStorageProtocol', 'provider']
802+
options: ['primaryStorageScope', 'primaryStorageProtocol', 'provider', 'primaryStorageProvider']
727803
}
728804
},
729805
created () {
@@ -750,6 +826,17 @@ export default {
750826
}
751827
}
752828
},
829+
watch: {
830+
'prefillContent.provider' (newVal, oldVal) {
831+
if (['SolidFire', 'PowerFlex'].includes(newVal) && !['SolidFire', 'PowerFlex'].includes(oldVal)) {
832+
this.$emit('fieldsChanged', { primaryStorageProtocol: undefined })
833+
} else if (!['SolidFire', 'PowerFlex'].includes(newVal) && ['SolidFire', 'PowerFlex'].includes(oldVal)) {
834+
this.$emit('fieldsChanged', { primaryStorageProtocol: undefined })
835+
}
836+
837+
this.fetchProtocol()
838+
}
839+
},
753840
methods: {
754841
nextPressed () {
755842
if (this.currentStep === this.steps.length - 1) {
@@ -800,6 +887,9 @@ export default {
800887
case 'provider':
801888
this.fetchProvider()
802889
break
890+
case 'primaryStorageProvider':
891+
this.fetchPrimaryStorageProvider()
892+
break
803893
default:
804894
break
805895
}
@@ -912,6 +1002,7 @@ export default {
9121002
})
9131003
}
9141004
1005+
protocols.push({ id: 'custom', description: 'custom' })
9151006
this.primaryStorageProtocols = protocols
9161007
},
9171008
async fetchConfigurationSwitch () {
@@ -956,6 +1047,13 @@ export default {
9561047
this.storageProviders = storageProviders
9571048
})
9581049
},
1050+
fetchPrimaryStorageProvider () {
1051+
this.primaryStorageProviders = []
1052+
api('listStorageProviders', { type: 'primary' }).then(json => {
1053+
this.primaryStorageProviders = json.liststorageprovidersresponse.dataStoreProvider || []
1054+
this.primaryStorageProviders.map((item, idx) => { this.primaryStorageProviders[idx].id = item.name })
1055+
})
1056+
},
9591057
submitLaunchZone () {
9601058
this.$emit('submitLaunchZone')
9611059
},

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,7 @@ export default {
12761276
params.clusterid = this.stepData.clusterReturned.id
12771277
params.name = this.prefillContent?.primaryStorageName || null
12781278
params.scope = this.prefillContent?.primaryStorageScope || null
1279+
params.provider = this.prefillContent.provider
12791280
12801281
if (params.scope === 'zone') {
12811282
const hypervisor = this.prefillContent.hypervisor
@@ -1324,6 +1325,7 @@ export default {
13241325
}
13251326
url = this.ocfs2URL(server, path)
13261327
} else if (protocol === 'SharedMountPoint') {
1328+
server = 'localhost'
13271329
let path = this.prefillContent?.primaryStoragePath || ''
13281330
if (path.substring(0, 1) !== '/') {
13291331
path = '/' + path
@@ -1356,7 +1358,7 @@ export default {
13561358
if (protocol === 'datastorecluster') {
13571359
url = this.datastoreclusterURL('dummy', path)
13581360
}
1359-
} else {
1361+
} else if (protocol === 'iscsi') {
13601362
let iqn = this.prefillContent?.primaryStorageTargetIQN || ''
13611363
if (iqn.substring(0, 1) !== '/') {
13621364
iqn = '/' + iqn
@@ -1366,6 +1368,27 @@ export default {
13661368
}
13671369
13681370
params.url = url
1371+
if (this.prefillContent.provider !== 'DefaultPrimary' && this.prefillContent.provider !== 'PowerFlex') {
1372+
if (this.prefillContent.managed) {
1373+
params.managed = true
1374+
} else {
1375+
params.managed = false
1376+
}
1377+
if (this.prefillContent.capacityBytes && this.prefillContent.capacityBytes.length > 0) {
1378+
params.capacityBytes = this.prefillContent.capacityBytes.split(',').join('')
1379+
}
1380+
if (this.prefillContent.capacityIops && this.prefillContent.capacityIops.length > 0) {
1381+
params.capacityIops = this.prefillContent.capacityIops.split(',').join('')
1382+
}
1383+
if (this.prefillContent.url && this.prefillContent.url.length > 0) {
1384+
params.url = this.prefillContent.url
1385+
}
1386+
}
1387+
if (this.prefillContent.provider === 'PowerFlex') {
1388+
params.url = this.powerflexURL(this.prefillContent.powerflexGateway, this.prefillContent.powerflexGatewayUsername,
1389+
this.prefillContent.powerflexGatewayPassword, this.prefillContent.powerflexStoragePool)
1390+
}
1391+
13691392
params.tags = this.prefillContent?.primaryStorageTags || ''
13701393
13711394
try {
@@ -2168,6 +2191,11 @@ export default {
21682191
url = server + iqn + '/' + lun
21692192
}
21702193
return url
2194+
},
2195+
powerflexURL (gateway, username, password, pool) {
2196+
var url = 'powerflex://' + encodeURIComponent(username) + ':' + encodeURIComponent(password) + '@' +
2197+
gateway + '/' + encodeURIComponent(pool)
2198+
return url
21712199
}
21722200
}
21732201
}

0 commit comments

Comments
 (0)