summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgy Kibardin <gkibardin@mirantis.com>2017-03-20 11:59:21 +0300
committerGeorgy Kibardin <gkibardin@mirantis.com>2017-03-21 13:45:07 +0300
commitfba3bc344523da0d43f94e130b4944efe0d32529 (patch)
treebb8033e56b4d61f9d8974f97aace9de5b5ddd6f2
parent847e9a81b944bab5642fbcda496526d080d697a7 (diff)
Use tags instead of roles
Now the deployment behaviour is driven by tags rather than role names, i.e. role name cannot be relied upon. Change-Id: Icfabeeb0b7fb6a9d697a09c3cf1fa020bbd4c323 Closes-Bug: #1669743
Notes
Notes (review): Verified+1: Fuel CI <fuel-ci-bot@mirantis.com> Code-Review+2: Alexander Kislitsky <akislitsky@mirantis.com> Workflow+1: Ihor Kalnytskyi <ikalnitsky@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 24 Mar 2017 11:48:45 +0000 Reviewed-on: https://review.openstack.org/447417 Project: openstack/fuel-web Branch: refs/heads/master
-rw-r--r--nailgun/nailgun/objects/cluster.py7
-rw-r--r--nailgun/nailgun/test/unit/test_objects.py5
2 files changed, 10 insertions, 2 deletions
diff --git a/nailgun/nailgun/objects/cluster.py b/nailgun/nailgun/objects/cluster.py
index 669b963..298b33b 100644
--- a/nailgun/nailgun/objects/cluster.py
+++ b/nailgun/nailgun/objects/cluster.py
@@ -868,7 +868,7 @@ class Cluster(NailgunObject):
868 @classmethod 868 @classmethod
869 def get_roles_by_tag(cls, tag_name, instance): 869 def get_roles_by_tag(cls, tag_name, instance):
870 roles = set() 870 roles = set()
871 for role, meta in six.iteritems(cls.get_own_roles(instance)): 871 for role, meta in six.iteritems(cls.get_roles(instance)):
872 if tag_name in meta.get('tags', {}): 872 if tag_name in meta.get('tags', {}):
873 roles.add(role) 873 roles.add(role)
874 return roles 874 return roles
@@ -1036,13 +1036,16 @@ class Cluster(NailgunObject):
1036 return nodegroups[0] 1036 return nodegroups[0]
1037 1037
1038 @classmethod 1038 @classmethod
1039 def get_node_groups(cls, instance, noderoles): 1039 def get_node_groups(cls, instance, nodetags):
1040 """Returns node groups for given node roles. 1040 """Returns node groups for given node roles.
1041 1041
1042 :param instance: a Cluster instance 1042 :param instance: a Cluster instance
1043 :param noderoles: a list of node roles 1043 :param noderoles: a list of node roles
1044 :returns: a query for list of NodeGroup instances 1044 :returns: a query for list of NodeGroup instances
1045 """ 1045 """
1046 noderoles = set()
1047 for tag in nodetags:
1048 noderoles.update(cls.get_roles_by_tag(tag, instance) or [tag])
1046 psql_noderoles = sa.cast( 1049 psql_noderoles = sa.cast(
1047 psql.array(noderoles), 1050 psql.array(noderoles),
1048 psql.ARRAY(sa.String(consts.ROLE_NAME_MAX_SIZE))) 1051 psql.ARRAY(sa.String(consts.ROLE_NAME_MAX_SIZE)))
diff --git a/nailgun/nailgun/test/unit/test_objects.py b/nailgun/nailgun/test/unit/test_objects.py
index 3697cc9..3fef915 100644
--- a/nailgun/nailgun/test/unit/test_objects.py
+++ b/nailgun/nailgun/test/unit/test_objects.py
@@ -1098,6 +1098,7 @@ class TestClusterObject(BaseTestCase):
1098 super(TestClusterObject, self).setUp() 1098 super(TestClusterObject, self).setUp()
1099 self.cluster = self.env.create( 1099 self.cluster = self.env.create(
1100 cluster_kwargs={'net_provider': 'neutron'}, 1100 cluster_kwargs={'net_provider': 'neutron'},
1101 release_kwargs={'version': 'newton-10.0', 'api': False},
1101 nodes_kwargs=[ 1102 nodes_kwargs=[
1102 {'roles': ['controller']}, 1103 {'roles': ['controller']},
1103 {'roles': ['controller']}, 1104 {'roles': ['controller']},
@@ -1240,6 +1241,10 @@ class TestClusterObject(BaseTestCase):
1240 controller.group_id, 1241 controller.group_id,
1241 objects.Cluster.get_common_node_group(self.cluster, 1242 objects.Cluster.get_common_node_group(self.cluster,
1242 ['controller']).id) 1243 ['controller']).id)
1244 self.assertEqual(
1245 controller.group_id,
1246 objects.Cluster.get_common_node_group(self.cluster,
1247 ['neutron']).id)
1243 1248
1244 def test_get_node_group_multiple_return_same_group(self): 1249 def test_get_node_group_multiple_return_same_group(self):
1245 group_id = self.env.create_node_group().json_body['id'] 1250 group_id = self.env.create_node_group().json_body['id']