Change cluster to cluster_id in nodegroup

Introduced by change-id: I413f77ce1dca59ae2c48ba743513ddf5584713e8
Nodegroup 'cluster' field has been changed to 'cluster_id' in
nailgun. So we need to adjust fuelclient accordingly.

Also includes some changes in nodegroups unit tests.

Change-Id: Iba3df02142279c14910578770187ac93157190c4
Closes-bug: #1518341
This commit is contained in:
Aleksandr Didenko 2015-11-23 14:48:03 +01:00
parent 3e7738fd3f
commit 4f9a873b1a
5 changed files with 55 additions and 9 deletions

View File

@ -31,7 +31,7 @@ class NodeGroupAction(Action):
"""Show or modify node groups
"""
action_name = "nodegroup"
acceptable_keys = ("id", "cluster", "name")
acceptable_keys = ("id", "cluster_id", "name")
def __init__(self):
super(NodeGroupAction, self).__init__()

View File

@ -25,7 +25,7 @@ class NodeGroup(BaseObject):
@property
def env_id(self):
return self.get_fresh_data()["cluster"]
return self.get_fresh_data()["cluster_id"]
@property
def name(self):
@ -79,5 +79,5 @@ class NodeGroupCollection(object):
return cls(NodeGroup.get_all())
def filter_by_env_id(self, env_id):
predicate = lambda group: group.data['cluster'] == env_id
predicate = lambda group: group.data['cluster_id'] == env_id
self.collection = filter(predicate, self.collection)

View File

@ -16,8 +16,7 @@ import mock
from six import StringIO
from fuelclient.tests.unit.v1 import base
from fuelclient.tests.utils import fake_env
from fuelclient.tests.utils import fake_network_group
from fuelclient.tests import utils
class TestNodeGroupActions(base.UnitTestCase):
@ -25,12 +24,13 @@ class TestNodeGroupActions(base.UnitTestCase):
def setUp(self):
super(TestNodeGroupActions, self).setUp()
self.env = fake_env.get_fake_env()
self.env = utils.get_fake_env()
self.req_base_path = '/api/v1/nodegroups/'
self.ng = fake_network_group.get_fake_network_group()
self.ng = utils.get_fake_node_group()
self.ngs = utils.get_fake_node_groups()
def test_list_nodegroups(self):
mget = self.m_request.get(self.req_base_path, json=[])
mget = self.m_request.get(self.req_base_path, json=self.ngs)
self.execute(['fuel', 'nodegroup', '--list'])
self.assertTrue(mget.called)

View File

@ -22,6 +22,8 @@ from fuelclient.tests.utils.fake_node import get_fake_node
from fuelclient.tests.utils.fake_env import get_fake_env
from fuelclient.tests.utils.fake_fuel_version import get_fake_fuel_version
from fuelclient.tests.utils.fake_task import get_fake_task
from fuelclient.tests.utils.fake_node_group import get_fake_node_group
from fuelclient.tests.utils.fake_node_group import get_fake_node_groups
__all__ = (get_fake_env,
@ -31,4 +33,6 @@ __all__ = (get_fake_env,
get_fake_node,
get_fake_network_config,
get_fake_task,
random_string)
random_string,
get_fake_node_group,
get_fake_node_groups)

View File

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
#
# Copyright 2015 Mirantis, 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.
def get_fake_node_group(name=None, cluster_id=None, id=None):
"""Create a random fake network node group
Returns the serialized and parametrized representation of a dumped Fuel
nodegroup. Represents the average amount of data.
"""
return {
'name': name or 'testng',
'id': id or 42,
'cluster_id': cluster_id or 5,
}
def get_fake_node_groups():
"""Create a fake network node group list
Returns the serialized and parametrized representation of a dumped Fuel
nodegroups list.
"""
return [
{"cluster_id": 1, "id": 1, "name": "default"},
{"cluster_id": 1, "id": 2, "name": "custom-group"}
]