mirror of https://github.com/rancher/ui.git
Fixes for machines, nodes, and clusters
This commit is contained in:
parent
278d2ab5e1
commit
466501b83c
|
|
@ -8,12 +8,10 @@ import NewOrEdit from 'ui/mixins/new-or-edit';
|
||||||
import EmberObject from '@ember/object';
|
import EmberObject from '@ember/object';
|
||||||
import { reject, all as PromiseAll } from 'rsvp';
|
import { reject, all as PromiseAll } from 'rsvp';
|
||||||
|
|
||||||
const RKECONFIGHOST_DEFAULT = {
|
const RKECONFIGNODE_DEFAULT = {
|
||||||
advertisedHostname: '',
|
|
||||||
role: null,
|
role: null,
|
||||||
type: 'rkeConfigHost',
|
type: 'rkeConfigHost',
|
||||||
user: '',
|
machineId: null,
|
||||||
ssh: '',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const headersAll = [
|
const headersAll = [
|
||||||
|
|
@ -122,15 +120,15 @@ export default Controller.extend(NewOrEdit, {
|
||||||
return get(this, 'countMap.worker') >= 1;
|
return get(this, 'countMap.worker') >= 1;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
countState: observer('config.hosts.[]', function() {
|
countState: observer('config.nodes.[]', function() {
|
||||||
let hosts = (get(this, 'config.hosts') || []);
|
let nodes = (get(this, 'config.nodes') || []);
|
||||||
let countMap = {
|
let countMap = {
|
||||||
etcd: 0,
|
etcd: 0,
|
||||||
controlplane: 0,
|
controlplane: 0,
|
||||||
worker: 0,
|
worker: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
hosts.forEach((host) => {
|
nodes.forEach((host) => {
|
||||||
get(host, 'role').forEach((role) => {
|
get(host, 'role').forEach((role) => {
|
||||||
countMap[role]++;
|
countMap[role]++;
|
||||||
});
|
});
|
||||||
|
|
@ -140,14 +138,14 @@ export default Controller.extend(NewOrEdit, {
|
||||||
|
|
||||||
scopeChanged: observer('scope', function() {
|
scopeChanged: observer('scope', function() {
|
||||||
let config = get(this, 'config');
|
let config = get(this, 'config');
|
||||||
set(config, 'hosts', []);
|
set(config, 'nodes', []);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
addHost() {
|
addHost() {
|
||||||
get(this, 'modal').toggleModal('modal-add-cluster', {
|
get(this, 'modal').toggleModal('modal-add-cluster', {
|
||||||
templates: get(this, 'model.machineTemplates'),
|
templates: get(this, 'model.machineTemplates'),
|
||||||
hosts: get(this, 'model.hosts'),
|
nodes: get(this, 'model.nodes'),
|
||||||
drivers: get(this, 'model.machineDrivers'),
|
drivers: get(this, 'model.machineDrivers'),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -156,10 +154,10 @@ export default Controller.extend(NewOrEdit, {
|
||||||
},
|
},
|
||||||
addRole(host, type) {
|
addRole(host, type) {
|
||||||
let clusterStore = get(this, 'clusterStore');
|
let clusterStore = get(this, 'clusterStore');
|
||||||
let neu = EmberObject.create(RKECONFIGHOST_DEFAULT);
|
let neu = EmberObject.create(RKECONFIGNODE_DEFAULT);
|
||||||
let config = get(this, 'config');
|
let config = get(this, 'config');
|
||||||
let hosts = ( get(config, 'hosts') || [] ).slice();
|
let nodes = ( get(config, 'nodes') || [] ).slice();
|
||||||
let match = hosts.findBy('advertisedHostname', get(host, 'displayName'))
|
let match = nodes.findBy('machineId', get(host, 'id'));
|
||||||
if (match) {
|
if (match) {
|
||||||
let roles = get(match, 'role');
|
let roles = get(match, 'role');
|
||||||
// exists now check roles
|
// exists now check roles
|
||||||
|
|
@ -168,7 +166,7 @@ export default Controller.extend(NewOrEdit, {
|
||||||
roles.removeObject(type);
|
roles.removeObject(type);
|
||||||
//last one? remove that as well
|
//last one? remove that as well
|
||||||
if (roles.length === 0) {
|
if (roles.length === 0) {
|
||||||
hosts.removeObject(match);
|
nodes.removeObject(match);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//add new role
|
//add new role
|
||||||
|
|
@ -176,16 +174,16 @@ export default Controller.extend(NewOrEdit, {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
neu.setProperties({
|
neu.setProperties({
|
||||||
advertisedHostname: get(host, 'displayName'),
|
|
||||||
role: [type],
|
role: [type],
|
||||||
type: 'rkeConfigHost',
|
type: 'rkeConfigHost',
|
||||||
user: 'root',
|
machineId: get(host, 'id')
|
||||||
ssh: '123',
|
// user: 'root',
|
||||||
|
// ssh: '123',
|
||||||
});
|
});
|
||||||
neu = clusterStore.createRecord(neu);
|
neu = clusterStore.createRecord(neu);
|
||||||
hosts.addObject(neu);
|
nodes.addObject(neu);
|
||||||
}
|
}
|
||||||
set(config, 'hosts', hosts); //so the countState observer updates
|
set(config, 'nodes', nodes); //so the countState observer updates
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ export default Ember.Route.extend({
|
||||||
options: [],
|
options: [],
|
||||||
plugin:'flannel',
|
plugin:'flannel',
|
||||||
},
|
},
|
||||||
auth: {
|
authentication: {
|
||||||
options: [],
|
options: [],
|
||||||
strategy: 'x509',
|
strategy: 'x509',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let config = clusterStore.createRecord(def);
|
let config = clusterStore.createRecord(def);
|
||||||
let models = this.modelFor('clusters.new');
|
let models = this.modelFor('clusters.new');
|
||||||
let { cluster, machineTemplates, machineDrivers, hosts, roleTemplates: roles, policies } = models;
|
let { cluster, machineTemplates, machineDrivers, hosts: nodes, roleTemplates: roles, policies } = models;
|
||||||
|
|
||||||
set(cluster, 'rancherKubernetesEngineConfig', config);
|
set(cluster, 'rancherKubernetesEngineConfig', config);
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ export default Ember.Route.extend({
|
||||||
cluster,
|
cluster,
|
||||||
machineTemplates,
|
machineTemplates,
|
||||||
machineDrivers,
|
machineDrivers,
|
||||||
hosts,
|
nodes,
|
||||||
roles,
|
roles,
|
||||||
policies,
|
policies,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
}}
|
}}
|
||||||
{{#sortable-table
|
{{#sortable-table
|
||||||
classNames="grid sortable-table"
|
classNames="grid sortable-table"
|
||||||
body=model.hosts
|
body=model.nodes
|
||||||
searchText=searchText
|
searchText=searchText
|
||||||
sortBy=sortBy
|
sortBy=sortBy
|
||||||
fullRows=true
|
fullRows=true
|
||||||
|
|
@ -152,7 +152,7 @@
|
||||||
classNames="form-control"
|
classNames="form-control"
|
||||||
content=authChoices
|
content=authChoices
|
||||||
localizedLabel=true
|
localizedLabel=true
|
||||||
value=config.auth.strategy
|
value=config.authentication.strategy
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
<div class="col span-6">
|
<div class="col span-6">
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import Component from '@ember/component';
|
||||||
import Driver from 'shared/mixins/host-driver';
|
import Driver from 'shared/mixins/host-driver';
|
||||||
import layout from './template';
|
import layout from './template';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import { get } from '@ember/object';
|
import { get, set } from '@ember/object';
|
||||||
|
|
||||||
export default Component.extend(Driver, {
|
export default Component.extend(Driver, {
|
||||||
layout,
|
layout,
|
||||||
|
|
@ -19,8 +19,11 @@ export default Component.extend(Driver, {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
let cm = get(this, 'clusterStore').createRecord({type: 'machine'});
|
let cm = get(this, 'clusterStore').createRecord({type: 'machine'});
|
||||||
|
|
||||||
|
set(cm, 'machineTemplateId', get(this, 'machineTemplate.id'));
|
||||||
|
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
hostOptions: this.get(`machineTemplate.${this.get('machineTemplate.driver')}Config`),
|
hostOptions: get(this, `machineTemplate.${this.get('machineTemplate.driver')}Config`),
|
||||||
// @@TODO@@ - 11-28-17 - not sure we should be doing this this way how the heck do we know which host to clone labels from?
|
// @@TODO@@ - 11-28-17 - not sure we should be doing this this way how the heck do we know which host to clone labels from?
|
||||||
// clonedModel: this.get('host').clone(),
|
// clonedModel: this.get('host').clone(),
|
||||||
clonedModel: cm,
|
clonedModel: cm,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
<hr/>
|
||||||
{{#if driver.hasUi}}
|
{{#if driver.hasUi}}
|
||||||
{{component (concat 'host/host-templates/' machineTemplate.driver) machineTemplate=model.template}}
|
{{component (concat 'host-template-' machineTemplate.driver) machineTemplate=model.template}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{component 'host-template-other' machineTemplate=model.template}}
|
{{component 'host-template-other' machineTemplate=model.template}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue