Merge "Separate server_groups_client from servers_client"
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 6136e01..ea8e112 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -57,6 +57,7 @@
     def setup_clients(cls):
         super(BaseComputeTest, cls).setup_clients()
         cls.servers_client = cls.os.servers_client
+        cls.server_groups_client = cls.os.server_groups_client
         cls.flavors_client = cls.os.flavors_client
         cls.images_client = cls.os.images_client
         cls.extensions_client = cls.os.extensions_client
@@ -184,7 +185,7 @@
         LOG.debug('Clearing server groups: %s', ','.join(cls.server_groups))
         for server_group_id in cls.server_groups:
             try:
-                cls.servers_client.delete_server_group(server_group_id)
+                cls.server_groups_client.delete_server_group(server_group_id)
             except lib_exc.NotFound:
                 # The server-group may have already been deleted which is OK.
                 pass
@@ -232,7 +233,7 @@
             name = data_utils.rand_name(cls.__name__ + "-Server-Group")
         if policy is None:
             policy = ['affinity']
-        body = cls.servers_client.create_server_group(name, policy)
+        body = cls.server_groups_client.create_server_group(name, policy)
         cls.server_groups.append(body['id'])
         return body
 
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index ea5f142..94b6cf0 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -121,17 +121,18 @@
         # Create a server with the scheduler hint "group".
         name = data_utils.rand_name('server_group')
         policies = ['affinity']
-        body = self.client.create_server_group(name=name,
-                                               policies=policies)
+        body = self.server_groups_client.create_server_group(
+            name=name, policies=policies)
         group_id = body['id']
-        self.addCleanup(self.client.delete_server_group, group_id)
+        self.addCleanup(self.server_groups_client.delete_server_group,
+                        group_id)
 
         hints = {'group': group_id}
         server = self.create_test_server(sched_hints=hints,
                                          wait_until='ACTIVE')
 
         # Check a server is in the group
-        server_group = self.client.get_server_group(group_id)
+        server_group = self.server_groups_client.get_server_group(group_id)
         self.assertIn(server['id'], server_group['members'])
 
     @test.idempotent_id('0578d144-ed74-43f8-8e57-ab10dbf9b3c2')
diff --git a/tempest/api/compute/servers/test_server_group.py b/tempest/api/compute/servers/test_server_group.py
index f6dd5e3..0e7c1eb 100644
--- a/tempest/api/compute/servers/test_server_group.py
+++ b/tempest/api/compute/servers/test_server_group.py
@@ -37,7 +37,7 @@
     @classmethod
     def setup_clients(cls):
         super(ServerGroupTestJSON, cls).setup_clients()
-        cls.client = cls.servers_client
+        cls.client = cls.server_groups_client
 
     @classmethod
     def resource_setup(cls):
diff --git a/tempest/clients.py b/tempest/clients.py
index 0ab0465..6a2c601 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -67,6 +67,8 @@
     SecurityGroupDefaultRulesClient
 from tempest.services.compute.json.security_groups_client import \
     SecurityGroupsClient
+from tempest.services.compute.json.server_groups_client import \
+    ServerGroupsClient
 from tempest.services.compute.json.servers_client import ServersClient
 from tempest.services.compute.json.services_client import ServicesClient
 from tempest.services.compute.json.tenant_networks_client import \
@@ -267,6 +269,8 @@
             enable_instance_password=CONF.compute_feature_enabled
                 .enable_instance_password,
             **params)
+        self.server_groups_client = ServerGroupsClient(
+            self.auth_provider, **params)
         self.limits_client = LimitsClient(self.auth_provider, **params)
         self.images_client = ImagesClient(self.auth_provider, **params)
         self.keypairs_client = KeyPairsClient(self.auth_provider, **params)
