Explorar el Código

Merge pull request #349 from smiclea/CORWEB-195

Automatically detect storage mapping support CORWEB-195
Dorin Paslaru hace 7 años
padre
commit
ad94cd2729

+ 0 - 3
config.js

@@ -28,9 +28,6 @@ const conf: Config = {
   // The timeout between polling requests
   requestPollTimeout: 5000,
 
-  // The list of providers which offer storage listing
-  storageProviders: ['openstack', 'azure', 'oracle_vm'],
-
   // The list of providers which offer source options
   sourceOptionsProviders: ['aws'],
 

+ 10 - 6
src/components/organisms/EditReplica/EditReplica.jsx

@@ -38,9 +38,9 @@ import type { Endpoint, StorageBackend, StorageMap } from '../../../types/Endpoi
 import type { Field } from '../../../types/Field'
 import type { Instance, Nic, Disk } from '../../../types/Instance'
 import type { Network, NetworkMap } from '../../../types/Network'
+import { providerTypes } from '../../../constants'
 
 import StyleProps from '../../styleUtils/StyleProps'
-import configLoader from '../../../utils/Config'
 
 const PanelContent = styled.div`
   padding: 32px;
@@ -100,9 +100,11 @@ class EditReplica extends React.Component<Props, State> {
   scrollableRef: HTMLElement
 
   componentWillMount() {
-    if (this.hasStorageMap()) {
-      endpointStore.loadStorage(this.props.destinationEndpoint.id, {})
-    }
+    providerStore.loadProviders().then(() => {
+      if (this.hasStorageMap()) {
+        endpointStore.loadStorage(this.props.destinationEndpoint.id, {})
+      }
+    })
 
     providerStore.loadDestinationSchema(this.props.destinationEndpoint.type, this.props.type || 'replica').then(() => {
       return providerStore.getDestinationOptions(this.props.destinationEndpoint.id, this.props.destinationEndpoint.type, undefined, true)
@@ -111,13 +113,15 @@ class EditReplica extends React.Component<Props, State> {
     })
   }
 
-  hasStorageMap() {
+  hasStorageMap(): boolean {
     if (this.props.type === 'replica') {
       // storage mapping edit is not currently supported by the API
       return false
     }
 
-    return Boolean(configLoader.config.storageProviders.find(p => p === this.props.destinationEndpoint.type))
+    return providerStore.providers && providerStore.providers[this.props.destinationEndpoint.type] ?
+      !!providerStore.providers[this.props.destinationEndpoint.type].types.find(t => t === providerTypes.STORAGE)
+      : false
   }
 
   isUpdateDisabled() {

+ 6 - 5
src/components/pages/WizardPage/WizardPage.jsx

@@ -35,7 +35,7 @@ import notificationStore from '../../../stores/NotificationStore'
 import scheduleStore from '../../../stores/ScheduleStore'
 import replicaStore from '../../../stores/ReplicaStore'
 import KeyboardManager from '../../../utils/KeyboardManager'
-import { wizardPages, executionOptions } from '../../../constants'
+import { wizardPages, executionOptions, providerTypes } from '../../../constants'
 import configLoader from '../../../utils/Config'
 
 import type { MainItem } from '../../../types/MainItem'
@@ -82,14 +82,15 @@ class WizardPage extends React.Component<Props, State> {
 
   get pages() {
     let sourceProvider = wizardStore.data.source ? wizardStore.data.source.type : ''
-    let destProvider = wizardStore.data.target ? wizardStore.data.target.type : ''
+    let destProvider = wizardStore.data.target ? wizardStore.data.target.type || '' : ''
     let pages = wizardPages
     let sourceOptionsProviders = configLoader.config.sourceOptionsProviders
-    let storageOptionsProviders = configLoader.config.storageProviders
+    let hasStorageMapping = () => providerStore.providers && providerStore.providers[destProvider]
+      ? !!providerStore.providers[destProvider].types.find(t => t === providerTypes.STORAGE) : false
+
     return pages
       .filter(p => !p.excludeFrom || p.excludeFrom !== this.state.type)
-      .filter(p => p.id !== 'storage'
-        || storageOptionsProviders.find(p => p === destProvider))
+      .filter(p => p.id !== 'storage' || hasStorageMapping())
       .filter(p => p.id !== 'source-options'
         || sourceOptionsProviders.find(p => p === sourceProvider))
   }

+ 1 - 0
src/constants.js

@@ -51,6 +51,7 @@ export const providerTypes = {
   TARGET_REPLICA: 4,
   SOURCE_REPLICA: 8,
   CONNECTION: 16,
+  STORAGE: 32768,
 }
 
 export const loginButtons = [

+ 0 - 1
src/types/Config.js

@@ -7,7 +7,6 @@ export type Config = {
   showOpenstackCurrentUserSwitch: boolean,
   useBarbicanSecrets: boolean,
   requestPollTimeout: number,
-  storageProviders: string[],
   sourceOptionsProviders: string[],
   instancesListBackgroundLoading: { default: number, [string]: number },
   providersWithExtraOptions: Array<string | { name: string, envRequiredFields: string[] }>,