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
This commit is contained in:
Mateusz Kowalski 2016-12-01 15:00:54 +01:00
parent 8934671b75
commit 40c8338e48
8 changed files with 49 additions and 6 deletions

View File

@ -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']

View File

@ -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
});
}

View File

@ -41,7 +41,8 @@
master_count: null,
node_count: null,
discover_url: null,
create_timeout: null
create_timeout: null,
keypair: null
};
}

View File

@ -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'));

View File

@ -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;
}
});
};

View File

@ -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});
});
}
}
})();

View File

@ -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 $}">
</div>
<div class="form-group">
<label class="control-label" for="cluster-keypair" translate>Keypair</label>
<select name="cluster-keypair" type="text" class="form-control" id="cluster-keypair"
ng-model="model.newClusterSpec.keypair" ng-required="false"
ng-options="keypair.id as keypair.name for keypair in ctrl.keypairs">
</select>
</div>
</div>
</div>
</div>
</div>

View File

@ -57,6 +57,8 @@
</div>
</div>
</dd>
<dt translate>Keypair</dt>
<dd>{$ ctrl.cluster.keypair $}</dd>
</dl>
</div>
<div class="col-md-6 detail">