diff --git a/app/models/storageclass.js b/app/models/storageclass.js index 8e3d4ff00..1eeac7792 100644 --- a/app/models/storageclass.js +++ b/app/models/storageclass.js @@ -19,6 +19,7 @@ registerProvisioner('azure-file', 'kubernetes.io/azure-file', true); registerProvisioner('portworx-volume','kubernetes.io/portworx-volume', true); registerProvisioner('scaleio', 'kubernetes.io/scaleio', true); registerProvisioner('storageos', 'kubernetes.io/storageos', true); +registerProvisioner('longhorn', 'rancher.io/longhorn', true); export function registerProvisioner(name, provisioner, component) { if ( component === true ) { diff --git a/app/models/volume.js b/app/models/volume.js index b3cd7d593..30c5304b6 100644 --- a/app/models/volume.js +++ b/app/models/volume.js @@ -3,7 +3,7 @@ import { inject as service } from '@ember/service'; import Resource from 'ember-api-store/models/resource'; const SOURCES = []; -// name/component field component ephemeral persistent +// name/component field component ephemeral persistent driver registerSource('aws-ebs', 'awsElasticBlockStore', true, true, true); registerSource('azure-disk', 'azureDisk', true, true, true); registerSource('azure-file', 'azureFile', true, true, true); @@ -14,6 +14,7 @@ registerSource('config-map', 'configMap', true, true, f registerSource('empty-dir', 'emptyDir', true, true, false); registerSource('fc', 'fc', true, true, true); registerSource('flex-volume', 'flexVolume', true, true, true); +registerSource('flex-volume-longhorn', 'flexVolume', true, true, true, 'rancher.io/longhorn'); registerSource('flocker', 'flocker', true, true, true); registerSource('gce-pd', 'gcePersistentDisk', true, true, true); //registerSource('git-repo', 'gitRepo', true, true, false); @@ -33,7 +34,7 @@ registerSource('secret', 'secret', true, true, f registerSource('storageos', 'storageos', true, true, true); registerSource('vsphere-volume', 'vsphereVolume', true, true, true); -export function registerSource(name, field, component, ephemeral=true, persistent=true) { +export function registerSource(name, field, component, ephemeral=true, persistent=true, driver='') { if ( component === true ) { component = name; } @@ -46,6 +47,7 @@ export function registerSource(name, field, component, ephemeral=true, persisten SOURCES.push({ name: name, value: field, + driver, component: component, ephemeral: !!ephemeral, persistent: !!persistent, @@ -91,14 +93,29 @@ var Volume = Resource.extend({ return get(this, key); } }), - - displaySource: computed('configName','intl.locale', function() { - const intl = get(this, 'intl'); + sourceName: computed('configName', function(){ const key = get(this, 'configName'); - const entry = SOURCES.findBy('value', key); - - if ( key ) { - return intl.t(`volumeSource.${entry.name}.title`); + if ( !key ) { + return + } + let entry; + let driver = get(this, key).driver; + entry = SOURCES.findBy('value', key); + if(key === 'flexVolume' && driver){ + let specialSource = SOURCES.findBy('driver', driver); + if(specialSource){ + entry = specialSource; + } + } + if(entry){ + return entry.name; + } + }), + displaySource: computed('sourceName','intl.locale', function() { + const intl = get(this, 'intl'); + const sourceName = get(this, 'sourceName'); + if ( sourceName ) { + return intl.t(`volumeSource.${sourceName}.title`); } }), diff --git a/lib/shared/addon/components/cru-persistent-volume/component.js b/lib/shared/addon/components/cru-persistent-volume/component.js index cf5092b27..2e6147b56 100644 --- a/lib/shared/addon/components/cru-persistent-volume/component.js +++ b/lib/shared/addon/components/cru-persistent-volume/component.js @@ -35,12 +35,7 @@ export default Component.extend(ViewNewEdit, { set(this, 'capacity', 10); } else { - const configName = get(this,'primaryResource.configName'); - const sources = getSources('persistent'); - const entry = sources.findBy('value', configName); - if ( entry ) { - set(this, 'sourceName', entry.name); - } + set(this, 'sourceName', get(this,'primaryResource.sourceName')); const capacity = get(this, 'primaryResource.capacity.storage'); if ( capacity ) { diff --git a/lib/shared/addon/components/cru-volume/component.js b/lib/shared/addon/components/cru-volume/component.js index 432977813..7bb4514b5 100644 --- a/lib/shared/addon/components/cru-volume/component.js +++ b/lib/shared/addon/components/cru-volume/component.js @@ -32,12 +32,7 @@ export default Component.extend(ViewNewEdit, { }.property('scope'), didReceiveAttrs() { - const configName = get(this,'primaryResource.configName'); - const sources = getSources('ephemeral'); - const entry = sources.findBy('value', configName); - if ( entry ) { - set(this, 'sourceName', entry.name); - } + set(this, 'sourceName', get(this,'primaryResource.sourceName')); }, willSave() { diff --git a/lib/shared/addon/components/storage-class/provisioner-longhorn/component.js b/lib/shared/addon/components/storage-class/provisioner-longhorn/component.js new file mode 100644 index 000000000..b6f2bd4ee --- /dev/null +++ b/lib/shared/addon/components/storage-class/provisioner-longhorn/component.js @@ -0,0 +1,12 @@ +import Component from '@ember/component'; +import layout from './template'; +import StorageClassProvisioner from 'shared/mixins/storage-class-provisioner'; + +const FIELDS = ['numberOfReplicas', 'staleReplicaTimeout', 'fromBackup']; + +export default Component.extend(StorageClassProvisioner, { + layout, + + provisioner: 'longhorn', + fields: FIELDS, +}); diff --git a/lib/shared/addon/components/storage-class/provisioner-longhorn/template.hbs b/lib/shared/addon/components/storage-class/provisioner-longhorn/template.hbs new file mode 100644 index 000000000..e80e6de2f --- /dev/null +++ b/lib/shared/addon/components/storage-class/provisioner-longhorn/template.hbs @@ -0,0 +1,12 @@ +{{#each fieldsGroup as |fields|}} +