Use tempest-lib's agents_client

Now tempest-lib provides agents_client module as library and the
interface is stable. So tempest repogitory doesn't need to contain
the module.
This patch makes tempest use tempest-lib's agents_client and removes
the own module for the maintenance.

Change-Id: I610b962de89d71090d70cec7ba5db5bdf0ef75a9
diff --git a/tempest/clients.py b/tempest/clients.py
index dd0d145..563876c 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -16,6 +16,7 @@
 import copy
 
 from oslo_log import log as logging
+from tempest_lib.services.compute.agents_client import AgentsClient
 from tempest_lib.services.identity.v2.token_client import TokenClient
 from tempest_lib.services.identity.v3.token_client import V3TokenClient
 
@@ -27,8 +28,6 @@
 from tempest.services.baremetal.v1.json.baremetal_client import \
     BaremetalClient
 from tempest.services import botoclients
-from tempest.services.compute.json.agents_client import \
-    AgentsClient
 from tempest.services.compute.json.aggregates_client import \
     AggregatesClient
 from tempest.services.compute.json.availability_zone_client import \
diff --git a/tempest/services/compute/json/agents_client.py b/tempest/services/compute/json/agents_client.py
deleted file mode 100644
index d38c8cd..0000000
--- a/tempest/services/compute/json/agents_client.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2014 NEC Corporation.  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.
-
-from oslo_serialization import jsonutils as json
-from six.moves.urllib import parse as urllib
-
-from tempest.api_schema.response.compute.v2_1 import agents as schema
-from tempest.common import service_client
-
-
-class AgentsClient(service_client.ServiceClient):
-    """
-    Tests Agents API
-    """
-
-    def list_agents(self, **params):
-        """List all agent builds."""
-        url = 'os-agents'
-        if params:
-            url += '?%s' % urllib.urlencode(params)
-        resp, body = self.get(url)
-        body = json.loads(body)
-        self.validate_response(schema.list_agents, resp, body)
-        return service_client.ResponseBody(resp, body)
-
-    def create_agent(self, **kwargs):
-        """Create an agent build."""
-        post_body = json.dumps({'agent': kwargs})
-        resp, body = self.post('os-agents', post_body)
-        body = json.loads(body)
-        self.validate_response(schema.create_agent, resp, body)
-        return service_client.ResponseBody(resp, body)
-
-    def delete_agent(self, agent_id):
-        """Delete an existing agent build."""
-        resp, body = self.delete("os-agents/%s" % agent_id)
-        self.validate_response(schema.delete_agent, resp, body)
-        return service_client.ResponseBody(resp, body)
-
-    def update_agent(self, agent_id, **kwargs):
-        """Update an agent build."""
-        put_body = json.dumps({'para': kwargs})
-        resp, body = self.put('os-agents/%s' % agent_id, put_body)
-        body = json.loads(body)
-        return service_client.ResponseBody(resp, body)
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index 00b8470..3f72340 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -17,7 +17,6 @@
 import six
 
 from tempest.services.baremetal.v1.json import baremetal_client
-from tempest.services.compute.json import agents_client
 from tempest.services.compute.json import aggregates_client
 from tempest.services.compute.json import availability_zone_client
 from tempest.services.compute.json import certificates_client
@@ -109,7 +108,6 @@
     def test_service_client_creations_with_specified_args(self, mock_init):
         test_clients = [
             baremetal_client.BaremetalClient,
-            agents_client.AgentsClient,
             aggregates_client.AggregatesClient,
             availability_zone_client.AvailabilityZoneClient,
             certificates_client.CertificatesClient,
diff --git a/tempest/tests/services/compute/test_agents_client.py b/tempest/tests/services/compute/test_agents_client.py
deleted file mode 100644
index 31e576e..0000000
--- a/tempest/tests/services/compute/test_agents_client.py
+++ /dev/null
@@ -1,109 +0,0 @@
-# Copyright 2015 NEC Corporation.  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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import agents_client
-from tempest.tests.services.compute import base
-
-
-class TestAgentsClient(base.BaseComputeServiceTest):
-    FAKE_CREATE_AGENT = {
-        "agent":
-        {
-            "url": "http://foo.com",
-            "hypervisor": "kvm",
-            "md5hash": "md5",
-            "version": "2",
-            "architecture": "x86_64",
-            "os": "linux",
-            "agent_id": 1
-        }
-    }
-
-    FAKE_UPDATE_AGENT = {
-        "agent":
-        {
-            "url": "http://foo.com",
-            "hypervisor": "kvm",
-            "md5hash": "md5",
-            "version": "2",
-            "architecture": "x86_64",
-            "os": "linux",
-            "agent_id": 1
-        }
-    }
-
-    def setUp(self):
-        super(TestAgentsClient, self).setUp()
-        fake_auth = fake_auth_provider.FakeAuthProvider()
-        self.client = agents_client.AgentsClient(fake_auth,
-                                                 'compute', 'regionOne')
-
-    def _test_list_agents(self, bytes_body=False):
-        self.check_service_client_function(
-            self.client.list_agents,
-            'tempest.common.service_client.ServiceClient.get',
-            {"agents": []},
-            bytes_body)
-        self.check_service_client_function(
-            self.client.list_agents,
-            'tempest.common.service_client.ServiceClient.get',
-            {"agents": []},
-            bytes_body,
-            hypervisor="kvm")
-
-    def _test_create_agent(self, bytes_body=False):
-        self.check_service_client_function(
-            self.client.create_agent,
-            'tempest.common.service_client.ServiceClient.post',
-            self.FAKE_CREATE_AGENT,
-            bytes_body,
-            url="http://foo.com", hypervisor="kvm", md5hash="md5",
-            version="2", architecture="x86_64", os="linux")
-
-    def _test_delete_agent(self):
-        self.check_service_client_function(
-            self.client.delete_agent,
-            'tempest.common.service_client.ServiceClient.delete',
-            {}, agent_id="1")
-
-    def _test_update_agent(self, bytes_body=False):
-        self.check_service_client_function(
-            self.client.update_agent,
-            'tempest.common.service_client.ServiceClient.put',
-            self.FAKE_UPDATE_AGENT,
-            bytes_body,
-            agent_id="1", url="http://foo.com", md5hash="md5", version="2")
-
-    def test_list_agents_with_str_body(self):
-        self._test_list_agents()
-
-    def test_list_agents_with_bytes_body(self):
-        self._test_list_agents(bytes_body=True)
-
-    def test_create_agent_with_str_body(self):
-        self._test_create_agent()
-
-    def test_create_agent_with_bytes_body(self):
-        self._test_create_agent(bytes_body=True)
-
-    def test_delete_agent(self):
-        self._test_delete_agent()
-
-    def test_update_agent_with_str_body(self):
-        self._test_update_agent()
-
-    def test_update_agent_with_bytes_body(self):
-        self._test_update_agent(bytes_body=True)