Merge "Migrate advanced server network to tempest clients"
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 47f2f1a..c145551 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -25,7 +25,7 @@
 LOG = logging.getLogger(__name__)
 
 
-class TestNetworkAdvancedServerOps(manager.NetworkScenarioTest):
+class TestNetworkAdvancedServerOps(manager.NeutronScenarioTest):
 
     """
     This test case checks VM connectivity after some advanced
@@ -40,9 +40,8 @@
     """
 
     @classmethod
-    def setUpClass(cls):
-        super(TestNetworkAdvancedServerOps, cls).setUpClass()
-        cls.check_preconditions()
+    def check_preconditions(cls):
+        super(TestNetworkAdvancedServerOps, cls).check_preconditions()
         if not (CONF.network.tenant_networks_reachable
                 or CONF.network.public_network_id):
             msg = ('Either tenant_networks_reachable must be "true", or '
@@ -50,20 +49,23 @@
             cls.enabled = False
             raise cls.skipException(msg)
 
-    def _setup_network_and_servers(self):
-        key_name = data_utils.rand_name('keypair-smoke-')
-        self.keypair = self.create_keypair(name=key_name)
-        security_group =\
-            self._create_security_group_neutron(tenant_id=self.tenant_id)
-        network, subnet, router = self.create_networks(self.tenant_id)
+    @classmethod
+    def setUpClass(cls):
+        # Create no network resources for these tests.
+        cls.set_network_resources()
+        super(TestNetworkAdvancedServerOps, cls).setUpClass()
 
+    def _setup_network_and_servers(self):
+        self.keypair = self.create_keypair()
+        security_group = self._create_security_group()
+        network, subnet, router = self.create_networks()
         public_network_id = CONF.network.public_network_id
         create_kwargs = {
             'nics': [
                 {'net-id': network.id},
             ],
-            'key_name': self.keypair.name,
-            'security_groups': [security_group.name],
+            'key_name': self.keypair['name'],
+            'security_groups': [security_group],
         }
         server_name = data_utils.rand_name('server-smoke')
         self.server = self.create_server(name=server_name,
@@ -76,9 +78,10 @@
 
     def _check_network_connectivity(self, should_connect=True):
         username = CONF.compute.image_ssh_user
-        private_key = self.keypair.private_key
+        private_key = self.keypair['private_key']
         self._check_tenant_network_connectivity(
-            self.server, username, private_key, should_connect=should_connect,
+            self.server, username, private_key,
+            should_connect=should_connect,
             servers_for_debug=[self.server])
         floating_ip = self.floating_ip.floating_ip_address
         self._check_public_network_connectivity(floating_ip, username,
@@ -86,31 +89,31 @@
                                                 servers=[self.server])
 
     def _wait_server_status_and_check_network_connectivity(self):
-        self.status_timeout(self.compute_client.servers, self.server.id,
-                            'ACTIVE')
+        self.servers_client.wait_for_server_status(self.server['id'], 'ACTIVE')
         self._check_network_connectivity()
 
     @test.services('compute', 'network')
     def test_server_connectivity_stop_start(self):
         self._setup_network_and_servers()
-        self.server.stop()
-        self.status_timeout(self.compute_client.servers, self.server.id,
-                            'SHUTOFF')
+        self.servers_client.stop(self.server['id'])
+        self.servers_client.wait_for_server_status(self.server['id'],
+                                                   'SHUTOFF')
         self._check_network_connectivity(should_connect=False)
-        self.server.start()
+        self.servers_client.start(self.server['id'])
         self._wait_server_status_and_check_network_connectivity()
 
     @test.services('compute', 'network')
     def test_server_connectivity_reboot(self):
         self._setup_network_and_servers()
-        self.server.reboot()
+        self.servers_client.reboot(self.server['id'], reboot_type='SOFT')
         self._wait_server_status_and_check_network_connectivity()
 
     @test.services('compute', 'network')
     def test_server_connectivity_rebuild(self):
         self._setup_network_and_servers()
         image_ref_alt = CONF.compute.image_ref_alt
-        self.server.rebuild(image_ref_alt)
+        self.servers_client.rebuild(self.server['id'],
+                                    image_ref=image_ref_alt)
         self._wait_server_status_and_check_network_connectivity()
 
     @testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -118,11 +121,10 @@
     @test.services('compute', 'network')
     def test_server_connectivity_pause_unpause(self):
         self._setup_network_and_servers()
-        self.server.pause()
-        self.status_timeout(self.compute_client.servers, self.server.id,
-                            'PAUSED')
+        self.servers_client.pause_server(self.server['id'])
+        self.servers_client.wait_for_server_status(self.server['id'], 'PAUSED')
         self._check_network_connectivity(should_connect=False)
-        self.server.unpause()
+        self.servers_client.unpause_server(self.server['id'])
         self._wait_server_status_and_check_network_connectivity()
 
     @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
@@ -130,11 +132,11 @@
     @test.services('compute', 'network')
     def test_server_connectivity_suspend_resume(self):
         self._setup_network_and_servers()
-        self.server.suspend()
-        self.status_timeout(self.compute_client.servers, self.server.id,
-                            'SUSPENDED')
+        self.servers_client.suspend_server(self.server['id'])
+        self.servers_client.wait_for_server_status(self.server['id'],
+                                                   'SUSPENDED')
         self._check_network_connectivity(should_connect=False)
-        self.server.resume()
+        self.servers_client.resume_server(self.server['id'])
         self._wait_server_status_and_check_network_connectivity()
 
     @testtools.skipUnless(CONF.compute_feature_enabled.resize,
@@ -146,9 +148,8 @@
             msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
             raise self.skipException(msg)
         self._setup_network_and_servers()
-        resize_flavor = CONF.compute.flavor_ref_alt
-        self.server.resize(resize_flavor)
-        self.status_timeout(self.compute_client.servers, self.server.id,
-                            'VERIFY_RESIZE')
-        self.server.confirm_resize()
+        self.servers_client.resize(self.server['id'], flavor_ref=resize_flavor)
+        self.servers_client.wait_for_server_status(self.server['id'],
+                                                   'VERIFY_RESIZE')
+        self.servers_client.confirm_resize(self.server['id'])
         self._wait_server_status_and_check_network_connectivity()