Merge "Remove code duplication in delete methods"
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index c987100..80f858b 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -16,7 +16,7 @@
 from oslo_log import log as logging
 from tempest_lib import exceptions as lib_exc
 
-from tempest.common import fixed_network
+from tempest.common import compute
 from tempest.common.utils import data_utils
 from tempest import config
 from tempest import exceptions
@@ -162,12 +162,13 @@
 
     @classmethod
     def create_server(cls, name, **kwargs):
-        network = cls.get_tenant_network()
-        network_kwargs = fixed_network.set_networks_kwarg(network, kwargs)
-        return cls.servers_client.create_server(name,
-                                                cls.image_ref,
-                                                cls.flavor_ref,
-                                                **network_kwargs)
+        tenant_network = cls.get_tenant_network()
+        body, _ = compute.create_test_server(
+            cls.os,
+            tenant_network=tenant_network,
+            name=name,
+            **kwargs)
+        return body
 
 
 class BaseVolumeAdminTest(BaseVolumeTest):
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 79615b3..d81462e 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -37,9 +37,9 @@
 
         # Create a test shared instance
         srv_name = data_utils.rand_name(cls.__name__ + '-Instance')
-        cls.server = cls.create_server(srv_name)
-        waiters.wait_for_server_status(cls.servers_client, cls.server['id'],
-                                       'ACTIVE')
+        cls.server = cls.create_server(
+            name=srv_name,
+            wait_until='ACTIVE')
 
         # Create a test shared volume for attach/detach tests
         cls.volume = cls.create_volume()
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 48f40f0..7c373b7 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -180,12 +180,13 @@
     @test.services('compute')
     def test_attach_volumes_with_nonexistent_volume_id(self):
         srv_name = data_utils.rand_name('Instance')
-        server = self.create_server(srv_name)
+        server = self.create_server(
+            name=srv_name,
+            wait_until='ACTIVE')
         self.addCleanup(waiters.wait_for_server_termination,
                         self.servers_client, server['id'])
         self.addCleanup(self.servers_client.delete_server, server['id'])
-        waiters.wait_for_server_status(self.servers_client, server['id'],
-                                       'ACTIVE')
+
         self.assertRaises(lib_exc.NotFound,
                           self.client.attach_volume,
                           str(uuid.uuid4()),
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 058e220..4bbb0f1 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -14,7 +14,6 @@
 
 from tempest.api.volume import base
 from tempest.common.utils import data_utils
-from tempest.common import waiters
 from tempest import config
 from tempest import test
 
@@ -68,10 +67,10 @@
         # Create a snapshot when volume status is in-use
         # Create a test instance
         server_name = data_utils.rand_name('instance')
-        server = self.create_server(server_name)
+        server = self.create_server(
+            name=server_name,
+            wait_until='ACTIVE')
         self.addCleanup(self.servers_client.delete_server, server['id'])
-        waiters.wait_for_server_status(self.servers_client, server['id'],
-                                       'ACTIVE')
         mountpoint = '/dev/%s' % CONF.compute.volume_device_name
         self.servers_client.attach_volume(
             server['id'], volumeId=self.volume_origin['id'],
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 2a22c42..8ca5e72 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -17,7 +17,6 @@
 import re
 
 from oslo_log import log as logging
-from tempest_lib import decorators
 import testtools
 
 from tempest.common.utils import data_utils
@@ -660,7 +659,6 @@
         self.assertEqual('', port['device_owner'])
 
     @test.idempotent_id('2e788c46-fb3f-4ac9-8f82-0561555bea73')
-    @decorators.skip_because(bug="1489929")
     @test.services('compute', 'network')
     def test_router_rescheduling(self):
         """Tests that router can be removed from agent and add to a new agent.
@@ -686,6 +684,14 @@
         agent_list = set(a["id"] for a in
                          self._list_agents(agent_type="L3 agent"))
         self._setup_network_and_servers()
+
+        # NOTE(kevinbenton): we have to use the admin credentials to check
+        # for the distributed flag because self.router only has a tenant view.
+        admin = self.admin_manager.network_client.show_router(self.router.id)
+        if admin['router'].get('distributed', False):
+            msg = "Rescheduling test does not apply to distributed routers."
+            raise self.skipException(msg)
+
         self.check_public_network_connectivity(should_connect=True)
 
         # remove resource from agents
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 9fbd03c..5603fed 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -97,35 +97,16 @@
         self.validate_response(create_schema, resp, body)
         return service_client.ResponseBody(resp, body['server'])
 
-    def update_server(self, server_id, name=None, meta=None, accessIPv4=None,
-                      accessIPv6=None, disk_config=None):
+    def update_server(self, server_id, **kwargs):
+        """Updates the properties of an existing server.
+        Most parameters except the following are passed to the API without
+        any changes.
+        :param disk_config: The name is changed to OS-DCF:diskConfig
         """
-        Updates the properties of an existing server.
-        server_id: The id of an existing server.
-        name: The name of the server.
-        personality: A list of files to be injected into the server.
-        accessIPv4: The IPv4 access address for the server.
-        accessIPv6: The IPv6 access address for the server.
-        """
+        if kwargs.get('disk_config'):
+            kwargs['OS-DCF:diskConfig'] = kwargs.pop('disk_config')
 
-        post_body = {}
-
-        if meta is not None:
-            post_body['metadata'] = meta
-
-        if name is not None:
-            post_body['name'] = name
-
-        if accessIPv4 is not None:
-            post_body['accessIPv4'] = accessIPv4
-
-        if accessIPv6 is not None:
-            post_body['accessIPv6'] = accessIPv6
-
-        if disk_config is not None:
-            post_body['OS-DCF:diskConfig'] = disk_config
-
-        post_body = json.dumps({'server': post_body})
+        post_body = json.dumps({'server': kwargs})
         resp, body = self.put("servers/%s" % server_id, post_body)
         body = json.loads(body)
         self.validate_response(schema.update_server, resp, body)
diff --git a/tempest/tests/services/compute/test_fixedIPs_client.py b/tempest/tests/services/compute/test_fixedIPs_client.py
new file mode 100644
index 0000000..d7a9694
--- /dev/null
+++ b/tempest/tests/services/compute/test_fixedIPs_client.py
@@ -0,0 +1,45 @@
+# 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.services.compute.json import fixed_ips_client
+from tempest.tests import fake_auth_provider
+from tempest.tests.services.compute import base
+
+
+class TestFixedIPsClient(base.BaseComputeServiceTest):
+    FIXED_IP_INFO = {"fixed_ip": {"address": "10.0.0.1",
+                                  "cidr": "10.11.12.0/24",
+                                  "host": "localhost",
+                                  "hostname": "OpenStack"}}
+
+    def setUp(self):
+        super(TestFixedIPsClient, self).setUp()
+        fake_auth = fake_auth_provider.FakeAuthProvider()
+        self.fixedIPsClient = (fixed_ips_client.
+                               FixedIPsClient
+                               (fake_auth, 'compute',
+                                'regionOne'))
+
+    def _test_show_fixed_ip(self, bytes_body=False):
+        self.check_service_client_function(
+            self.fixedIPsClient.show_fixed_ip,
+            'tempest.common.service_client.ServiceClient.get',
+            self.FIXED_IP_INFO, bytes_body,
+            status=200, fixed_ip='Identifier')
+
+    def test_show_fixed_ip_with_str_body(self):
+        self._test_show_fixed_ip()
+
+    def test_show_fixed_ip_with_bytes_body(self):
+        self._test_show_fixed_ip(True)