Merge "Functional tests for create share from snapshot different pools/azs"
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index aa97335..a6523e5 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -1,17 +1,35 @@
-If you would like to contribute to the development of OpenStack, you must
-follow the steps in this page:
+Contributor Guidelines
+======================
 
-   https://docs.openstack.org/infra/manual/developers.html
+The source repository for this project can be found at:
 
-If you already have a good understanding of how the system works and your
-OpenStack accounts are set up, you can skip to the development workflow
-section of this documentation to learn how changes to OpenStack should be
-submitted for review via the Gerrit tool:
+   https://opendev.org/openstack/manila-tempest-plugin
 
-   https://docs.openstack.org/infra/manual/developers.html#development-workflow
+Pull requests submitted through GitHub are not monitored.
 
-Pull requests submitted through GitHub will be ignored.
+To start contributing to OpenStack, follow the steps in the contribution guide
+to set up and use Gerrit:
 
-Bugs should be filed on Launchpad, not GitHub:
+   https://docs.openstack.org/contributors/code-and-documentation/quick-start.html
 
-   https://bugs.launchpad.net/manila-tempest-plugin
+Bugs should be filed against the Manila project on Launchpad:
+
+   https://bugs.launchpad.net/manila
+
+For more specific information about contributing to this repository, see the
+manila contributor guide. That guide has information regarding the team's task
+trackers, communicating with other project developers and contacting the
+core team. It also has plenty of tips and tricks to get started with a
+development environment to contribute to, and test changes within this
+tempest plugin repository:
+
+   https://docs.openstack.org/manila/latest/contributor/contributing.html
+
+Information regarding running tests from this repository is here:
+
+   https://docs.openstack.org/manila/latest/contributor/tempest_tests.html
+
+This project makes extensive use of tempest-lib, a stable interface to the
+Tempest project. You can read more about it here:
+
+   https://docs.openstack.org/tempest/latest/library.html
diff --git a/HACKING.rst b/HACKING.rst
index cd3c49c..da529fb 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -1,4 +1,6 @@
-openstack Style Commandments
-===============================================
+OpenStack Style Commandments
+============================
 
-Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/
+Read the OpenStack Style Commandments here:
+
+    https://docs.openstack.org/hacking/latest/
diff --git a/README.rst b/README.rst
index de0ec32..cf2f7fb 100644
--- a/README.rst
+++ b/README.rst
@@ -2,9 +2,10 @@
 manila-tempest-plugin
 =====================
 
-Tempest plugin manila-tempest-plugin
+This repository contains a `Tempest`_ `test plugin`_ to verify the
+functionality of the `OpenStack Shared File System Service`_, Manila.
 
-Tempest plugin to test Manila's features
+See `contributor information`_ to learn more.
 
 * Free software: Apache license
 * Documentation: https://docs.openstack.org/manila/latest/
@@ -12,7 +13,7 @@
 * Source: https://opendev.org/openstack/manila-tempest-plugin
 * Bugs: https://bugs.launchpad.net/manila
 
-Features
---------
-
-* TODO
+.. _Tempest: https://docs.openstack.org/tempest
+.. _test plugin: https://docs.openstack.org/tempest/latest/plugin.html
+.. _contributor information: CONTRIBUTING.rst
+.. _OpenStack Shared File System Service: https://docs.openstack.org/manila
\ No newline at end of file
diff --git a/manila_tempest_tests/README.rst b/manila_tempest_tests/README.rst
deleted file mode 100644
index 7569d96..0000000
--- a/manila_tempest_tests/README.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-====================
-Tempest Integration
-====================
-
-This directory contains Tempest tests to cover Manila project.
-
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index b5db8b3..2ed43c7 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -711,7 +711,7 @@
                  service['binary'] == 'manila-share' and
                  service['state'] == 'up' and
                  re.search(backends, service['host'])]
-        return zones
+        return list(set(zones))
 
     @classmethod
     def get_pools_matching_share_type(cls, share_type, client=None):
diff --git a/manila_tempest_tests/tests/scenario/manager.py b/manila_tempest_tests/tests/scenario/manager.py
index 6e8a2f6..dede47a 100644
--- a/manila_tempest_tests/tests/scenario/manager.py
+++ b/manila_tempest_tests/tests/scenario/manager.py
@@ -681,28 +681,36 @@
         return subnet
 
     def _get_server_port_id_and_ip4(self, server, ip_addr=None):
