Fixes for machines, nodes, and clusters

This commit is contained in:
Westly Wright 2017-12-27 15:56:29 -07:00
parent 278d2ab5e1
commit 466501b83c
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
5 changed files with 27 additions and 26 deletions

View File

@ -8,12 +8,10 @@ import NewOrEdit from 'ui/mixins/new-or-edit';
import EmberObject from '@ember/object';
import { reject, all as PromiseAll } from 'rsvp';
const RKECONFIGHOST_DEFAULT = {
advertisedHostname: '',
const RKECONFIGNODE_DEFAULT = {
role: null,
type: 'rkeConfigHost',
user: '',
ssh: '',
machineId: null,
};
const headersAll = [
@ -122,15 +120,15 @@ export default Controller.extend(NewOrEdit, {
return get(this, 'countMap.worker') >= 1;
}),
countState: observer('config.hosts.[]', function() {
let hosts = (get(this, 'config.hosts') || []);
countState: observer('config.nodes.[]', function() {
let nodes = (get(this, 'config.nodes') || []);
let countMap = {
etcd: 0,
controlplane: 0,
worker: 0,
};
hosts.forEach((host) => {
nodes.forEach((host) => {
get(host, 'role').forEach((role) => {
countMap[role]++;
});
@ -140,14 +138,14 @@ export default Controller.extend(NewOrEdit, {
scopeChanged: observer('scope', function() {
let config = get(this, 'config');
set(config, 'hosts', []);
set(config, 'nodes', []);
}),
actions: {
addHost() {
get(this, 'modal').toggleModal('modal-add-cluster', {
templates: get(this, 'model.machineTemplates'),
hosts: get(this, 'model.hosts'),
nodes: get(this, 'model.nodes'),
drivers: get(this, 'model.machineDrivers'),
});
},
@ -156,10 +154,10 @@ export default Controller.extend(NewOrEdit, {
},
addRole(host, type) {
let clusterStore = get(this, 'clusterStore');
let neu = EmberObject.create(RKECONFIGHOST_DEFAULT);
let neu = EmberObject.create(RKECONFIGNODE_DEFAULT);
let config = get(this, 'config');
let hosts = ( get(config, 'hosts') || [] ).slice();
let match = hosts.findBy('advertisedHostname', get(host, 'displayName'))
let nodes = ( get(config, 'nodes') || [] ).slice();
let match = nodes.findBy('machineId', get(host, 'id'));
if (match) {
let roles = get(match, 'role');
// exists now check roles
@ -168,7 +166,7 @@ export default Controller.extend(NewOrEdit, {
roles.removeObject(type);
//last one? remove that as well
if (roles.length === 0) {
hosts.removeObject(match);
nodes.removeObject(match);
}
} else {
//add new role
@ -176,16 +174,16 @@ export default Controller.extend(NewOrEdit, {
}
} else {
neu.setProperties({
advertisedHostname: get(host, 'displayName'),
role: [type],
type: 'rkeConfigHost',
user: 'root',
ssh: '123',
machineId: get(host, 'id')
// user: 'root',
// ssh: '123',
});
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
}
},

View File

@ -15,14 +15,14 @@ export default Ember.Route.extend({
options: [],
plugin:'flannel',
},
auth: {
authentication: {
options: [],
strategy: 'x509',
}
};
let config = clusterStore.createRecord(def);
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);
@ -30,7 +30,7 @@ export default Ember.Route.extend({
cluster,
machineTemplates,
machineDrivers,
hosts,
nodes,
roles,
policies,
};

View File

@ -47,7 +47,7 @@
}}
{{#sortable-table
classNames="grid sortable-table"
body=model.hosts
body=model.nodes
searchText=searchText
sortBy=sortBy
fullRows=true
@ -152,7 +152,7 @@
classNames="form-control"
content=authChoices
localizedLabel=true
value=config.auth.strategy
value=config.authentication.strategy
}}
</div>
<div class="col span-6">

View File

@ -3,7 +3,7 @@ import Component from '@ember/component';
import Driver from 'shared/mixins/host-driver';
import layout from './template';
import { inject as service } from '@ember/service';
import { get } from '@ember/object';
import { get, set } from '@ember/object';
export default Component.extend(Driver, {
layout,
@ -19,8 +19,11 @@ export default Component.extend(Driver, {
this._super(...arguments);
let cm = get(this, 'clusterStore').createRecord({type: 'machine'});
set(cm, 'machineTemplateId', get(this, 'machineTemplate.id'));
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?
// clonedModel: this.get('host').clone(),
clonedModel: cm,

View File

@ -28,7 +28,7 @@
</div>
<hr/>
{{#if driver.hasUi}}
{{component (concat 'host/host-templates/' machineTemplate.driver) machineTemplate=model.template}}
{{component (concat 'host-template-' machineTemplate.driver) machineTemplate=model.template}}
{{else}}
{{component 'host-template-other' machineTemplate=model.template}}
{{/if}}