Merge "part 2 of delete xml"
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index ea4365e..522aa43 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -456,6 +456,68 @@
 
         return tempest.test.call_until_true(ping, timeout, 1)
 
+    def check_vm_connectivity(self, ip_address,
+                              username=None,
+                              private_key=None,
+                              should_connect=True):
+        """
+        :param ip_address: server to test against
+        :param username: server's ssh username
+        :param private_key: server's ssh private key to be used
+        :param should_connect: True/False indicates positive/negative test
+            positive - attempt ping and ssh
+            negative - attempt ping and fail if succeed
+
+        :raises: AssertError if the result of the connectivity check does
+            not match the value of the should_connect param
+        """
+        if should_connect:
+            msg = "Timed out waiting for %s to become reachable" % ip_address
+        else:
+            msg = "ip address %s is reachable" % ip_address
+        self.assertTrue(self.ping_ip_address(ip_address,
+                                             should_succeed=should_connect),
+                        msg=msg)
+        if should_connect:
+            # no need to check ssh for negative connectivity
+            self.get_remote_client(ip_address, username, private_key)
+
+    def check_public_network_connectivity(self, ip_address, username,
+                                          private_key, should_connect=True,
+                                          msg=None, servers=None):
+        # The target login is assumed to have been configured for
+        # key-based authentication by cloud-init.
+        LOG.debug('checking network connections to IP %s with user: %s' %
+                  (ip_address, username))
+        try:
+            self.check_vm_connectivity(ip_address,
+                                       username,
+                                       private_key,
+                                       should_connect=should_connect)
+        except Exception as e:
+            ex_msg = 'Public network connectivity check failed'
+            if msg:
+                ex_msg += ": " + msg
+            LOG.exception(ex_msg)
+            self._log_console_output(servers)
+            # network debug is called as part of ssh init
+            if not isinstance(e, exceptions.SSHTimeout):
+                debug.log_net_debug()
+            raise
+
+    def create_floating_ip(self, thing, pool_name=None):
+        """Creates a floating IP and associates to a server using
+        Nova clients
+        """
+
+        _, floating_ip = self.floating_ips_client.create_floating_ip(pool_name)
+        self.addCleanup(self.delete_wrapper,
+                        self.floating_ips_client.delete_floating_ip,
+                        floating_ip['id'])
+        self.floating_ips_client.associate_floating_ip_to_server(
+            floating_ip['ip'], thing['id'])
+        return floating_ip
+
 
 class NetworkScenarioTest(ScenarioTest):
     """Base class for network scenario tests.
@@ -591,8 +653,13 @@
         net = self._list_networks(name=network_name)
         return net_resources.AttributeDict(net[0])
 
-    def _create_floating_ip(self, thing, external_network_id, port_id=None,
-                            client=None):
+    def create_floating_ip(self, thing, external_network_id=None,
+                           port_id=None, client=None):
+        """Creates a floating IP and associates to a resource/port using
+        Neutron client
+        """
+        if not external_network_id:
+            external_network_id = CONF.network.public_network_id
         if not client:
             client = self.network_client
         if not port_id:
@@ -645,53 +712,6 @@
         LOG.info("FloatingIP: {fp} is at status: {st}"
                  .format(fp=floating_ip, st=status))
 
-    def _check_vm_connectivity(self, ip_address,
-                               username=None,
-                               private_key=None,
-                               should_connect=True):
-        """
-        :param ip_address: server to test against
-        :param username: server's ssh username
-        :param private_key: server's ssh private key to be used
-        :param should_connect: True/False indicates positive/negative test
-            positive - attempt ping and ssh
-            negative - attempt ping and fail if succeed
-
-        :raises: AssertError if the result of the connectivity check does
-            not match the value of the should_connect param
-        """
-        if should_connect:
-            msg = "Timed out waiting for %s to become reachable" % ip_address
-        else:
-            msg = "ip address %s is reachable" % ip_address
-        self.assertTrue(self.ping_ip_address(ip_address,
-                                             should_succeed=should_connect),
-                        msg=msg)
-        if should_connect:
-            # no need to check ssh for negative connectivity
-            self.get_remote_client(ip_address, username, private_key)
-
-    def _check_public_network_connectivity(self, ip_address, username,
-                                           private_key, should_connect=True,
-                                           msg=None, servers=None):
-        # The target login is assumed to have been configured for
-        # key-based authentication by cloud-init.
-        LOG.debug('checking network connections to IP %s with user: %s' %
-                  (ip_address, username))
-        try:
-            self._check_vm_connectivity(ip_address,
-                                        username,
-                                        private_key,
-                                        should_connect=should_connect)
-        except Exception as e:
-            ex_msg = 'Public network connectivity check failed'
-            if msg:
-                ex_msg += ": " + msg
-            LOG.exception(ex_msg)
-            self._log_console_output(servers)
-            self._log_net_info(e)
-            raise
-
     def _check_tenant_network_connectivity(self, server,
                                            username,
                                            private_key,
@@ -706,10 +726,10 @@
         try:
             for net_name, ip_addresses in server['networks'].iteritems():
                 for ip_address in ip_addresses:
-                    self._check_vm_connectivity(ip_address,
-                                                username,
-                                                private_key,
-                                                should_connect=should_connect)
+                    self.check_vm_connectivity(ip_address,
+                                               username,
+                                               private_key,
+                                               should_connect=should_connect)
         except Exception as e:
             LOG.exception('Tenant network connectivity check failed')
             self._log_console_output(servers_for_debug)
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
index 9e404c8..d061406 100644
--- a/tempest/scenario/test_load_balancer_basic.py
+++ b/tempest/scenario/test_load_balancer_basic.py
@@ -137,7 +137,7 @@
         if (config.network.public_network_id and not
                 config.network.tenant_networks_reachable):
             public_network_id = config.network.public_network_id
-            floating_ip = self._create_floating_ip(
+            floating_ip = self.create_floating_ip(
                 server, public_network_id)
             self.floating_ips[floating_ip] = server
             self.server_ips[server['id']] = floating_ip.floating_ip_address
@@ -257,8 +257,8 @@
     def _assign_floating_ip_to_vip(self, vip):
         public_network_id = config.network.public_network_id
         port_id = vip.port_id
-        floating_ip = self._create_floating_ip(vip, public_network_id,
-                                               port_id=port_id)
+        floating_ip = self.create_floating_ip(vip, public_network_id,
+                                              port_id=port_id)
         self.floating_ips.setdefault(vip.id, [])
         self.floating_ips[vip.id].append(floating_ip)
 
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index ead021e..59af6b3 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -89,16 +89,6 @@
         self.servers_client.reboot(self.server['id'], 'SOFT')
         self._wait_for_server_status('ACTIVE')
 
-    def nova_floating_ip_create(self):
-        _, self.floating_ip = self.floating_ips_client.create_floating_ip()
-        self.addCleanup(self.delete_wrapper,
-                        self.floating_ips_client.delete_floating_ip,
-                        self.floating_ip['id'])
-
-    def nova_floating_ip_add(self):
-        self.floating_ips_client.associate_floating_ip_to_server(
-            self.floating_ip['ip'], self.server['id'])
-
     def ssh_to_server(self):
         try:
             self.linux_client = self.get_remote_client(self.floating_ip['ip'])
@@ -155,8 +145,7 @@
         self.addCleanup(self.nova_volume_detach)
         self.cinder_show()
 
-        self.nova_floating_ip_create()
-        self.nova_floating_ip_add()
+        self.floating_ip = self.create_floating_ip(self.server)
         self.create_and_add_security_group()
         self.ssh_to_server()
         self.nova_reboot()
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 0c48334..ad7f18c 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -70,8 +70,8 @@
         server_name = data_utils.rand_name('server-smoke')
         self.server = self.create_server(name=server_name,
                                          create_kwargs=create_kwargs)
-        self.floating_ip = self._create_floating_ip(self.server,
-                                                    public_network_id)
+        self.floating_ip = self.create_floating_ip(self.server,
+                                                   public_network_id)
         # Verify that we can indeed connect to the server before we mess with
         # it's state
         self._wait_server_status_and_check_network_connectivity()
@@ -84,9 +84,9 @@
             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,
-                                                private_key, should_connect,
-                                                servers=[self.server])
+        self.check_public_network_connectivity(floating_ip, username,
+                                               private_key, should_connect,
+                                               servers=[self.server])
         self.check_floating_ip_status(self.floating_ip, 'ACTIVE')
 
     def _wait_server_status_and_check_network_connectivity(self):
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index e3f87e9..bac955d 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -112,7 +112,8 @@
         server = self._create_server(name, self.network)
         self._check_tenant_network_connectivity()
 
-        self._create_and_associate_floating_ips(server)
+        floating_ip = self.create_floating_ip(server)
+        self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
 
     def check_networks(self):
         """
