mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 11:46:06 +08:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6700b2055e | ||
|
|
e486852f7a | ||
|
|
c19341bec9 | ||
|
|
8cbb9d6b18 | ||
|
|
00f0953592 | ||
|
|
58507f0b2e | ||
|
|
7785d7f469 | ||
|
|
2c043e0a8e |
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "harvester-ui-extension",
|
||||
"version": "1.8.0-dev",
|
||||
"version": "1.7.0-rc2",
|
||||
"private": false,
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
@@ -24,11 +24,11 @@
|
||||
"glob": "7.2.3",
|
||||
"glob-parent": "6.0.2",
|
||||
"json5": "2.2.3",
|
||||
"@types/lodash": "4.17.21",
|
||||
"@types/lodash": "4.17.20",
|
||||
"merge": "2.1.1",
|
||||
"node-forge": "1.3.3",
|
||||
"node-forge": "1.3.1",
|
||||
"nth-check": "2.1.1",
|
||||
"qs": "6.14.1",
|
||||
"qs": "6.14.0",
|
||||
"roarr": "7.21.2",
|
||||
"semver": "7.7.3",
|
||||
"@vue/cli-service/html-webpack-plugin": "^5.0.0"
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
# harvester-ui-extension
|
||||
|
||||
The Harvester UI Extension is a Rancher extension that provides the user interface for [Harvester](https://harvesterhci.io) within the [Rancher Dashboard](https://github.com/rancher/dashboard).
|
||||
|
||||
> **Note:**
|
||||
> This extension is available starting from **Rancher 2.10.0**. Ensure your Rancher version is **2.10.0 or later** to access Harvester integration.
|
||||
|
||||
## Installation
|
||||
|
||||
For detailed installation instructions, please refer to the [official Harvester documentation](https://docs.harvesterhci.io/v1.5/rancher/harvester-ui-extension#installation-on-rancher-210).
|
||||
|
||||
|
||||
## Development Setup
|
||||
|
||||
Ensure **Node.js v20 or later** is installed for development and debugging.
|
||||
|
||||
### Standalone Mode
|
||||
|
||||
Run the extension standalone with hot reload at `https://localhost:8005`.
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
yarn install
|
||||
|
||||
# Start the development server
|
||||
RANCHER_ENV=harvester API=https://your-harvester-ip yarn dev
|
||||
|
||||
# Example with specific server version
|
||||
RANCHER_ENV=harvester VUE_APP_SERVER_VERSION=v1.5.0 API=https://192.168.1.123 yarn dev
|
||||
```
|
||||
|
||||
You may also define environment variables in a `.env` file:
|
||||
|
||||
```env
|
||||
RANCHER_ENV=harvester
|
||||
VUE_APP_SERVER_VERSION=v1.5.0
|
||||
API=https://192.168.1.123
|
||||
```
|
||||
|
||||
### Rancher Integration Mode
|
||||
|
||||
To run as a Rancher extension, follow the [Rancher UI Extension Guide](https://extensions.rancher.io/extensions/next/extensions-getting-started#running-the-app).
|
||||
|
||||
```bash
|
||||
API=https://your-rancher-ip yarn dev
|
||||
```
|
||||
|
||||
## Commit Message Guidelines
|
||||
|
||||
This project uses [commit-lint](https://commitlint.js.org/) with [Conventional Commits](https://www.conventionalcommits.org/) to ensure consistent and meaningful commit messages.
|
||||
|
||||
### Commit Message Format
|
||||
|
||||
All commit messages must follow the conventional commit format:
|
||||
|
||||
```
|
||||
<type>[optional scope]: <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer(s)]
|
||||
```
|
||||
|
||||
### Supported Types
|
||||
|
||||
- **feat**: New features
|
||||
- **fix**: Bug fixes
|
||||
- **docs**: Documentation changes
|
||||
- **style**: Code style changes (formatting, missing semicolons, etc.)
|
||||
- **refactor**: Code refactoring
|
||||
- **perf**: Performance improvements
|
||||
- **test**: Adding or updating tests
|
||||
- **build**: Build system or external dependencies
|
||||
- **ci**: CI/CD changes
|
||||
- **chore**: Other changes that don't modify src or test files
|
||||
- **revert**: Reverts a previous commit
|
||||
- **wip**: Work in progress
|
||||
- **deps**: Dependency updates
|
||||
- **security**: Security fixes
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# Feature
|
||||
git commit -m "feat: add new virtual machine creation wizard"
|
||||
|
||||
# Bug fix
|
||||
git commit -m "fix: resolve memory leak in VM console"
|
||||
|
||||
# Documentation
|
||||
git commit -m "docs: update installation instructions"
|
||||
|
||||
# Breaking change
|
||||
git commit -m "feat!: change API endpoint structure
|
||||
|
||||
BREAKING CHANGE: The /api/v1/vms endpoint has been replaced with /api/v2/vms"
|
||||
```
|
||||
|
||||
### Git Hooks
|
||||
|
||||
The project uses [Husky](https://typicode.github.io/husky/) to automatically validate commit messages and run linting before commits:
|
||||
|
||||
- **pre-commit**: Runs ESLint to ensure code quality
|
||||
- **commit-msg**: Validates commit message format using commit-lint
|
||||
|
||||
These hooks are automatically installed when you run `yarn install`.
|
||||
|
||||
### Manual Validation
|
||||
|
||||
You can manually validate commit messages:
|
||||
|
||||
```bash
|
||||
# Validate the last commit
|
||||
yarn commitlint
|
||||
|
||||
# Validate a specific commit
|
||||
npx commitlint --from <commit-hash>
|
||||
|
||||
# Validate a range of commits
|
||||
npx commitlint --from <start-hash> --to <end-hash>
|
||||
```
|
||||
|
||||
## Branch Structure
|
||||
|
||||
- **`main`** – Main development branch
|
||||
- **`release-harvester-vX.Y`** – Stable release branches per version series
|
||||
- **`vX.Y-head`** – Testing branches for ongoing changes to extension builds in each release series
|
||||
|
||||
> **Note:**
|
||||
> The `vX.Y-head` branches are auto-generated and kept in sync with release branches. Use these for testing the latest changes in each version series.
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
### UI Extension Testing
|
||||
|
||||
To validate changes in a release series, switch to the appropriate `vX.Y-head` branch. For main branch testing, use `main-head`.
|
||||
|
||||
- Examples:
|
||||
- Test `1.0.x` series → `v1.0-head`
|
||||
- Test `1.5.x` series → `v1.5-head`
|
||||
|
||||
**Steps:**
|
||||
1. Navigate to **Rancher UI** → **Local** → **App** → **Repositories**
|
||||
2. Refresh the Harvester repository using the target `vX.Y-head` branch
|
||||
3. Go to the **Extensions** page and install the desired version
|
||||
|
||||
### Standalone Mode Testing
|
||||
|
||||
To test the standalone UI, configure Harvester to load the UI from an external source.
|
||||
|
||||
- Examples of `ui-index`:
|
||||
- Main branch → `https://releases.rancher.com/harvester-ui/dashboard/latest/index.html`
|
||||
- Release series `1.5.x` → `https://releases.rancher.com/harvester-ui/dashboard/release-harvester-v1.5/index.html`
|
||||
|
||||
**Steps:**
|
||||
1. Go to **Harvester UI** → **Advanced** → **Settings** → **UI**
|
||||
2. Set **ui-source** to `External`
|
||||
3. Set **ui-index** to the desired URL
|
||||
|
||||
## Contributing
|
||||
|
||||
If you want to contribute, start by reading this document, then visit our [Getting Started guide](https://extensions.rancher.io/extensions/next/extensions-getting-started) to learn how to develop and submit changes.
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2014-2025 [SUSE, LLC.](https://www.suse.com/)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -18,20 +18,16 @@ export default {
|
||||
|
||||
await this.$store.dispatch('harvester/findAll', { type: NAMESPACE });
|
||||
|
||||
if (this.customSupportBundleFeatureEnabled) {
|
||||
try {
|
||||
const url = this.$store.getters['harvester-common/getHarvesterClusterUrl']('v1/harvester/namespaces?link=supportbundle');
|
||||
const response = await this.$store.dispatch('harvester/request', { url });
|
||||
try {
|
||||
const url = this.$store.getters['harvester-common/getHarvesterClusterUrl']('v1/harvester/namespaces?link=supportbundle');
|
||||
const response = await this.$store.dispatch('harvester/request', { url });
|
||||
|
||||
this.defaultNamespaces = response.data || [];
|
||||
} catch (error) {
|
||||
this.defaultNamespaces = [];
|
||||
}
|
||||
} else {
|
||||
this.defaultNamespaces = response.data || [];
|
||||
} catch (error) {
|
||||
this.defaultNamespaces = [];
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -46,38 +42,24 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
customSupportBundleFeatureEnabled() {
|
||||
return this.$store.getters['harvester-common/getFeatureEnabled']('customSupportBundle');
|
||||
},
|
||||
|
||||
allNamespaces() {
|
||||
return this.$store.getters['harvester/all'](NAMESPACE).map((ns) => ns.id);
|
||||
},
|
||||
|
||||
filteredNamespaces() {
|
||||
if (!this.customSupportBundleFeatureEnabled) {
|
||||
return this.allNamespaces;
|
||||
}
|
||||
|
||||
const defaultIds = this.defaultNamespaces.map((ns) => ns.id);
|
||||
|
||||
return this.allNamespaces.filter((ns) => !defaultIds.includes(ns));
|
||||
},
|
||||
|
||||
namespaceOptions() {
|
||||
const mappedNamespaces = this.filteredNamespaces.map((ns) => ({ label: ns, value: ns }));
|
||||
|
||||
if (!this.customSupportBundleFeatureEnabled) {
|
||||
return mappedNamespaces;
|
||||
}
|
||||
|
||||
const allSelected =
|
||||
this.namespaces.length === this.filteredNamespaces.length &&
|
||||
this.filteredNamespaces.every((ns) => this.namespaces.includes(ns));
|
||||
|
||||
const controlOption = allSelected ? { label: this.t('harvester.modal.bundle.namespaces.unselectAll'), value: UNSELECT_ALL } : { label: this.t('harvester.modal.bundle.namespaces.selectAll'), value: SELECT_ALL };
|
||||
|
||||
return [controlOption, ...mappedNamespaces];
|
||||
return [controlOption, ...this.filteredNamespaces];
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ export const HCI = {
|
||||
STORAGE_CLASS: 'harvesterhci.io/storageClassName',
|
||||
STORAGE_NETWORK: 'storage-network.settings.harvesterhci.io',
|
||||
ADDON_EXPERIMENTAL: 'addon.harvesterhci.io/experimental',
|
||||
ADDON_DISPLAYNAME: 'addon.harvesterhci.io/displayName',
|
||||
VOLUME_ERROR: 'longhorn.io/volume-scheduling-error',
|
||||
VOLUME_FOR_VM: 'harvesterhci.io/volumeForVirtualMachine',
|
||||
KVM_AMD_CPU: 'cpu-feature.node.kubevirt.io/svm',
|
||||
@@ -77,5 +76,4 @@ export const HCI = {
|
||||
CLONE_STRATEGY: 'cdi.harvesterhci.io/storageProfileCloneStrategy',
|
||||
VOLUME_MODE_ACCESS_MODES: 'cdi.harvesterhci.io/storageProfileVolumeModeAccessModes',
|
||||
VOLUME_SNAPSHOT_CLASS: 'cdi.harvesterhci.io/storageProfileVolumeSnapshotClass',
|
||||
MAC_ADDRESS: 'harvesterhci.io/mac-address',
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ export default {
|
||||
<div class="row">
|
||||
<div class="col span-6 mb-20">
|
||||
<LabelValue
|
||||
:name="t('harvester.schedule.cron.label')"
|
||||
:name="t('harvester.schedule.cron')"
|
||||
:value="cronExpression"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,7 @@ export default {
|
||||
resources: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -43,7 +43,7 @@ export default {
|
||||
...mapState('action-menu', ['modalData']),
|
||||
|
||||
title() {
|
||||
return this.modalData?.title || 'dialog.promptRemove.title';
|
||||
return this.modalData.title || 'dialog.promptRemove.title';
|
||||
},
|
||||
|
||||
formattedType() {
|
||||
@@ -51,7 +51,7 @@ export default {
|
||||
},
|
||||
|
||||
warningMessage() {
|
||||
if (this.modalData?.warningMessage) return this.modalData.warningMessage;
|
||||
if (this.modalData.warningMessage) return this.modalData.warningMessage;
|
||||
|
||||
const isPlural = this.type.endsWith('s');
|
||||
const thisOrThese = isPlural ? 'these' : 'this';
|
||||
@@ -145,7 +145,6 @@ export default {
|
||||
try {
|
||||
for (const resource of this.resources) {
|
||||
await resource.remove();
|
||||
if (this.modalData?.extraActionAfterRemove) await this.modalData.extraActionAfterRemove();
|
||||
}
|
||||
buttonDone(true);
|
||||
this.close();
|
||||
|
||||
@@ -62,7 +62,7 @@ export default {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !pvc.attachVM;
|
||||
})
|
||||
.map((pvc) => {
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { RadioGroup } from '@components/Form/Radio';
|
||||
import { Banner } from '@components/Banner';
|
||||
import { LabeledInput } from '@components/Form/LabeledInput';
|
||||
@@ -17,7 +16,6 @@ import { sortBy } from '@shell/utils/sort';
|
||||
import { BACKUP_TYPE } from '../config/types';
|
||||
import { _EDIT, _CREATE } from '@shell/config/query-params';
|
||||
import { isBackupTargetSettingEmpty, isBackupTargetSettingUnavailable } from '../utils/setting';
|
||||
import CronExpressionEditorModal from '@shell/components/Cron/CronExpressionEditorModal.vue';
|
||||
|
||||
export default {
|
||||
name: 'CreateVMSchedule',
|
||||
@@ -30,7 +28,6 @@ export default {
|
||||
LabeledSelect,
|
||||
MessageLink,
|
||||
Banner,
|
||||
CronExpressionEditorModal
|
||||
},
|
||||
|
||||
mixins: [CreateEditView],
|
||||
@@ -89,12 +86,10 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
return { settings: [], showModel: false };
|
||||
return { settings: [] };
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters({ t: 'i18n/t' }),
|
||||
|
||||
backupTargetResource() {
|
||||
return this.settings.find( (O) => O.id === 'backup-target');
|
||||
},
|
||||
@@ -177,9 +172,6 @@ export default {
|
||||
this.value.spec['maxFailure'] = this.value.spec.retain;
|
||||
}
|
||||
},
|
||||
openModal() {
|
||||
this.showModel = true;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -264,28 +256,16 @@ export default {
|
||||
:weight="99"
|
||||
class="bordered-table"
|
||||
>
|
||||
<div class="cronEditor">
|
||||
<LabeledInput
|
||||
v-model:value="value.spec.cron"
|
||||
class="mb-30"
|
||||
type="cron"
|
||||
required
|
||||
:mode="mode"
|
||||
:label="t('harvester.schedule.cron.label')"
|
||||
placeholder="0 * * * *"
|
||||
:disabled="isBackupTargetUnAvailable || isView"
|
||||
/>
|
||||
<button
|
||||
class="editCronBtn btn role-primary"
|
||||
@click="openModal"
|
||||
>
|
||||
{{ t('harvester.schedule.cron.editButton') }}
|
||||
</button>
|
||||
<CronExpressionEditorModal
|
||||
v-model:show="showModel"
|
||||
v-model:cron-expression="value.spec.cron"
|
||||
/>
|
||||
</div>
|
||||
<LabeledInput
|
||||
v-model:value="value.spec.cron"
|
||||
class="mb-30"
|
||||
type="cron"
|
||||
required
|
||||
:mode="mode"
|
||||
:label="t('harvester.schedule.cron')"
|
||||
placeholder="0 * * * *"
|
||||
:disabled="isBackupTargetUnAvailable || isView"
|
||||
/>
|
||||
<LabeledInput
|
||||
v-model:value.number="value.spec.retain"
|
||||
class="mb-30"
|
||||
@@ -312,16 +292,3 @@ export default {
|
||||
</Tabbed>
|
||||
</CruResource>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.cronEditor {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.editCronBtn {
|
||||
margin-bottom: 30px;
|
||||
margin-left: 10px;
|
||||
height: 60px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -371,7 +371,7 @@ export default {
|
||||
<div class="key">
|
||||
<input
|
||||
v-model="scope.row.value"
|
||||
:placeholder="t('harvester.subnet.excludeIPs.placeholder')"
|
||||
:placeholder="t('harvester.setting.storageNetwork.exclude.placeholder')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+8
-6
@@ -99,6 +99,7 @@ export default {
|
||||
this.allPVCs
|
||||
.filter( (pvc) => {
|
||||
let isAvailable = true;
|
||||
let isBeingUsed = false;
|
||||
|
||||
this.rows.forEach( (O) => {
|
||||
if (O.volumeName === pvc.metadata.name) {
|
||||
@@ -110,16 +111,17 @@ export default {
|
||||
return false;
|
||||
}
|
||||
|
||||
// already used as image volume
|
||||
if (this.idx > 0 && pvc.metadata?.annotations?.[HCI_ANNOTATIONS.IMAGE_ID]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pvc.isGoldenImageVolume) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isAvailable && pvc.isAvailable;
|
||||
if (pvc.attachVM && isAvailable && pvc.attachVM?.id === this.vm?.id && this.isEdit) {
|
||||
isBeingUsed = false;
|
||||
} else if (pvc.attachVM) {
|
||||
isBeingUsed = true;
|
||||
}
|
||||
|
||||
return isAvailable && !isBeingUsed && pvc.isAvailable;
|
||||
})
|
||||
.map((pvc) => {
|
||||
return {
|
||||
|
||||
@@ -96,6 +96,7 @@ export default {
|
||||
templateVersionId: '',
|
||||
namePrefix: '',
|
||||
isSingle: true,
|
||||
useTemplate: false,
|
||||
isOpen: false,
|
||||
hostname,
|
||||
isRestartImmediately,
|
||||
@@ -254,7 +255,6 @@ export default {
|
||||
return volume;
|
||||
});
|
||||
|
||||
delete cloneVersionVM.metadata.annotations[HCI_ANNOTATIONS.MAC_ADDRESS];
|
||||
cloneVersionVM.metadata.annotations[HCI_ANNOTATIONS.VOLUME_CLAIM_TEMPLATE] = JSON.stringify(deleteDataSource);
|
||||
|
||||
// Update instance labels, labels and annotations
|
||||
@@ -490,7 +490,6 @@ export default {
|
||||
if (this.isSingle) {
|
||||
if (!this.value.spec.template.spec.hostname) {
|
||||
this.value.spec.template.spec['hostname'] = this.value.metadata.name;
|
||||
this.spec.template.spec['hostname'] = this.value.metadata.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -983,9 +983,7 @@ harvester:
|
||||
createTitle: Create Schedule
|
||||
createButtonText: Create Schedule
|
||||
scheduleType: Virtual Machine Schedule Type
|
||||
cron:
|
||||
label: Cron Schedule
|
||||
editButton: Edit
|
||||
cron: Cron Schedule
|
||||
detail:
|
||||
namespace: Namespace
|
||||
sourceVM: Source Virtual Machine
|
||||
@@ -1091,8 +1089,6 @@ harvester:
|
||||
placeholder: e.g. 172.16.0.0/16
|
||||
excludeIPs:
|
||||
tooltip: The IP address list to reserve from automatic assignment. The gateway IP address is always excluded and will be automatically added to the list.
|
||||
placeholder: single IP or 192.168.0.100..192.168.0.200
|
||||
|
||||
acl:
|
||||
label: Access Control List
|
||||
tooltip: The ACL to apply to this Subnet. Must be one of the ACLs in the same namespace.
|
||||
@@ -1208,7 +1204,7 @@ harvester:
|
||||
vlan: VLAN ID
|
||||
exclude:
|
||||
label: Exclude IPs
|
||||
placeholder: CIDR format, e.g. 172.16.0.10/32
|
||||
placeholder: e.g. 172.16.0.1
|
||||
invalid: '"Exclude list" is invalid.'
|
||||
addIp: Add Exclude IP
|
||||
warning: 'WARNING: <br/> Any change to storage-network requires shutting down all virtual machines before applying this setting. <br/> Users have to ensure the cluster network is configured and VLAN Configuration will cover all nodes and ensure the network connectivity is working and expected in all nodes.'
|
||||
@@ -1563,7 +1559,6 @@ harvester:
|
||||
'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.
|
||||
'descheduler': 'The virtual machine auto balance optimizes workload scheduling by evicting pods that are not optimally placed according to administrator-defined policies.'
|
||||
vmImport:
|
||||
titles:
|
||||
basic: Basic
|
||||
|
||||
@@ -142,7 +142,6 @@ export default {
|
||||
showYaml: false,
|
||||
spec: null,
|
||||
osType: 'linux',
|
||||
useTemplate: false,
|
||||
sshKey: [],
|
||||
maintenanceStrategies,
|
||||
maintenanceStrategy: 'Migrate',
|
||||
@@ -274,7 +273,7 @@ export default {
|
||||
|
||||
needNewSecret() {
|
||||
// When creating a template it is always necessary to create a new secret.
|
||||
return this.isCreate || this.showYaml ? false : this.resourceType === HCI.VM_VERSION;
|
||||
return this.isCreate ? true : this.showYaml ? false : this.resourceType === HCI.VM_VERSION;
|
||||
},
|
||||
|
||||
defaultTerminationSetting() {
|
||||
@@ -710,7 +709,16 @@ export default {
|
||||
|
||||
disk.forEach( (R, index) => {
|
||||
const prefixName = this.value.metadata?.name || '';
|
||||
const dataVolumeName = this.parseDataVolumeName(R, prefixName);
|
||||
|
||||
let dataVolumeName = '';
|
||||
|
||||
if (R.source === SOURCE_TYPE.ATTACH_VOLUME) {
|
||||
dataVolumeName = R.volumeName;
|
||||
} else if (this.isClone || !this.hasCreateVolumes.includes(R.realName)) {
|
||||
dataVolumeName = `${ prefixName }-${ R.name }-${ randomStr(5).toLowerCase() }`;
|
||||
} else {
|
||||
dataVolumeName = R.realName;
|
||||
}
|
||||
|
||||
const _disk = this.parseDisk(R, index);
|
||||
const _volume = this.parseVolume(R, dataVolumeName);
|
||||
@@ -1005,20 +1013,6 @@ export default {
|
||||
this['cpuMemoryHotplugEnabled'] = cpuMemoryHotplugEnabled;
|
||||
},
|
||||
|
||||
parseDataVolumeName(R, prefixName) {
|
||||
let dataVolumeName = '';
|
||||
|
||||
if (R.source === SOURCE_TYPE.ATTACH_VOLUME) {
|
||||
dataVolumeName = R.volumeName;
|
||||
} else if (this.isClone || !this.hasCreateVolumes.includes(R.realName)) {
|
||||
dataVolumeName = `${ prefixName }-${ R.name }-${ randomStr(5).toLowerCase() }`;
|
||||
} else {
|
||||
dataVolumeName = R.realName;
|
||||
}
|
||||
|
||||
return dataVolumeName;
|
||||
},
|
||||
|
||||
parseDisk(R, index) {
|
||||
const out = { name: R.name };
|
||||
|
||||
@@ -1644,8 +1638,7 @@ export default {
|
||||
|
||||
secretRef: {
|
||||
handler(secret) {
|
||||
// we should not inherit the secret if it's from VM template.
|
||||
if (secret && this.resourceType !== HCI.BACKUP && !this.useTemplate) {
|
||||
if (secret && this.resourceType !== HCI.BACKUP) {
|
||||
this.secretName = secret?.metadata.name;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import SteveModel from '@shell/plugins/steve/steve-class';
|
||||
import { escapeHtml } from '@shell/utils/string';
|
||||
import { colorForState } from '@shell/plugins/dashboard-store/resource-class';
|
||||
import HarvesterResource from './harvester';
|
||||
|
||||
/**
|
||||
* Class representing vGPU MIGConfiguration resource.
|
||||
* @extends HarvesterResource
|
||||
* @extends SteveModal
|
||||
*/
|
||||
export default class MIGCONFIGURATION extends HarvesterResource {
|
||||
export default class MIGCONFIGURATION extends SteveModel {
|
||||
get _availableActions() {
|
||||
let out = super._availableActions;
|
||||
|
||||
|
||||
@@ -113,9 +113,8 @@ export default class HciAddonConfig extends HarvesterResource {
|
||||
|
||||
get displayName() {
|
||||
const isExperimental = this.metadata?.labels?.[HCI_ANNOTATIONS.ADDON_EXPERIMENTAL] === 'true';
|
||||
const name = this.metadata?.labels?.[HCI_ANNOTATIONS.ADDON_DISPLAYNAME] || this.metadata.name;
|
||||
|
||||
return isExperimental ? `${ name } (${ this.t('generic.experimental') })` : name;
|
||||
return isExperimental ? `${ this.metadata.name } (${ this.t('generic.experimental') })` : this.metadata.name;
|
||||
}
|
||||
|
||||
get customValidationRules() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "harvester",
|
||||
"description": "Rancher UI Extension for Harvester",
|
||||
"version": "1.8.0-dev",
|
||||
"version": "1.7.0-rc2",
|
||||
"private": false,
|
||||
"rancher": {
|
||||
"annotations": {
|
||||
|
||||
@@ -12,7 +12,6 @@ import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../../../config/harvester'
|
||||
import ImagePercentageBar from '@shell/components/formatter/ImagePercentageBar';
|
||||
import { Banner } from '@components/Banner';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import { STORAGE_CLASS } from '@shell/config/types';
|
||||
|
||||
const IMAGE_METHOD = {
|
||||
NEW: 'new',
|
||||
@@ -33,7 +32,6 @@ export default {
|
||||
|
||||
async fetch() {
|
||||
await this.$store.dispatch('harvester/findAll', { type: HCI.IMAGE });
|
||||
await this.$store.dispatch('harvester/findAll', { type: STORAGE_CLASS });
|
||||
|
||||
const value = await this.$store.dispatch('harvester/create', {
|
||||
type: HCI.UPGRADE,
|
||||
@@ -65,7 +63,6 @@ export default {
|
||||
sourceType: UPLOAD,
|
||||
uploadController: null,
|
||||
uploadResult: null,
|
||||
storageClassValue: null,
|
||||
imageValue: null,
|
||||
enableLogging: true,
|
||||
IMAGE_METHOD,
|
||||
@@ -82,6 +79,7 @@ export default {
|
||||
skipSingleReplicaDetachedVolFeatureEnabled() {
|
||||
return this.$store.getters['harvester-common/getFeatureEnabled']('skipSingleReplicaDetachedVol');
|
||||
},
|
||||
|
||||
allOSImages() {
|
||||
return this.$store.getters['harvester/all'](HCI.IMAGE).filter((I) => I.isOSImage) || [];
|
||||
},
|
||||
@@ -118,7 +116,7 @@ export default {
|
||||
},
|
||||
|
||||
fileName() {
|
||||
return this.preprocessImageName(this.file?.name || '');
|
||||
return this.file?.name || '';
|
||||
},
|
||||
|
||||
canEnableLogging() {
|
||||
@@ -183,38 +181,6 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
async createImageStorageClass(imageName = '') {
|
||||
// delete related SC if existed
|
||||
await this.deleteImageStorageClass(imageName);
|
||||
|
||||
const storageClassPayload = {
|
||||
apiVersion: 'storage.k8s.io/v1',
|
||||
type: STORAGE_CLASS,
|
||||
metadata: { name: imageName },
|
||||
volumeBindingMode: 'Immediate',
|
||||
reclaimPolicy: 'Delete',
|
||||
allowVolumeExpansion: true, // must be boolean type
|
||||
provisioner: 'driver.longhorn.io',
|
||||
};
|
||||
|
||||
this.storageClassValue = await this.$store.dispatch('harvester/create', storageClassPayload);
|
||||
|
||||
if (this.storageClassValue && this.storageClassValue.save) {
|
||||
await this.storageClassValue.save();
|
||||
}
|
||||
},
|
||||
|
||||
async deleteImageStorageClass(imageName = '') {
|
||||
const inStore = this.$store.getters['currentProduct'].inStore;
|
||||
const storageClasses = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS);
|
||||
|
||||
const targetSC = storageClasses.find((sc) => sc.id === imageName);
|
||||
|
||||
if (targetSC && targetSC.remove) {
|
||||
await targetSC.remove();
|
||||
}
|
||||
},
|
||||
|
||||
async initImageValue() {
|
||||
this.imageValue = await this.$store.dispatch('harvester/create', {
|
||||
type: HCI.IMAGE,
|
||||
@@ -225,7 +191,6 @@ export default {
|
||||
annotations: {}
|
||||
},
|
||||
spec: {
|
||||
backend: 'cdi',
|
||||
sourceType: UPLOAD,
|
||||
displayName: '',
|
||||
checksum: this.imageValue?.spec?.checksum || '',
|
||||
@@ -238,9 +203,8 @@ export default {
|
||||
|
||||
this.file = {};
|
||||
this.errors = [];
|
||||
const imageDisplayName = this.imageValue?.spec?.displayName || '';
|
||||
|
||||
if (!imageDisplayName && this.createNewImage) {
|
||||
if (!this.imageValue.spec.displayName && this.createNewImage) {
|
||||
this.errors.push(this.$store.getters['i18n/t']('validation.required', { key: this.t('generic.name') }));
|
||||
buttonCb(false);
|
||||
|
||||
@@ -248,31 +212,24 @@ export default {
|
||||
}
|
||||
|
||||
try {
|
||||
// Save the image first if creating a new one
|
||||
if (this.imageSource === IMAGE_METHOD.NEW) {
|
||||
this.imageValue.metadata.annotations[HCI_ANNOTATIONS.OS_UPGRADE_IMAGE] = 'True';
|
||||
|
||||
if (this.sourceType === UPLOAD && this.uploadImageId !== '') { // upload new image
|
||||
this.value.spec.image = this.uploadImageId;
|
||||
} else if (this.sourceType === DOWNLOAD) { // give URL to download new image
|
||||
// check if URL is provided
|
||||
this.imageValue.spec.sourceType = DOWNLOAD;
|
||||
if (!this.imageValue.spec.url) {
|
||||
this.errors.push(this.$store.getters['i18n/t']('harvester.setting.upgrade.imageUrl'));
|
||||
buttonCb(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// create related image storage class first
|
||||
await this.createImageStorageClass(imageDisplayName);
|
||||
this.imageValue.spec.sourceType = DOWNLOAD;
|
||||
this.imageValue.spec.targetStorageClassName = imageDisplayName;
|
||||
|
||||
res = await this.imageValue.save();
|
||||
|
||||
this.value.spec.image = res.id;
|
||||
}
|
||||
} else if (this.imageSource === IMAGE_METHOD.EXIST) { // select existing image
|
||||
} else if (this.imageSource === IMAGE_METHOD.EXIST) {
|
||||
if (!this.imageId) {
|
||||
this.errors.push(this.$store.getters['i18n/t']('harvester.setting.upgrade.chooseFile'));
|
||||
buttonCb(false);
|
||||
@@ -282,7 +239,7 @@ export default {
|
||||
|
||||
this.value.spec.image = this.imageId;
|
||||
}
|
||||
// enable logging or skip single replica detection if checked
|
||||
|
||||
if (this.canEnableLogging) {
|
||||
this.value.spec.logEnabled = this.enableLogging;
|
||||
}
|
||||
@@ -295,13 +252,11 @@ export default {
|
||||
} catch (e) {
|
||||
this.errors = [e?.message] || exceptionToErrorsArray(e);
|
||||
buttonCb(false);
|
||||
// if anything failed, delete the created image storage class
|
||||
await this.deleteImageStorageClass(imageDisplayName);
|
||||
}
|
||||
},
|
||||
|
||||
async uploadFile(file) {
|
||||
const fileName = this.preprocessImageName(file.name);
|
||||
const fileName = file.name;
|
||||
|
||||
if (!fileName) {
|
||||
this.errors.push(this.$store.getters['i18n/t']('harvester.setting.upgrade.unknownImageName'));
|
||||
@@ -325,10 +280,6 @@ export default {
|
||||
this.imageValue.spec.url = '';
|
||||
|
||||
try {
|
||||
// before uploading image, we need to create related image storage class first
|
||||
await this.createImageStorageClass(fileName);
|
||||
this.imageValue.spec.targetStorageClassName = fileName;
|
||||
|
||||
const res = await this.imageValue.save();
|
||||
|
||||
this.uploadImageId = res.id;
|
||||
@@ -345,35 +296,20 @@ export default {
|
||||
} else {
|
||||
this.errors = exceptionToErrorsArray(e);
|
||||
}
|
||||
// if upload failed, delete the created image storage class
|
||||
await this.deleteImageStorageClass(fileName);
|
||||
this.file = {};
|
||||
this.uploadImageId = '';
|
||||
}
|
||||
},
|
||||
|
||||
// replace _ to - to meet storage class name requirement
|
||||
preprocessImageName(name) {
|
||||
if (!name) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return name.toLowerCase().replace(/[_]/g, '-');
|
||||
},
|
||||
|
||||
handleImageDelete(imageId) {
|
||||
const image = this.allOSImages.find((I) => I.id === imageId);
|
||||
const imageDisplayName = image?.spec?.displayName || '';
|
||||
|
||||
if (image && imageDisplayName) {
|
||||
if (image) {
|
||||
this.$store.dispatch('harvester/promptModal', {
|
||||
resources: [image],
|
||||
component: 'ConfirmRelatedToRemoveDialog',
|
||||
needConfirmation: false,
|
||||
warningMessage: this.$store.getters['i18n/t']('harvester.modal.osImage.message', { name: imageDisplayName }),
|
||||
extraActionAfterRemove: async() => {
|
||||
await this.deleteImageStorageClass(imageDisplayName);
|
||||
}
|
||||
resources: [image],
|
||||
component: 'ConfirmRelatedToRemoveDialog',
|
||||
needConfirmation: false,
|
||||
warningMessage: this.$store.getters['i18n/t']('harvester.modal.osImage.message', { name: image.displayName })
|
||||
});
|
||||
this.deleteImageId = '';
|
||||
}
|
||||
@@ -483,13 +419,13 @@ export default {
|
||||
v-if="showUploadSuccessBanner"
|
||||
color="success"
|
||||
class="mt-0 mb-30"
|
||||
:label="t('harvester.setting.upgrade.uploadSuccess', { name: fileName })"
|
||||
:label="t('harvester.setting.upgrade.uploadSuccess', { name: file.name })"
|
||||
/>
|
||||
<Banner
|
||||
v-if="showUploadingWarningBanner"
|
||||
color="warning"
|
||||
class="mt-0 mb-30"
|
||||
:label="t('harvester.image.warning.osUpgrade.uploading', { name: fileName })"
|
||||
:label="t('harvester.image.warning.osUpgrade.uploading', { name: file.name })"
|
||||
/>
|
||||
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user