Explorar el Código

Add ovirt / olvm plugin support

Sergiu Miclea hace 4 años
padre
commit
ec10976e34

+ 2 - 0
config.ts

@@ -103,6 +103,7 @@ const conf: Config = {
     oci: 3,
     opc: 3,
     oracle_vm: 3,
+    ovirt: 3,
   },
 
   providerNames: {
@@ -116,6 +117,7 @@ const conf: Config = {
     oci: 'OCI',
     opc: 'Oracle Cloud',
     oracle_vm: 'Oracle VM',
+    ovirt: 'OLVM',
   },
 
   // The list of the users to hide in the UI

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 22 - 0
server/api/resources/providerLogos/ovirt-128-disabled.svg


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 23 - 0
server/api/resources/providerLogos/ovirt-128.svg


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 23 - 0
server/api/resources/providerLogos/ovirt-32-white.svg


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 23 - 0
server/api/resources/providerLogos/ovirt-32.svg


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 22 - 0
server/api/resources/providerLogos/ovirt-42.svg


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 17 - 0
server/api/resources/providerLogos/ovirt-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' | 'kubevirt'
+export type ProviderTypes = 'azure' | 'openstack' | 'opc' | 'oracle_vm' | 'vmware_vsphere' | 'aws' | 'oci' | 'hyper-v' | 'scvmm' | 'ovirt' | 'kubevirt'
 
 export type Providers = {
   [provider in ProviderTypes]: {

+ 2 - 0
src/plugins/endpoint/index.ts

@@ -26,6 +26,7 @@ import DefaultOptionsSchemaPlugin from './default/OptionsSchemaPlugin'
 import OvmOptionsSchemaPlugin from './ovm/OptionsSchemaPlugin'
 import VmwareOptionsSchemaPlugin from './vmware_vsphere/OptionsSchemaPlugin'
 import OpenstackOptionsSchemaPlugin from './openstack/OptionsSchemaPlugin'
+import OvirtOptionsSchemaPlugin from './ovirt/OptionsSchemaPlugin'
 
 import DefaultInstanceInfoPlugin from './default/InstanceInfoPlugin'
 import OciInstanceInfoPlugin from './oci/InstanceInfoPlugin'
@@ -59,6 +60,7 @@ export const OptionsSchemaPlugin = {
       oracle_vm: OvmOptionsSchemaPlugin,
       openstack: OpenstackOptionsSchemaPlugin,
       vmware_vsphere: VmwareOptionsSchemaPlugin,
+      ovirt: OvirtOptionsSchemaPlugin,
     }
     if (hasKey(map, provider)) {
       return map[provider]

+ 113 - 0
src/plugins/endpoint/ovirt/OptionsSchemaPlugin.ts

@@ -0,0 +1,113 @@
+/*
+Copyright (C) 2017  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 DefaultOptionsSchemaPlugin, {
+  defaultFillMigrationImageMapValues,
+  defaultFillFieldValues,
+  defaultGetDestinationEnv,
+  defaultGetMigrationImageMap,
+} from '../default/OptionsSchemaPlugin'
+
+import type { InstanceScript } from '../../../@types/Instance'
+import type { Field } from '../../../@types/Field'
+import type { OptionValues, StorageMap } from '../../../@types/Endpoint'
+import type { SchemaProperties, SchemaDefinitions } from '../../../@types/Schema'
+import type { NetworkMap } from '../../../@types/Network'
+import { UserScriptData } from '../../../@types/MainItem'
+
+export default class OptionsSchemaParser {
+  static migrationImageMapFieldName = 'migr_template_map'
+
+  static parseSchemaToFields(
+    schema: SchemaProperties,
+    schemaDefinitions: SchemaDefinitions | null | undefined,
+    dictionaryKey: string,
+  ) {
+    const fields: Field[] = DefaultOptionsSchemaPlugin.parseSchemaToFields(schema, schemaDefinitions, dictionaryKey)
+    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
+  }
+
+  static sortFields(fields: Field[]) {
+    DefaultOptionsSchemaPlugin.sortFields(fields)
+  }
+
+  static fillFieldValues(field: Field, options: OptionValues[]) {
+    const option = options.find(f => f.name === field.name)
+    if (!option) {
+      return
+    }
+    if (!defaultFillMigrationImageMapValues(
+      field,
+      option,
+      this.migrationImageMapFieldName,
+    )) {
+      defaultFillFieldValues(field, option)
+    }
+  }
+
+  static getDestinationEnv(options: { [prop: string]: any } | null, oldOptions?: any) {
+    const env = {
+      ...defaultGetDestinationEnv(options, oldOptions),
+      ...defaultGetMigrationImageMap(
+        options,
+        oldOptions,
+        this.migrationImageMapFieldName,
+      ),
+    }
+    return env
+  }
+
+  static getNetworkMap(networkMappings: NetworkMap[] | null | undefined) {
+    return DefaultOptionsSchemaPlugin.getNetworkMap(networkMappings)
+  }
+
+  static getStorageMap(
+    defaultStorage: { value: string | null, busType?: string | null },
+    storageMap: StorageMap[] | null,
+    configDefault?: string | null,
+  ) {
+    return DefaultOptionsSchemaPlugin.getStorageMap(defaultStorage, storageMap, configDefault)
+  }
+
+  static getUserScripts(
+    uploadedUserScripts: InstanceScript[],
+    removedUserScripts: InstanceScript[],
+    userScriptData: UserScriptData | null | undefined,
+  ) {
+    return DefaultOptionsSchemaPlugin.getUserScripts(uploadedUserScripts, removedUserScripts, userScriptData)
+  }
+}

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio