Remove base class complex and confusing variable

neutron base class have base create method like create_network,
create_routers, create_port and create_subnets etc and these
base method append the created resources in base class variable
like cls.ports, cls.sunets etc.

These variable were initially  created and used while cleanup the
created resources in corresponding delete methods. But now those
delete methods has been switched to use addClassResourceCleanup.

Few test class still use them for list resources etc which is
hard to find that these were from base class and value is being
populated from derived class test cases.

This commit removes the base class variables and define those
in derived test class wherever they are being used.

Change-Id: I24fdfbdb8a2d7bcb4ccab8e57f1967b13f35f184
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index 8315c5d..4631ea9 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -63,7 +63,6 @@
     def test_add_remove_network_from_dhcp_agent(self):
         # The agent is now bound to the network, we can free the port
         self.ports_client.delete_port(self.port['id'])
-        self.ports.remove(self.port)
         agent = dict()
         agent['agent_type'] = None
         body = self.admin_agents_client.list_agents()
diff --git a/tempest/api/network/admin/test_routers.py b/tempest/api/network/admin/test_routers.py
index 8cdb41e..a7355f3 100644
--- a/tempest/api/network/admin/test_routers.py
+++ b/tempest/api/network/admin/test_routers.py
@@ -32,7 +32,6 @@
 
     def _cleanup_router(self, router):
         self.delete_router(router)
-        self.routers.remove(router)
 
     def _create_router(self, name=None, admin_state_up=False,
                        external_network_id=None, enable_snat=None):
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 8670165..9032fdc 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -88,9 +88,6 @@
     @classmethod
     def resource_setup(cls):
         super(BaseNetworkTest, cls).resource_setup()
-        cls.subnets = []
-        cls.ports = []
-        cls.routers = []
         cls.ethertype = "IPv" + str(cls._ip_version)
         if cls._ip_version == 4:
             cls.cidr = netaddr.IPNetwork(CONF.network.project_network_cidr)
@@ -155,7 +152,6 @@
         cls.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc,
                                     cls.subnets_client.delete_subnet,
                                     subnet['id'])
-        cls.subnets.append(subnet)
         return subnet
 
     @classmethod
@@ -166,7 +162,6 @@
         port = body['port']
         cls.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc,
                                     cls.ports_client.delete_port, port['id'])
-        cls.ports.append(port)
         return port
 
     @classmethod
@@ -194,7 +189,6 @@
         router = body['router']
         cls.addClassResourceCleanup(test_utils.call_and_ignore_notfound_exc,
                                     cls.delete_router, router)
-        cls.routers.append(router)
         return router
 
     @classmethod
diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py
index 9d6d700..0730d58 100644
--- a/tempest/api/network/test_dhcp_ipv6.py
+++ b/tempest/api/network/test_dhcp_ipv6.py
@@ -56,6 +56,9 @@
     def resource_setup(cls):
         super(NetworksTestDHCPv6, cls).resource_setup()
         cls.network = cls.create_network()
+        cls.ports = []
+        cls.subnets = []
+        cls.routers = []
 
     def _remove_from_list_by_index(self, things_list, elem):
         for index, i in enumerate(things_list):
@@ -90,8 +93,10 @@
 
     def _get_ips_from_subnet(self, **kwargs):
         subnet = self.create_subnet(self.network, **kwargs)
+        self.subnets.append(subnet)
         port_mac = data_utils.rand_mac_address()
         port = self.create_port(self.network, mac_address=port_mac)
+        self.ports.append(port)
         real_ip = next(iter(port['fixed_ips']), None)['ip_address']
         eui_ip = str(netutils.get_ipv6_addr_by_EUI64(
             subnet['cidr'], port_mac))
@@ -182,16 +187,21 @@
                 kwargs_dhcp = {'ipv6_address_mode': 'dhcpv6-stateful'}
                 if order == "slaac_first":
                     subnet_slaac = self.create_subnet(self.network, **kwargs)
+                    self.subnets.append(subnet_slaac)
                     subnet_dhcp = self.create_subnet(
                         self.network, **kwargs_dhcp)
+                    self.subnets.append(subnet_dhcp)
                 else:
                     subnet_dhcp = self.create_subnet(
                         self.network, **kwargs_dhcp)
+                    self.subnets.append(subnet_dhcp)
                     subnet_slaac = self.create_subnet(self.network, **kwargs)
+                    self.subnets.append(subnet_slaac)
                 port_mac = data_utils.rand_mac_address()
                 eui_ip = str(netutils.get_ipv6_addr_by_EUI64(
                     subnet_slaac['cidr'], port_mac))
                 port = self.create_port(self.network, mac_address=port_mac)
+                self.ports.append(port)
                 real_ips = dict([(k['subnet_id'], k['ip_address'])
                                  for k in port['fixed_ips']])
                 real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
