Skip to content

Commit

Permalink
WIP! Enable/disable role by cluster settings
Browse files Browse the repository at this point in the history
Change-Id: I1d46279597d95997bb566a7b7d482037d6c302e2
  • Loading branch information
Ivan Kolodyazhny committed Jan 30, 2014
1 parent 6f97668 commit b9d37d0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
10 changes: 8 additions & 2 deletions nailgun/nailgun/fixtures/openstack.json
Expand Up @@ -16,7 +16,7 @@
"description": "This configuration requires multiple OpenStack controllers (3+) and provides high availability for all OpenStack components, including MySQL/Galera, RabbitMQ, and Cinder, as well as OpenStack API services. Select this configuration if you want to build a production-grade OpenStack cloud with 6 nodes or more."
}
},
"roles": ["controller", "compute", "cinder", "ceph-osd"],
"roles": ["controller", "compute", "cinder", "ceph-osd", "mongo"],
"roles_metadata": {
"controller": {
"name": "Controller",
Expand All @@ -35,7 +35,13 @@
"ceph-osd": {
"name": "Storage - Ceph OSD",
"description": "Ceph storage can be configured to provide storage for block volumes (Cinder), images (Glance) and ephemeral instance storage (Nova). It can also provide object storage through the S3 and Swift API (See settings to enable each)."
}
},
"mongo": {
"name": "Mongo",
"description": "Storage - MongoDB for Ceilometer",
"conflicts": ["compute"],
"depends_on": "editable.additional_components.ceilometer.value"
}
},
"networks_metadata": {
"nova_network": {
Expand Down
3 changes: 2 additions & 1 deletion nailgun/static/i18n/translation.json
Expand Up @@ -184,7 +184,8 @@
"no_nodes_in_environment": "To add nodes to the environment, select the Add Nodes option, choose the nodes you want to allocate and assign roles to each.",
"no_nodes_in_fuel": "A pool of one or more unallocated nodes is needed for this operation. To add to the pool, configure nodes to boot from the network (a.k.a. PXE booting). Fuel will automatically provision and discover the nodes.",
"one_controller_restriction": "Only one controller can be assigned in a multi-node deployment that is not Highly-Available (HA).",
"incompatible_roles_warning" : "This role cannot be combined with the other roles already selected."
"incompatible_roles_warning" : "This role cannot be combined with the other roles already selected.",
"dependent_setting_warning": "This role can not be active due to cluster OpenStack settings."
},
"settings_tab": {
"title": "OpenStack Settings"
Expand Down
5 changes: 5 additions & 0 deletions nailgun/static/js/app.js
Expand Up @@ -112,6 +112,11 @@ function(Coccyx, coccyxMixins, models, commonViews, ClusterPage, NodesTab, Clust
cluster.set('release', new models.Release({id: cluster.get('release_id')}));
return cluster.fetchRelated('release');
}, this))
.then(_.bind(function(){
cluster.set({'settings': new models.Settings()}, {silent: true});
cluster.get('settings').deferred = cluster.get('settings').fetch({url: _.result(cluster, 'url') + '/attributes'});
return cluster.get('settings').deferred;
}, this))
.done(_.bind(render, this))
.fail(_.bind(this.listClusters, this));
}
Expand Down
15 changes: 13 additions & 2 deletions nailgun/static/js/views/cluster_page_tabs/nodes_tab.js
Expand Up @@ -424,7 +424,9 @@ function(utils, models, commonViews, dialogViews, nodesManagementPanelTemplate,
checkForConflicts: function(e) {
this.collection.each(function(role) {
var selectedRoles = this.collection.filter(function(role) {return role.get('checked') || role.get('indeterminate');});
role.set('disabled', !this.screen.nodes.length || !this.isControllerSelectable(role) || _.contains(this.getListOfIncompatibleRoles(selectedRoles), role.get('name')));
var roleConflict = _.contains(this.getListOfIncompatibleRoles(selectedRoles), role.get('name'));
var isDisabled = !this.screen.nodes.length || !this.isControllerSelectable(role) || roleConflict || role.get('dependentSettingState');
role.set('disabled', isDisabled);
}, this);
if (this.cluster.get('mode') == 'multinode' && this.screen.nodeList) {
var controllerNode = this.nodes.filter(function(node) {return node.hasRole('controller');})[0];
Expand All @@ -438,14 +440,20 @@ function(utils, models, commonViews, dialogViews, nodesManagementPanelTemplate,
initialize: function(options) {
_.defaults(this, options);
this.cluster = this.screen.tab.model;
this.clusterSettings = this.cluster.get("settings");
this.collection = new Backbone.Collection(_.map(this.cluster.get('release').get('roles'), function(role) {
var roleData = this.cluster.get('release').get('roles_metadata')[role];
var nodesWithRole = this.nodes.filter(function(node) {return node.hasRole(role);});
var dependentSettingState;
try {
dependentSettingState = !this.clusterSettings.get(roleData.depends_on);
} catch (e) {}
return {
name: role,
label: roleData.name,
description: roleData.description,
disabled: false,
dependentSettingState: dependentSettingState,
checked: !!nodesWithRole.length && nodesWithRole.length == this.nodes.length,
indeterminate: !!nodesWithRole.length && nodesWithRole.length != this.nodes.length
};
Expand All @@ -472,8 +480,11 @@ function(utils, models, commonViews, dialogViews, nodesManagementPanelTemplate,
observe: 'disabled',
stickitChange: role,
onGet: _.bind(function(value, options) {
// display warning message for inactive role
var role = options.stickitChange;
if (value && this.screen.nodes.length) {
return this.isControllerSelectable(options.stickitChange) ? $.t('cluster_page.nodes_tab.incompatible_roles_warning'): $.t('cluster_page.nodes_tab.one_controller_restriction');
var prefix = 'cluster_page.nodes_tab.';
return role.get('dependentSettingState') ? $.t(prefix + 'dependent_setting_warning') : this.isControllerSelectable(role) ? $.t(prefix + 'incompatible_roles_warning'): $.t(prefix + 'one_controller_restriction');
}
return '';
}, this)
Expand Down

0 comments on commit b9d37d0

Please sign in to comment.