Bay Detail
+-
+
- Name +
- {$ baydetail.name $} +
- ID +
- {$ baydetail.id $} +
- BayModel ID +
- {$ baydetail.baymodel_id $} +
- Master Count +
- {$ baydetail.master_count $} +
- Node Count +
- {$ baydetail.node_count $} +
- Timeout +
- {$ baydetail.timeout $} +
diff --git a/magnum_ui/api/magnum.py b/magnum_ui/api/magnum.py index 731ca75d..37746650 100644 --- a/magnum_ui/api/magnum.py +++ b/magnum_ui/api/magnum.py @@ -106,14 +106,14 @@ def bay_show(request, id): return magnumclient(request).bays.get(id) -def container_create(request, bay_id, **kwargs): +def container_create(request, bay_uuid, **kwargs): """Creates a container object :param request: Request context - :param bay_id: ID of a bay (Required) + :param bay_uuid: ID of a bay (Required) :param kwargs: Image ID, Name, Command, Memory :returns: Container object """ - return magnumclient(request).containers.create(bay_id=bay_id, **kwargs) + return magnumclient(request).containers.create(bay_uuid=bay_uuid, **kwargs) def container_delete(request, id): diff --git a/magnum_ui/static/dashboard/containers/containers.scss b/magnum_ui/static/dashboard/containers/containers.scss index bb28c275..4609a00b 100644 --- a/magnum_ui/static/dashboard/containers/containers.scss +++ b/magnum_ui/static/dashboard/containers/containers.scss @@ -7,3 +7,4 @@ @import "baymodel/baymodel"; @import "bay/bay"; +@import "containers/containers"; diff --git a/magnum_ui/static/dashboard/containers/containers/containers.scss b/magnum_ui/static/dashboard/containers/containers/containers.scss new file mode 100644 index 00000000..371da264 --- /dev/null +++ b/magnum_ui/static/dashboard/containers/containers/containers.scss @@ -0,0 +1,2 @@ +// Custom Style Variables +@import "create/info/info"; diff --git a/magnum_ui/static/dashboard/containers/containers/create/container-model.js b/magnum_ui/static/dashboard/containers/containers/create/container-model.js new file mode 100644 index 00000000..cf1f9773 --- /dev/null +++ b/magnum_ui/static/dashboard/containers/containers/create/container-model.js @@ -0,0 +1,74 @@ +/** + * Copyright 2015 Cisco Systems, Inc. + * + * 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'; + + angular + .module('horizon.dashboard.containers.containers') + .factory('containerModel', containerModel); + + containerModel.$inject = [ + 'horizon.app.core.openstack-service-api.magnum' + ]; + + function containerModel(magnum) { + var model = { + newContainerSpec: {}, + + // API methods + init: init, + createContainer: createContainer + }; + + function initNewContainerSpec() { + model.newContainerSpec = { + name: null, + bay_uuid: null, + image: null, + memory: null, + memorysize: null, + memoryunit: "m", + command: null + }; + } + + function init() { + // Reset the new Bay spec + initNewContainerSpec(); + } + + function createContainer() { + var finalSpec = angular.copy(model.newContainerSpec); + + cleanNullProperties(finalSpec); + + return magnum.createContainer(finalSpec); + } + + function cleanNullProperties(finalSpec) { + // Initially clean fields that don't have any value. + for (var key in finalSpec) { + if (finalSpec.hasOwnProperty(key) && finalSpec[key] === null + || key === "memorysize" || key === "memoryunit") { + delete finalSpec[key]; + } + } + } + + return model; + } +})(); diff --git a/magnum_ui/static/dashboard/containers/containers/create/create-workflow.service.js b/magnum_ui/static/dashboard/containers/containers/create/create-workflow.service.js new file mode 100644 index 00000000..f5f6aa47 --- /dev/null +++ b/magnum_ui/static/dashboard/containers/containers/create/create-workflow.service.js @@ -0,0 +1,57 @@ +/** + * Copyright 2015 Cisco Systems, Inc. + * + * 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'; + + angular + .module('horizon.dashboard.containers.containers') + .factory('horizon.dashboard.containers.containers.workflow', containerWorkflow); + + containerWorkflow.$inject = [ + 'horizon.dashboard.containers.basePath', + 'horizon.app.core.workflow.factory' + ]; + + function containerWorkflow(basePath, dashboardWorkflow) { + return dashboardWorkflow({ + title: gettext('Create Container'), + + steps: [ + { + title: gettext('Info'), + templateUrl: basePath + 'containers/create/info/info.html', + helpUrl: basePath + 'containers/create/info/info.help.html', + formName: 'containerInfoForm' + }, + { + title: gettext('Spec'), + templateUrl: basePath + 'containers/create/spec/spec.html', + helpUrl: basePath + 'containers/create/spec/spec.help.html', + formName: 'containerSpecForm' + } + ], + + btnText: { + finish: gettext('Create') + }, + + btnIcon: { + finish: 'fa fa-cloud-download' + } + }); + } +})(); diff --git a/magnum_ui/static/dashboard/containers/containers/create/info/container.info.controller.js b/magnum_ui/static/dashboard/containers/containers/create/info/container.info.controller.js new file mode 100644 index 00000000..bc9824ea --- /dev/null +++ b/magnum_ui/static/dashboard/containers/containers/create/info/container.info.controller.js @@ -0,0 +1,89 @@ +/** + * 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 createContainerInfoController + * @ngController + * + * @description + * Controller for the container info step in create workflow + */ + angular + .module('horizon.dashboard.containers.containers') + .controller('createContainerInfoController', createContainerInfoController); + + createContainerInfoController.$inject = [ + '$q', + '$scope', + 'horizon.dashboard.containers.basePath', + 'horizon.app.core.openstack-service-api.magnum' + ]; + + function createContainerInfoController($q, $scope, basePath, magnum) { + var ctrl = this; + ctrl.bays = [{id:"", name: gettext("Choose a Bay")}]; + $scope.model.newContainerSpec.bay_uuid = ""; + $scope.baydetail = { + name: "", + id: "", + baymodel: "", + master_count: "", + node_count: "", + discovery_url: "", + timeout: "" + }; + + $scope.changeBay = function(){ + // show Bay Detail + if(!$scope.model.newContainerSpec.bay_uuid){ + $("#bay_detail").hide(); + $("#bay_detail_none").show(); + } else { + angular.forEach(ctrl.bays, function(bay, idx){ + if($scope.model.newContainerSpec.bay_uuid === bay.id){ + $("#bay_detail").show(); + $("#bay_detail_none").hide(); + $scope.baydetail.name = bay.name; + $scope.baydetail.id = bay.id; + $scope.baydetail.baymodel_id = bay.baymodel_id; + $scope.baydetail.master_count = bay.master_count; + $scope.baydetail.node_count = bay.node_count; + $scope.baydetail.discovery_url = bay.discovery_url; + $scope.baydetail.timeout = bay.timeout; + } + }); + } + }; + + init(); + $("#bay_detail").hide(); + $("#bay_detail_none").show(); + + function init() { + magnum.getBays({paginate: false}).success(onGetBays); + } + + function onGetBays(response) { + Array.prototype.push.apply(ctrl.bays, response.items); + } + + } + +})(); diff --git a/magnum_ui/static/dashboard/containers/containers/create/info/info.help.html b/magnum_ui/static/dashboard/containers/containers/create/info/info.help.html new file mode 100644 index 00000000..9a433105 --- /dev/null +++ b/magnum_ui/static/dashboard/containers/containers/create/info/info.help.html @@ -0,0 +1,4 @@ +
Specify container name and choose bay.
+Specify the specs for the container.
+