Use "cluster" and "cluster_template" of magnumclient

This patch changes "bay" and "baymodel" of magnumclient to
"cluster" and "cluster_template", as last change for renaming
bay to cluster.

Change-Id: I77b6dc02738a1c455274bdb34bddcc91e21a30cb
Implements: blueprint rename-bay-to-cluster
This commit is contained in:
Shu Muto 2016-09-13 11:18:03 +09:00
parent 04d0257d71
commit 21afc6c0d5
10 changed files with 37 additions and 36 deletions

View File

@ -36,8 +36,8 @@ CLUSTER_TEMPLATE_CREATE_ATTRS = ['name', 'image_id', 'flavor_id',
'floating_ip_enabled', 'master_lb_enabled',
'insecure_registry']
CLUSTER_CREATE_ATTRS = ['name', 'baymodel_id', 'node_count',
'discovery_url', 'cluster_create_timeout',
CLUSTER_CREATE_ATTRS = ['name', 'cluster_template_id', 'node_count',
'discovery_url', 'create_timeout',
'master_count']
CERTIFICATE_CREATE_ATTRS = ['cluster_uuid', 'csr']
@ -83,21 +83,21 @@ def cluster_template_create(request, **kwargs):
kv = v.split("=", 1)
labels[kv[0]] = kv[1]
args["labels"] = labels
return magnumclient(request).baymodels.create(**args)
return magnumclient(request).cluster_templates.create(**args)
def cluster_template_delete(request, id):
return magnumclient(request).baymodels.delete(id)
return magnumclient(request).cluster_templates.delete(id)
def cluster_template_list(request, limit=None, marker=None, sort_key=None,
sort_dir=None, detail=True):
return magnumclient(request).baymodels.list(limit, marker, sort_key,
sort_dir, detail)
return magnumclient(request).cluster_templates.list(
limit, marker, sort_key, sort_dir, detail)
def cluster_template_show(request, id):
return magnumclient(request).baymodels.get(id)
return magnumclient(request).cluster_templates.get(id)
def cluster_create(request, **kwargs):
@ -108,25 +108,25 @@ def cluster_create(request, **kwargs):
else:
raise exceptions.BadRequest(
"Key must be in %s" % ",".join(CLUSTER_CREATE_ATTRS))
return magnumclient(request).bays.create(**args)
return magnumclient(request).clusters.create(**args)
def cluster_update(request, id, patch):
return magnumclient(request).bays.update(id, patch)
return magnumclient(request).clusters.update(id, patch)
def cluster_delete(request, id):
return magnumclient(request).bays.delete(id)
return magnumclient(request).clusters.delete(id)
def cluster_list(request, limit=None, marker=None, sort_key=None,
sort_dir=None, detail=True):
return magnumclient(request).bays.list(limit, marker, sort_key,
return magnumclient(request).clusters.list(limit, marker, sort_key,
sort_dir, detail)
def cluster_show(request, id):
return magnumclient(request).bays.get(id)
return magnumclient(request).clusters.get(id)
def certificate_create(request, **kwargs):

View File

@ -37,11 +37,11 @@
function initNewClusterSpec() {
model.newClusterSpec = {
name: null,
baymodel_id: null,
cluster_template_id: null,
master_count: null,
node_count: null,
discover_url: null,
bay_create_timeout: null
create_timeout: null
};
}

View File

@ -39,7 +39,7 @@
function createClusterInfoController($q, $scope, basePath, magnum) {
var ctrl = this;
ctrl.cluster_templates = [{id:"", name: gettext("Choose a Cluster Template")}];
$scope.model.newClusterSpec.baymodel_id = "";
$scope.model.newClusterSpec.cluster_template_id = "";
$scope.cluster_template_detail = {
name: "",
id: "",
@ -53,7 +53,7 @@
$scope.changeClusterTemplate = function(){
angular.forEach(ctrl.cluster_templates, function(model, idx){
if($scope.model.newClusterSpec.baymodel_id === model.id){
if($scope.model.newClusterSpec.cluster_template_id === model.id){
$scope.cluster_template_detail.name = model.name;
$scope.cluster_template_detail.id = model.id;
$scope.cluster_template_detail.coe = model.coe;
@ -75,7 +75,7 @@
function onGetClusterTemplates(response) {
Array.prototype.push.apply(ctrl.cluster_templates, response.items);
if($scope.selected instanceof Object){
$scope.model.newClusterSpec.baymodel_id = $scope.selected.id;
$scope.model.newClusterSpec.cluster_template_id = $scope.selected.id;
$scope.changeClusterTemplate();
}
}

View File

@ -15,14 +15,14 @@
<span class="hz-icon-required fa fa-asterisk"></span>
</label>
<select class="form-control" name="cluster-model" id="cluster-model"
ng-model="model.newClusterSpec.baymodel_id"
ng-model="model.newClusterSpec.cluster_template_id"
ng-required="true"
ng-options="cluster_template.id as cluster_template.name|noName for cluster_template in ctrl.cluster_templates"
ng-change="changeClusterTemplate()">
</select>
</div>
<div class="detail" ng-show="model.newClusterSpec.baymodel_id">
<div class="detail" ng-show="model.newClusterSpec.cluster_template_id">
<span translate class="h4">Cluster Template Detail</span>
<dl class="dl-horizontal">
<dt translate>Name</dt>

View File

@ -10,7 +10,7 @@
<div class="form-group">
<label class="control-label" for="cluster-timeout" translate>Timeout</label>
<input name="cluster-timeout" type="number" min="0" class="form-control"
ng-model="model.newClusterSpec.bay_create_timeout" id="cluster-timeout"
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>

View File

@ -18,7 +18,7 @@
<div class="row">
<dl class="col-md-5">
<dt translate>Cluster Template</dt>
<dd><a ng-href="project/ngdetails/OS::Magnum::ClusterTemplate/{$ item.baymodel_id $}">{$ item.baymodel_id $}</a></dd>
<dd><a ng-href="project/ngdetails/OS::Magnum::ClusterTemplate/{$ item.cluster_template_id $}">{$ item.cluster_template_id $}</a></dd>
</dl>
<dl class="col-md-3">
<dt translate>Node Addresses</dt>

View File

@ -41,7 +41,7 @@
function onGetCluster(cluster) {
ctrl.cluster = cluster.data;
magnum.getClusterTemplate(ctrl.cluster.baymodel_id).success(onGetClusterTemplate);
magnum.getClusterTemplate(ctrl.cluster.cluster_template_id).success(onGetClusterTemplate);
}
function onGetClusterTemplate(cluster_template) {

View File

@ -48,12 +48,12 @@
<dd>{$ ctrl.cluster.discovery_url $}</dd>
<dt translate>Cluster Create Timeout</dt>
<dd>
<div ng-switch on="ctrl.cluster.bay_create_timeout === 0 || ctrl.cluster.bay_create_timeout === null">
<div ng-switch on="ctrl.cluster.create_timeout === 0 || ctrl.cluster.create_timeout === null">
<div ng-switch-when="true" translate>Infinite</div>
<div ng-switch-default translate
translate-n="ctrl.cluster.bay_create_timeout"
translate-plural="{$ ctrl.cluster.bay_create_timeout $} minutes">
{$ ctrl.cluster.bay_create_timeout $} minute
translate-n="ctrl.cluster.create_timeout"
translate-plural="{$ ctrl.cluster.create_timeout $} minutes">
{$ ctrl.cluster.create_timeout $} minute
</div>
</div>
</dd>

View File

@ -58,13 +58,14 @@ class MagnumRestTestCase(test.TestCase):
def test_cluster_template_delete(self, client):
test_cluster_template = TEST.cluster_templates.first()
request = self.mock_rest_request(
body='{"baymodel_id":' + str(test_cluster_template['uuid']) + '}')
body='{"cluster_template_id":'
+ str(test_cluster_template['uuid']) + '}')
response = magnum.ClusterTemplates().delete(request)
self.assertStatusCode(response, 204)
client.cluster_template_delete.assert_called_once_with(
request,
u'baymodel_id')
u'cluster_template_id')
# Clusters
@mock.patch.object(magnum, 'magnum')
@ -97,13 +98,13 @@ class MagnumRestTestCase(test.TestCase):
def test_cluster_delete(self, client):
test_cluster = TEST.clusters.first()
request = self.mock_rest_request(
body='{"bay_id":' + str(test_cluster['uuid']) + '}')
body='{"cluster_id":' + str(test_cluster['uuid']) + '}')
response = magnum.Clusters().delete(request)
self.assertStatusCode(response, 204)
client.cluster_delete.assert_called_once_with(
request,
u'bay_id')
u'cluster_id')
# Certificates
@mock.patch.object(magnum, 'magnum')

View File

@ -51,11 +51,11 @@ def data(TEST):
# Clusters
cluster_dict_1 = {"uuid": 1,
"name": "peopleknowme",
"baymodel": cluster_template_dict_1["uuid"],
"node-count": "",
"master-count": "",
"discovery-url": "",
"timeout": 0}
"cluster_template_id": cluster_template_dict_1["uuid"],
"node_count": "",
"master_count": "",
"discovery_url": "",
"create_timeout": 0}
TEST.clusters.add(cluster_dict_1)