Compare commits

..
24 changed files with 1584 additions and 2144 deletions
+6 -8
View File
@@ -7,7 +7,7 @@
}, },
"dependencies": { "dependencies": {
"@babel/plugin-transform-class-static-block": "7.29.7", "@babel/plugin-transform-class-static-block": "7.29.7",
"@rancher/shell": "3.0.13", "@rancher/shell": "3.0.12-rc.7",
"@vue-flow/background": "^1.3.0", "@vue-flow/background": "^1.3.0",
"@vue-flow/controls": "^1.1.1", "@vue-flow/controls": "^1.1.1",
"@vue-flow/core": "^1.33.5", "@vue-flow/core": "^1.33.5",
@@ -35,11 +35,11 @@
"glob": "7.2.3", "glob": "7.2.3",
"glob-parent": "6.0.2", "glob-parent": "6.0.2",
"json5": "2.2.3", "json5": "2.2.3",
"@types/lodash": "4.17.25", "@types/lodash": "4.17.24",
"merge": "2.1.1", "merge": "2.1.1",
"node-forge": "1.4.0", "node-forge": "1.4.0",
"nth-check": "2.1.1", "nth-check": "2.1.1",
"qs": "6.16.0", "qs": "6.15.3",
"roarr": "7.21.7", "roarr": "7.21.7",
"semver": "7.8.5", "semver": "7.8.5",
"@vue/cli-service/html-webpack-plugin": "^5.0.0" "@vue/cli-service/html-webpack-plugin": "^5.0.0"
@@ -48,17 +48,15 @@
"dev": "NODE_ENV=dev ./node_modules/.bin/vue-cli-service serve", "dev": "NODE_ENV=dev ./node_modules/.bin/vue-cli-service serve",
"build": "./node_modules/.bin/vue-cli-service build", "build": "./node_modules/.bin/vue-cli-service build",
"clean": "./node_modules/@rancher/shell/scripts/clean", "clean": "./node_modules/@rancher/shell/scripts/clean",
"lint": "./node_modules/@rancher/shell/scripts/lint --max-warnings 0 --ext .js,.ts,.vue .", "lint": "./node_modules/.bin/eslint --max-warnings 0 --ext .js,.ts,.vue .",
"lint:fix": "./node_modules/@rancher/shell/scripts/lint --fix --max-warnings 0 --ext .js,.ts,.vue .", "lint:fix": "./node_modules/.bin/eslint --fix --max-warnings 0 --ext .js,.ts,.vue .",
"build-pkg": "./node_modules/@rancher/shell/scripts/build-pkg.sh", "build-pkg": "./node_modules/@rancher/shell/scripts/build-pkg.sh",
"serve-pkgs": "./node_modules/@rancher/shell/scripts/serve-pkgs", "serve-pkgs": "./node_modules/@rancher/shell/scripts/serve-pkgs",
"publish-pkgs": "./node_modules/@rancher/shell/scripts/extension/publish", "publish-pkgs": "./node_modules/@rancher/shell/scripts/extension/publish",
"parse-tag-name": "./node_modules/@rancher/shell/scripts/extension/parse-tag-name", "parse-tag-name": "./node_modules/@rancher/shell/scripts/extension/parse-tag-name",
"commitlint": "commitlint --edit", "commitlint": "commitlint --edit",
"prepare": "husky", "prepare": "husky",
"agents:generate": "./scripts/generate-agent-and-persona-mds.sh", "agents:generate": "./scripts/generate-agent-and-persona-mds.sh"
"prelint": "npm --prefix node_modules/@rancher/shell/eslint-legacy install eslint-plugin-jest@^24 --no-save --no-audit --no-fund --legacy-peer-deps --loglevel=error",
"prelint:fix": "npm --prefix node_modules/@rancher/shell/eslint-legacy install eslint-plugin-jest@^24 --no-save --no-audit --no-fund --legacy-peer-deps --loglevel=error"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/load": "^19.8.1", "@commitlint/load": "^19.8.1",
+12 -17
View File
@@ -231,21 +231,14 @@ export default {
v-if="setting.customized" v-if="setting.customized"
class="modified" class="modified"
> >
{{ t('advancedSettings.tags.modified.label') }} Modified
</span> </span>
<span <span
v-if="setting.experimental" v-if="setting.experimental"
v-clean-tooltip="t('advancedSettings.tags.experimental.description')" v-clean-tooltip="t('advancedSettings.experimental')"
class="experimental" class="experimental"
> >
{{ t('advancedSettings.tags.experimental.label') }} Experimental
</span>
<span
v-if="setting.preview"
v-clean-tooltip="t('advancedSettings.tags.preview.description')"
class="preview"
>
{{ t('advancedSettings.tags.preview.label') }}
</span> </span>
</h1> </h1>
<h2 v-clean-html="t(setting.description, getDocLinkParams(setting) || {}, true)"> <h2 v-clean-html="t(setting.description, getDocLinkParams(setting) || {}, true)">
@@ -359,19 +352,21 @@ export default {
flex: 1; flex: 1;
} }
.modified, .modified {
.experimental,
.preview {
margin-left: 10px; margin-left: 10px;
border: 1px solid; border: 1px solid var(--primary);
border-radius: 5px; border-radius: 5px;
padding: 2px 10px; padding: 2px 10px;
font-size: 12px; font-size: 12px;
} }
.modified { border-color: var(--primary); } .experimental {
.experimental { border-color: var(--error); } margin-left: 10px;
.preview { border-color: var(--warning); } border: 1px solid var(--error);
border-radius: 5px;
padding: 2px 10px;
font-size: 12px;
}
.no-search-match { .no-search-match {
text-align: center; text-align: center;
@@ -15,7 +15,7 @@ import MappingColumn from './MappingColumn.vue';
import StorageDefaultsModal from './StorageDefaultsModal.vue'; import StorageDefaultsModal from './StorageDefaultsModal.vue';
const DEFAULT_VOLUME_MODE = VOLUME_MODE.FILE_SYSTEM; const DEFAULT_VOLUME_MODE = VOLUME_MODE.FILE_SYSTEM;
const DEFAULT_ACCESS_MODE = ACCESS_MODE?.READ_WRITE_MANY ?? 'ReadWriteMany'; const DEFAULT_ACCESS_MODES = [ACCESS_MODE.READ_WRITE_MANY];
const props = defineProps({ const props = defineProps({
providerName: { type: String, default: '' }, providerName: { type: String, default: '' },
@@ -268,9 +268,9 @@ const buildStorageEntries = () => {
capacity: 0, capacity: 0,
target: '', target: '',
volumeMode: DEFAULT_VOLUME_MODE, volumeMode: DEFAULT_VOLUME_MODE,
accessModes: [DEFAULT_ACCESS_MODE], accessModes: [...DEFAULT_ACCESS_MODES],
inheritedVolumeMode: DEFAULT_VOLUME_MODE, inheritedVolumeMode: DEFAULT_VOLUME_MODE,
inheritedAccessModes: [DEFAULT_ACCESS_MODE], inheritedAccessModes: [...DEFAULT_ACCESS_MODES],
inheritedFromProvider: false, inheritedFromProvider: false,
overridden: false, overridden: false,
usedBy: [], usedBy: [],
@@ -310,9 +310,9 @@ const buildStorageEntriesFromProvider = (datastoresData) => {
capacity: ds.capacity || 0, capacity: ds.capacity || 0,
target: '', target: '',
volumeMode: DEFAULT_VOLUME_MODE, volumeMode: DEFAULT_VOLUME_MODE,
accessModes: [DEFAULT_ACCESS_MODE], accessModes: [...DEFAULT_ACCESS_MODES],
inheritedVolumeMode: DEFAULT_VOLUME_MODE, inheritedVolumeMode: DEFAULT_VOLUME_MODE,
inheritedAccessModes: [DEFAULT_ACCESS_MODE], inheritedAccessModes: [...DEFAULT_ACCESS_MODES],
inheritedFromProvider: false, inheritedFromProvider: false,
overridden: false, overridden: false,
usedBy: [], usedBy: [],
@@ -273,6 +273,19 @@ const startMigrationAction = async() => {
await plan.save(); await plan.save();
const planOwnerRef = {
apiVersion: FORKLIFT_API_VERSION,
kind: 'Plan',
name: plan.metadata.name,
uid: plan.metadata.uid,
blockOwnerDeletion: true,
};
networkMap.metadata.ownerReferences = [planOwnerRef];
await networkMap.save();
storageMap.metadata.ownerReferences = [planOwnerRef];
await storageMap.save();
// Kick off the first migration through the model so the Migration payload // Kick off the first migration through the model so the Migration payload
// lives in a single place (also reused by the dashboard start/restart action). // lives in a single place (also reused by the dashboard start/restart action).
await plan.startMigration(); await plan.startMigration();
@@ -8,22 +8,16 @@ import { useI18n } from '@shell/composables/useI18n';
import { VOLUME_MODE, ACCESS_MODE } from '../../config/types'; import { VOLUME_MODE, ACCESS_MODE } from '../../config/types';
const VOLUME_MODE_OPTIONS = [VOLUME_MODE.FILE_SYSTEM, VOLUME_MODE.BLOCK]; const VOLUME_MODE_OPTIONS = [VOLUME_MODE.FILE_SYSTEM, VOLUME_MODE.BLOCK];
const { const ACCESS_MODE_OPTIONS = [ACCESS_MODE.READ_WRITE_ONCE, ACCESS_MODE.READ_WRITE_MANY, ACCESS_MODE.READ_ONLY_MANY];
READ_WRITE_ONCE = 'ReadWriteOnce',
READ_ONLY_MANY = 'ReadOnlyMany',
READ_WRITE_MANY = 'ReadWriteMany',
READ_WRITE_ONCE_POD = 'ReadWriteOncePod'
} = ACCESS_MODE || {};
const ACCESS_MODE_OPTIONS = [READ_WRITE_ONCE, READ_WRITE_MANY, READ_ONLY_MANY, READ_WRITE_ONCE_POD];
const props = defineProps({ const props = defineProps({
storageClassName: { type: String, default: '' }, storageClassName: { type: String, default: '' },
providerName: { type: String, default: '' }, providerName: { type: String, default: '' },
showInherited: { type: Boolean, default: false }, showInherited: { type: Boolean, default: false },
volumeMode: { type: String, default: VOLUME_MODE.FILE_SYSTEM }, volumeMode: { type: String, default: VOLUME_MODE.FILE_SYSTEM },
accessModes: { type: Array, default: () => ['ReadWriteMany'] }, accessModes: { type: Array, default: () => [ACCESS_MODE.READ_WRITE_MANY] },
inheritedVolumeMode: { type: String, default: VOLUME_MODE.FILE_SYSTEM }, inheritedVolumeMode: { type: String, default: VOLUME_MODE.FILE_SYSTEM },
inheritedAccessModes: { type: Array, default: () => ['ReadWriteMany'] }, inheritedAccessModes: { type: Array, default: () => [ACCESS_MODE.READ_WRITE_MANY] },
}); });
const emit = defineEmits(['apply', 'close']); const emit = defineEmits(['apply', 'close']);
@@ -32,7 +26,7 @@ const store = useStore();
const { t } = useI18n(store); const { t } = useI18n(store);
const localVolumeMode = ref(props.volumeMode || VOLUME_MODE.FILE_SYSTEM); const localVolumeMode = ref(props.volumeMode || VOLUME_MODE.FILE_SYSTEM);
const localAccessMode = ref(props.accessModes?.[0] || READ_WRITE_MANY); const localAccessMode = ref(props.accessModes?.[0] || ACCESS_MODE.READ_WRITE_MANY);
const volumeModeOptions = VOLUME_MODE_OPTIONS.map((value) => ({ label: value, value })); const volumeModeOptions = VOLUME_MODE_OPTIONS.map((value) => ({ label: value, value }));
const accessModeOptions = ACCESS_MODE_OPTIONS.map((value) => ({ label: value, value })); const accessModeOptions = ACCESS_MODE_OPTIONS.map((value) => ({ label: value, value }));
@@ -48,7 +42,7 @@ const apply = () => {
// Repopulate the dropdowns with the provider default values; the user then applies. // Repopulate the dropdowns with the provider default values; the user then applies.
const reset = () => { const reset = () => {
localVolumeMode.value = props.inheritedVolumeMode || VOLUME_MODE.FILE_SYSTEM; localVolumeMode.value = props.inheritedVolumeMode || VOLUME_MODE.FILE_SYSTEM;
localAccessMode.value = props.inheritedAccessModes?.[0] || READ_WRITE_MANY; localAccessMode.value = props.inheritedAccessModes?.[0] || ACCESS_MODE.READ_WRITE_MANY;
}; };
const cancel = () => { const cancel = () => {
+1 -3
View File
@@ -111,17 +111,15 @@ export const HCI_ALLOWED_SETTINGS = {
[HCI_SETTING.KUBECONFIG_DEFAULT_TOKEN_TTL_MINUTES]: { kind: 'number', featureFlag: 'kubeconfigDefaultTokenTTLMinutesSetting' }, [HCI_SETTING.KUBECONFIG_DEFAULT_TOKEN_TTL_MINUTES]: { kind: 'number', featureFlag: 'kubeconfigDefaultTokenTTLMinutesSetting' },
[HCI_SETTING.LONGHORN_V2_DATA_ENGINE_ENABLED]: { [HCI_SETTING.LONGHORN_V2_DATA_ENGINE_ENABLED]: {
kind: 'boolean', kind: 'boolean',
preview: true, experimental: true,
featureFlag: 'longhornV2LVMSupport' featureFlag: 'longhornV2LVMSupport'
}, },
[HCI_SETTING.LONGHORN_V2_DATA_ENGINE_HUGEPAGE_ENABLED]: { [HCI_SETTING.LONGHORN_V2_DATA_ENGINE_HUGEPAGE_ENABLED]: {
kind: 'boolean', kind: 'boolean',
preview: true,
featureFlag: 'longhornV2HugepageSettings' featureFlag: 'longhornV2HugepageSettings'
}, },
[HCI_SETTING.LONGHORN_V2_DATA_ENGINE_MEMORY_SIZE]: { [HCI_SETTING.LONGHORN_V2_DATA_ENGINE_MEMORY_SIZE]: {
kind: 'number', kind: 'number',
preview: true,
featureFlag: 'longhornV2HugepageSettings' featureFlag: 'longhornV2HugepageSettings'
}, },
[HCI_SETTING.ADDITIONAL_GUEST_MEMORY_OVERHEAD_RATIO]: { kind: 'string', from: 'import' }, [HCI_SETTING.ADDITIONAL_GUEST_MEMORY_OVERHEAD_RATIO]: { kind: 'string', from: 'import' },
@@ -390,17 +390,14 @@ export default {
:vmi-resource="vmi" :vmi-resource="vmi"
:vmim-resource="vmim" :vmim-resource="vmim"
/> />
<div <DashboardMetrics
v-if="showVmMetrics && liveMigrationProgressEnabled" v-if="showVmMetrics && liveMigrationProgressEnabled"
class="migration-metrics-scroll mb-30" :detail-url="VM_MIGRATION_DETAIL_URL"
> graph-height="640px"
<DashboardMetrics :has-summary-and-detail="false"
:detail-url="VM_MIGRATION_DETAIL_URL" :vars="graphVars"
graph-height="960px" class="mb-30"
:has-summary-and-detail="false" />
:vars="graphVars"
/>
</div>
<Events <Events
v-if="liveMigrationProgressEnabled" v-if="liveMigrationProgressEnabled"
:resource="vmi" :resource="vmi"
@@ -439,10 +436,3 @@ export default {
</Tabbed> </Tabbed>
</div> </div>
</template> </template>
<style lang="scss" scoped>
.migration-metrics-scroll {
max-height: 640px;
overflow-y: auto;
}
</style>
-164
View File
@@ -1,164 +0,0 @@
<script>
import merge from 'lodash/merge';
import jsyaml from 'js-yaml';
import { mapGetters } from 'vuex';
import { Card } from '@components/Card';
import { LabeledInput } from '@components/Form/LabeledInput';
import AsyncButton from '@shell/components/AsyncButton';
import { escapeHtml } from '@shell/utils/string';
const DEFAULT_VALUE = {
rancher: {
hostname: '',
version: '',
bootstrapPassword: '',
},
};
export default {
name: 'HarvesterEnableK3k',
emits: ['close'],
components: {
AsyncButton,
Card,
LabeledInput,
},
props: {
resources: {
type: Array,
required: true
}
},
data() {
const addon = this.resources[0];
let valuesContentJson;
try {
valuesContentJson = merge({}, DEFAULT_VALUE, jsyaml.load(addon.spec.valuesContent));
} catch (e) {
valuesContentJson = merge({}, DEFAULT_VALUE);
}
return { valuesContentJson };
},
computed: {
...mapGetters({ t: 'i18n/t' }),
buttonDisabled() {
const { rancher } = this.valuesContentJson;
return !(rancher?.hostname || '').trim() || !(rancher?.version || '').trim() || !(rancher?.bootstrapPassword || '').trim();
}
},
methods: {
close() {
this.$emit('close');
},
async enable(buttonCb) {
const addon = this.resources[0];
try {
addon.spec.valuesContent = jsyaml.dump(this.valuesContentJson);
addon.spec.enabled = true;
await addon.save();
buttonCb(true);
this.close();
} catch (err) {
addon.spec.enabled = false;
this.$store.dispatch('growl/fromError', {
title: this.t('generic.notification.title.error', { name: escapeHtml(addon.metadata.name) }),
err,
}, { root: true });
buttonCb(false);
}
}
}
};
</script>
<template>
<Card :show-highlight-border="false">
<template #title>
<h4
v-clean-html="t('harvester.addons.rancherK3k.enable.title')"
class="text-default-text"
/>
</template>
<template #body>
<div class="body">
<div class="row mb-15">
<div class="col span-6">
<LabeledInput
v-model:value="valuesContentJson.rancher.hostname"
:required="true"
:label="t('harvester.addons.rancherK3k.hostname')"
placeholder="rancher.$vip.nip.io"
/>
</div>
<div class="col span-6">
<LabeledInput
v-model:value="valuesContentJson.rancher.version"
:required="true"
:label="t('harvester.addons.rancherK3k.version')"
placeholder="v1.14.0"
/>
</div>
</div>
<div class="row mb-15">
<div class="col span-12">
<LabeledInput
v-model:value="valuesContentJson.rancher.bootstrapPassword"
:required="true"
type="password"
:label="t('harvester.addons.rancherK3k.password')"
:tooltip="t('harvester.addons.rancherK3k.passwordTooltip')"
/>
</div>
</div>
</div>
</template>
<template #actions>
<div class="buttons actions">
<button
class="btn role-secondary mr-10"
@click="close"
>
{{ t('generic.cancel') }}
</button>
<AsyncButton
mode="enable"
:disabled="buttonDisabled"
@click="enable"
/>
</div>
</template>
</Card>
</template>
<style lang="scss" scoped>
.body {
display: flex;
flex-direction: column;
min-width: 400px;
}
.actions {
width: 100%;
}
.buttons {
display: flex;
justify-content: flex-end;
width: 100%;
}
</style>
@@ -1,167 +0,0 @@
<script>
import merge from 'lodash/merge';
import jsyaml from 'js-yaml';
import { LabeledInput } from '@components/Form/LabeledInput';
import { RadioGroup } from '@components/Form/Radio';
const DEFAULT_VALUE = {
certManagerVersion: 'v1.20.2',
rancher: {
hostname: '',
version: '',
bootstrapPassword: '',
},
k3kCluster: {
servers: 1,
version: 'v1.35.4-k3s1',
storageClassName: 'harvester-longhorn',
},
};
export default {
name: 'EditAddonRancherK3k',
components: { LabeledInput, RadioGroup },
inheritAttrs: false,
props: {
value: {
type: Object,
required: true,
},
mode: {
type: String,
required: true
},
registerBeforeHook: {
type: Function,
required: true,
},
},
data() {
let valuesContentJson = {};
try {
valuesContentJson = merge({}, DEFAULT_VALUE, jsyaml.load(this.value.spec.valuesContent));
} catch (err) {
valuesContentJson = merge({}, DEFAULT_VALUE);
this.$store.dispatch('growl/fromError', {
title: this.$store.getters['i18n/t']('generic.notification.title.error'),
err: err.data || err,
}, { root: true });
}
return { valuesContentJson };
},
created() {
if (this.registerBeforeHook) {
this.registerBeforeHook(this.willSave, 'willSave');
}
},
methods: {
willSave() {
const errors = [];
if (!this.value.spec.enabled) {
return Promise.resolve();
}
if (!this.valuesContentJson.rancher.hostname) {
errors.push(this.t('validation.required', { key: this.t('harvester.addons.rancherK3k.hostname') }, true));
}
if (!this.valuesContentJson.rancher.version) {
errors.push(this.t('validation.required', { key: this.t('harvester.addons.rancherK3k.version') }, true));
}
if (!this.valuesContentJson.rancher.bootstrapPassword) {
errors.push(this.t('validation.required', { key: this.t('harvester.addons.rancherK3k.password') }, true));
}
if (errors.length > 0) {
return Promise.reject(errors);
} else {
return Promise.resolve();
}
},
},
watch: {
valuesContentJson: {
handler(neu) {
this.value.spec['valuesContent'] = jsyaml.dump(neu);
},
deep: true,
immediate: true
},
},
};
</script>
<template>
<div>
<div class="row">
<div class="col span-12">
<RadioGroup
v-model:value="value.spec.enabled"
class="mb-20"
name="model"
:mode="mode"
:options="[true,false]"
:labels="[t('generic.enabled'), t('generic.disabled')]"
/>
</div>
</div>
<template v-if="value.spec.enabled">
<div class="row mb-20">
<div class="col span-6">
<LabeledInput
v-model:value="valuesContentJson.rancher.hostname"
label-key="harvester.addons.rancherK3k.hostname"
:required="true"
:mode="mode"
placeholder="rancher.$vip.nip.io"
/>
</div>
<div class="col span-6">
<LabeledInput
v-model:value="valuesContentJson.rancher.version"
label-key="harvester.addons.rancherK3k.version"
:required="true"
:mode="mode"
placeholder="v1.14.0"
/>
</div>
</div>
<div class="row mt-20">
<div class="col span-6">
<LabeledInput
v-model:value="valuesContentJson.rancher.bootstrapPassword"
label-key="harvester.addons.rancherK3k.password"
:mode="mode"
:required="true"
type="password"
:tooltip="t('harvester.addons.rancherK3k.passwordTooltip')"
/>
</div>
</div>
</template>
</div>
</template>
<style lang="scss" scoped>
:deep() .radio-group {
display: flex;
.radio-container {
margin-right: 30px;
}
}
</style>
@@ -1,4 +1,5 @@
<script> <script>
import jsyaml from 'js-yaml';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import Tabbed from '@shell/components/Tabbed'; import Tabbed from '@shell/components/Tabbed';
import Tab from '@shell/components/Tabbed/Tab'; import Tab from '@shell/components/Tabbed/Tab';
@@ -177,8 +178,17 @@ export default {
}, },
async saveVMT(buttonCb) { async saveVMT(buttonCb) {
this.errors = [];
this.parseVM(); this.parseVM();
this.validateCloudInit();
if (this.errors.length) {
buttonCb(false);
return;
}
const templates = await this.$store.dispatch('harvester/findAll', { type: HCI.VM_TEMPLATE }); const templates = await this.$store.dispatch('harvester/findAll', { type: HCI.VM_TEMPLATE });
const template = templates.find( (O) => O.metadata.name === this.templateValue.metadata.name); const template = templates.find( (O) => O.metadata.name === this.templateValue.metadata.name);
@@ -237,6 +247,24 @@ export default {
this.$refs.yamlEditor?.refresh(); this.$refs.yamlEditor?.refresh();
} }
}, },
validateCloudInit() {
if (this.userScript) {
try {
jsyaml.load(this.userScript);
} catch (e) {
this.errors.push(this.t('harvester.virtualMachine.cloudConfig.user.invalidYaml'));
}
}
if (this.networkScript) {
try {
jsyaml.load(this.networkScript);
} catch (e) {
this.errors.push(this.t('harvester.virtualMachine.cloudConfig.network.invalidYaml'));
}
}
},
}, },
}; };
</script> </script>
@@ -246,27 +246,4 @@ export default {
.group-actions { .group-actions {
display: inline; display: inline;
} }
// Match the enable/disable passthrough bulk-action buttons height to the .btn (40px) on the right.
:deep(.bulk .rc-button.btn-medium.bulk-action:not(.btn-sm)) {
min-height: 40px;
}
// Make the collapsed "Actions" dropdown button 40px too.
:deep(.bulk .rc-button.btn-medium.bulk-actions-dropdown:not(.btn-sm)) {
min-height: 40px;
}
// Lay the bulk row out with flex so the "N selected" label can wrap below the buttons.
:deep(.bulk) {
display: flex;
flex-wrap: wrap;
align-items: center;
}
:deep(.bulk .action-availability) {
flex-basis: 100%;
margin-left: 0;
margin-top: 6px;
}
</style> </style>
@@ -5,7 +5,6 @@ import LabeledSelect from '@shell/components/form/LabeledSelect';
import Banner from '@components/Banner/Banner.vue'; import Banner from '@components/Banner/Banner.vue';
import remove from 'lodash/remove'; import remove from 'lodash/remove';
import { set } from '@shell/utils/object'; import { set } from '@shell/utils/object';
import { uniq } from '@shell/utils/array';
import { HCI } from '../../../types'; import { HCI } from '../../../types';
import DeviceList from './DeviceList'; import DeviceList from './DeviceList';
import CompatibilityMatrix from '../CompatibilityMatrix'; import CompatibilityMatrix from '../CompatibilityMatrix';
@@ -61,15 +60,7 @@ export default {
row.allowDisable = !vmDeviceNames.includes(row.metadata.name); row.allowDisable = !vmDeviceNames.includes(row.metadata.name);
}); });
// When off, read from spec; otherwise the spec name is a placeholder ('provisioned'), vmDevices.forEach(({ name }) => {
// so read the real allocated device names from the deviceAllocationDetails annotation.
const hostDeviceNames = this.vm.isOff ? [
...vmDevices.map(({ name }) => name),
] : [
...Object.values(this.vm?.provisionedHostDevices || {}).reduce((acc, devices) => [...acc, ...devices], []),
];
uniq(hostDeviceNames).forEach((name) => {
if (this.enabledDevices.find((device) => device?.metadata?.name === name)) { if (this.enabledDevices.find((device) => device?.metadata?.name === name)) {
selectedDevices.push(name); selectedDevices.push(name);
} }
@@ -1,4 +1,5 @@
<script> <script>
import jsyaml from 'js-yaml';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import Tabbed from '@shell/components/Tabbed'; import Tabbed from '@shell/components/Tabbed';
@@ -379,6 +380,7 @@ export default {
this.validateCPUMemory(); this.validateCPUMemory();
this.validateWindowsSysprep(); this.validateWindowsSysprep();
this.validateCloudInit();
// block create VM flow if has validation errors // block create VM flow if has validation errors
if (this.errors.length) { if (this.errors.length) {
@@ -424,6 +426,24 @@ export default {
} }
}, },
validateCloudInit() {
if (this.userScript) {
try {
jsyaml.load(this.userScript);
} catch (e) {
this.errors.push(this.t('harvester.virtualMachine.cloudConfig.user.invalidYaml'));
}
}
if (this.networkScript) {
try {
jsyaml.load(this.networkScript);
} catch (e) {
this.errors.push(this.t('harvester.virtualMachine.cloudConfig.network.invalidYaml'));
}
}
},
async saveSingle(buttonCb) { async saveSingle(buttonCb) {
this.parseVM(); this.parseVM();
this.value.spec.template.spec.hostname = this.hostname ? this.hostname : this.value.metadata.name; this.value.spec.template.spec.hostname = this.hostname ? this.hostname : this.value.metadata.name;
-1
View File
@@ -1 +0,0 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 165"><defs><style>.cls-1{fill:#30BA78;}.cls-2{fill:#fff;}</style></defs><rect class="cls-1" width="200" height="165" rx="20"/><path class="cls-2" d="M158.93945,121.73682H119.40527a5.0009,5.0009,0,0,1-4.33007-2.5L95.30859,84.99951a4.99813,4.99813,0,0,1,0-5L115.0752,45.7627a5.00088,5.00088,0,0,1,4.33007-2.5h39.53418a5.00088,5.00088,0,0,1,4.33008,2.5l19.7666,34.23681a4.99808,4.99808,0,0,1,0,5l-19.7666,34.23731A5.0009,5.0009,0,0,1,158.93945,121.73682Zm-36.64746-10h33.76074l16.87989-29.23731L156.05273,53.2627H122.292L105.41211,82.49951Z"/><path class="cls-2" d="M147.39258,101.73633H130.95312a5.0009,5.0009,0,0,1-4.33007-2.5L118.40332,85a4.99813,4.99813,0,0,1,0-5l8.21973-14.2373a5.00088,5.00088,0,0,1,4.33007-2.5h16.43946a5.00091,5.00091,0,0,1,4.33008,2.5L159.94238,80a4.99808,4.99808,0,0,1,0,5l-8.21972,14.23633A5.00093,5.00093,0,0,1,147.39258,101.73633Zm-13.55274-10h10.666l5.333-9.23633-5.333-9.2373h-10.666l-5.333,9.2373Z"/><path class="cls-2" d="M50.34082,121.73682H40.958a5.00092,5.00092,0,0,1-4.33008-2.5L16.86133,84.99951a4.99808,4.99808,0,0,1,0-5L36.62793,45.7627a5.0009,5.0009,0,0,1,4.33008-2.5h9.38281a5,5,0,0,1,0,10H43.84473L26.96484,82.49951l16.87989,29.23731h6.49609a5,5,0,1,1,0,10Z"/><path class="cls-2" d="M76.49023,121.73682H67.10742a5.00093,5.00093,0,0,1-4.33008-2.5L43.01074,84.99951a4.99813,4.99813,0,0,1,0-5L62.77734,45.7627a5.00091,5.00091,0,0,1,4.33008-2.5h9.38281a5,5,0,0,1,0,10H69.99414L53.11426,82.49951l16.87988,29.23731h6.49609a5,5,0,0,1,0,10Z"/><path class="cls-2" d="M102.63867,121.73682H93.25684a5.0009,5.0009,0,0,1-4.33008-2.5L69.16016,84.99951a4.99808,4.99808,0,0,1,0-5L88.92676,45.7627a5.00088,5.00088,0,0,1,4.33008-2.5h9.38183a5,5,0,0,1,0,10H96.14355L79.26367,82.49951l16.87988,29.23731h6.49512a5,5,0,1,1,0,10Z"/><path class="cls-2" d="M130.958,73.26367a4.99757,4.99757,0,0,1-4.335-2.501l-11.54785-20a5,5,0,1,1,8.66015-5l11.54785,20a5.00157,5.00157,0,0,1-4.32519,7.501Z"/><path class="cls-2" d="M147.3877,73.26367a5.00157,5.00157,0,0,1-4.3252-7.501l11.54688-20a5,5,0,1,1,8.66015,5l-11.54687,20A4.99758,4.99758,0,0,1,147.3877,73.26367Z"/><path class="cls-2" d="M178.70605,87.5H155.6123a5,5,0,0,1,0-10h23.09375a5,5,0,0,1,0,10Z"/><path class="cls-2" d="M122.7334,87.5H99.63867a5,5,0,1,1,0-10H122.7334a5,5,0,1,1,0,10Z"/><path class="cls-2" d="M119.40039,121.73779a5.00157,5.00157,0,0,1-4.32519-7.501l11.54785-20.00049a5,5,0,1,1,8.66015,5l-11.54785,20.00049A4.99757,4.99757,0,0,1,119.40039,121.73779Z"/><path class="cls-2" d="M158.94434,121.73779a4.99757,4.99757,0,0,1-4.335-2.501L143.0625,99.23633a5,5,0,0,1,8.66016-5l11.54687,20.00049a5.00157,5.00157,0,0,1-4.32519,7.501Z"/><path class="cls-2" d="M101.50195,87.49951H21.19141a5,5,0,0,1,0-10h80.31054a5,5,0,0,1,0,10Z"/></svg>

Before

Width:  |  Height:  |  Size: 2.7 KiB

+3 -15
View File
@@ -7,11 +7,10 @@ import harvesterStore from './store/harvester-store';
import customValidators from './validators'; import customValidators from './validators';
import { PRODUCT_NAME } from './config/harvester'; import { PRODUCT_NAME } from './config/harvester';
import { defineAsyncComponent } from 'vue'; import { defineAsyncComponent } from 'vue';
import semver from 'semver';
import './styles/vue-flow.scss'; import './styles/vue-flow.scss';
// Init the package // Init the package
export default function(plugin: IPlugin) { export default function (plugin: IPlugin) {
const isDev = process.env.NODE_ENV !== 'production'; const isDev = process.env.NODE_ENV !== 'production';
const isSingleVirtualCluster = process.env.rancherEnv === PRODUCT_NAME; const isSingleVirtualCluster = process.env.rancherEnv === PRODUCT_NAME;
@@ -21,19 +20,8 @@ export default function(plugin: IPlugin) {
// Provide plugin metadata from package.json // Provide plugin metadata from package.json
plugin.metadata = require('./package.json'); plugin.metadata = require('./package.json');
const version = semver.parse(plugin.metadata.version); // Built-in icon
const isHarvesterPrime = (version?.patch ?? 0) > 0; plugin.metadata.icon = require('./icon.svg');
const rancher = typeof plugin.metadata.rancher === 'object' ? plugin.metadata.rancher : {};
plugin.metadata.description = isHarvesterPrime ? 'Rancher UI Extension for Harvester Prime' : 'Rancher UI Extension for Harvester';
plugin.metadata.rancher = {
...rancher,
annotations: {
...rancher?.annotations,
'catalog.cattle.io/display-name': isHarvesterPrime ? 'SUSE Virtualization' : 'Harvester',
},
};
plugin.metadata.icon = isHarvesterPrime ? require('./harvester-prime.svg') : require('./icon.svg');
plugin.addProduct(require('./config/harvester-cluster')); plugin.addProduct(require('./config/harvester-cluster'));
+6 -22
View File
@@ -830,18 +830,20 @@ harvester:
label: User Data Template label: User Data Template
title: "User Data:" title: "User Data:"
tip: "You can specify user data to configure an instance or run a configuration script during launch. If you launch more than one instance at a time, the user data is available to all the instances in that reservation. <a href='https://cloudinit.readthedocs.io/en/latest/topics/examples.html' target='_blank'>Learn more</a>" tip: "You can specify user data to configure an instance or run a configuration script during launch. If you launch more than one instance at a time, the user data is available to all the instances in that reservation. <a href='https://cloudinit.readthedocs.io/en/latest/topics/examples.html' target='_blank'>Learn more</a>"
invalidYaml: 'Invalid User Data YAML syntax'
network: network:
label: Network Data Template label: Network Data Template
title: "Network Data:" title: "Network Data:"
tip: "The network-data configuration allows you to customize the instance's networking interfaces by assigning subnet configuration, virtual device creation (bonds, bridges, VLANs) routes and DNS configuration. <a href='https://cloudinit.readthedocs.io/en/latest/reference/network-config-format-v1.html' target='_blank'>Learn more</a>" tip: "The network-data configuration allows you to customize the instance's networking interfaces by assigning subnet configuration, virtual device creation (bonds, bridges, VLANs) routes and DNS configuration. <a href='https://cloudinit.readthedocs.io/en/latest/reference/network-config-format-v1.html' target='_blank'>Learn more</a>"
invalidYaml: 'Invalid Network Data YAML syntax'
sysprep: sysprep:
title: Windows Unattended & Sysprep Configuration title: Windows Sysprep Configuration
description: "Configure Windows automated installation using autounattend.xml. The configuration will be stored in a Kubernetes Secret and mounted as a CD-ROM during installation. <a href='https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/automate-windows-setup' target='_blank'>Learn more</a>" description: "Configure Windows automated installation using autounattend.xml. The configuration will be stored in a Kubernetes Secret and mounted as a CD-ROM during installation. <a href='https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/automate-windows-setup' target='_blank'>Learn more</a>"
createNew: Create new... createNew: Create new...
createNewTitle: Create Windows Unattended & Sysprep Template createNewTitle: Create Windows Sysprep Template
xmlContent: autounattend.xml content xmlContent: autounattend.xml content
secret: secret:
label: Windows Unattended & Sysprep Template label: Windows Sysprep Template
validation: validation:
invalidXml: Invalid XML syntax invalidXml: Invalid XML syntax
invalidNamespace: Invalid unattend.xml namespace. Expected 'urn:schemas-microsoft-com:unattend' invalidNamespace: Invalid unattend.xml namespace. Expected 'urn:schemas-microsoft-com:unattend'
@@ -1832,8 +1834,6 @@ harvester:
'rancher-logging': rancher-logging is an add-on to collect versatile logs, events, and audits from the Harvester cluster and route them to many kinds of servers based on flows. 'rancher-logging': rancher-logging is an add-on to collect versatile logs, events, and audits from the Harvester cluster and route them to many kinds of servers based on flows.
'rancher-monitoring': rancher-monitoring is an add-on to collect Harvester cluster and virtual machine metrics, view them on the embedded dashboard, and send alert(s) to remote servers. 'rancher-monitoring': rancher-monitoring is an add-on to collect Harvester cluster and virtual machine metrics, view them on the embedded dashboard, and send alert(s) to remote servers.
'rancher-vcluster': rancher-vcluster deploys a virtual cluster (vcluster) with Rancher installed. 'rancher-vcluster': rancher-vcluster deploys a virtual cluster (vcluster) with Rancher installed.
'k3k': k3k is an add-on to deploy the k3k controller.
'rancher-k3k': rancher-k3k deploys a k3k virtual cluster with Rancher installed.
'harvester-seeder': harvester-seeder is an add-on that uses IPMI and Redfish to discover hardware information and perform out-of-band operations. 'harvester-seeder': harvester-seeder is an add-on that uses IPMI and Redfish to discover hardware information and perform out-of-band operations.
'harvester-system/harvester-seeder': harvester-seeder is an add-on that uses IPMI and Redfish to discover hardware information and perform out-of-band operations. 'harvester-system/harvester-seeder': harvester-seeder is an add-on that uses IPMI and Redfish to discover hardware information and perform out-of-band operations.
'harvester-csi-driver-lvm': harvester-csi-driver-lvm is an add-on allowing users to create PVC through the LVM with local devices. 'harvester-csi-driver-lvm': harvester-csi-driver-lvm is an add-on allowing users to create PVC through the LVM with local devices.
@@ -2138,14 +2138,6 @@ harvester:
hostname: Hostname hostname: Hostname
rancherVersion: Rancher Version rancherVersion: Rancher Version
password: Bootstrap Password password: Bootstrap Password
rancherK3k:
accessRancher: Access the Rancher Dashboard
hostname: Hostname
version: Rancher Version
password: Bootstrap Password
passwordTooltip: The initial password in Rancher for the first time login.
enable:
title: Enable K3k
switchFailed: "{action} {name} failed!" switchFailed: "{action} {name} failed!"
nvidiaDriverToolkit: nvidiaDriverToolkit:
titles: titles:
@@ -2427,15 +2419,7 @@ typeDescription:
harvester: "Branding allows administrators to globally re-brand the UI by customizing the Harvester product name, logos and color scheme." harvester: "Branding allows administrators to globally re-brand the UI by customizing the Harvester product name, logos and color scheme."
advancedSettings: advancedSettings:
tags: experimental: 'Experimental features allow users to test and evaluate early-access functionality prior to official supported releases'
modified:
label: Modified
experimental:
label: Experimental
description: 'Experimental: The feature is incomplete but its essential functionality is operational. The feature is not recommended for use in production environments.'
preview:
label: Technical Preview
description: 'Technical Preview: The feature is almost complete and its functionality is not expected to change significantly. Explore the feature extensively before using in production environments.'
descriptions: descriptions:
'harv-vlan': Default Network Interface name of the VLAN network. 'harv-vlan': Default Network Interface name of the VLAN network.
'harv-backup-target': Custom backup target to store virtual machine backups. 'harv-backup-target': Custom backup target to store virtual machine backups.
+1 -1
View File
@@ -72,7 +72,7 @@ export default {
/> />
<a <a
v-if="['rancher-vcluster', 'rancher-k3k'].includes(scope.row.metadata.name) && scope.row.spec.enabled" v-if="scope.row.metadata.name === 'rancher-vcluster' && scope.row.spec.enabled"
v-tooltip="t('harvester.addons.rancherVcluster.accessRancher')" v-tooltip="t('harvester.addons.rancherVcluster.accessRancher')"
class="ml-5" class="ml-5"
rel="nofollow noopener noreferrer" rel="nofollow noopener noreferrer"
-12
View File
@@ -38,10 +38,6 @@ export const SSH_EXISTING_TYPE = {
export default { export default {
methods: { methods: {
hasCloudConfigComment(userScript) { hasCloudConfigComment(userScript) {
if (typeof userScript === 'string' && /^\s*#cloud-config(\s|$)/.test(userScript)) {
return true;
}
// Check that userData contains: #cloud-config // Check that userData contains: #cloud-config
const userDataDoc = userScript ? YAML.parseDocument(userScript) : YAML.parseDocument({}); const userDataDoc = userScript ? YAML.parseDocument(userScript) : YAML.parseDocument({});
const items = userDataDoc?.contents?.items || []; const items = userDataDoc?.contents?.items || [];
@@ -56,14 +52,6 @@ export default {
exist = true; exist = true;
} }
if (userDataDoc?.contents?.commentBefore === 'cloud-config' || userDataDoc?.contents?.commentBefore?.includes('cloud-config\n')) {
exist = true;
}
if (userDataDoc?.contents?.comment === 'cloud-config' || userDataDoc?.contents?.comment?.includes('cloud-config\n')) {
exist = true;
}
items.map((item) => { items.map((item) => {
const key = item.key; const key = item.key;
+3 -5
View File
@@ -1211,10 +1211,9 @@ export default {
userDataDoc = config.installAgent ? this.mergeQGA({ userDataDoc, ...config }) : this.deleteQGA({ userDataDoc, ...config }); userDataDoc = config.installAgent ? this.mergeQGA({ userDataDoc, ...config }) : this.deleteQGA({ userDataDoc, ...config });
const userDataYaml = userDataDoc.toString(); const userDataYaml = userDataDoc.toString();
const userDataValue = userDataDoc.toJSON();
if (userDataValue === null || (typeof userDataValue === 'object' && !Array.isArray(userDataValue) && isEmpty(userDataValue))) { if (userDataYaml === '{}\n') {
// Empty userData should not create cloud-init content like `null`. // When the YAML parsed value is '{}\n', it means that the userData is empty, then undefined is returned.
return undefined; return undefined;
} }
@@ -1317,9 +1316,8 @@ export default {
case SOURCE_TYPE.IMAGE: { case SOURCE_TYPE.IMAGE: {
const image = this.images.find( (I) => R.image === I.id); const image = this.images.find( (I) => R.image === I.id);
out.spec.storageClassName = R.realName ? R.storageClassName : (R.storageClassName || image?.storageClassName);
if (image) { if (image) {
out.spec.storageClassName = image.storageClassName;
out.metadata.annotations = { [HCI_ANNOTATIONS.IMAGE_ID]: image.id }; out.metadata.annotations = { [HCI_ANNOTATIONS.IMAGE_ID]: image.id };
} else { } else {
out.metadata.annotations = { [HCI_ANNOTATIONS.IMAGE_ID]: '' }; out.metadata.annotations = { [HCI_ANNOTATIONS.IMAGE_ID]: '' };
@@ -5,7 +5,6 @@ import SYSTEM_NAMESPACES from '@shell/config/system-namespaces';
import { get } from '@shell/utils/object'; import { get } from '@shell/utils/object';
import { NAMESPACE } from '@shell/config/types'; import { NAMESPACE } from '@shell/config/types';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '@pkg/harvester/config/harvester'; import { PRODUCT_NAME as HARVESTER_PRODUCT } from '@pkg/harvester/config/harvester';
import { FORKLIFT_NAMESPACE } from '@pkg/harvester/config/harvester-map';
import { HCI } from '../../types'; import { HCI } from '../../types';
const OBSCURE_NAMESPACE_PREFIX = [ const OBSCURE_NAMESPACE_PREFIX = [
@@ -94,10 +93,6 @@ export default class HciNamespace extends namespace {
} }
get isSystem() { get isSystem() {
if (this.metadata?.name === FORKLIFT_NAMESPACE) {
return false;
}
const systemNamespaces = ['fleet-default']; const systemNamespaces = ['fleet-default'];
if (systemNamespaces.includes(this.metadata.name)) { if (systemNamespaces.includes(this.metadata.name)) {
+6 -18
View File
@@ -5,14 +5,12 @@ import HarvesterResource from './harvester';
import { HCI } from '../types'; import { HCI } from '../types';
const HARVESTER_NVIDIA_DRIVER_TOOLKIT = 'harvester-system/nvidia-driver-toolkit'; const HARVESTER_NVIDIA_DRIVER_TOOLKIT = 'harvester-system/nvidia-driver-toolkit';
const RANCHER_VCLUSTER = 'harvester-system/rancher-vcluster';
const RANCHER_K3K_ADDON = 'rancher-k3k/rancher-k3k';
export default class HciAddonConfig extends HarvesterResource { export default class HciAddonConfig extends HarvesterResource {
get availableActions() { get availableActions() {
const out = super._availableActions; const out = super._availableActions;
if (this.id === RANCHER_VCLUSTER || this.id === RANCHER_K3K_ADDON) { if (this.id === 'harvester-system/rancher-vcluster') {
const rancherDashboard = { const rancherDashboard = {
action: 'goToRancher', action: 'goToRancher',
enabled: this.spec.enabled, enabled: this.spec.enabled,
@@ -59,15 +57,6 @@ export default class HciAddonConfig extends HarvesterResource {
return; return;
} }
if (!this.spec.enabled && this.id === RANCHER_K3K_ADDON) {
this.$dispatch('promptModal', {
resources: [this],
component: 'HarvesterEnableK3k',
});
return;
}
this.spec.enabled = !this.spec.enabled; this.spec.enabled = !this.spec.enabled;
await this.save(); await this.save();
} catch (err) { } catch (err) {
@@ -80,19 +69,18 @@ export default class HciAddonConfig extends HarvesterResource {
} }
goToRancher() { goToRancher() {
const valuesContent = jsyaml.load(this.spec.valuesContent);
window.open( window.open(
this.rancherHostname, `https://${ valuesContent.hostname }`,
'_blank', '_blank',
); );
} }
get rancherHostname() { get rancherHostname() {
const valuesContent = jsyaml.load(this.spec.valuesContent) || {}; const valuesContent = jsyaml.load(this.spec.valuesContent);
// rancher-k3k nests the hostname under `rancher`, rancher-vcluster keeps it at the top level return `https://${ valuesContent.hostname }`;
const hostname = this.id === RANCHER_K3K_ADDON ? valuesContent.rancher?.hostname : valuesContent.hostname;
return `https://${ hostname }`;
} }
get stateColor() { get stateColor() {
@@ -1315,18 +1315,6 @@ export default class VirtVm extends HarvesterResource {
} }
} }
get provisionedHostDevices() {
// Rancher-provisioned VMs store hostDevices.name as a placeholder ('provisioned'); the
// real allocated PCI device names live in this annotation, keyed by resourceName.
try {
const deviceAllocationDetails = JSON.parse(this.metadata?.annotations[HCI_ANNOTATIONS.VM_DEVICE_ALLOCATION_DETAILS] || '{}');
return deviceAllocationDetails?.hostdevices || {};
} catch (error) {
return {};
}
}
get schedulingVMBackupFeatureEnabled() { get schedulingVMBackupFeatureEnabled() {
return this.$rootGetters['harvester-common/getFeatureEnabled']('schedulingVMBackup'); return this.$rootGetters['harvester-common/getFeatureEnabled']('schedulingVMBackup');
} }
@@ -68,35 +68,29 @@ export default defineComponent({
return (this.value || []).map((plan) => { return (this.value || []).map((plan) => {
const planName = plan?.metadata?.name || '-'; const planName = plan?.metadata?.name || '-';
const namespace = plan?.metadata?.namespace || ''; const namespace = plan?.metadata?.namespace || '';
const networkMapRef = this.getPlanMapRef(plan, 'network');
const storageMapRef = this.getPlanMapRef(plan, 'storage');
const migrations = existing[HCI.FORKLIFT_MIGRATION] const migrations = existing[HCI.FORKLIFT_MIGRATION]
.filter((resource) => this.ownedByPlan(resource, plan)) .filter((resource) => this.ownedByPlan(resource, plan))
.map((resource) => resource?.metadata?.name) .map((resource) => ({
.filter(Boolean); name: resource?.metadata?.name,
namespace: resource?.metadata?.namespace || namespace,
}));
const matchedNetworkMap = networkMapRef ? existing[HCI.FORKLIFT_NETWORK_MAP].find((resource) => resource?.metadata?.name === networkMapRef.name && resource?.metadata?.namespace === networkMapRef.namespace) : null; const matchedNetworkMap = existing[HCI.FORKLIFT_NETWORK_MAP].find((resource) => this.ownedByPlan(resource, plan));
const matchedStorageMap = storageMapRef ? existing[HCI.FORKLIFT_STORAGE_MAP].find((resource) => resource?.metadata?.name === storageMapRef.name && resource?.metadata?.namespace === storageMapRef.namespace) : null; const matchedStorageMap = existing[HCI.FORKLIFT_STORAGE_MAP].find((resource) => this.ownedByPlan(resource, plan));
return { return {
planName, planName,
namespace, namespace,
migrations, migrations,
networkMap: matchedNetworkMap ? { networkMap: matchedNetworkMap ? {
namespace: matchedNetworkMap?.metadata?.namespace || networkMapRef?.namespace || namespace, namespace: matchedNetworkMap?.metadata?.namespace || namespace,
name: matchedNetworkMap?.metadata?.name, name: matchedNetworkMap?.metadata?.name,
} : (networkMapRef ? { } : null,
namespace: networkMapRef.namespace,
name: networkMapRef.name,
} : null),
storageMap: matchedStorageMap ? { storageMap: matchedStorageMap ? {
namespace: matchedStorageMap?.metadata?.namespace || storageMapRef?.namespace || namespace, namespace: matchedStorageMap?.metadata?.namespace || namespace,
name: matchedStorageMap?.metadata?.name, name: matchedStorageMap?.metadata?.name,
} : (storageMapRef ? { } : null,
namespace: storageMapRef.namespace,
name: storageMapRef.name,
} : null),
}; };
}); });
}, },
@@ -119,20 +113,6 @@ export default defineComponent({
methods: { methods: {
resourceNames, resourceNames,
getPlanMapRef(plan, mapType) {
const ref = plan?.spec?.map?.[mapType];
const name = ref?.name;
if (!name) {
return null;
}
return {
name,
namespace: ref?.namespace || plan?.metadata?.namespace || '',
};
},
/** /**
* Determine whether a related resource (migration / network map / storage map) * Determine whether a related resource (migration / network map / storage map)
* is owned by the given plan by inspecting its `metadata.ownerReferences`. * is owned by the given plan by inspecting its `metadata.ownerReferences`.
@@ -157,8 +137,9 @@ export default defineComponent({
const existing = this.existingRelatedResources; const existing = this.existingRelatedResources;
const targets = new Map(); const targets = new Map();
const addTarget = (type, name, namespace) => { const addTarget = (type, resource) => {
const ns = namespace || ''; const name = resource?.metadata?.name;
const ns = resource?.metadata?.namespace;
if (!name) { if (!name) {
return; return;
@@ -172,20 +153,17 @@ export default defineComponent({
}; };
for (const plan of this.value || []) { for (const plan of this.value || []) {
const networkMapRef = this.getPlanMapRef(plan, 'network'); existing[HCI.FORKLIFT_NETWORK_MAP]
const storageMapRef = this.getPlanMapRef(plan, 'storage'); .filter((resource) => this.ownedByPlan(resource, plan))
.forEach((resource) => addTarget(HCI.FORKLIFT_NETWORK_MAP, resource));
if (networkMapRef) { existing[HCI.FORKLIFT_STORAGE_MAP]
addTarget(HCI.FORKLIFT_NETWORK_MAP, networkMapRef.name, networkMapRef.namespace); .filter((resource) => this.ownedByPlan(resource, plan))
} .forEach((resource) => addTarget(HCI.FORKLIFT_STORAGE_MAP, resource));
if (storageMapRef) {
addTarget(HCI.FORKLIFT_STORAGE_MAP, storageMapRef.name, storageMapRef.namespace);
}
existing[HCI.FORKLIFT_MIGRATION] existing[HCI.FORKLIFT_MIGRATION]
.filter((resource) => this.ownedByPlan(resource, plan)) .filter((resource) => this.ownedByPlan(resource, plan))
.forEach((resource) => addTarget(HCI.FORKLIFT_MIGRATION, resource?.metadata?.name, resource?.metadata?.namespace)); .forEach((resource) => addTarget(HCI.FORKLIFT_MIGRATION, resource));
} }
return [...targets.values()]; return [...targets.values()];
@@ -278,11 +256,11 @@ export default defineComponent({
<div>• {{ t('harvester.addons.vmMigration.labels.migration') }}:</div> <div>• {{ t('harvester.addons.vmMigration.labels.migration') }}:</div>
<template v-if="summary.migrations.length"> <template v-if="summary.migrations.length">
<div <div
v-for="migrationName in summary.migrations" v-for="migration in summary.migrations"
:key="migrationName" :key="`${ migration.namespace }/${ migration.name }`"
> >
<div class="ml-20"> <div class="ml-20">
- {{ migrationName }} - {{ migration.name }}
</div> </div>
</div> </div>
</template> </template>
+1444 -1583
View File
File diff suppressed because it is too large Load Diff