Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-reload the network dropdown in the Cluster: Create Harvester page #13110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 43 additions & 19 deletions pkg/harvester-manager/machine-config/harvester.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,7 @@ export default {
this.networkDataOptions = networkDataOptions;
this.images = res.images.value?.data;
this.storageClass = res.storageClass.value?.data;
this.networkOptions = (res.networks.value?.data || []).filter((O) => O.metadata?.annotations?.[STORAGE_NETWORK] !== 'true').map((O) => {
let value;
let label;

try {
const config = JSON.parse(O.spec.config);

const id = config.vlan;

value = O.id;
label = `${ value } (vlanId=${ id })`;
} catch (err) {}

return {
label,
value
};
});
this.networks = res.networks.value?.data;

let systemNamespaces = (res.settings.value?.data || []).filter((x) => x.id === SETTING.SYSTEM_NAMESPACES);

Expand Down Expand Up @@ -391,7 +374,7 @@ export default {
storageClass: [],
namespaces: [],
namespaceOptions: [],
networkOptions: [],
networks: [],
userDataOptions: [],
networkDataOptions: [],
allNodeObjects: [],
Expand Down Expand Up @@ -440,6 +423,31 @@ export default {
}
},

networkOptions: {
get() {
return (this.networks || []).filter((O) => O.metadata?.annotations?.[STORAGE_NETWORK] !== 'true').map((O) => {
let value;
let label;

try {
const config = JSON.parse(O.spec.config);
const id = config.vlan;

value = O.id;
label = `${ value } (vlanId=${ id })`;
} catch (err) {}

return {
label,
value
};
});
},
set(neu) {
this.networks = neu;
}
},

namespaceDisabled() {
return this.disabledEdit || this.poolIndex > 0;
},
Expand Down Expand Up @@ -738,6 +746,21 @@ export default {
}
},

async getAvailableNetworks() {
try {
const clusterId = get(this.credential, 'decodedData.clusterId');

if (clusterId) {
const url = `/k8s/clusters/${ clusterId }/v1`;
const res = await this.$store.dispatch('cluster/request', { url: `${ url }/k8s.cni.cncf.io.network-attachment-definitions` });

this.networks = res?.data;
}
} catch (e) {
this.errors = exceptionToErrorsArray(e);
}
},

async getAvailableVGpuDevices() {
const clusterId = get(this.credential, 'decodedData.clusterId');

Expand Down Expand Up @@ -1400,6 +1423,7 @@ export default {
:required="true"
label-key="cluster.credential.harvester.network.networkName"
:placeholder="t('cluster.harvester.machinePool.network.placeholder')"
@on-open="getAvailableNetworks"
@update:value="update"
/>
</div>
Expand Down
Loading