Bladeren bron

Add support for 'rhev' provider

Sergiu Miclea 3 jaren geleden
bovenliggende
commit
bc6c709d14

+ 2 - 0
config.ts

@@ -110,6 +110,7 @@ const conf: Config = {
     opc: 3,
     oracle_vm: 3,
     olvm: 3,
+    rhev: 3,
     metal: 4,
   },
 
@@ -126,6 +127,7 @@ const conf: Config = {
     oracle_vm: 'Oracle VM',
     olvm: 'OLVM',
     metal: 'Bare Metal',
+    rhev: 'Red Hat',
   },
 
   // The list of providers for which to disable setting the 'Execute Now Options' field

File diff suppressed because it is too large
+ 14 - 0
server/api/resources/providerLogos/rhev-128-disabled.svg


File diff suppressed because it is too large
+ 14 - 0
server/api/resources/providerLogos/rhev-128.svg


File diff suppressed because it is too large
+ 12 - 0
server/api/resources/providerLogos/rhev-32-white.svg


File diff suppressed because it is too large
+ 12 - 0
server/api/resources/providerLogos/rhev-32.svg


File diff suppressed because it is too large
+ 12 - 0
server/api/resources/providerLogos/rhev-42.svg


File diff suppressed because it is too large
+ 12 - 0
server/api/resources/providerLogos/rhev-64.svg


+ 1 - 1
src/@types/Providers.ts

@@ -12,7 +12,7 @@ You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-export type ProviderTypes = 'azure' | 'openstack' | 'opc' | 'oracle_vm' | 'vmware_vsphere' | 'aws' | 'oci' | 'hyper-v' | 'scvmm' | 'olvm' | 'kubevirt' | 'metal'
+export type ProviderTypes = 'azure' | 'openstack' | 'opc' | 'oracle_vm' | 'vmware_vsphere' | 'aws' | 'oci' | 'hyper-v' | 'scvmm' | 'olvm' | 'kubevirt' | 'metal' | 'rhev'
 
 export type Providers = {
   [provider in ProviderTypes]: {

+ 2 - 0
src/plugins/index.ts

@@ -30,6 +30,7 @@ import OvmOptionsSchemaPlugin from './ovm/OptionsSchemaPlugin'
 import VmwareOptionsSchemaPlugin from './vmware_vsphere/OptionsSchemaPlugin'
 import OpenstackOptionsSchemaPlugin from './openstack/OptionsSchemaPlugin'
 import OlvmOptionsSchemaPlugin from './olvm/OptionsSchemaPlugin'
+import RhevOptionsSchemaPlugin from './rhev/OptionsSchemaPlugin'
 import AzureOptionsSchemaPlugin from './azure/OptionsSchemaPlugin'
 
 import DefaultInstanceInfoPlugin from './default/InstanceInfoPlugin'
@@ -65,6 +66,7 @@ export const OptionsSchemaPlugin = {
       openstack: new OpenstackOptionsSchemaPlugin(),
       vmware_vsphere: new VmwareOptionsSchemaPlugin(),
       olvm: new OlvmOptionsSchemaPlugin(),
+      rhev: new RhevOptionsSchemaPlugin(),
       azure: new AzureOptionsSchemaPlugin(),
     }
     if (hasKey(map, provider)) {

+ 91 - 0
src/plugins/rhev/OptionsSchemaPlugin.ts

@@ -0,0 +1,91 @@
+/*
+Copyright (C) 2022  Cloudbase Solutions SRL
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+import type { Field } from '@src/@types/Field'
+import type { OptionValues } from '@src/@types/Endpoint'
+import type { SchemaProperties, SchemaDefinitions } from '@src/@types/Schema'
+import OptionsSchemaPluginBase, {
+  defaultFillMigrationImageMapValues,
+  defaultFillFieldValues,
+  defaultGetDestinationEnv,
+  defaultGetMigrationImageMap,
+} from '../default/OptionsSchemaPlugin'
+
+export default class OptionsSchemaParser extends OptionsSchemaPluginBase {
+  override migrationImageMapFieldName = 'migr_template_map'
+
+  override parseSchemaToFields(opts: {
+    schema: SchemaProperties,
+    schemaDefinitions?: SchemaDefinitions | null | undefined,
+    dictionaryKey?: string,
+    requiresWindowsImage?: boolean,
+  }) {
+    const fields: Field[] = super.parseSchemaToFields(opts)
+    fields.forEach(f => {
+      if (
+        f.name !== 'migr_template_username_map'
+        && f.name !== 'migr_template_password_map'
+      ) {
+        return
+      }
+
+      const password = f.name === 'migr_template_password_map'
+      f.properties = [
+        {
+          type: 'string',
+          name: 'windows',
+          password,
+        },
+        {
+          type: 'string',
+          name: 'linux',
+          password,
+        },
+      ]
+    })
+
+    return fields
+  }
+
+  // @TODO - check if this override is necessary, aka this.migrationImageMapFieldName is used from this class
+  override fillFieldValues(opts: { field: Field, options: OptionValues[], requiresWindowsImage: boolean }) {
+    const { field, options, requiresWindowsImage } = opts
+
+    const option = options.find(f => f.name === field.name)
+    if (!option) {
+      return
+    }
+    if (!defaultFillMigrationImageMapValues({
+      field,
+      option,
+      migrationImageMapFieldName: this.migrationImageMapFieldName,
+      requiresWindowsImage,
+    })) {
+      defaultFillFieldValues(field, option)
+    }
+  }
+
+  // @TODO - check if this override is necessary, aka this.migrationImageMapFieldName is used from this class
+  override getDestinationEnv(options: { [prop: string]: any } | null, oldOptions?: any) {
+    const env = {
+      ...defaultGetDestinationEnv(options, oldOptions),
+      ...defaultGetMigrationImageMap(
+        options,
+        oldOptions,
+        this.migrationImageMapFieldName,
+      ),
+    }
+    return env
+  }
+}

Some files were not shown because too many files changed in this diff