@@ -169,13 +170,8 @@
                     server, ssh_login, self._get_server_key(server),
                     servers_for_debug=self.servers)
 
-    def _create_and_associate_floating_ips(self, server):
-        public_network_id = CONF.network.public_network_id
-        floating_ip = self._create_floating_ip(server, public_network_id)
-        self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
-
-    def _check_public_network_connectivity(self, should_connect=True,
-                                           msg=None):
+    def check_public_network_connectivity(self, should_connect=True,
+                                          msg=None):
         """Verifies connectivty to a VM via public network and floating IP,
         and verifies floating IP has resource status is correct.
 
@@ -194,7 +190,7 @@
             private_key = self._get_server_key(server)
             floatingip_status = 'ACTIVE'
         # call the common method in the parent class
-        super(TestNetworkBasicOps, self)._check_public_network_connectivity(
+        super(TestNetworkBasicOps, self).check_public_network_connectivity(
             ip_address, ssh_login, private_key, should_connect, msg,
             self.servers)
         self.check_floating_ip_status(floating_ip, floatingip_status)
@@ -367,17 +363,17 @@
 
         """
         self._setup_network_and_servers()
-        self._check_public_network_connectivity(should_connect=True)
+        self.check_public_network_connectivity(should_connect=True)
         self._check_network_internal_connectivity(network=self.network)
         self._check_network_external_connectivity()
         self._disassociate_floating_ips()
