瀏覽代碼

Disable VMWare target deployment disk cloning

Sergiu Miclea 5 年之前
父節點
當前提交
9569ef1618

+ 9 - 0
config.ts

@@ -86,6 +86,15 @@ const conf: Config = {
     },
     },
   ],
   ],
 
 
+  providerMigrationOptions: {
+    vmware_vsphere: {
+      cloneDiskDisabledOptions: {
+        defaultValue: false,
+        description: 'Replica Deployments on VMware do not currently support Replica disk cloning',
+      },
+    },
+  },
+
   /*
   /*
   Lower number means that the provider will appear sooner in the list.
   Lower number means that the provider will appear sooner in the list.
   Equal number means alphabetical order within the same group number.
   Equal number means alphabetical order within the same group number.

+ 14 - 0
src/@types/Config.ts

@@ -1,3 +1,5 @@
+import { ProviderTypes } from './Providers'
+
 type Type = 'source' | 'destination'
 type Type = 'source' | 'destination'
 
 
 type ExtraOption = {
 type ExtraOption = {
@@ -20,6 +22,17 @@ export type Services = {
   coriolisLicensing: string,
   coriolisLicensing: string,
 }
 }
 
 
+export type ProviderMigrationCloneDiskDisabledOption = {
+  defaultValue: boolean
+  description: string
+}
+
+export type ProviderMigrationOptions = {
+  [provider in ProviderTypes]?: {
+    cloneDiskDisabledOptions: ProviderMigrationCloneDiskDisabledOption
+  }
+}
+
 export type Config = {
 export type Config = {
   disabledPages: string[],
   disabledPages: string[],
   showUserDomainInput: boolean,
   showUserDomainInput: boolean,
@@ -36,4 +49,5 @@ export type Config = {
   mainListItemsPerPage: number,
   mainListItemsPerPage: number,
   servicesUrls: Services,
   servicesUrls: Services,
   maxMinionPoolEventsPerPage: number,
   maxMinionPoolEventsPerPage: number,
+  providerMigrationOptions: ProviderMigrationOptions
 }
 }

+ 18 - 4
src/components/organisms/ReplicaMigrationOptions/ReplicaMigrationOptions.tsx

@@ -33,6 +33,7 @@ import type { Instance, InstanceScript } from '../../../@types/Instance'
 import { TransferItemDetails } from '../../../@types/MainItem'
 import { TransferItemDetails } from '../../../@types/MainItem'
 import { MinionPool } from '../../../@types/MinionPool'
 import { MinionPool } from '../../../@types/MinionPool'
 import { INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS } from '../WizardOptions/WizardOptions'
 import { INSTANCE_OSMORPHING_MINION_POOL_MAPPINGS } from '../WizardOptions/WizardOptions'
+import { ProviderMigrationCloneDiskDisabledOption } from '../../../@types/Config'
 
 
 const Wrapper = styled.div<any>`
 const Wrapper = styled.div<any>`
   display: flex;
   display: flex;
@@ -83,6 +84,7 @@ type Props = {
   minionPools: MinionPool[]
   minionPools: MinionPool[]
   loadingInstances: boolean,
   loadingInstances: boolean,
   defaultSkipOsMorphing?: boolean | null,
   defaultSkipOsMorphing?: boolean | null,
+  disabledCloneDisk?: ProviderMigrationCloneDiskDisabledOption | null,
   onCancelClick: () => void,
   onCancelClick: () => void,
   onMigrateClick: (
   onMigrateClick: (
     fields: Field[],
     fields: Field[],
@@ -116,9 +118,20 @@ class ReplicaMigrationOptions extends React.Component<Props, State> {
     const mappings = this.props.transferItem?.instance_osmorphing_minion_pool_mappings || {}
     const mappings = this.props.transferItem?.instance_osmorphing_minion_pool_mappings || {}
 
 
     this.setState({
     this.setState({
-      fields: replicaMigrationFields.map(f => (f.name === 'skip_os_morphing' ? (
-        { ...f, value: this.props.defaultSkipOsMorphing || null }
-      ) : f)),
+      fields: replicaMigrationFields.map(f => {
+        if (f.name === 'skip_os_morphing') {
+          return { ...f, value: this.props.defaultSkipOsMorphing || null }
+        }
+        if (f.name === 'clone_disks' && this.props.disabledCloneDisk) {
+          return {
+            ...f,
+            disabled: true,
+            value: this.props.disabledCloneDisk.defaultValue,
+            description: this.props.disabledCloneDisk.description,
+          }
+        }
+        return f
+      }),
       minionPoolMappings: { ...mappings },
       minionPoolMappings: { ...mappings },
     })
     })
   }
   }
@@ -200,7 +213,8 @@ class ReplicaMigrationOptions extends React.Component<Props, State> {
         layout="page"
         layout="page"
         label={field.label || LabelDictionary.get(field.name)}
         label={field.label || LabelDictionary.get(field.name)}
         onChange={value => this.handleValueChange(field, value)}
         onChange={value => this.handleValueChange(field, value)}
-        description={LabelDictionary.getDescription(field.name)}
+        description={field.description || LabelDictionary.getDescription(field.name)}
+        disabled={field.disabled}
       />
       />
     )
     )
   }
   }

+ 2 - 0
src/components/pages/MigrationDetailsPage/MigrationDetailsPage.tsx

@@ -443,6 +443,8 @@ Note that this may lead to scheduled cleanup tasks being forcibly skipped, and t
               loadingInstances={instanceStore.loadingInstancesDetails}
               loadingInstances={instanceStore.loadingInstancesDetails}
               defaultSkipOsMorphing={migrationStore
               defaultSkipOsMorphing={migrationStore
                 .getDefaultSkipOsMorphing(migrationStore.migrationDetails)}
                 .getDefaultSkipOsMorphing(migrationStore.migrationDetails)}
+              disabledCloneDisk={migrationStore.getDisabledCloneDiskOptions(endpointStore.endpoints
+                .find(e => e.id === migrationStore.migrationDetails?.destination_endpoint_id)?.type)}
             />
             />
           </Modal>
           </Modal>
         ) : null}
         ) : null}

+ 2 - 0
src/components/pages/ReplicaDetailsPage/ReplicaDetailsPage.tsx

@@ -650,6 +650,8 @@ class ReplicaDetailsPage extends React.Component<Props, State> {
               instances={instanceStore.instancesDetails}
               instances={instanceStore.instancesDetails}
               onCancelClick={() => { this.handleCloseMigrationModal() }}
               onCancelClick={() => { this.handleCloseMigrationModal() }}
               onMigrateClick={(o, s, r, m) => { this.migrateReplica(o, s, r, m) }}
               onMigrateClick={(o, s, r, m) => { this.migrateReplica(o, s, r, m) }}
+              disabledCloneDisk={migrationStore.getDisabledCloneDiskOptions(endpointStore.endpoints
+                .find(e => e.id === replicaStore.replicaDetails?.destination_endpoint_id)?.type)}
             />
             />
           </Modal>
           </Modal>
         ) : null}
         ) : null}

+ 10 - 0
src/components/pages/ReplicasPage/ReplicasPage.tsx

@@ -46,6 +46,7 @@ import Palette from '../../styleUtils/Palette'
 import configLoader from '../../../utils/Config'
 import configLoader from '../../../utils/Config'
 import { ReplicaItem } from '../../../@types/MainItem'
 import { ReplicaItem } from '../../../@types/MainItem'
 import userStore from '../../../stores/UserStore'
 import userStore from '../../../stores/UserStore'
+import { ProviderMigrationCloneDiskDisabledOption } from '../../../@types/Config'
 
 
 const Wrapper = styled.div<any>``
 const Wrapper = styled.div<any>``
 
 
@@ -330,6 +331,14 @@ class ReplicasPage extends React.Component<{ history: any }, State> {
       action: () => { this.handleShowDeleteReplicas() },
       action: () => { this.handleShowDeleteReplicas() },
     }]
     }]
 
 
+    let disabledDiskOptions: ProviderMigrationCloneDiskDisabledOption | null = null
+    this.state.selectedReplicas.forEach(r => {
+      const options = migrationStore.getDisabledCloneDiskOptions(this.getEndpoint(r.destination_endpoint_id)?.type)
+      if (options) {
+        disabledDiskOptions = options
+      }
+    })
+
     return (
     return (
       <Wrapper>
       <Wrapper>
         <MainTemplate
         <MainTemplate
@@ -431,6 +440,7 @@ class ReplicasPage extends React.Component<{ history: any }, State> {
                 this.setState({ showCreateMigrationsModal: false, modalIsOpen: false })
                 this.setState({ showCreateMigrationsModal: false, modalIsOpen: false })
               }}
               }}
               onMigrateClick={(options, s) => { this.migrateSelectedReplicas(options, s) }}
               onMigrateClick={(options, s) => { this.migrateSelectedReplicas(options, s) }}
+              disabledCloneDisk={disabledDiskOptions}
             />
             />
           </Modal>
           </Modal>
         ) : null}
         ) : null}

+ 9 - 0
src/stores/MigrationStore.ts

@@ -21,6 +21,8 @@ import type { Field } from '../@types/Field'
 import type { Endpoint } from '../@types/Endpoint'
 import type { Endpoint } from '../@types/Endpoint'
 import type { InstanceScript } from '../@types/Instance'
 import type { InstanceScript } from '../@types/Instance'
 import MigrationSource from '../sources/MigrationSource'
 import MigrationSource from '../sources/MigrationSource'
+import configLoader from '../utils/Config'
+import { ProviderTypes } from '../@types/Providers'
 
 
 class MigrationStore {
 class MigrationStore {
   @observable migrations: MigrationItem[] = []
   @observable migrations: MigrationItem[] = []
@@ -59,6 +61,13 @@ class MigrationStore {
     return null
     return null
   }
   }
 
 
+  getDisabledCloneDiskOptions(provider: ProviderTypes | undefined) {
+    if (!provider) {
+      return null
+    }
+    return configLoader.config.providerMigrationOptions[provider]?.cloneDiskDisabledOptions || null
+  }
+
   @action async recreateFullCopy(migration: MigrationItemOptions) {
   @action async recreateFullCopy(migration: MigrationItemOptions) {
     return MigrationSource.recreateFullCopy(migration)
     return MigrationSource.recreateFullCopy(migration)
   }
   }