@@ -228,16 +238,21 @@
                           'ipv6_address_mode': add_mode}
                 if order == "slaac_first":
                     subnet_slaac = self.create_subnet(self.network, **kwargs)
+                    self.subnets.append(subnet_slaac)
                     subnet_dhcp = self.create_subnet(
                         self.network, ip_version=4)
+                    self.subnets.append(subnet_dhcp)
                 else:
                     subnet_dhcp = self.create_subnet(
                         self.network, ip_version=4)
+                    self.subnets.append(subnet_dhcp)
                     subnet_slaac = self.create_subnet(self.network, **kwargs)
+                    self.subnets.append(subnet_slaac)
                 port_mac = data_utils.rand_mac_address()
                 eui_ip = str(netutils.get_ipv6_addr_by_EUI64(
                     subnet_slaac['cidr'], port_mac))
                 port = self.create_port(self.network, mac_address=port_mac)
+                self.ports.append(port)
                 real_ips = dict([(k['subnet_id'], k['ip_address'])
                                  for k in port['fixed_ips']])
                 real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
@@ -267,7 +282,9 @@
                       'ipv6_address_mode': add_mode}
             kwargs = dict((k, v) for k, v in kwargs.items() if v)
             subnet = self.create_subnet(self.network, **kwargs)
+            self.subnets.append(subnet)
             port = self.create_port(self.network)
+            self.ports.append(port)
             port_ip = next(iter(port['fixed_ips']), None)['ip_address']
             self._clean_network()
             msg = ('Real IP address is {0} and it is NOT on '
@@ -289,6 +306,7 @@
                       'ipv6_address_mode': add_mode}
             kwargs = dict((k, v) for k, v in kwargs.items() if v)
             subnet = self.create_subnet(self.network, **kwargs)
+            self.subnets.append(subnet)
             ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
                                        subnet["allocation_pools"][0]["end"])
             ip = netaddr.IPAddress(random.randrange(ip_range.first,
@@ -296,6 +314,7 @@
             port = self.create_port(self.network,
                                     fixed_ips=[{'subnet_id': subnet['id'],
                                                 'ip_address': ip}])
+            self.ports.append(port)
             port_ip = next(iter(port['fixed_ips']), None)['ip_address']
             self._clean_network()
             self.assertEqual(port_ip, ip,
@@ -310,6 +329,7 @@
         kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
                   'ipv6_address_mode': 'dhcpv6-stateful'}
         subnet = self.create_subnet(self.network, **kwargs)
+        self.subnets.append(subnet)
         ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
                                    subnet["allocation_pools"][0]["end"])
         ip = netaddr.IPAddress(random.randrange(
@@ -327,14 +347,16 @@
         kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
                   'ipv6_address_mode': 'dhcpv6-stateful'}
         subnet = self.create_subnet(self.network, **kwargs)
+        self.subnets.append(subnet)
         ip_range = netaddr.IPRange(subnet["allocation_pools"][0]["start"],
                                    subnet["allocation_pools"][0]["end"])
         ip = netaddr.IPAddress(random.randrange(
             ip_range.first, ip_range.last)).format()
-        self.create_port(self.network,
-                         fixed_ips=[
-                             {'subnet_id': subnet['id'],
-                              'ip_address': ip}])
+        port = self.create_port(self.network,
+                                fixed_ips=[
+                                    {'subnet_id': subnet['id'],
+                                     'ip_address': ip}])
+        self.ports.append(port)
         self.assertRaisesRegex(lib_exc.Conflict,
                                "IpAddressAlreadyAllocated|IpAddressInUse",
                                self.create_port,
@@ -344,7 +366,9 @@
 
     def _create_subnet_router(self, kwargs):
         subnet = self.create_subnet(self.network, **kwargs)
+        self.subnets.append(subnet)
         router = self.create_router(admin_state_up=True)
+        self.routers.append(router)
         port = self.create_router_interface(router['id'],
                                             subnet['id'])
         body = self.ports_client.show_port(port['port_id'])
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index b4bb88e..504bfa8 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -64,8 +64,10 @@
         cls.router = cls.create_router(external_network_id=cls.ext_net_id)
         cls.create_router_interface(cls.router['id'], cls.subnet['id'])
         # Create two ports one each for Creation and Updating of floatingIP
+        cls.ports = []
         for i in range(2):
-            cls.create_port(cls.network)
+            port = cls.create_port(cls.network)
+            cls.ports.append(port)
 
     @decorators.attr(type='smoke')
     @decorators.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e8718')
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 3ff12e4..8b03631 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -29,7 +29,6 @@
 
     def _cleanup_router(self, router):
         self.delete_router(router)
-        self.routers.remove(router)
 
     def _create_router(self, name=None, admin_state_up=False,
                        external_network_id=None, enable_snat=None):