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
deleted file mode 100644
index e16558ba..00000000
--- a/magnum_ui/static/dashboard/container-infra/clusters/create/misc/cluster.misc.controller.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Copyright 2015 NEC Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License. You may obtain
- * a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-(function() {
- 'use strict';
-
- /**
- * @ngdoc controller
- * @name createClusterMiscController
- * @ngController
- *
- * @description
- * Controller for the container-infra cluster misc step in create workflow
- */
- angular
- .module('horizon.dashboard.container-infra.clusters')
- .controller('createClusterMiscController', createClusterMiscController);
-
- createClusterMiscController.$inject = [
- '$scope',
- 'horizon.app.core.openstack-service-api.nova'
- ];
-
- 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});
- });
- }
-
- function getKeypair() {
- return $scope.model.templateKeypair;
- }
-
- function toggleKeypairRequirement(newValue) {
- ctrl.templateKeypair = newValue;
- }
- var keypairWatcher = $scope.$watch(getKeypair, toggleKeypairRequirement, true);
- $scope.$on('$destroy', function() {
- keypairWatcher();
- });
- }
-})();
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
deleted file mode 100644
index 9128fa54..00000000
--- a/magnum_ui/static/dashboard/container-infra/clusters/create/misc/misc.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/size/cluster.size.controller.js b/magnum_ui/static/dashboard/container-infra/clusters/create/size/cluster.size.controller.js
deleted file mode 100644
index 3a80aff6..00000000
--- a/magnum_ui/static/dashboard/container-infra/clusters/create/size/cluster.size.controller.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright 2015 NEC Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License. You may obtain
- * a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-(function() {
- 'use strict';
-
- /**
- * @ngdoc controller
- * @name createClusterSizeController
- * @ngController
- *
- * @description
- * Controller for the container-infra cluster size step in create workflow
- */
- angular
- .module('horizon.dashboard.container-infra.clusters')
- .controller('createClusterSizeController', createClusterSizeController);
-
- createClusterSizeController.$inject = [
- ];
-
- function createClusterSizeController() {
- }
-
-})();
diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/size/size.html b/magnum_ui/static/dashboard/container-infra/clusters/create/size/size.html
deleted file mode 100644
index 26262ad7..00000000
--- a/magnum_ui/static/dashboard/container-infra/clusters/create/size/size.html
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.controller.js b/magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.controller.js
new file mode 100644
index 00000000..7c49eeba
--- /dev/null
+++ b/magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.controller.js
@@ -0,0 +1,88 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+(function() {
+ 'use strict';
+
+ /**
+ * @ngdoc controller
+ * @name clusterTemplateController
+ * @ngController
+ *
+ * @description
+ * Controller to show cluster template info for info step in workflow
+ */
+ angular
+ .module('horizon.dashboard.container-infra.clusters')
+ .controller(
+ 'horizon.dashboard.container-infra.clusters.workflow.clusterTemplateController',
+ clusterTemplateController);
+
+ clusterTemplateController.$inject = [
+ '$scope',
+ 'horizon.app.core.openstack-service-api.magnum'
+ ];
+
+ function clusterTemplateController($scope, magnum) {
+ var ctrl = this;
+ init();
+
+ function init() {
+ ctrl.clusterTemplate = {
+ name: "",
+ id: "",
+ coe: "",
+ image_id: "",
+ public: "",
+ registry_enabled: "",
+ tls_disabled: "",
+ apiserver_port: "",
+ keypair_id: ""
+ };
+ }
+
+ loadClusterTemplate($scope.model.cluster_template_id);
+
+ function loadClusterTemplate(id, old) {
+ if (id !== old) {
+ if (id === '') {
+ $scope.model.keypair = "";
+ } else {
+ magnum.getClusterTemplate(id).then(onGetClusterTemplate);
+ }
+ }
+ }
+
+ function onGetClusterTemplate(response) {
+ ctrl.clusterTemplate = response.data;
+ if (response.data.keypair_id === null) {
+ $scope.model.keypair = "";
+ } else {
+ $scope.model.keypair = response.data.keypair_id;
+ }
+ }
+
+ function watchClusterTemplateId() {
+ return $scope.model.cluster_template_id;
+ }
+
+ var clusterTemplateWatcher = $scope.$watch(
+ watchClusterTemplateId, loadClusterTemplate, true
+ );
+
+ $scope.$on('$destroy', function() {
+ clusterTemplateWatcher();
+ });
+ }
+})();
diff --git a/magnum_ui/static/dashboard/container-infra/clusters/create/info/cluster.info.controller.spec.js b/magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.controller.spec.js
similarity index 50%
rename from magnum_ui/static/dashboard/container-infra/clusters/create/info/cluster.info.controller.spec.js
rename to magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.controller.spec.js
index f607b7c3..b6402218 100644
--- a/magnum_ui/static/dashboard/container-infra/clusters/create/info/cluster.info.controller.spec.js
+++ b/magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.controller.spec.js
@@ -1,6 +1,4 @@
/**
- * (c) Copyright 2016 NEC Corporation
- *
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
@@ -17,62 +15,46 @@
(function() {
'use strict';
describe('horizon.dashboard.container-infra.clusters', function() {
- var magnum, controller, $scope;
-
- function fakePromise() {
- return {
- success : angular.noop,
- items : {
- id : ''
- }
- };
- }
-
- $scope = {
- model: {
- newClusterSpec: {
- id: ''
- }
- }
- };
+ var magnum, controller, $scope, $q, deferred;
beforeEach(module('horizon.framework'));
beforeEach(module('horizon.app.core.openstack-service-api'));
beforeEach(module('horizon.dashboard.container-infra.clusters'));
- beforeEach(inject(function ($injector) {
+ beforeEach(inject(function ($injector, _$rootScope_, _$q_) {
+ $q = _$q_;
+ $scope = _$rootScope_.$new();
+ $scope.model = {
+ cluster_template_id: '1'
+ };
magnum = $injector.get('horizon.app.core.openstack-service-api.magnum');
controller = $injector.get('$controller');
-
- spyOn(magnum, 'getClusterTemplates').and.callFake(fakePromise);
+ deferred = $q.defer();
+ deferred.resolve({data: {keypair_id: '1'}});
+ spyOn(magnum, 'getClusterTemplate').and.returnValue(deferred.promise);
+ createController($scope);
}));
function createController($scoped) {
- return controller('createClusterInfoController', {
- $scope: $scoped,
- magnum: magnum
- });
+ return controller(
+ 'horizon.dashboard.container-infra.clusters.workflow.clusterTemplateController',
+ {
+ $scope: $scoped,
+ magnum: magnum
+ });
}
- it('should init() pass', function() {
-
- createController($scope);
- expect(magnum.getClusterTemplates).toHaveBeenCalled();
+ it('should load cluster template', function() {
+ expect(magnum.getClusterTemplate).toHaveBeenCalled();
});
- it('should changeClusterTemplate() pass', function() {
-
- createController($scope);
-
- $scope.model.newClusterSpec.cluster_template_id = '1';
- $scope.changeClusterTemplate();
- expect($scope.cluster_template_detail.name).toBe('');
-
- $scope.model.newClusterSpec.cluster_template_id = '';
- $scope.changeClusterTemplate();
- expect($scope.cluster_template_detail.name).toBe('Choose a Cluster Template');
+ it('should keypair is changed by cluster template\'s keypair', function() {
+ $scope.$apply();
+ expect($scope.model.keypair).toBe('1');
+ $scope.model.cluster_template_id = '';
+ $scope.$digest();
+ expect($scope.model.keypair).toBe('');
});
-
});
})();
diff --git a/magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.html b/magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.html
new file mode 100644
index 00000000..bc500847
--- /dev/null
+++ b/magnum_ui/static/dashboard/container-infra/clusters/workflow/cluster-template.html
@@ -0,0 +1,27 @@
+