Browse Source

Merge "Use tags instead of roles"

Jenkins 2 years ago
parent
commit
36b90eacdc
2 changed files with 10 additions and 2 deletions
  1. 5
    2
      nailgun/nailgun/objects/cluster.py
  2. 5
    0
      nailgun/nailgun/test/unit/test_objects.py

+ 5
- 2
nailgun/nailgun/objects/cluster.py View File

@@ -868,7 +868,7 @@ class Cluster(NailgunObject):
868 868
     @classmethod
869 869
     def get_roles_by_tag(cls, tag_name, instance):
870 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 872
             if tag_name in meta.get('tags', {}):
873 873
                 roles.add(role)
874 874
         return roles
@@ -1036,13 +1036,16 @@ class Cluster(NailgunObject):
1036 1036
         return nodegroups[0]
1037 1037
 
1038 1038
     @classmethod
1039
-    def get_node_groups(cls, instance, noderoles):
1039
+    def get_node_groups(cls, instance, nodetags):
1040 1040
         """Returns node groups for given node roles.
1041 1041
 
1042 1042
         :param instance: a Cluster instance
1043 1043
         :param noderoles: a list of node roles
1044 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 1049
         psql_noderoles = sa.cast(
1047 1050
             psql.array(noderoles),
1048 1051
             psql.ARRAY(sa.String(consts.ROLE_NAME_MAX_SIZE)))

+ 5
- 0
nailgun/nailgun/test/unit/test_objects.py View File

@@ -1098,6 +1098,7 @@ class TestClusterObject(BaseTestCase):
1098 1098
         super(TestClusterObject, self).setUp()
1099 1099
         self.cluster = self.env.create(
1100 1100
             cluster_kwargs={'net_provider': 'neutron'},
1101
+            release_kwargs={'version': 'newton-10.0', 'api': False},
1101 1102
             nodes_kwargs=[
1102 1103
                 {'roles': ['controller']},
1103 1104
                 {'roles': ['controller']},
@@ -1240,6 +1241,10 @@ class TestClusterObject(BaseTestCase):
1240 1241
             controller.group_id,
1241 1242
             objects.Cluster.get_common_node_group(self.cluster,
1242 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 1249
     def test_get_node_group_multiple_return_same_group(self):
1245 1250
         group_id = self.env.create_node_group().json_body['id']

Loading…
Cancel
Save