-        self._check_public_network_connectivity(should_connect=False,
-                                                msg="after disassociate "
-                                                    "floating ip")
+        self.check_public_network_connectivity(should_connect=False,
+                                               msg="after disassociate "
+                                                   "floating ip")
         self._reassociate_floating_ips()
-        self._check_public_network_connectivity(should_connect=True,
-                                                msg="after re-associate "
-                                                    "floating ip")
+        self.check_public_network_connectivity(should_connect=True,
+                                               msg="after re-associate "
+                                                   "floating ip")
 
     @testtools.skipUnless(CONF.compute_feature_enabled.interface_attach,
                           'NIC hotplug not available')
@@ -393,7 +389,7 @@
 
         """
         self._setup_network_and_servers()
-        self._check_public_network_connectivity(should_connect=True)
+        self.check_public_network_connectivity(should_connect=True)
         self._create_new_network()
         self._hotplug_server()
         self._check_network_internal_connectivity(network=self.new_net)
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 6ea3253..747850b 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -271,7 +271,7 @@
 
     def _assign_floating_ips(self, tenant, server):
         public_network_id = CONF.network.public_network_id
-        floating_ip = self._create_floating_ip(
+        floating_ip = self.create_floating_ip(
             server, public_network_id,
             client=tenant.manager.network_client)
         self.floating_ips.setdefault(server['id'], floating_ip)
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index dc32edc..9a99da4 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -65,17 +65,6 @@
         got_timestamp = ssh_client.exec_command('cat /tmp/timestamp')
         self.assertEqual(self.timestamp, got_timestamp)
 
-    def _create_floating_ip(self):
-        _, floating_ip = self.floating_ips_client.create_floating_ip()
-        self.addCleanup(self.delete_wrapper,
-                        self.floating_ips_client.delete_floating_ip,
-                        floating_ip['id'])
-        return floating_ip
-
-    def _set_floating_ip_to_server(self, server, floating_ip):
-        self.floating_ips_client.associate_floating_ip_to_server(
-            floating_ip['ip'], server['id'])
-
     @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
                           'Snapshotting is not available.')
     @test.services('compute', 'network', 'image')
@@ -87,8 +76,7 @@
         # boot a instance and create a timestamp file in it
         server = self._boot_image(CONF.compute.image_ref)
         if CONF.compute.use_floatingip_for_ssh:
-            fip_for_server = self._create_floating_ip()
-            self._set_floating_ip_to_server(server, fip_for_server)
+            fip_for_server = self.create_floating_ip(server)
             self._write_timestamp(fip_for_server['ip'])
         else:
             self._write_timestamp(server)
@@ -101,9 +89,7 @@
 
         # check the existence of the timestamp file in the second instance
         if CONF.compute.use_floatingip_for_ssh:
-            fip_for_snapshot = self._create_floating_ip()
-            self._set_floating_ip_to_server(server_from_snapshot,
-                                            fip_for_snapshot)
+            fip_for_snapshot = self.create_floating_ip(server_from_snapshot)
             self._check_timestamp(fip_for_snapshot['ip'])
         else:
             self._check_timestamp(server_from_snapshot)
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index e30c824..ee2c737 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -71,17 +71,6 @@
     def _add_keypair(self):
         self.keypair = self.create_keypair()
 
-    def _create_floating_ip(self):
-        _, floating_ip = self.floating_ips_client.create_floating_ip()
-        self.addCleanup(self.delete_wrapper,
-                        self.floating_ips_client.delete_floating_ip,
-                        floating_ip['id'])
-        return floating_ip
-
-    def _add_floating_ip(self, server, floating_ip):
-        self.floating_ips_client.associate_floating_ip_to_server(
-            floating_ip['ip'], server['id'])
-
     def _ssh_to_server(self, server_or_ip):
         return self.get_remote_client(server_or_ip)
 
@@ -163,8 +152,7 @@
 
         # create and add floating IP to server1
         if CONF.compute.use_floatingip_for_ssh:
-            floating_ip_for_server = self._create_floating_ip()
-            self._add_floating_ip(server, floating_ip_for_server)
+            floating_ip_for_server = self.create_floating_ip(server)
             ip_for_server = floating_ip_for_server['ip']
         else:
             ip_for_server = server
@@ -189,9 +177,8 @@
 
         # create and add floating IP to server_from_snapshot
         if CONF.compute.use_floatingip_for_ssh:
-            floating_ip_for_snapshot = self._create_floating_ip()
-            self._add_floating_ip(server_from_snapshot,
-                                  floating_ip_for_snapshot)
+            floating_ip_for_snapshot = self.create_floating_ip(
+                server_from_snapshot)
             ip_for_snapshot = floating_ip_for_snapshot['ip']
         else:
             ip_for_snapshot = server_from_snapshot
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 62876c4..dd115e7 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -136,6 +136,7 @@
         actual = self._get_content(ssh_client)
         self.assertEqual(expected, actual)
 
+    @test.skip_because(bug='1373513')
     @test.services('compute', 'volume', 'image')
     def test_volume_boot_pattern(self):
         keypair = self.create_keypair()
diff --git a/tox.ini b/tox.ini
index f75e868..edfee15 100644
--- a/tox.ini
+++ b/tox.ini
@@ -17,7 +17,9 @@
 whitelist_externals = *
 deps = -r{toxinidir}/requirements.txt
        -r{toxinidir}/test-requirements.txt
-commands = bash tools/pretty_tox.sh '{posargs}'
+commands =
+         find . -type f -name "*.pyc" -delete
+         bash tools/pretty_tox.sh '{posargs}'
 
 [testenv:genconfig]
 commands = oslo-config-generator --config-file tools/config/config-generator.tempest.conf
@@ -33,6 +35,7 @@
          OS_TEST_TIMEOUT=1200
 deps = {[tempestenv]deps}
 commands =
+  find . -type f -name "*.pyc" -delete
   bash tools/pretty_tox.sh '{posargs}'
 
 [testenv:full]
@@ -42,6 +45,7 @@
 # The regex below is used to select which tests to run and exclude the slow tag:
 # See the testrepostiory bug: https://bugs.launchpad.net/testrepository/+bug/1208610
 commands =
+  find . -type f -name "*.pyc" -delete
   bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
 
 [testenv:full-serial]
@@ -51,6 +55,7 @@
 # The regex below is used to select which tests to run and exclude the slow tag:
 # See the testrepostiory bug: https://bugs.launchpad.net/testrepository/+bug/1208610
 commands =
+  find . -type f -name "*.pyc" -delete
   bash tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
 
 [testenv:heat-slow]
@@ -60,6 +65,7 @@
 deps = {[tempestenv]deps}
 # The regex below is used to select heat api/scenario tests tagged as slow.
 commands =
+  find . -type f -name "*.pyc" -delete
   bash tools/pretty_tox.sh '(?=.*\[.*\bslow\b.*\])(^tempest\.(api|scenario)\.orchestration) {posargs}'
 
 [testenv:large-ops]
@@ -67,6 +73,7 @@
 setenv = {[tempestenv]setenv}
 deps = {[tempestenv]deps}
 commands =
+  find . -type f -name "*.pyc" -delete
   python setup.py testr --slowest --testr-args='tempest.scenario.test_large_ops {posargs}'
 
 [testenv:smoke]
@@ -74,6 +81,7 @@
 setenv = {[tempestenv]setenv}
 deps = {[tempestenv]deps}
 commands =
+  find . -type f -name "*.pyc" -delete
    bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
 
 [testenv:smoke-serial]
@@ -84,6 +92,7 @@
 # https://bugs.launchpad.net/tempest/+bug/1216076 so the neutron smoke
 # job would fail if we moved it to parallel.
 commands =
+  find . -type f -name "*.pyc" -delete
    bash tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
 
 [testenv:stress]