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('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 ) {
|
||||
|
|
|
|||
|
|
@ -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`);
|
||||
}
|
||||
}),
|
||||
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 layout from './template';
|
||||
import VolumeSource from 'shared/mixins/volume-source';
|
||||
import { set, get } from '@ember/object';
|
||||
|
||||
export default Component.extend(VolumeSource, {
|
||||
layout,
|
||||
field: 'flexVolume',
|
||||
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:
|
||||
label: Filesystem Type
|
||||
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:
|
||||
quobyteAPIServer:
|
||||
label: Quobyte API Server
|
||||
|
|
@ -5419,6 +5429,8 @@ storageClass:
|
|||
title: Gluster Volume
|
||||
local:
|
||||
title: Local Node Disk
|
||||
longhorn:
|
||||
title: Longhorn
|
||||
portworx-volume:
|
||||
title: Portworx Volume
|
||||
quobyte:
|
||||
|
|
@ -5453,6 +5465,8 @@ volumeSource:
|
|||
title: Fibre Channel
|
||||
flex-volume:
|
||||
title: Flex Volume
|
||||
flex-volume-longhorn:
|
||||
title: Longhorn
|
||||
flocker:
|
||||
title: Flocker
|
||||
gce-pd:
|
||||
|
|
|
|||
Loading…
Reference in New Issue