From 40c8338e4890610000ba4e6f6d76a7b2663a43bd Mon Sep 17 00:00:00 2001 From: Mateusz Kowalski Date: Thu, 1 Dec 2016 15:00:54 +0100 Subject: [PATCH] Allow keypair in cluster creation The patch introduces the same functionality as the command line interface. When the template contains keypair, user can either provide a new keypair for the cluster or inherit one from the template. When template has no keypair attached, user has to provide a keypair for the cluster, otherwise the error will be returned (exactly as for the CLI). Closes-Bug: #1645754 Change-Id: I07c43be68022492f3c59b391ce6c31efc7b0aa79 --- magnum_ui/api/magnum.py | 2 +- .../clusters/clusters.module.js | 12 ++++++++++++ .../clusters/create/cluster-model.js | 3 ++- .../clusters/create/cluster-model.spec.js | 3 ++- .../create/info/cluster.info.controller.js | 4 +++- .../create/misc/cluster.misc.controller.js | 19 ++++++++++++++++++- .../clusters/create/misc/misc.html | 10 +++++++++- .../clusters/details/overview.html | 2 ++ 8 files changed, 49 insertions(+), 6 deletions(-) diff --git a/magnum_ui/api/magnum.py b/magnum_ui/api/magnum.py index 8883c870..7bdbaca3 100644 --- a/magnum_ui/api/magnum.py +++ b/magnum_ui/api/magnum.py @@ -38,7 +38,7 @@ CLUSTER_TEMPLATE_CREATE_ATTRS = ['name', 'image_id', 'flavor_id', CLUSTER_CREATE_ATTRS = ['name', 'cluster_template_id', 'node_count', 'discovery_url', 'create_timeout', - 'master_count'] + 'master_count', 'keypair'] CERTIFICATE_CREATE_ATTRS = ['cluster_uuid', 'csr'] diff --git a/magnum_ui/static/dashboard/container-infra/clusters/clusters.module.js b/magnum_ui/static/dashboard/container-infra/clusters/clusters.module.js index 2ae8c271..4b237672 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/clusters.module.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/clusters.module.js @@ -79,6 +79,9 @@ .setProperty('node_count', { label: gettext('Node Count') }) + .setProperty('keypair', { + label: gettext('Keypair') + }) .setListFunction(clustersService.getClustersPromise) .tableColumns .append({ @@ -103,6 +106,10 @@ .append({ id: 'node_count', priority: 2 + }) + .append({ + id: 'keypair', + priority: 2 }); // for magic-search @@ -148,6 +155,11 @@ 'label': gettext('Node Count'), 'name': 'node_count', 'singleton': true + }) + .append({ + 'label': gettext('Keypair'), + 'name': 'keypair', + 'singleton': true }); } diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/cluster-model.js b/magnum_ui/static/dashboard/container-infra/clusters/create/cluster-model.js index 3ce3f082..01673460 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/create/cluster-model.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/create/cluster-model.js @@ -41,7 +41,8 @@ master_count: null, node_count: null, discover_url: null, - create_timeout: null + create_timeout: null, + keypair: null }; } diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/cluster-model.spec.js b/magnum_ui/static/dashboard/container-infra/clusters/create/cluster-model.spec.js index 8d95d2be..d8a7a78e 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/create/cluster-model.spec.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/create/cluster-model.spec.js @@ -26,7 +26,8 @@ master_count: null, node_count: null, discover_url: null, - create_timeout: null + create_timeout: null, + keypair: null }; beforeEach(module('horizon.dashboard.container-infra.clusters')); diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/info/cluster.info.controller.js b/magnum_ui/static/dashboard/container-infra/clusters/create/info/cluster.info.controller.js index a9e3944a..8f9008e2 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/create/info/cluster.info.controller.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/create/info/cluster.info.controller.js @@ -48,7 +48,8 @@ public: "", registry_enabled: "", tls_disabled: "", - apiserver_port: "" + apiserver_port: "", + keypair: "" }; $scope.changeClusterTemplate = function() { @@ -62,6 +63,7 @@ $scope.cluster_template_detail.registry_enabled = model.registry_enabled; $scope.cluster_template_detail.tls_disabled = model.tls_disabled; $scope.cluster_template_detail.apiserver_port = model.apiserver_port; + $scope.cluster_template_detail.keypair = model.keypair; } }); }; diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/misc/cluster.misc.controller.js b/magnum_ui/static/dashboard/container-infra/clusters/create/misc/cluster.misc.controller.js index 658c36fa..1b245ae3 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/create/misc/cluster.misc.controller.js +++ b/magnum_ui/static/dashboard/container-infra/clusters/create/misc/cluster.misc.controller.js @@ -30,9 +30,26 @@ .controller('createClusterMiscController', createClusterMiscController); createClusterMiscController.$inject = [ + '$scope', + 'horizon.app.core.openstack-service-api.nova' ]; - function createClusterMiscController() { + function createClusterMiscController($scope, nova) { + var ctrl = this; + ctrl.keypairs = [{id:null, name: gettext("Choose a Keypair")}]; + $scope.model.newClusterSpec.keypair = null; + + init(); + + function init() { + nova.getKeypairs().success(onGetKeypairs); + } + + function onGetKeypairs(response) { + angular.forEach(response.items, function(item) { + ctrl.keypairs.push({id: item.keypair.name, name: item.keypair.name}); + }); + } } })(); diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/misc/misc.html b/magnum_ui/static/dashboard/container-infra/clusters/create/misc/misc.html index bbe4cf5c..d033046b 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/create/misc/misc.html +++ b/magnum_ui/static/dashboard/container-infra/clusters/create/misc/misc.html @@ -13,5 +13,13 @@ ng-model="model.newClusterSpec.create_timeout" id="cluster-timeout" placeholder="{$ 'The timeout for cluster creation in minutes. Set to 0 for no timeout. The default is no timeout.'|translate $}"> +
+ + +
- + + \ No newline at end of file diff --git a/magnum_ui/static/dashboard/container-infra/clusters/details/overview.html b/magnum_ui/static/dashboard/container-infra/clusters/details/overview.html index ad43eb48..95a9ce72 100644 --- a/magnum_ui/static/dashboard/container-infra/clusters/details/overview.html +++ b/magnum_ui/static/dashboard/container-infra/clusters/details/overview.html @@ -57,6 +57,8 @@ +
Keypair
+
{$ ctrl.cluster.keypair $}