mirror of https://github.com/rancher/ui.git
Add longhorn storageClass/volume-source
This commit is contained in:
parent
991378665c
commit
1651ea9a27
|
|
@ -19,6 +19,7 @@ registerProvisioner('azure-file', 'kubernetes.io/azure-file', true);
|
||||||
registerProvisioner('portworx-volume','kubernetes.io/portworx-volume', true);
|
registerProvisioner('portworx-volume','kubernetes.io/portworx-volume', true);
|
||||||
registerProvisioner('scaleio', 'kubernetes.io/scaleio', true);
|
registerProvisioner('scaleio', 'kubernetes.io/scaleio', true);
|
||||||
registerProvisioner('storageos', 'kubernetes.io/storageos', true);
|
registerProvisioner('storageos', 'kubernetes.io/storageos', true);
|
||||||
|
registerProvisioner('longhorn', 'rancher.io/longhorn', true);
|
||||||
|
|
||||||
export function registerProvisioner(name, provisioner, component) {
|
export function registerProvisioner(name, provisioner, component) {
|
||||||
if ( component === true ) {
|
if ( component === true ) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { inject as service } from '@ember/service';
|
||||||
import Resource from 'ember-api-store/models/resource';
|
import Resource from 'ember-api-store/models/resource';
|
||||||
|
|
||||||
const SOURCES = [];
|
const SOURCES = [];
|
||||||
// name/component field component ephemeral persistent
|
// name/component field component ephemeral persistent driver
|
||||||
registerSource('aws-ebs', 'awsElasticBlockStore', true, true, true);
|
registerSource('aws-ebs', 'awsElasticBlockStore', true, true, true);
|
||||||
registerSource('azure-disk', 'azureDisk', true, true, true);
|
registerSource('azure-disk', 'azureDisk', true, true, true);
|
||||||
registerSource('azure-file', 'azureFile', 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('empty-dir', 'emptyDir', true, true, false);
|
||||||
registerSource('fc', 'fc', true, true, true);
|
registerSource('fc', 'fc', true, true, true);
|
||||||
registerSource('flex-volume', 'flexVolume', 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('flocker', 'flocker', true, true, true);
|
||||||
registerSource('gce-pd', 'gcePersistentDisk', true, true, true);
|
registerSource('gce-pd', 'gcePersistentDisk', true, true, true);
|
||||||
//registerSource('git-repo', 'gitRepo', true, true, false);
|
//registerSource('git-repo', 'gitRepo', true, true, false);
|
||||||
|
|
@ -33,7 +34,7 @@ registerSource('secret', 'secret', true, true, f
|
||||||
registerSource('storageos', 'storageos', true, true, true);
|
registerSource('storageos', 'storageos', true, true, true);
|
||||||
registerSource('vsphere-volume', 'vsphereVolume', 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 ) {
|
if ( component === true ) {
|
||||||
component = name;
|
component = name;
|
||||||
}
|
}
|
||||||
|
|
@ -46,6 +47,7 @@ export function registerSource(name, field, component, ephemeral=true, persisten
|
||||||
SOURCES.push({
|
SOURCES.push({
|
||||||
name: name,
|
name: name,
|
||||||
value: field,
|
value: field,
|
||||||
|
driver,
|
||||||
component: component,
|
component: component,
|
||||||
ephemeral: !!ephemeral,
|
ephemeral: !!ephemeral,
|
||||||
persistent: !!persistent,
|
persistent: !!persistent,
|
||||||
|
|
@ -91,14 +93,29 @@ var Volume = Resource.extend({
|
||||||
return get(this, key);
|
return get(this, key);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
sourceName: computed('configName', function(){
|
||||||
displaySource: computed('configName','intl.locale', function() {
|
|
||||||
const intl = get(this, 'intl');
|
|
||||||
const key = get(this, 'configName');
|
const key = get(this, 'configName');
|
||||||
const entry = SOURCES.findBy('value', key);
|
if ( !key ) {
|
||||||
|
return
|
||||||
if ( key ) {
|
}
|
||||||
return intl.t(`volumeSource.${entry.name}.title`);
|
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`);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,7 @@ export default Component.extend(ViewNewEdit, {
|
||||||
set(this, 'capacity', 10);
|
set(this, 'capacity', 10);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const configName = get(this,'primaryResource.configName');
|
set(this, 'sourceName', get(this,'primaryResource.sourceName'));
|
||||||
const sources = getSources('persistent');
|
|
||||||
const entry = sources.findBy('value', configName);
|
|
||||||
if ( entry ) {
|
|
||||||
set(this, 'sourceName', entry.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
const capacity = get(this, 'primaryResource.capacity.storage');
|
const capacity = get(this, 'primaryResource.capacity.storage');
|
||||||
if ( capacity ) {
|
if ( capacity ) {
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,7 @@ export default Component.extend(ViewNewEdit, {
|
||||||
}.property('scope'),
|
}.property('scope'),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
const configName = get(this,'primaryResource.configName');
|
set(this, 'sourceName', get(this,'primaryResource.sourceName'));
|
||||||
const sources = getSources('ephemeral');
|
|
||||||
const entry = sources.findBy('value', configName);
|
|
||||||
if ( entry ) {
|
|
||||||
set(this, 'sourceName', entry.name);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
willSave() {
|
willSave() {
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{{#each fieldsGroup as |fields|}}
|
||||||
|
<div class="row mb-20">
|
||||||
|
{{#each fields as |field|}}
|
||||||
|
<div class="col span-4">
|
||||||
|
<label class="acc-label">{{t (concat 'cruStorageClass.' provisioner '.' field '.label')}}</label>
|
||||||
|
{{#input-or-display editable=editing value=(get model field)}}
|
||||||
|
{{input type="text" value=(get model field) classNames="form-control" placeholder=(t (concat 'cruStorageClass.' provisioner '.' field '.placeholder'))}}
|
||||||
|
{{/input-or-display}}
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { get, set } from '@ember/object';
|
||||||
|
import Component from '@ember/component';
|
||||||
|
import layout from './template';
|
||||||
|
import VolumeSource from 'shared/mixins/volume-source';
|
||||||
|
|
||||||
|
export default Component.extend(VolumeSource, {
|
||||||
|
layout,
|
||||||
|
field: 'flexVolume',
|
||||||
|
fieldType: 'flexVolumeSource',
|
||||||
|
init() {
|
||||||
|
this._super();
|
||||||
|
get(this, 'config.driver')||set(this, 'config.driver', 'rancher.io/longhorn');
|
||||||
|
get(this, 'config.options')||set(this, 'config.options', {
|
||||||
|
size: "2Gi",
|
||||||
|
numberOfReplicas: "3",
|
||||||
|
staleReplicaTimeout: "20",
|
||||||
|
fromBackup: ""
|
||||||
|
});
|
||||||
|
get(this, 'config.secretRef')||set(this, 'config.secretRef',{});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
<div class="row mb-20">
|
||||||
|
<div class="col span-6">
|
||||||
|
<label class="acc-label">{{t 'cruPersistentVolume.flexVolume.driver.label'}}</label>
|
||||||
|
{{#input-or-display editable=false value=config.driver}}
|
||||||
|
{{input type="text" value=config.driver classNames="form-control" placeholder=(t 'cruPersistentVolume.flexVolume.driver.placeholder')}}
|
||||||
|
{{/input-or-display}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col span-6">
|
||||||
|
<label class="acc-label">{{t 'cruPersistentVolume.flexVolume.fsType.label'}}</label>
|
||||||
|
{{#input-or-display editable=editing value=config.fsType}}
|
||||||
|
{{input type="text" value=config.fsType classNames="form-control" placeholder=(t 'cruPersistentVolume.flexVolume.fsType.placeholder')}}
|
||||||
|
{{/input-or-display}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-20">
|
||||||
|
<div class="col span-6">
|
||||||
|
{{form-key-value
|
||||||
|
initialMap=config.options
|
||||||
|
editing=editing
|
||||||
|
header=(t 'cruPersistentVolume.flexVolume.options.label')
|
||||||
|
addActionLabel="cruPersistentVolume.flexVolume.options.addActionLabel"
|
||||||
|
changed=(action (mut config.options))
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col span-6">
|
||||||
|
<label class="acc-label">{{t 'cruPersistentVolume.flexVolume.readOnly.label'}}</label>
|
||||||
|
{{#if editing}}
|
||||||
|
<div class="text-muted">
|
||||||
|
<label>
|
||||||
|
{{radio-button selection=config.readOnly value=true}} {{t 'generic.yes'}}
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
{{radio-button selection=config.readOnly value=false}} {{t 'generic.no'}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="text-muted">
|
||||||
|
{{config.readOnly}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col span-6">
|
||||||
|
<label class="acc-label">{{t 'cruPersistentVolume.flexVolume.secretRef.label'}}</label>
|
||||||
|
{{#input-or-display editable=editing value=config.secretRef.name}}
|
||||||
|
{{input type="text" value=config.secretRef.name classNames="form-control" placeholder=(t 'cruPersistentVolume.flexVolume.secretRef.placeholder')}}
|
||||||
|
{{/input-or-display}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import layout from './template';
|
import layout from './template';
|
||||||
import VolumeSource from 'shared/mixins/volume-source';
|
import VolumeSource from 'shared/mixins/volume-source';
|
||||||
|
import { set, get } from '@ember/object';
|
||||||
|
|
||||||
export default Component.extend(VolumeSource, {
|
export default Component.extend(VolumeSource, {
|
||||||
layout,
|
layout,
|
||||||
field: 'flexVolume',
|
field: 'flexVolume',
|
||||||
fieldType: 'flexVolumeSource',
|
fieldType: 'flexVolumeSource',
|
||||||
|
didInsertElement() {
|
||||||
|
get(this, 'config.secretRef')||set(this, 'config.secretRef',{});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export { default } from 'shared/components/storage-class/provisioner-longhorn/component';
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export { default } from 'shared/components/volume-source/source-flex-volume-longhorn/component';
|
||||||
|
|
@ -2535,6 +2535,16 @@ cruStorageClass:
|
||||||
fsType:
|
fsType:
|
||||||
label: Filesystem Type
|
label: Filesystem Type
|
||||||
placeholder: "e.g. ext4"
|
placeholder: "e.g. ext4"
|
||||||
|
longhorn:
|
||||||
|
numberOfReplicas:
|
||||||
|
label: Number Of Relicas
|
||||||
|
placeholder: "e.g. 3"
|
||||||
|
staleReplicaTimeout:
|
||||||
|
label: Stale Replica Timeout
|
||||||
|
placeholder: "e.g. 30"
|
||||||
|
fromBackup:
|
||||||
|
label: From Backup
|
||||||
|
placeholder: ""
|
||||||
quobyte:
|
quobyte:
|
||||||
quobyteAPIServer:
|
quobyteAPIServer:
|
||||||
label: Quobyte API Server
|
label: Quobyte API Server
|
||||||
|
|
@ -5419,6 +5429,8 @@ storageClass:
|
||||||
title: Gluster Volume
|
title: Gluster Volume
|
||||||
local:
|
local:
|
||||||
title: Local Node Disk
|
title: Local Node Disk
|
||||||
|
longhorn:
|
||||||
|
title: Longhorn
|
||||||
portworx-volume:
|
portworx-volume:
|
||||||
title: Portworx Volume
|
title: Portworx Volume
|
||||||
quobyte:
|
quobyte:
|
||||||
|
|
@ -5453,6 +5465,8 @@ volumeSource:
|
||||||
title: Fibre Channel
|
title: Fibre Channel
|
||||||
flex-volume:
|
flex-volume:
|
||||||
title: Flex Volume
|
title: Flex Volume
|
||||||
|
flex-volume-longhorn:
|
||||||
|
title: Longhorn
|
||||||
flocker:
|
flocker:
|
||||||
title: Flocker
|
title: Flocker
|
||||||
gce-pd:
|
gce-pd:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue