From 36a2116822273404431817d5df2f2446053a18f5 Mon Sep 17 00:00:00 2001 From: Shu Muto Date: Wed, 27 Dec 2017 12:46:10 +0900 Subject: [PATCH] Add flavor, master flavor and labels for cluster create This patch adds flavor_id, master_flavor_id and labels for cluster creation. Change-Id: Ie56e19daf7371e3b22c803b4bfa2813826797d7a --- .../clusters/update/update.service.js | 10 +++ .../clusters/workflow/labels.help.html | 1 + .../clusters/workflow/workflow.service.js | 75 ++++++++++++++++++- .../workflow/workflow.service.spec.js | 2 +- 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 magnum_ui/static/dashboard/container-infra/clusters/workflow/labels.help.html diff --git a/magnum_ui/static/dashboard/container-infra/clusters/update/update.service.js b/magnum_ui/static/dashboard/container-infra/clusters/update/update.service.js index d211acb2..74b576dd 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/update/update.service.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/update/update.service.js @@ -79,6 +79,16 @@ ? response.data.keypair : ""; config.model.docker_volume_size = response.data.docker_volume_size ? response.data.docker_volume_size : ""; + var labels = ""; + for (var key in response.data.labels) { + if (response.data.labels.hasOwnProperty(key)) { + if (labels !== "") { + labels += ","; + } + labels += key + "=" + response.data.labels[key]; + } + } + config.model.labels = labels; } return modal.open(config).then(submit); diff --git a/magnum_ui/static/dashboard/container-infra/clusters/workflow/labels.help.html b/magnum_ui/static/dashboard/container-infra/clusters/workflow/labels.help.html new file mode 100644 index 00000000..03fc98b9 --- /dev/null +++ b/magnum_ui/static/dashboard/container-infra/clusters/workflow/labels.help.html @@ -0,0 +1 @@ +

Arbitrary labels in the form of key=value pairs to associate with a clusters. May be used multiple times.

\ No newline at end of file diff --git a/magnum_ui/static/dashboard/container-infra/clusters/workflow/workflow.service.js b/magnum_ui/static/dashboard/container-infra/clusters/workflow/workflow.service.js index a153edee..60d52230 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/workflow/workflow.service.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/workflow/workflow.service.js @@ -37,7 +37,7 @@ }; function init(action, title, $scope) { - var schema, form, model; + var schema, form, model, nflavors, mflavors; var clusterTemplates = [{value:"", name: gettext("Choose a Cluster Template")}]; var keypairs = [{value:"", name: gettext("Choose a Keypair")}]; var dockerVolumeSizeDescription = gettext( @@ -82,9 +82,21 @@ title: gettext('Docker Volume Size (GB)'), type: 'number' }, + 'master_flavor_id': { + title: gettext('Master Flavor ID'), + type: 'string' + }, + 'flavor_id': { + title: gettext('Node Flavor ID'), + type: 'string' + }, 'rollback': { title: gettext('Rollback cluster on update failure'), type: 'boolean' + }, + 'labels': { + title: gettext('Labels'), + type: 'string' } } }; @@ -188,9 +200,53 @@ readonly: action === 'update' } ] + }, + { + type: 'section', + htmlClass: 'col-xs-6', + items: [ + { + key: 'master_flavor_id', + type: 'select', + titleMap: mflavors, + readonly: action === 'update' + } + ] + }, + { + type: 'section', + htmlClass: 'col-xs-6', + items: [ + { + key: 'flavor_id', + type: 'select', + titleMap: nflavors, + readonly: action === 'update' + } + ] } ], required: true + }, + { + title: gettext('Labels'), + help: basePath + 'clusters/workflow/labels.help.html', + type: 'section', + htmlClass: 'row', + items: [ + { + type: 'section', + htmlClass: 'col-xs-12', + items: [ + { + key: 'labels', + type: 'textarea', + placeholder: gettext('KEY1=VALUE1, KEY2=VALUE2...'), + readonly: action === 'update' + } + ] + } + ] } ] } @@ -198,6 +254,7 @@ magnum.getClusterTemplates().then(onGetClusterTemplates); nova.getKeypairs().then(onGetKeypairs); + nova.getFlavors(false, false).then(onGetFlavors); function onGetKeypairs(response) { angular.forEach(response.data.items, function(item) { @@ -205,6 +262,17 @@ }); } + function onGetFlavors(response) { + nflavors = [{value:"", name: gettext("Choose a Flavor for the Node")}]; + mflavors = [{value:"", name: gettext("Choose a Flavor for the Master Node")}]; + angular.forEach(response.data.items, function(item) { + nflavors.push({value: item.name, name: item.name}); + mflavors.push({value: item.name, name: item.name}); + }); + form[0].tabs[2].items[1].items[0].titleMap = nflavors; + form[0].tabs[2].items[2].items[0].titleMap = mflavors; + } + function onGetClusterTemplates(response) { angular.forEach(response.data.items, function(item) { clusterTemplates.push({value: item.id, name: item.name}); @@ -220,7 +288,10 @@ rollback: false, discovery_url: "", create_timeout: null, - keypair: "" + keypair: "", + flavor_id: "", + master_flavor_id: "", + labels: "" }; var config = { diff --git a/magnum_ui/static/dashboard/container-infra/clusters/workflow/workflow.service.spec.js b/magnum_ui/static/dashboard/container-infra/clusters/workflow/workflow.service.spec.js index a4e8085f..f7999edd 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/workflow/workflow.service.spec.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/workflow/workflow.service.spec.js @@ -37,8 +37,8 @@ keyDeferred = $q.defer(); keyDeferred.resolve({data:{items:{1:{keypair:{name:1}},2:{keypair:{name:2}}}}}); spyOn(magnum, 'getClusterTemplates').and.returnValue(deferred.promise); + spyOn(nova, 'getFlavors').and.returnValue(deferred.promise); spyOn(nova, 'getKeypairs').and.returnValue(keyDeferred.promise); - })); it('should be init', inject(function($timeout) {