From d4a8023d17f672f10e83e48fab4e97dc0796af76 Mon Sep 17 00:00:00 2001 From: Kevin Fox Date: Tue, 31 May 2016 17:00:20 -0700 Subject: [PATCH] Set some useful default values with the new launch wizard. In Mitaka, the new launch instance wizard regresses functionality from the old launch wizard with regards to defaults. If there is only one neutron network, it is not automatically selected, if there is only one keypair, its not selected, and the default security group is not automatically selected. This patch fixes all of that. Change-Id: I23bab6998e38ba1066b926a4fe71713768d9dff4 Closes-Bug: #1587681 --- .../launch-instance-model.service.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js index 4922a14834..9bdd42a677 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js @@ -344,6 +344,9 @@ e.keypair.id = e.keypair.name; return e.keypair; })); + if (data.data.items.length === 1) { + model.newInstanceSpec.key_pair.push(data.data.items[0].keypair); + } } function setFinalSpecKeyPairs(finalSpec) { @@ -361,6 +364,15 @@ function onGetSecurityGroups(data) { model.securityGroups.length = 0; + angular.forEach(data.data.items, function addDefault(item) { + // 'default' is a special security group in neutron. It can not be + // deleted and is guaranteed to exist. It by default contains all + // of the rules needed for an instance to reach out to the network + // so the instance can provision itself. + if (item.name === 'default') { + model.newInstanceSpec.security_groups.push(item); + } + }); push.apply(model.securityGroups, data.data.items); } @@ -386,6 +398,9 @@ function onGetNetworks(data) { model.neutronEnabled = true; model.networks.length = 0; + if (data.data.items.length === 1) { + model.newInstanceSpec.networks.push(data.data.items[0]); + } push.apply(model.networks, data.data.items); return data; }