-        ports = self.os_admin.ports_client.list_ports(
-            device_id=server['id'], fixed_ip=ip_addr)['ports']
+        if ip_addr:
+            ports = self.os_admin.ports_client.list_ports(
+                device_id=server['id'],
+                fixed_ips='ip_address=%s' % ip_addr)['ports']
+        else:
+            ports = self.os_admin.ports_client.list_ports(
+                device_id=server['id'])['ports']
         # A port can have more than one IP address in some cases.
         # If the network is dual-stack (IPv4 + IPv6), this port is associated
         # with 2 subnets
-        p_status = ['ACTIVE']
-        # NOTE(vsaienko) With Ironic, instances live on separate hardware
-        # servers. Neutron does not bind ports for Ironic instances, as a
-        # result the port remains in the DOWN state.
-        # TODO(vsaienko) remove once bug: #1599836 is resolved.
-        if getattr(CONF.service_available, 'ironic', False):
-            p_status.append('DOWN')
+
+        def _is_active(port):
+            # NOTE(vsaienko) With Ironic, instances live on separate hardware
+            # servers. Neutron does not bind ports for Ironic instances, as a
+            # result the port remains in the DOWN state. This has been fixed
+            # with the introduction of the networking-baremetal plugin but
+            # it's not mandatory (and is not used on all stable branches).
+            return (port['status'] == 'ACTIVE' or
+                    port.get('binding:vnic_type') == 'baremetal')
+
         port_map = [(p["id"], fxip["ip_address"])
                     for p in ports
                     for fxip in p["fixed_ips"]
-                    if netutils.is_valid_ipv4(fxip["ip_address"])
-                    and p['status'] in p_status]
+                    if (netutils.is_valid_ipv4(fxip["ip_address"]) and
+                        _is_active(p))]
         inactive = [p for p in ports if p['status'] != 'ACTIVE']
         if inactive:
             LOG.warning("Instance has ports that are not ACTIVE: %s", inactive)
 
-        self.assertNotEqual(0, len(port_map),
+        self.assertNotEmpty(port_map,
                             "No IPv4 addresses found in: %s" % ports)
         self.assertEqual(len(port_map), 1,
                          "Found multiple IPv4 addresses: %s. "
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index 1ae1b4a..eaffa35 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -26,7 +26,6 @@
 from tempest.common import waiters
 from tempest import config
 from tempest.lib.common.utils import data_utils
-from tempest.lib.common.utils import test_utils
 from tempest.lib import exceptions
 
 from tempfile import mkstemp
@@ -162,10 +161,9 @@
             server_ip = self._get_ipv6_server_ip(instance)
         if not server_ip:
             # Obtain a floating IP
-            floating_ip = (
-                self.compute_floating_ips_client.create_floating_ip()
-                ['floating_ip'])
+            floating_ip = self.create_floating_ip(instance)
             self.floating_ips[instance['id']] = floating_ip
+            server_ip = floating_ip['floating_ip_address']
 
             if self.storage_network:
                 storage_net_nic = instance['addresses'].get(
@@ -174,15 +172,10 @@
                     self.storage_network_nic_ips[instance['id']] = (
                         storage_net_nic[0]['addr']
                     )
-
-            self.addCleanup(
-                test_utils.call_and_ignore_notfound_exc,
-                self.compute_floating_ips_client.delete_floating_ip,
-                floating_ip['id'])
             # Attach a floating IP
             self.compute_floating_ips_client.associate_floating_ip_to_server(
-                floating_ip['ip'], instance['id'])
-            server_ip = floating_ip['ip']
+                floating_ip['floating_ip_address'], instance['id'])
+
         self.assertIsNotNone(server_ip)
         # Check ssh
         remote_client = self.get_remote_client(
@@ -337,10 +330,12 @@
             if self.ipv6_enabled and not self.storage_network:
                 server_ip = self._get_ipv6_server_ip(instance)
             else:
-                server_ip = (CONF.share.override_ip_for_nfs_access or
-                             self.storage_network_nic_ips.get(
-                                 instance['id']) or
-                             self.floating_ips[instance['id']]['ip'])
+                server_ip = (
+                    CONF.share.override_ip_for_nfs_access
+                    or self.storage_network_nic_ips.get(instance['id'])
+                    or self.floating_ips[instance['id']]['floating_ip_address']
+                )
+
             self.assertIsNotNone(server_ip)
             return self.allow_access_ip(
                 share['id'], ip=server_ip,