Use allocation pools to prevent IP address conflicts

- test_tagged_boot_devices
- test_port_list_filter_by_ip_substr

Related-Prod: PRODX-46121
Change-Id: Idea42c9da91b021629784911b19a4a58b943f485
diff --git a/tempest/api/compute/servers/test_device_tagging.py b/tempest/api/compute/servers/test_device_tagging.py
index c7ff4ba..adc1b0b 100644
--- a/tempest/api/compute/servers/test_device_tagging.py
+++ b/tempest/api/compute/servers/test_device_tagging.py
@@ -193,6 +193,13 @@
         subnet2 = self.subnets_client.create_subnet(
             network_id=net2['id'],
             cidr='10.2.2.0/24',
+            # Add allocation pool to prevent IP address conflicts.
+            allocation_pools=[
+                {
+                    "start": "10.2.2.10",
+                    "end": "10.2.2.90"
+                }
+            ],
             ip_version=4)['subnet']
         self.addCleanup(self.subnets_client.delete_subnet, subnet2['id'])
 
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index dc5504d..d66c8e9 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -230,7 +230,13 @@
         """Test listing ports filtered by part of ip address string"""
         # Create network and subnet
         network = self._create_network()
-        subnet = self._create_subnet(network)
+        address = self.cidr
+        # Add allocation pool to prevent IP address conflicts.
+        pool_start = ipaddress.ip_address(str(address[2]))
+        pool_end = ipaddress.ip_address(str(address[8]))
+        allocation_pools = {'allocation_pools': [{'start': str(pool_start),
+                                                  'end': str(pool_end)}]}
+        subnet = self._create_subnet(network, **allocation_pools)
         # Get two IP addresses
         ip_address_1 = None
         ip_address_2 = None
@@ -238,9 +244,7 @@
         for ip in ip_network:
             if ip == ip_network.network_address:
                 continue
-            if self.ports_client.list_ports(
-                network_id=network['id'],
-                fixed_ips='ip_address=' + str(ip))['ports']:
+            if pool_start <= ip <= pool_end:
                 continue
             if ip_address_1 is None:
                 ip_address_1 = str(ip)