From 681b1e4261242d0b9b924ac2d2bdb39931867dfd Mon Sep 17 00:00:00 2001 From: Francesco Torchia Date: Mon, 4 Nov 2024 18:38:51 +0100 Subject: [PATCH] Remove Virtualization Management Signed-off-by: Francesco Torchia --- pkg/harvester/config/harvester-manager.js | 114 --------- .../harvesterhci.io.management.cluster.vue | 104 -------- .../harvesterhci.io.management.cluster.vue | 160 ------------ pkg/harvester/l10n/en-us.yaml | 14 - .../harvesterhci.io.management.cluster.vue | 241 ------------------ .../harvesterhci.io.management.cluster.js | 177 ------------- 6 files changed, 810 deletions(-) delete mode 100644 pkg/harvester/config/harvester-manager.js delete mode 100644 pkg/harvester/detail/harvesterhci.io.management.cluster.vue delete mode 100644 pkg/harvester/edit/harvesterhci.io.management.cluster.vue delete mode 100644 pkg/harvester/list/harvesterhci.io.management.cluster.vue delete mode 100644 pkg/harvester/models/harvesterhci.io.management.cluster.js diff --git a/pkg/harvester/config/harvester-manager.js b/pkg/harvester/config/harvester-manager.js deleted file mode 100644 index b157a8b4..00000000 --- a/pkg/harvester/config/harvester-manager.js +++ /dev/null @@ -1,114 +0,0 @@ -import { HCI, MANAGEMENT, CAPI } from '@shell/config/types'; -import { HARVESTER, MULTI_CLUSTER } from '@shell/store/features'; -import { STATE, NAME as NAME_COL, AGE, VERSION } from '@shell/config/table-headers'; -import { allHash } from '@shell/utils/promise'; -import { BLANK_CLUSTER } from '@shell/store/store-types.js'; - -export const PRODUCT_NAME = 'harvester-manager'; - -export const NAME = 'harvesterManager'; - -const MACHINE_POOLS = { - name: 'summary', - labelKey: 'tableHeaders.machines', - sort: false, - search: false, - value: 'nodes.length', - align: 'center', - width: 100, -}; - -const harvesterClustersLocation = { - name: 'c-cluster-product-resource', - params: { - cluster: BLANK_CLUSTER, - product: NAME, - resource: HCI.CLUSTER - } -}; - -export function init($plugin, store) { - const { - product, - basicType, - headers, - spoofedType, - configureType - } = $plugin.DSL(store, NAME); - - product({ - ifHaveType: CAPI.RANCHER_CLUSTER, - ifFeature: [MULTI_CLUSTER, HARVESTER], - inStore: 'management', - icon: 'harvester', - removable: false, - showClusterSwitcher: false, - weight: 100, - to: harvesterClustersLocation, - category: 'hci', - }); - - configureType(HCI.CLUSTER, { showListMasthead: false }); - headers(HCI.CLUSTER, [ - STATE, - NAME_COL, - { - ...VERSION, - value: 'kubernetesVersion', - getValue: (row) => row.kubernetesVersion - }, - MACHINE_POOLS, - AGE, - { - name: 'harvester', - label: ' ', - align: 'right', - width: 65, - }, - ]); - basicType([HCI.CLUSTER]); - spoofedType({ - labelKey: 'harvesterManager.cluster.label', - name: HCI.CLUSTER, - type: HCI.CLUSTER, - namespaced: false, - weight: -1, - route: { - name: 'c-cluster-product-resource', - params: { - product: NAME, - resource: HCI.CLUSTER, - } - }, - exact: false, - schemas: [ - { - id: HCI.CLUSTER, - type: 'schema', - collectionMethods: [], - resourceFields: {}, - attributes: { namespaced: true }, - }, - ], - group: 'Root', - getInstances: async() => { - const hash = { - rancherClusters: store.dispatch('management/findAll', { type: CAPI.RANCHER_CLUSTER }), - clusters: store.dispatch('management/findAll', { type: MANAGEMENT.CLUSTER }), - }; - - if (store.getters['management/schemaFor'](MANAGEMENT.NODE)) { - hash.nodes = store.dispatch('management/findAll', { type: MANAGEMENT.NODE }); - } - - const res = await allHash(hash); - - return res.rancherClusters.map((c) => { - return { - ...c, - type: HCI.CLUSTER, - }; - }); - }, - }); -} diff --git a/pkg/harvester/detail/harvesterhci.io.management.cluster.vue b/pkg/harvester/detail/harvesterhci.io.management.cluster.vue deleted file mode 100644 index c3525838..00000000 --- a/pkg/harvester/detail/harvesterhci.io.management.cluster.vue +++ /dev/null @@ -1,104 +0,0 @@ - - - diff --git a/pkg/harvester/edit/harvesterhci.io.management.cluster.vue b/pkg/harvester/edit/harvesterhci.io.management.cluster.vue deleted file mode 100644 index 93860b88..00000000 --- a/pkg/harvester/edit/harvesterhci.io.management.cluster.vue +++ /dev/null @@ -1,160 +0,0 @@ - - - diff --git a/pkg/harvester/l10n/en-us.yaml b/pkg/harvester/l10n/en-us.yaml index 0b1f1429..c633a5e4 100644 --- a/pkg/harvester/l10n/en-us.yaml +++ b/pkg/harvester/l10n/en-us.yaml @@ -1,14 +1,4 @@ harvesterManager: - manage: Manage - cluster: - label: Harvester Clusters - none: There are no Harvester Clusters - learnMore: Learn more about Harvester from the Harvester Web Site or read the the Harvester Docs - description: Harvester is a modern Hyperconverged infrastructure (HCI) solution built for bare metal servers using enterprise-grade open source technologies including Kubernetes, Kubevirt and Longhorn. - plugins: - loadError: Error loading harvester plugin - rke: - templateError: Incorrect template format affinity: thisPodNamespace: This VM's namespace matchExpressions: @@ -20,10 +10,6 @@ harvesterManager: addLabel: Add Workload Selector topologyKey: placeholder: 'topology.kubernetes.io/zone' - vGpu: - title: VGPUs - label: VGPU type - placeholder: 'Please select a VGPU' generic: tip: Tip diff --git a/pkg/harvester/list/harvesterhci.io.management.cluster.vue b/pkg/harvester/list/harvesterhci.io.management.cluster.vue deleted file mode 100644 index 4e6f47db..00000000 --- a/pkg/harvester/list/harvesterhci.io.management.cluster.vue +++ /dev/null @@ -1,241 +0,0 @@ - - - - - diff --git a/pkg/harvester/models/harvesterhci.io.management.cluster.js b/pkg/harvester/models/harvesterhci.io.management.cluster.js deleted file mode 100644 index 6a2a407e..00000000 --- a/pkg/harvester/models/harvesterhci.io.management.cluster.js +++ /dev/null @@ -1,177 +0,0 @@ -import ProvCluster from '@shell/models/provisioning.cattle.io.cluster'; -import { DEFAULT_WORKSPACE, HCI, MANAGEMENT } from '@shell/config/types'; -import { HARVESTER_NAME, HARVESTER_NAME as VIRTUAL } from '@shell/config/features'; -import { SETTING } from '@shell/config/settings'; - -export default class HciCluster extends ProvCluster { - get stateObj() { - return this._stateObj; - } - - applyDefaults() { - if ( !this.spec ) { - this['spec'] = { agentEnvVars: [] }; - this['metadata'] = { namespace: DEFAULT_WORKSPACE }; - } - } - - get isReady() { - // If the Connected condition exists, use that (2.6+) - if ( this.hasCondition('Connected') ) { - return this.isCondition('Connected'); - } - - // Otherwise use Ready (older) - return this.isCondition('Ready'); - } - - get canEdit() { - return false; - } - - /** - * Fetch and cache the response for /ui-info - * - * Storing this in a cache means any changes to `ui-info` require a dashboard refresh... but it cuts out a http request every time we - * go to a cluster - * - * @param {string} clusterId - */ - async _getUiInfo(clusterId) { - if (!this._uiInfo) { - try { - const infoUrl = `/k8s/clusters/${ clusterId }/v1/harvester/ui-info`; - - this._uiInfo = await this.$dispatch('request', { url: infoUrl }); - } catch (e) { - console.info(`Failed to fetch harvester ui-info from ${ this.nameDisplay }, this may be an older cluster that cannot provide one`); // eslint-disable-line no-console - } - } - - return this._uiInfo; - } - - /** - * Determine the harvester plugin's package name and url for legacy clusters that don't provide the package (i.e. it's coming from - * outside the cluster) - */ - _legacyClusterPkgDetails() { - let uiOfflinePreferred = this.$rootGetters['management/byId'](MANAGEMENT.SETTING, SETTING.UI_OFFLINE_PREFERRED)?.value; - // options: ['dynamic', 'true', 'false'] - - if (uiOfflinePreferred === 'dynamic') { - // We shouldn't need to worry about the version of the dashboard when embedded in harvester (aka in isSingleProduct) - const version = this.$rootGetters['management/byId'](MANAGEMENT.SETTING, SETTING.VERSION_RANCHER)?.value; - - if (version.endsWith('-head')) { - uiOfflinePreferred = 'false'; - } else { - uiOfflinePreferred = 'true'; - } - } - - // This is the version that's embedded in the dashboard - const pkgName = `${ HARVESTER_NAME }-1.0.3`; - - if (uiOfflinePreferred === 'true') { - // Embedded (aka give me the embedded plugin that was in the last rancher release) - const embeddedPath = `${ pkgName }/${ pkgName }.umd.min.js`; - - return { - pkgUrl: process.env.dev ? `${ process.env.api }/dashboard/${ embeddedPath }` : embeddedPath, - pkgName - }; - } - - if (uiOfflinePreferred === 'false') { - // Remote (aka give me the latest version of the embedded plugin that might not have been released yet) - const uiDashboardHarvesterRemotePlugin = this.$rootGetters['management/byId'](MANAGEMENT.SETTING, SETTING.UI_DASHBOARD_HARVESTER_LEGACY_PLUGIN)?.value; - const parts = uiDashboardHarvesterRemotePlugin?.replace('.umd.min.js', '').split('/'); - const pkgNameFromUrl = parts?.length > 1 ? parts[parts.length - 1] : null; - - if (!pkgNameFromUrl) { - throw new Error(`Unable to determine harvester plugin name from '${ uiDashboardHarvesterRemotePlugin }'`); - } - - return { - pkgUrl: uiDashboardHarvesterRemotePlugin, - pkgName: pkgNameFromUrl - }; - } - - throw new Error(`Unsupported value for ${ SETTING.UI_OFFLINE_PREFERRED }: 'uiOfflinePreferred'`); - } - - /** - * Determine the harvester plugin's package name and url for clusters that provide the plugin - */ - _supportedClusterPkgDetails(uiInfo, clusterId) { - let pkgName = `${ HARVESTER_NAME }-${ uiInfo['ui-plugin-bundled-version'] }`; - const fileName = `${ pkgName }.umd.min.js`; - let pkgUrl; - - if (uiInfo['ui-source'] === 'bundled' ) { // offline bundled - pkgUrl = `/k8s/clusters/${ clusterId }/v1/harvester/plugin-assets/${ fileName }`; - } else if (uiInfo['ui-source'] === 'external') { - if (uiInfo['ui-plugin-index']) { - pkgUrl = uiInfo['ui-plugin-index']; - - // When using an external address, the pkgName should also be get from the url - const names = pkgUrl.split('/'); - const jsName = names[names.length - 1]; - - pkgName = jsName?.split('.umd.min.js')[0]; - } else { - throw new Error('Harvester cluster requested the plugin at `ui-plugin-index` is used, however did not provide a value for it'); - } - } - - return { - pkgUrl, - pkgName - }; - } - - _overridePkgDetails() { - // Support loading the pkg from a locally, or other, address - // This helps testing of the harvester plugin when packaged up, instead of directly imported - const harvesterPkgUrl = process.env.harvesterPkgUrl; - - if (!harvesterPkgUrl) { - return; - } - const parts = harvesterPkgUrl.replace('.umd.min.js', '').split('/'); - const pkgNameFromUrl = parts.length > 1 ? parts[parts.length - 1] : null; - - if (pkgNameFromUrl) { - return { - pkgUrl: harvesterPkgUrl, - pkgName: pkgNameFromUrl - }; - } - } - - async _pkgDetails() { - const overridePkgDetails = this._overridePkgDetails(); - - if (overridePkgDetails) { - return overridePkgDetails; - } - - const clusterId = this.mgmt.id; - const uiInfo = await this._getUiInfo(clusterId); - - return uiInfo ? this._supportedClusterPkgDetails(uiInfo, clusterId) : this._legacyClusterPkgDetails(); - } - - async goToCluster() { - this.currentRouter().push({ - name: `${ VIRTUAL }-c-cluster-resource`, - params: { - cluster: this.status.clusterName, - product: VIRTUAL, - resource: HCI.DASHBOARD // Go directly to dashboard to avoid blip of components on screen - } - }); - } -}