diff --git a/tempest/services/compute/json/server_groups_client.py b/tempest/services/compute/json/server_groups_client.py
new file mode 100644
index 0000000..9fec930
--- /dev/null
+++ b/tempest/services/compute/json/server_groups_client.py
@@ -0,0 +1,61 @@
+# Copyright 2012 OpenStack Foundation
+# Copyright 2013 Hewlett-Packard Development Company, L.P.
+# All Rights Reserved.
+#
+#    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.
+
+import json
+
+from tempest.api_schema.response.compute.v2_1 import servers as schema
+from tempest.common import service_client
+
+
+class ServerGroupsClient(service_client.ServiceClient):
+
+    def create_server_group(self, name, policies):
+        """
+        Create the server group
+        name : Name of the server-group
+        policies : List of the policies - affinity/anti-affinity)
+        """
+        post_body = {
+            'name': name,
+            'policies': policies,
+        }
+
+        post_body = json.dumps({'server_group': post_body})
+        resp, body = self.post('os-server-groups', post_body)
+
+        body = json.loads(body)
+        self.validate_response(schema.create_get_server_group, resp, body)
+        return service_client.ResponseBody(resp, body['server_group'])
+
+    def delete_server_group(self, server_group_id):
+        """Delete the given server-group."""
+        resp, body = self.delete("os-server-groups/%s" % server_group_id)
+        self.validate_response(schema.delete_server_group, resp, body)
+        return service_client.ResponseBody(resp, body)
+
+    def list_server_groups(self):
+        """List the server-groups."""
+        resp, body = self.get("os-server-groups")
+        body = json.loads(body)
+        self.validate_response(schema.list_server_groups, resp, body)
+        return service_client.ResponseBodyList(resp, body['server_groups'])
+
+    def get_server_group(self, server_group_id):
+        """Get the details of given server_group."""
+        resp, body = self.get("os-server-groups/%s" % server_group_id)
+        body = json.loads(body)
+        self.validate_response(schema.create_get_server_group, resp, body)
+        return service_client.ResponseBody(resp, body['server_group'])
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 7263014..1a3864c 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -525,41 +525,3 @@
         return self.action(server_id, "os-getVNCConsole",
                            "console", schema.get_vnc_console,
                            type=console_type)
-
-    def create_server_group(self, name, policies):
-        """
-        Create the server group
-        name : Name of the server-group
-        policies : List of the policies - affinity/anti-affinity)
-        """
-        post_body = {
-            'name': name,
-            'policies': policies,
-        }
-
-        post_body = json.dumps({'server_group': post_body})
-        resp, body = self.post('os-server-groups', post_body)
-
-        body = json.loads(body)
-        self.validate_response(schema.create_get_server_group, resp, body)
-        return service_client.ResponseBody(resp, body['server_group'])
-
-    def delete_server_group(self, server_group_id):
-        """Delete the given server-group."""
-        resp, body = self.delete("os-server-groups/%s" % server_group_id)
-        self.validate_response(schema.delete_server_group, resp, body)
-        return service_client.ResponseBody(resp, body)
-
-    def list_server_groups(self):
-        """List the server-groups."""
-        resp, body = self.get("os-server-groups")
-        body = json.loads(body)
-        self.validate_response(schema.list_server_groups, resp, body)
-        return service_client.ResponseBodyList(resp, body['server_groups'])
-
-    def get_server_group(self, server_group_id):
-        """Get the details of given server_group."""
-        resp, body = self.get("os-server-groups/%s" % server_group_id)
-        body = json.loads(body)
-        self.validate_response(schema.create_get_server_group, resp, body)
-        return service_client.ResponseBody(resp, body['server_group'])
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index f57edc5..695d4a4 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -41,6 +41,7 @@
 from tempest.services.compute.json import security_group_default_rules_client \
     as nova_secgrop_default_client
 from tempest.services.compute.json import security_groups_client
+from tempest.services.compute.json import server_groups_client
 from tempest.services.compute.json import servers_client
 from tempest.services.compute.json import services_client
 from tempest.services.compute.json import tenant_usages_client
@@ -130,6 +131,7 @@
             quota_classes_client.QuotaClassesClient,
             nova_secgrop_default_client.SecurityGroupDefaultRulesClient,
             security_groups_client.SecurityGroupsClient,
+            server_groups_client.ServerGroupsClient,
             servers_client.ServersClient,
             services_client.ServicesClient,
             tenant_usages_client.TenantUsagesClient,