diff --git a/tempest/api/network/admin/test_lbaas_agent_scheduler.py b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
deleted file mode 100644
index 7234348..0000000
--- a/tempest/api/network/admin/test_lbaas_agent_scheduler.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-from tempest_lib.common.utils import data_utils
-
-from tempest.api.network import base
-from tempest import test
-
-
-class LBaaSAgentSchedulerTestJSON(base.BaseAdminNetworkTest):
-    """
-    Tests the following operations in the Neutron API using the REST client for
-    Neutron:
-
-        List pools the given LBaaS agent is hosting.
-        Show a LBaaS agent hosting the given pool.
-
-    v2.0 of the Neutron API is assumed. It is also assumed that the following
-    options are defined in the [networki-feature-enabled] section of
-    etc/tempest.conf:
-
-        api_extensions
-    """
-
-    @classmethod
-    def skip_checks(cls):
-        super(LBaaSAgentSchedulerTestJSON, cls).skip_checks()
-        if not test.is_extension_enabled('lbaas_agent_scheduler', 'network'):
-            msg = "LBaaS Agent Scheduler Extension not enabled."
-            raise cls.skipException(msg)
-
-    @classmethod
-    def resource_setup(cls):
-        super(LBaaSAgentSchedulerTestJSON, cls).resource_setup()
-        cls.network = cls.create_network()
-        cls.subnet = cls.create_subnet(cls.network)
-        pool_name = data_utils.rand_name('pool-')
-        cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN",
-                                   "HTTP", cls.subnet)
-
-    @test.idempotent_id('e5ea8b15-4f44-4350-963c-e0fcb533ee79')
-    def test_list_pools_on_lbaas_agent(self):
-        found = False
-        body = self.admin_client.list_agents(
-            agent_type="Loadbalancer agent")
-        agents = body['agents']
-        for a in agents:
-            msg = 'Load Balancer agent expected'
-            self.assertEqual(a['agent_type'], 'Loadbalancer agent', msg)
-            body = (
-                self.admin_client.list_pools_hosted_by_one_lbaas_agent(
-                    a['id']))
-            pools = body['pools']
-            if self.pool['id'] in [p['id'] for p in pools]:
-                found = True
-        msg = 'Unable to find Load Balancer agent hosting pool'
-        self.assertTrue(found, msg)
-
-    @test.idempotent_id('e2745593-fd79-4b98-a262-575fd7865796')
-    def test_show_lbaas_agent_hosting_pool(self):
-        body = self.admin_client.show_lbaas_agent_hosting_pool(
-            self.pool['id'])
-        self.assertEqual('Loadbalancer agent', body['agent']['agent_type'])
diff --git a/tempest/api/network/admin/test_load_balancer_admin_actions.py b/tempest/api/network/admin/test_load_balancer_admin_actions.py
deleted file mode 100644
index 24a04be..0000000
--- a/tempest/api/network/admin/test_load_balancer_admin_actions.py
+++ /dev/null
@@ -1,118 +0,0 @@
-# Copyright 2014 Mirantis.inc
-# All Rights Reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-from tempest_lib.common.utils import data_utils
-
-from tempest.api.network import base
-from tempest import test
-
-
-class LoadBalancerAdminTestJSON(base.BaseAdminNetworkTest):
-    """
-    Test admin actions for load balancer.
-
-    Create VIP for another tenant
-    Create health monitor for another tenant
-    """
-
-    force_tenant_isolation = True
-
-    @classmethod
-    def skip_checks(cls):
-        super(LoadBalancerAdminTestJSON, cls).skip_checks()
-        if not test.is_extension_enabled('lbaas', 'network'):
-            msg = "lbaas extension not enabled."
-            raise cls.skipException(msg)
-
-    @classmethod
-    def setup_clients(cls):
-        super(LoadBalancerAdminTestJSON, cls).setup_clients()
-        cls.client = cls.manager.network_client
-
-    @classmethod
-    def resource_setup(cls):
-        super(LoadBalancerAdminTestJSON, cls).resource_setup()
-        cls.tenant_id = cls.os.credentials.tenant_id
-        cls.network = cls.create_network()
-        cls.subnet = cls.create_subnet(cls.network)
-        cls.pool = cls.create_pool(data_utils.rand_name('pool-'),
-                                   "ROUND_ROBIN", "HTTP", cls.subnet)
-
-    @test.idempotent_id('6b0a20d8-4fcd-455e-b54f-ec4db5199518')
-    def test_create_vip_as_admin_for_another_tenant(self):
-        name = data_utils.rand_name('vip-')
-        body = self.admin_client.create_pool(
-            name=data_utils.rand_name('pool-'),
-            lb_method="ROUND_ROBIN",
-            protocol="HTTP",
-            subnet_id=self.subnet['id'],
-            tenant_id=self.tenant_id)
-        pool = body['pool']
-        self.addCleanup(self.admin_client.delete_pool, pool['id'])
-        body = self.admin_client.create_vip(name=name,
-                                            protocol="HTTP",
-                                            protocol_port=80,
-                                            subnet_id=self.subnet['id'],
-                                            pool_id=pool['id'],
-                                            tenant_id=self.tenant_id)
-        vip = body['vip']
-        self.addCleanup(self.admin_client.delete_vip, vip['id'])
-        self.assertIsNotNone(vip['id'])
-        self.assertEqual(self.tenant_id, vip['tenant_id'])
-        body = self.client.show_vip(vip['id'])
-        show_vip = body['vip']
-        self.assertEqual(vip['id'], show_vip['id'])
-        self.assertEqual(vip['name'], show_vip['name'])
-
-    @test.idempotent_id('74552cfc-ab78-4fb6-825b-f67bca379921')
-    def test_create_health_monitor_as_admin_for_another_tenant(self):
-        body = (
-            self.admin_client.create_health_monitor(delay=4,
-                                                    max_retries=3,
-                                                    type="TCP",
-                                                    timeout=1,
-                                                    tenant_id=self.tenant_id))
-        health_monitor = body['health_monitor']
-        self.addCleanup(self.admin_client.delete_health_monitor,
-                        health_monitor['id'])
-        self.assertIsNotNone(health_monitor['id'])
-        self.assertEqual(self.tenant_id, health_monitor['tenant_id'])
-        body = self.client.show_health_monitor(health_monitor['id'])
-        show_health_monitor = body['health_monitor']
-        self.assertEqual(health_monitor['id'], show_health_monitor['id'])
-
-    @test.idempotent_id('266a192d-3c22-46c4-a8fb-802450301e82')
-    def test_create_pool_from_admin_user_other_tenant(self):
-        body = self.admin_client.create_pool(
-            name=data_utils.rand_name('pool-'),
-            lb_method="ROUND_ROBIN",
-            protocol="HTTP",
-            subnet_id=self.subnet['id'],
-            tenant_id=self.tenant_id)
-        pool = body['pool']
-        self.addCleanup(self.admin_client.delete_pool, pool['id'])
-        self.assertIsNotNone(pool['id'])
-        self.assertEqual(self.tenant_id, pool['tenant_id'])
-
-    @test.idempotent_id('158bb272-b9ed-4cfc-803c-661dac46f783')
-    def test_create_member_from_admin_user_other_tenant(self):
-        body = self.admin_client.create_member(address="10.0.9.47",
-                                               protocol_port=80,
-                                               pool_id=self.pool['id'],
-                                               tenant_id=self.tenant_id)
-        member = body['member']
-        self.addCleanup(self.admin_client.delete_member, member['id'])
-        self.assertIsNotNone(member['id'])
-        self.assertEqual(self.tenant_id, member['tenant_id'])
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index 46d6651..f6046d3 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -90,10 +90,3 @@
     def test_quotas(self):
         new_quotas = {'network': 0, 'security_group': 0}
         self._check_quotas(new_quotas)
-
-    @test.idempotent_id('a7add2b1-691e-44d6-875f-697d9685f091')
-    @test.requires_ext(extension='lbaas', service='network')
-    def test_lbaas_quotas(self):
-        new_quotas = {'vip': 1, 'pool': 2,
-                      'member': 3, 'health_monitor': 4}
-        self._check_quotas(new_quotas)
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index f864f95..bbefc25 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -82,64 +82,19 @@
         cls.subnets = []
         cls.ports = []
         cls.routers = []
-        cls.pools = []
-        cls.vips = []
-        cls.members = []
-        cls.health_monitors = []
-        cls.vpnservices = []
-        cls.ikepolicies = []
         cls.floating_ips = []
         cls.metering_labels = []
         cls.metering_label_rules = []
-        cls.fw_rules = []
-        cls.fw_policies = []
-        cls.ipsecpolicies = []
         cls.ethertype = "IPv" + str(cls._ip_version)
 
     @classmethod
     def resource_cleanup(cls):
         if CONF.service_available.neutron:
-            # Clean up ipsec policies
-            for ipsecpolicy in cls.ipsecpolicies:
-                cls._try_delete_resource(cls.client.delete_ipsecpolicy,
-                                         ipsecpolicy['id'])
-            # Clean up firewall policies
-            for fw_policy in cls.fw_policies:
-                cls._try_delete_resource(cls.client.delete_firewall_policy,
-                                         fw_policy['id'])
-            # Clean up firewall rules
-            for fw_rule in cls.fw_rules:
-                cls._try_delete_resource(cls.client.delete_firewall_rule,
-                                         fw_rule['id'])
-            # Clean up ike policies
-            for ikepolicy in cls.ikepolicies:
-                cls._try_delete_resource(cls.client.delete_ikepolicy,
-                                         ikepolicy['id'])
-            # Clean up vpn services
-            for vpnservice in cls.vpnservices:
-                cls._try_delete_resource(cls.client.delete_vpnservice,
-                                         vpnservice['id'])
             # Clean up floating IPs
             for floating_ip in cls.floating_ips:
                 cls._try_delete_resource(cls.client.delete_floatingip,
                                          floating_ip['id'])
 
-            # Clean up health monitors
-            for health_monitor in cls.health_monitors:
-                cls._try_delete_resource(cls.client.delete_health_monitor,
-                                         health_monitor['id'])
-            # Clean up members
-            for member in cls.members:
-                cls._try_delete_resource(cls.client.delete_member,
-                                         member['id'])
-            # Clean up vips
-            for vip in cls.vips:
-                cls._try_delete_resource(cls.client.delete_vip,
-                                         vip['id'])
-            # Clean up pools
-            for pool in cls.pools:
-                cls._try_delete_resource(cls.client.delete_pool,
-                                         pool['id'])
             # Clean up metering label rules
             for metering_label_rule in cls.metering_label_rules:
                 cls._try_delete_resource(
@@ -284,78 +239,6 @@
         return fip
 
     @classmethod
-    def create_pool(cls, name, lb_method, protocol, subnet):
-        """Wrapper utility that returns a test pool."""
-        body = cls.client.create_pool(
-            name=name,
-            lb_method=lb_method,
-            protocol=protocol,
-            subnet_id=subnet['id'])
-        pool = body['pool']
-        cls.pools.append(pool)
-        return pool
-
-    @classmethod
-    def update_pool(cls, name):
-        """Wrapper utility that returns a test pool."""
-        body = cls.client.update_pool(name=name)
-        pool = body['pool']
-        return pool
-
-    @classmethod
-    def create_vip(cls, name, protocol, protocol_port, subnet, pool):
-        """Wrapper utility that returns a test vip."""
-        body = cls.client.create_vip(name=name,
-                                     protocol=protocol,
-                                     protocol_port=protocol_port,
-                                     subnet_id=subnet['id'],
-                                     pool_id=pool['id'])
-        vip = body['vip']
-        cls.vips.append(vip)
-        return vip
-
-    @classmethod
-    def update_vip(cls, name):
-        body = cls.client.update_vip(name=name)
-        vip = body['vip']
-        return vip
-
-    @classmethod
-    def create_member(cls, protocol_port, pool, ip_version=None):
-        """Wrapper utility that returns a test member."""
-        ip_version = ip_version if ip_version is not None else cls._ip_version
-        member_address = "fd00::abcd" if ip_version == 6 else "10.0.9.46"
-        body = cls.client.create_member(address=member_address,
-                                        protocol_port=protocol_port,
-                                        pool_id=pool['id'])
-        member = body['member']
-        cls.members.append(member)
-        return member
-
-    @classmethod
-    def update_member(cls, admin_state_up):
-        body = cls.client.update_member(admin_state_up=admin_state_up)
-        member = body['member']
-        return member
-
-    @classmethod
-    def create_health_monitor(cls, delay, max_retries, Type, timeout):
-        """Wrapper utility that returns a test health monitor."""
-        body = cls.client.create_health_monitor(delay=delay,
-                                                max_retries=max_retries,
-                                                type=Type,
-                                                timeout=timeout)
-        health_monitor = body['health_monitor']
-        cls.health_monitors.append(health_monitor)
-        return health_monitor
-
-    @classmethod
-    def update_health_monitor(cls, admin_state_up):
-        body = cls.client.update_vip(admin_state_up=admin_state_up)
-        health_monitor = body['health_monitor']
-        return health_monitor
-
-    @classmethod
     def create_router_interface(cls, router_id, subnet_id):
         """Wrapper utility that returns a router interface."""
         interface = cls.client.add_router_interface_with_subnet_id(
@@ -363,44 +246,6 @@
         return interface
 
     @classmethod
-    def create_vpnservice(cls, subnet_id, router_id):
-        """Wrapper utility that returns a test vpn service."""
-        body = cls.client.create_vpnservice(
-            subnet_id=subnet_id, router_id=router_id, admin_state_up=True,
-            name=data_utils.rand_name("vpnservice-"))
-        vpnservice = body['vpnservice']
-        cls.vpnservices.append(vpnservice)
-        return vpnservice
-
-    @classmethod
-    def create_ikepolicy(cls, name):
-        """Wrapper utility that returns a test ike policy."""
-        body = cls.client.create_ikepolicy(name=name)
-        ikepolicy = body['ikepolicy']
-        cls.ikepolicies.append(ikepolicy)
-        return ikepolicy
-
-    @classmethod
-    def create_firewall_rule(cls, action, protocol):
-        """Wrapper utility that returns a test firewall rule."""
-        body = cls.client.create_firewall_rule(
-            name=data_utils.rand_name("fw-rule"),
-            action=action,
-            protocol=protocol)
-        fw_rule = body['firewall_rule']
-        cls.fw_rules.append(fw_rule)
-        return fw_rule
-
-    @classmethod
-    def create_firewall_policy(cls):
-        """Wrapper utility that returns a test firewall policy."""
-        body = cls.client.create_firewall_policy(
-            name=data_utils.rand_name("fw-policy"))
-        fw_policy = body['firewall_policy']
-        cls.fw_policies.append(fw_policy)
-        return fw_policy
-
-    @classmethod
     def delete_router(cls, router):
         body = cls.client.list_router_interfaces(router['id'])
         interfaces = body['ports']
@@ -412,14 +257,6 @@
                 pass
         cls.client.delete_router(router['id'])
 
-    @classmethod
-    def create_ipsecpolicy(cls, name):
-        """Wrapper utility that returns a test ipsec policy."""
-        body = cls.client.create_ipsecpolicy(name=name)
-        ipsecpolicy = body['ipsecpolicy']
-        cls.ipsecpolicies.append(ipsecpolicy)
-        return ipsecpolicy
-
 
 class BaseAdminNetworkTest(BaseNetworkTest):
 
diff --git a/tempest/api/network/test_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
deleted file mode 100644
index 651b4ab..0000000
--- a/tempest/api/network/test_fwaas_extensions.py
+++ /dev/null
@@ -1,333 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import six
-from tempest_lib.common.utils import data_utils
-from tempest_lib import exceptions as lib_exc
-
-from tempest.api.network import base
-from tempest import config
-from tempest import exceptions
-from tempest import test
-
-CONF = config.CONF
-
-
-class FWaaSExtensionTestJSON(base.BaseNetworkTest):
-    """
-    Tests the following operations in the Neutron API using the REST client for
-    Neutron:
-
-        List firewall rules
-        Create firewall rule
-        Update firewall rule
-        Delete firewall rule
-        Show firewall rule
-        List firewall policies
-        Create firewall policy
-        Update firewall policy
-        Insert firewall rule to policy
-        Remove firewall rule from policy
-        Insert firewall rule after/before rule in policy
-        Update firewall policy audited attribute
-        Delete firewall policy
-        Show firewall policy
-        List firewall
-        Create firewall
-        Update firewall
-        Delete firewall
-        Show firewall
-    """
-
-    @classmethod
-    def skip_checks(cls):
-        super(FWaaSExtensionTestJSON, cls).skip_checks()
-        if not test.is_extension_enabled('fwaas', 'network'):
-            msg = "FWaaS Extension not enabled."
-            raise cls.skipException(msg)
-
-    @classmethod
-    def resource_setup(cls):
-        super(FWaaSExtensionTestJSON, cls).resource_setup()
-        cls.fw_rule = cls.create_firewall_rule("allow", "tcp")
-        cls.fw_policy = cls.create_firewall_policy()
-
-    def _try_delete_policy(self, policy_id):
-        # delete policy, if it exists
-        try:
-            self.client.delete_firewall_policy(policy_id)
-        # if policy is not found, this means it was deleted in the test
-        except lib_exc.NotFound:
-            pass
-
-    def _try_delete_rule(self, rule_id):
-        # delete rule, if it exists
-        try:
-            self.client.delete_firewall_rule(rule_id)
-        # if rule is not found, this means it was deleted in the test
-        except lib_exc.NotFound:
-            pass
-
-    def _try_delete_firewall(self, fw_id):
-        # delete firewall, if it exists
-        try:
-            self.client.delete_firewall(fw_id)
-        # if firewall is not found, this means it was deleted in the test
-        except lib_exc.NotFound:
-            pass
-
-        self.client.wait_for_resource_deletion('firewall', fw_id)
-
-    def _wait_until_ready(self, fw_id):
-        target_states = ('ACTIVE', 'CREATED')
-
-        def _wait():
-            firewall = self.client.show_firewall(fw_id)
-            firewall = firewall['firewall']
-            return firewall['status'] in target_states
-
-        if not test.call_until_true(_wait, CONF.network.build_timeout,
-                                    CONF.network.build_interval):
-            status = self.client.show_firewall(fw_id)['firewall']['status']
-            m = ("Timed out waiting for firewall %s to reach %s state(s) "
-                 "after %ss, currently in %s state." %
-                 (fw_id,
-                  target_states,
-                  CONF.network.build_interval,
-                  status))
-            raise exceptions.TimeoutException(m)
-
-    @test.idempotent_id('1b84cf01-9c09-4ce7-bc72-b15e39076468')
-    def test_list_firewall_rules(self):
-        # List firewall rules
-        fw_rules = self.client.list_firewall_rules()
-        fw_rules = fw_rules['firewall_rules']
-        self.assertIn((self.fw_rule['id'],
-                       self.fw_rule['name'],
-                       self.fw_rule['action'],
-                       self.fw_rule['protocol'],
-                       self.fw_rule['ip_version'],
-                       self.fw_rule['enabled']),
-                      [(m['id'],
-                        m['name'],
-                        m['action'],
-                        m['protocol'],
-                        m['ip_version'],
-                        m['enabled']) for m in fw_rules])
-
-    @test.idempotent_id('563564f7-7077-4f5e-8cdc-51f37ae5a2b9')
-    def test_create_update_delete_firewall_rule(self):
-        # Create firewall rule
-        body = self.client.create_firewall_rule(
-            name=data_utils.rand_name("fw-rule"),
-            action="allow",
-            protocol="tcp")
-        fw_rule_id = body['firewall_rule']['id']
-
-        # Update firewall rule
-        body = self.client.update_firewall_rule(fw_rule_id,
-                                                shared=True)
-        self.assertTrue(body["firewall_rule"]['shared'])
-
-        # Delete firewall rule
-        self.client.delete_firewall_rule(fw_rule_id)
-        # Confirm deletion
-        fw_rules = self.client.list_firewall_rules()
-        self.assertNotIn(fw_rule_id,
-                         [m['id'] for m in fw_rules['firewall_rules']])
-
-    @test.idempotent_id('3ff8c08e-26ff-4034-ae48-810ed213a998')
-    def test_show_firewall_rule(self):
-        # show a created firewall rule
-        fw_rule = self.client.show_firewall_rule(self.fw_rule['id'])
-        for key, value in six.iteritems(fw_rule['firewall_rule']):
-            self.assertEqual(self.fw_rule[key], value)
-
-    @test.idempotent_id('1086dd93-a4c0-4bbb-a1bd-6d4bc62c199f')
-    def test_list_firewall_policies(self):
-        fw_policies = self.client.list_firewall_policies()
-        fw_policies = fw_policies['firewall_policies']
-        self.assertIn((self.fw_policy['id'],
-                       self.fw_policy['name'],
-                       self.fw_policy['firewall_rules']),
-                      [(m['id'],
-                        m['name'],
-                        m['firewall_rules']) for m in fw_policies])
-
-    @test.idempotent_id('bbf37b6c-498c-421e-9c95-45897d3ed775')
-    def test_create_update_delete_firewall_policy(self):
-        # Create firewall policy
-        body = self.client.create_firewall_policy(
-            name=data_utils.rand_name("fw-policy"))
-        fw_policy_id = body['firewall_policy']['id']
-        self.addCleanup(self._try_delete_policy, fw_policy_id)
-
-        # Update firewall policy
-        body = self.client.update_firewall_policy(fw_policy_id,
-                                                  shared=True,
-                                                  name="updated_policy")
-        updated_fw_policy = body["firewall_policy"]
-        self.assertTrue(updated_fw_policy['shared'])
-        self.assertEqual("updated_policy", updated_fw_policy['name'])
-
-        # Delete firewall policy
-        self.client.delete_firewall_policy(fw_policy_id)
-        # Confirm deletion
-        fw_policies = self.client.list_firewall_policies()
-        fw_policies = fw_policies['firewall_policies']
-        self.assertNotIn(fw_policy_id, [m['id'] for m in fw_policies])
-
-    @test.idempotent_id('1df59b3a-517e-41d4-96f6-fc31cf4ecff2')
-    def test_show_firewall_policy(self):
-        # show a created firewall policy
-        fw_policy = self.client.show_firewall_policy(self.fw_policy['id'])
-        fw_policy = fw_policy['firewall_policy']
-        for key, value in six.iteritems(fw_policy):
-            self.assertEqual(self.fw_policy[key], value)
-
-    @test.idempotent_id('02082a03-3cdd-4789-986a-1327dd80bfb7')
-    def test_create_show_delete_firewall(self):
-        # Create tenant network resources required for an ACTIVE firewall
-        network = self.create_network()
-        subnet = self.create_subnet(network)
-        router = self.create_router(
-            data_utils.rand_name('router-'),
-            admin_state_up=True)
-        self.client.add_router_interface_with_subnet_id(
-            router['id'], subnet['id'])
-
-        # Create firewall
-        body = self.client.create_firewall(
-            name=data_utils.rand_name("firewall"),
-            firewall_policy_id=self.fw_policy['id'])
-        created_firewall = body['firewall']
-        firewall_id = created_firewall['id']
-        self.addCleanup(self._try_delete_firewall, firewall_id)
-
-        # Wait for the firewall resource to become ready
-        self._wait_until_ready(firewall_id)
-
-        # show a created firewall
-        firewall = self.client.show_firewall(firewall_id)
-        firewall = firewall['firewall']
-
-        for key, value in six.iteritems(firewall):
-            if key == 'status':
-                continue
-            self.assertEqual(created_firewall[key], value)
-
-        # list firewall
-        firewalls = self.client.list_firewalls()
-        firewalls = firewalls['firewalls']
-        self.assertIn((created_firewall['id'],
-                       created_firewall['name'],
-                       created_firewall['firewall_policy_id']),
-                      [(m['id'],
-                        m['name'],
-                        m['firewall_policy_id']) for m in firewalls])
-
-        # Delete firewall
-        self.client.delete_firewall(firewall_id)
-
-    @test.idempotent_id('53305b4b-9897-4e01-87c0-2ae386083180')
-    def test_firewall_rule_insertion_position_removal_rule_from_policy(self):
-        # Create firewall rule
-        body = self.client.create_firewall_rule(
-            name=data_utils.rand_name("fw-rule"),
-            action="allow",
-            protocol="tcp")
-        fw_rule_id1 = body['firewall_rule']['id']
-        self.addCleanup(self._try_delete_rule, fw_rule_id1)
-        # Create firewall policy
-        body = self.client.create_firewall_policy(
-            name=data_utils.rand_name("fw-policy"))
-        fw_policy_id = body['firewall_policy']['id']
-        self.addCleanup(self._try_delete_policy, fw_policy_id)
-
-        # Insert rule to firewall policy
-        self.client.insert_firewall_rule_in_policy(
-            fw_policy_id, fw_rule_id1, '', '')
-
-        # Verify insertion of rule in policy
-        self.assertIn(fw_rule_id1, self._get_list_fw_rule_ids(fw_policy_id))
-        # Create another firewall rule
-        body = self.client.create_firewall_rule(
-            name=data_utils.rand_name("fw-rule"),
-            action="allow",
-            protocol="icmp")
-        fw_rule_id2 = body['firewall_rule']['id']
-        self.addCleanup(self._try_delete_rule, fw_rule_id2)
-
-        # Insert rule to firewall policy after the first rule
-        self.client.insert_firewall_rule_in_policy(
-            fw_policy_id, fw_rule_id2, fw_rule_id1, '')
-
-        # Verify the posiition of rule after insertion
-        fw_rule = self.client.show_firewall_rule(
-            fw_rule_id2)
-
-        self.assertEqual(int(fw_rule['firewall_rule']['position']), 2)
-        # Remove rule from the firewall policy
-        self.client.remove_firewall_rule_from_policy(
-            fw_policy_id, fw_rule_id2)
-        # Insert rule to firewall policy before the first rule
-        self.client.insert_firewall_rule_in_policy(
-            fw_policy_id, fw_rule_id2, '', fw_rule_id1)
-        # Verify the posiition of rule after insertion
-        fw_rule = self.client.show_firewall_rule(
-            fw_rule_id2)
-        self.assertEqual(int(fw_rule['firewall_rule']['position']), 1)
-        # Remove rule from the firewall policy
-        self.client.remove_firewall_rule_from_policy(
-            fw_policy_id, fw_rule_id2)
-        # Verify removal of rule from firewall policy
-        self.assertNotIn(fw_rule_id2, self._get_list_fw_rule_ids(fw_policy_id))
-
-        # Remove rule from the firewall policy
-        self.client.remove_firewall_rule_from_policy(
-            fw_policy_id, fw_rule_id1)
-
-        # Verify removal of rule from firewall policy
-        self.assertNotIn(fw_rule_id1, self._get_list_fw_rule_ids(fw_policy_id))
-
-    def _get_list_fw_rule_ids(self, fw_policy_id):
-        fw_policy = self.client.show_firewall_policy(
-            fw_policy_id)
-        return [ruleid for ruleid in fw_policy['firewall_policy']
-                ['firewall_rules']]
-
-    @test.idempotent_id('8515ca8a-0d2f-4298-b5ff-6f924e4587ca')
-    def test_update_firewall_policy_audited_attribute(self):
-        # Create firewall rule
-        body = self.client.create_firewall_rule(
-            name=data_utils.rand_name("fw-rule"),
-            action="allow",
-            protocol="icmp")
-        fw_rule_id = body['firewall_rule']['id']
-        self.addCleanup(self._try_delete_rule, fw_rule_id)
-        # Create firewall policy
-        body = self.client.create_firewall_policy(
-            name=data_utils.rand_name('fw-policy'))
-        fw_policy_id = body['firewall_policy']['id']
-        self.addCleanup(self._try_delete_policy, fw_policy_id)
-        self.assertFalse(body['firewall_policy']['audited'])
-        # Update firewall policy audited attribute to ture
-        self.client.update_firewall_policy(fw_policy_id,
-                                           audited=True)
-        # Insert Firewall rule to firewall policy
-        self.client.insert_firewall_rule_in_policy(
-            fw_policy_id, fw_rule_id, '', '')
-        body = self.client.show_firewall_policy(
-            fw_policy_id)
-        self.assertFalse(body['firewall_policy']['audited'])
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
deleted file mode 100644
index 38a6fe9..0000000
--- a/tempest/api/network/test_load_balancer.py
+++ /dev/null
@@ -1,432 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import six
-from tempest_lib.common.utils import data_utils
-from tempest_lib import decorators
-
-from tempest.api.network import base
-from tempest import test
-
-
-class LoadBalancerTestJSON(base.BaseNetworkTest):
-    """
-    Tests the following operations in the Neutron API using the REST client for
-    Neutron:
-
-        create vIP, and Pool
-        show vIP
-        list vIP
-        update vIP
-        delete vIP
-        update pool
-        delete pool
-        show pool
-        list pool
-        health monitoring operations
-    """
-
-    @classmethod
-    def skip_checks(cls):
-        super(LoadBalancerTestJSON, cls).skip_checks()
-        if not test.is_extension_enabled('lbaas', 'network'):
-            msg = "lbaas extension not enabled."
-            raise cls.skipException(msg)
-
-    @classmethod
-    def resource_setup(cls):
-        super(LoadBalancerTestJSON, cls).resource_setup()
-        cls.network = cls.create_network()
-        cls.name = cls.network['name']
-        cls.subnet = cls.create_subnet(cls.network)
-        pool_name = data_utils.rand_name('pool-')
-        vip_name = data_utils.rand_name('vip-')
-        cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN",
-                                   "HTTP", cls.subnet)
-        cls.vip = cls.create_vip(name=vip_name,
-                                 protocol="HTTP",
-                                 protocol_port=80,
-                                 subnet=cls.subnet,
-                                 pool=cls.pool)
-        cls.member = cls.create_member(80, cls.pool, cls._ip_version)
-        cls.member_address = ("10.0.9.47" if cls._ip_version == 4
-                              else "2015::beef")
-        cls.health_monitor = cls.create_health_monitor(delay=4,
-                                                       max_retries=3,
-                                                       Type="TCP",
-                                                       timeout=1)
-
-    def _check_list_with_filter(self, obj_name, attr_exceptions, **kwargs):
-        create_obj = getattr(self.client, 'create_' + obj_name)
-        delete_obj = getattr(self.client, 'delete_' + obj_name)
-        list_objs = getattr(self.client, 'list_' + obj_name + 's')
-
-        body = create_obj(**kwargs)
-        obj = body[obj_name]
-        self.addCleanup(delete_obj, obj['id'])
-        for key, value in six.iteritems(obj):
-            # It is not relevant to filter by all arguments. That is why
-            # there is a list of attr to except
-            if key not in attr_exceptions:
-                body = list_objs(**{key: value})
-                objs = [v[key] for v in body[obj_name + 's']]
-                self.assertIn(value, objs)
-
-    @test.idempotent_id('c96dbfab-4a80-4e74-a535-e950b5bedd47')
-    def test_list_vips(self):
-        # Verify the vIP exists in the list of all vIPs
-        body = self.client.list_vips()
-        vips = body['vips']
-        self.assertIn(self.vip['id'], [v['id'] for v in vips])
-
-    @test.idempotent_id('b8853f65-5089-4e69-befd-041a143427ff')
-    def test_list_vips_with_filter(self):
-        name = data_utils.rand_name('vip-')
-        body = self.client.create_pool(name=data_utils.rand_name("pool-"),
-                                       lb_method="ROUND_ROBIN",
-                                       protocol="HTTPS",
-                                       subnet_id=self.subnet['id'])
-        pool = body['pool']
-        self.addCleanup(self.client.delete_pool, pool['id'])
-        attr_exceptions = ['status', 'session_persistence',
-                           'status_description']
-        self._check_list_with_filter(
-            'vip', attr_exceptions, name=name, protocol="HTTPS",
-            protocol_port=81, subnet_id=self.subnet['id'], pool_id=pool['id'],
-            description=data_utils.rand_name('description-'),
-            admin_state_up=False)
-
-    @test.idempotent_id('27f56083-9af9-4a48-abe9-ca1bcc6c9035')
-    def test_create_update_delete_pool_vip(self):
-        # Creates a vip
-        name = data_utils.rand_name('vip-')
-        address = self.subnet['allocation_pools'][0]['end']
-        body = self.client.create_pool(
-            name=data_utils.rand_name("pool-"),
-            lb_method='ROUND_ROBIN',
-            protocol='HTTP',
-            subnet_id=self.subnet['id'])
-        pool = body['pool']
-        body = self.client.create_vip(name=name,
-                                      protocol="HTTP",
-                                      protocol_port=80,
-                                      subnet_id=self.subnet['id'],
-                                      pool_id=pool['id'],
-                                      address=address)
-        vip = body['vip']
-        vip_id = vip['id']
-        # Confirm VIP's address correctness with a show
-        body = self.client.show_vip(vip_id)
-        vip = body['vip']
-        self.assertEqual(address, vip['address'])
-        # Verification of vip update
-        new_name = "New_vip"
-        new_description = "New description"
-        persistence_type = "HTTP_COOKIE"
-        update_data = {"session_persistence": {
-            "type": persistence_type}}
-        body = self.client.update_vip(vip_id,
-                                      name=new_name,
-                                      description=new_description,
-                                      connection_limit=10,
-                                      admin_state_up=False,
-                                      **update_data)
-        updated_vip = body['vip']
-        self.assertEqual(new_name, updated_vip['name'])
-        self.assertEqual(new_description, updated_vip['description'])
-        self.assertEqual(10, updated_vip['connection_limit'])
-        self.assertFalse(updated_vip['admin_state_up'])
-        self.assertEqual(persistence_type,
-                         updated_vip['session_persistence']['type'])
-        self.client.delete_vip(vip['id'])
-        self.client.wait_for_resource_deletion('vip', vip['id'])
-        # Verification of pool update
-        new_name = "New_pool"
-        body = self.client.update_pool(pool['id'],
-                                       name=new_name,
-                                       description="new_description",
-                                       lb_method='LEAST_CONNECTIONS')
-        updated_pool = body['pool']
-        self.assertEqual(new_name, updated_pool['name'])
-        self.assertEqual('new_description', updated_pool['description'])
-        self.assertEqual('LEAST_CONNECTIONS', updated_pool['lb_method'])
-        self.client.delete_pool(pool['id'])
-
-    @test.idempotent_id('0435a95e-1d19-4d90-9e9f-3b979e9ad089')
-    def test_show_vip(self):
-        # Verifies the details of a vip
-        body = self.client.show_vip(self.vip['id'])
-        vip = body['vip']
-        for key, value in six.iteritems(vip):
-            # 'status' should not be confirmed in api tests
-            if key != 'status':
-                self.assertEqual(self.vip[key], value)
-
-    @test.idempotent_id('6e7a7d31-8451-456d-b24a-e50479ce42a7')
-    def test_show_pool(self):
-        # Here we need to new pool without any dependence with vips
-        body = self.client.create_pool(name=data_utils.rand_name("pool-"),
-                                       lb_method='ROUND_ROBIN',
-                                       protocol='HTTP',
-                                       subnet_id=self.subnet['id'])
-        pool = body['pool']
-        self.addCleanup(self.client.delete_pool, pool['id'])
-        # Verifies the details of a pool
-        body = self.client.show_pool(pool['id'])
-        shown_pool = body['pool']
-        for key, value in six.iteritems(pool):
-            # 'status' should not be confirmed in api tests
-            if key != 'status':
-                self.assertEqual(value, shown_pool[key])
-
-    @test.idempotent_id('d1ab1ffa-e06a-487f-911f-56418cb27727')
-    def test_list_pools(self):
-        # Verify the pool exists in the list of all pools
-        body = self.client.list_pools()
-        pools = body['pools']
-        self.assertIn(self.pool['id'], [p['id'] for p in pools])
-
-    @test.idempotent_id('27cc4c1a-caac-4273-b983-2acb4afaad4f')
-    def test_list_pools_with_filters(self):
-        attr_exceptions = ['status', 'vip_id', 'members', 'provider',
-                           'status_description']
-        self._check_list_with_filter(
-            'pool', attr_exceptions, name=data_utils.rand_name("pool-"),
-            lb_method="ROUND_ROBIN", protocol="HTTPS",
-            subnet_id=self.subnet['id'],
-            description=data_utils.rand_name('description-'),
-            admin_state_up=False)
-
-    @test.idempotent_id('282d0dfd-5c3a-4c9b-b39c-c99782f39193')
-    def test_list_members(self):
-        # Verify the member exists in the list of all members
-        body = self.client.list_members()
-        members = body['members']
-        self.assertIn(self.member['id'], [m['id'] for m in members])
-
-    @test.idempotent_id('243b5126-24c6-4879-953e-7c7e32d8a57f')
-    def test_list_members_with_filters(self):
-        attr_exceptions = ['status', 'status_description']
-        self._check_list_with_filter('member', attr_exceptions,
-                                     address=self.member_address,
-                                     protocol_port=80,
-                                     pool_id=self.pool['id'])
-
-    @test.idempotent_id('fb833ee8-9e69-489f-b540-a409762b78b2')
-    def test_create_update_delete_member(self):
-        # Creates a member
-        body = self.client.create_member(address=self.member_address,
-                                         protocol_port=80,
-                                         pool_id=self.pool['id'])
-        member = body['member']
-        # Verification of member update
-        body = self.client.update_member(member['id'],
-                                         admin_state_up=False)
-        updated_member = body['member']
-        self.assertFalse(updated_member['admin_state_up'])
-        # Verification of member delete
-        self.client.delete_member(member['id'])
-
-    @test.idempotent_id('893cd71f-a7dd-4485-b162-f6ab9a534914')
-    def test_show_member(self):
-        # Verifies the details of a member
-        body = self.client.show_member(self.member['id'])
-        member = body['member']
-        for key, value in six.iteritems(member):
-            # 'status' should not be confirmed in api tests
-            if key != 'status':
-                self.assertEqual(self.member[key], value)
-
-    @test.idempotent_id('8e5822c5-68a4-4224-8d6c-a617741ebc2d')
-    def test_list_health_monitors(self):
-        # Verify the health monitor exists in the list of all health monitors
-        body = self.client.list_health_monitors()
-        health_monitors = body['health_monitors']
-        self.assertIn(self.health_monitor['id'],
-                      [h['id'] for h in health_monitors])
-
-    @test.idempotent_id('49bac58a-511c-4875-b794-366698211d25')
-    def test_list_health_monitors_with_filters(self):
-        attr_exceptions = ['status', 'status_description', 'pools']
-        self._check_list_with_filter('health_monitor', attr_exceptions,
-                                     delay=5, max_retries=4, type="TCP",
-                                     timeout=2)
-
-    @test.idempotent_id('e8ce05c4-d554-4d1e-a257-ad32ce134bb5')
-    def test_create_update_delete_health_monitor(self):
-        # Creates a health_monitor
-        body = self.client.create_health_monitor(delay=4,
-                                                 max_retries=3,
-                                                 type="TCP",
-                                                 timeout=1)
-        health_monitor = body['health_monitor']
-        # Verification of health_monitor update
-        body = (self.client.update_health_monitor
-                (health_monitor['id'],
-                 admin_state_up=False))
-        updated_health_monitor = body['health_monitor']
-        self.assertFalse(updated_health_monitor['admin_state_up'])
-        # Verification of health_monitor delete
-        body = self.client.delete_health_monitor(health_monitor['id'])
-
-    @test.idempotent_id('d3e1aebc-06c2-49b3-9816-942af54012eb')
-    def test_create_health_monitor_http_type(self):
-        hm_type = "HTTP"
-        body = self.client.create_health_monitor(delay=4,
-                                                 max_retries=3,
-                                                 type=hm_type,
-                                                 timeout=1)
-        health_monitor = body['health_monitor']
-        self.addCleanup(self.client.delete_health_monitor,
-                        health_monitor['id'])
-        self.assertEqual(hm_type, health_monitor['type'])
-
-    @test.idempotent_id('0eff9f67-90fb-4bb1-b4ed-c5fda99fff0c')
-    def test_update_health_monitor_http_method(self):
-        body = self.client.create_health_monitor(delay=4,
-                                                 max_retries=3,
-                                                 type="HTTP",
-                                                 timeout=1)
-        health_monitor = body['health_monitor']
-        self.addCleanup(self.client.delete_health_monitor,
-                        health_monitor['id'])
-        body = (self.client.update_health_monitor
-                (health_monitor['id'],
-                 http_method="POST",
-                 url_path="/home/user",
-                 expected_codes="290"))
-        updated_health_monitor = body['health_monitor']
-        self.assertEqual("POST", updated_health_monitor['http_method'])
-        self.assertEqual("/home/user", updated_health_monitor['url_path'])
-        self.assertEqual("290", updated_health_monitor['expected_codes'])
-
-    @test.idempotent_id('08e126ab-1407-483f-a22e-b11cc032ca7c')
-    def test_show_health_monitor(self):
-        # Verifies the details of a health_monitor
-        body = self.client.show_health_monitor(self.health_monitor['id'])
-        health_monitor = body['health_monitor']
-        for key, value in six.iteritems(health_monitor):
-            # 'status' should not be confirmed in api tests
-            if key != 'status':
-                self.assertEqual(self.health_monitor[key], value)
-
-    @test.idempotent_id('87f7628e-8918-493d-af50-0602845dbb5b')
-    def test_associate_disassociate_health_monitor_with_pool(self):
-        # Verify that a health monitor can be associated with a pool
-        self.client.associate_health_monitor_with_pool(
-            self.health_monitor['id'], self.pool['id'])
-        body = self.client.show_health_monitor(
-            self.health_monitor['id'])
-        health_monitor = body['health_monitor']
-        body = self.client.show_pool(self.pool['id'])
-        pool = body['pool']
-        self.assertIn(pool['id'],
-                      [p['pool_id'] for p in health_monitor['pools']])
-        self.assertIn(health_monitor['id'], pool['health_monitors'])
-        # Verify that a health monitor can be disassociated from a pool
-        (self.client.disassociate_health_monitor_with_pool
-            (self.health_monitor['id'], self.pool['id']))
-        body = self.client.show_pool(self.pool['id'])
-        pool = body['pool']
-        body = self.client.show_health_monitor(
-            self.health_monitor['id'])
-        health_monitor = body['health_monitor']
-        self.assertNotIn(health_monitor['id'], pool['health_monitors'])
-        self.assertNotIn(pool['id'],
-                         [p['pool_id'] for p in health_monitor['pools']])
-
-    @test.idempotent_id('525fc7dc-be24-408d-938d-822e9783e027')
-    def test_get_lb_pool_stats(self):
-        # Verify the details of pool stats
-        body = self.client.list_lb_pool_stats(self.pool['id'])
-        stats = body['stats']
-        self.assertIn("bytes_in", stats)
-        self.assertIn("total_connections", stats)
-        self.assertIn("active_connections", stats)
-        self.assertIn("bytes_out", stats)
-
-    @test.idempotent_id('66236be2-5121-4047-8cde-db4b83b110a5')
-    def test_update_list_of_health_monitors_associated_with_pool(self):
-        (self.client.associate_health_monitor_with_pool
-            (self.health_monitor['id'], self.pool['id']))
-        self.client.update_health_monitor(
-            self.health_monitor['id'], admin_state_up=False)
-        body = self.client.show_pool(self.pool['id'])
-        health_monitors = body['pool']['health_monitors']
-        for health_monitor_id in health_monitors:
-            body = self.client.show_health_monitor(health_monitor_id)
-            self.assertFalse(body['health_monitor']['admin_state_up'])
-            (self.client.disassociate_health_monitor_with_pool
-                (self.health_monitor['id'], self.pool['id']))
-
-    @test.idempotent_id('44ec9b40-b501-41e2-951f-4fc673b15ac0')
-    def test_update_admin_state_up_of_pool(self):
-        self.client.update_pool(self.pool['id'],
-                                admin_state_up=False)
-        body = self.client.show_pool(self.pool['id'])
-        pool = body['pool']
-        self.assertFalse(pool['admin_state_up'])
-
-    @test.idempotent_id('466a9d4c-37c6-4ea2-b807-133437beb48c')
-    def test_show_vip_associated_with_pool(self):
-        body = self.client.show_pool(self.pool['id'])
-        pool = body['pool']
-        body = self.client.show_vip(pool['vip_id'])
-        vip = body['vip']
-        self.assertEqual(self.vip['name'], vip['name'])
-        self.assertEqual(self.vip['id'], vip['id'])
-
-    @test.idempotent_id('7b97694e-69d0-4151-b265-e1052a465aa8')
-    def test_show_members_associated_with_pool(self):
-        body = self.client.show_pool(self.pool['id'])
-        members = body['pool']['members']
-        for member_id in members:
-            body = self.client.show_member(member_id)
-            self.assertIsNotNone(body['member']['status'])
-            self.assertEqual(member_id, body['member']['id'])
-            self.assertIsNotNone(body['member']['admin_state_up'])
-
-    @test.idempotent_id('73ed6f27-595b-4b2c-969c-dbdda6b8ab34')
-    def test_update_pool_related_to_member(self):
-        # Create new pool
-        body = self.client.create_pool(name=data_utils.rand_name("pool-"),
-                                       lb_method='ROUND_ROBIN',
-                                       protocol='HTTP',
-                                       subnet_id=self.subnet['id'])
-        new_pool = body['pool']
-        self.addCleanup(self.client.delete_pool, new_pool['id'])
-        # Update member with new pool's id
-        body = self.client.update_member(self.member['id'],
-                                         pool_id=new_pool['id'])
-        # Confirm with show that pool_id change
-        body = self.client.show_member(self.member['id'])
-        member = body['member']
-        self.assertEqual(member['pool_id'], new_pool['id'])
-        # Update member with old pool id, this is needed for clean up
-        body = self.client.update_member(self.member['id'],
-                                         pool_id=self.pool['id'])
-
-    @test.idempotent_id('cf63f071-bbe3-40ba-97a0-a33e11923162')
-    def test_update_member_weight(self):
-        self.client.update_member(self.member['id'],
-                                  weight=2)
-        body = self.client.show_member(self.member['id'])
-        member = body['member']
-        self.assertEqual(2, member['weight'])
-
-
-@decorators.skip_because(bug="1402007")
-class LoadBalancerIpV6TestJSON(LoadBalancerTestJSON):
-    _ip_version = 6
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
deleted file mode 100644
index 9fe2a56..0000000
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ /dev/null
@@ -1,319 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import six
-from tempest_lib.common.utils import data_utils
-from tempest_lib import exceptions as lib_exc
-
-from tempest.api.network import base
-from tempest import config
-from tempest import test
-
-CONF = config.CONF
-
-
-class VPNaaSTestJSON(base.BaseAdminNetworkTest):
-    """
-    Tests the following operations in the Neutron API using the REST client for
-    Neutron:
-        List, Show, Create, Delete, and Update VPN Service
-        List, Show, Create, Delete, and Update IKE policy
-        List, Show, Create, Delete, and Update IPSec policy
-    """
-
-    @classmethod
-    def skip_checks(cls):
-        super(VPNaaSTestJSON, cls).skip_checks()
-        if not test.is_extension_enabled('vpnaas', 'network'):
-            msg = "vpnaas extension not enabled."
-            raise cls.skipException(msg)
-
-    @classmethod
-    def resource_setup(cls):
-        super(VPNaaSTestJSON, cls).resource_setup()
-        cls.ext_net_id = CONF.network.public_network_id
-        cls.network = cls.create_network()
-        cls.subnet = cls.create_subnet(cls.network)
-        cls.router = cls.create_router(
-            data_utils.rand_name("router"),
-            external_network_id=CONF.network.public_network_id)
-        cls.create_router_interface(cls.router['id'], cls.subnet['id'])
-        cls.vpnservice = cls.create_vpnservice(cls.subnet['id'],
-                                               cls.router['id'])
-
-        cls.ikepolicy = cls.create_ikepolicy(
-            data_utils.rand_name("ike-policy-"))
-        cls.ipsecpolicy = cls.create_ipsecpolicy(
-            data_utils.rand_name("ipsec-policy-"))
-
-    def _delete_ike_policy(self, ike_policy_id):
-        # Deletes a ike policy and verifies if it is deleted or not
-        ike_list = list()
-        all_ike = self.client.list_ikepolicies()
-        for ike in all_ike['ikepolicies']:
-            ike_list.append(ike['id'])
-        if ike_policy_id in ike_list:
-            self.client.delete_ikepolicy(ike_policy_id)
-            # Asserting that the policy is not found in list after deletion
-            ikepolicies = self.client.list_ikepolicies()
-            ike_id_list = list()
-            for i in ikepolicies['ikepolicies']:
-                ike_id_list.append(i['id'])
-            self.assertNotIn(ike_policy_id, ike_id_list)
-
-    def _delete_ipsec_policy(self, ipsec_policy_id):
-        # Deletes an ike policy if it exists
-        try:
-            self.client.delete_ipsecpolicy(ipsec_policy_id)
-
-        except lib_exc.NotFound:
-            pass
-
-    def _assertExpected(self, expected, actual):
-        # Check if not expected keys/values exists in actual response body
-        for key, value in six.iteritems(expected):
-            self.assertIn(key, actual)
-            self.assertEqual(value, actual[key])
-
-    def _delete_vpn_service(self, vpn_service_id):
-        self.client.delete_vpnservice(vpn_service_id)
-        # Asserting if vpn service is found in the list after deletion
-        body = self.client.list_vpnservices()
-        vpn_services = [vs['id'] for vs in body['vpnservices']]
-        self.assertNotIn(vpn_service_id, vpn_services)
-
-    def _get_tenant_id(self):
-        """
-        Returns the tenant_id of the client current user
-        """
-        # TODO(jroovers) This is a temporary workaround to get the tenant_id
-        # of the the current client. Replace this once tenant_isolation for
-        # neutron is fixed.
-        body = self.client.show_network(self.network['id'])
-        return body['network']['tenant_id']
-
-    @test.idempotent_id('14311574-0737-4e53-ac05-f7ae27742eed')
-    def test_admin_create_ipsec_policy_for_tenant(self):
-        tenant_id = self._get_tenant_id()
-        # Create IPSec policy for the newly created tenant
-        name = data_utils.rand_name('ipsec-policy')
-        body = (self.admin_client.
-                create_ipsecpolicy(name=name, tenant_id=tenant_id))
-        ipsecpolicy = body['ipsecpolicy']
-        self.assertIsNotNone(ipsecpolicy['id'])
-        self.addCleanup(self.admin_client.delete_ipsecpolicy,
-                        ipsecpolicy['id'])
-
-        # Assert that created ipsec policy is found in API list call
-        body = self.client.list_ipsecpolicies()
-        ipsecpolicies = [policy['id'] for policy in body['ipsecpolicies']]
-        self.assertIn(ipsecpolicy['id'], ipsecpolicies)
-
-    @test.idempotent_id('b62acdc6-0c53-4d84-84aa-859b22b79799')
-    def test_admin_create_vpn_service_for_tenant(self):
-        tenant_id = self._get_tenant_id()
-
-        # Create vpn service for the newly created tenant
-        network2 = self.create_network()
-        subnet2 = self.create_subnet(network2)
-        router2 = self.create_router(data_utils.rand_name('router-'),
-                                     external_network_id=self.ext_net_id)
-        self.create_router_interface(router2['id'], subnet2['id'])
-        name = data_utils.rand_name('vpn-service')
-        body = self.admin_client.create_vpnservice(
-            subnet_id=subnet2['id'],
-            router_id=router2['id'],
-            name=name,
-            admin_state_up=True,
-            tenant_id=tenant_id)
-        vpnservice = body['vpnservice']
-        self.assertIsNotNone(vpnservice['id'])
-        self.addCleanup(self.admin_client.delete_vpnservice, vpnservice['id'])
-        # Assert that created vpnservice is found in API list call
-        body = self.client.list_vpnservices()
-        vpn_services = [vs['id'] for vs in body['vpnservices']]
-        self.assertIn(vpnservice['id'], vpn_services)
-
-    @test.idempotent_id('58cc4a1c-443b-4f39-8fb6-c19d39f343ab')
-    def test_admin_create_ike_policy_for_tenant(self):
-        tenant_id = self._get_tenant_id()
-
-        # Create IKE policy for the newly created tenant
-        name = data_utils.rand_name('ike-policy')
-        body = (self.admin_client.
-                create_ikepolicy(name=name, ike_version="v1",
-                                 encryption_algorithm="aes-128",
-                                 auth_algorithm="sha1",
-                                 tenant_id=tenant_id))
-        ikepolicy = body['ikepolicy']
-        self.assertIsNotNone(ikepolicy['id'])
-        self.addCleanup(self.admin_client.delete_ikepolicy, ikepolicy['id'])
-
-        # Assert that created ike policy is found in API list call
-        body = self.client.list_ikepolicies()
-        ikepolicies = [ikp['id'] for ikp in body['ikepolicies']]
-        self.assertIn(ikepolicy['id'], ikepolicies)
-
-    @test.idempotent_id('de5bb04c-3a1f-46b1-b329-7a8abba5c7f1')
-    def test_list_vpn_services(self):
-        # Verify the VPN service exists in the list of all VPN services
-        body = self.client.list_vpnservices()
-        vpnservices = body['vpnservices']
-        self.assertIn(self.vpnservice['id'], [v['id'] for v in vpnservices])
-
-    @test.idempotent_id('aacb13b1-fdc7-41fd-bab2-32621aee1878')
-    def test_create_update_delete_vpn_service(self):
-        # Creates a VPN service and sets up deletion
-        network1 = self.create_network()
-        subnet1 = self.create_subnet(network1)
-        router1 = self.create_router(data_utils.rand_name('router-'),
-                                     external_network_id=self.ext_net_id)
-        self.create_router_interface(router1['id'], subnet1['id'])
-        name = data_utils.rand_name('vpn-service1')
-        body = self.client.create_vpnservice(subnet_id=subnet1['id'],
-                                             router_id=router1['id'],
-                                             name=name,
-                                             admin_state_up=True)
-        vpnservice = body['vpnservice']
-        self.addCleanup(self._delete_vpn_service, vpnservice['id'])
-        # Assert if created vpnservices are not found in vpnservices list
-        body = self.client.list_vpnservices()
-        vpn_services = [vs['id'] for vs in body['vpnservices']]
-        self.assertIsNotNone(vpnservice['id'])
-        self.assertIn(vpnservice['id'], vpn_services)
-
-        # TODO(raies): implement logic to update  vpnservice
-        # VPNaaS client function to update is implemented.
-        # But precondition is that current state of vpnservice
-        # should be "ACTIVE" not "PENDING*"
-
-    @test.idempotent_id('0dedfc1d-f8ee-4e2a-bfd4-7997b9dc17ff')
-    def test_show_vpn_service(self):
-        # Verifies the details of a vpn service
-        body = self.client.show_vpnservice(self.vpnservice['id'])
-        vpnservice = body['vpnservice']
-        self.assertEqual(self.vpnservice['id'], vpnservice['id'])
-        self.assertEqual(self.vpnservice['name'], vpnservice['name'])
-        self.assertEqual(self.vpnservice['description'],
-                         vpnservice['description'])
-        self.assertEqual(self.vpnservice['router_id'], vpnservice['router_id'])
-        self.assertEqual(self.vpnservice['subnet_id'], vpnservice['subnet_id'])
-        self.assertEqual(self.vpnservice['tenant_id'], vpnservice['tenant_id'])
-        valid_status = ["ACTIVE", "DOWN", "BUILD", "ERROR", "PENDING_CREATE",
-                        "PENDING_UPDATE", "PENDING_DELETE"]
-        self.assertIn(vpnservice['status'], valid_status)
-
-    @test.idempotent_id('e0fb6200-da3d-4869-8340-a8c1956ca618')
-    def test_list_ike_policies(self):
-        # Verify the ike policy exists in the list of all IKE policies
-        body = self.client.list_ikepolicies()
-        ikepolicies = body['ikepolicies']
-        self.assertIn(self.ikepolicy['id'], [i['id'] for i in ikepolicies])
-
-    @test.idempotent_id('d61f29a5-160c-487d-bc0d-22e32e731b44')
-    def test_create_update_delete_ike_policy(self):
-        # Creates a IKE policy
-        name = data_utils.rand_name('ike-policy')
-        body = (self.client.create_ikepolicy(
-                name=name,
-                ike_version="v1",
-                encryption_algorithm="aes-128",
-                auth_algorithm="sha1"))
-        ikepolicy = body['ikepolicy']
-        self.assertIsNotNone(ikepolicy['id'])
-        self.addCleanup(self._delete_ike_policy, ikepolicy['id'])
-
-        # Update IKE Policy
-        new_ike = {'name': data_utils.rand_name("New-IKE"),
-                   'description': "Updated ike policy",
-                   'encryption_algorithm': "aes-256",
-                   'ike_version': "v2",
-                   'pfs': "group14",
-                   'lifetime': {'units': "seconds", 'value': 2000}}
-        self.client.update_ikepolicy(ikepolicy['id'], **new_ike)
-        # Confirm that update was successful by verifying using 'show'
-        body = self.client.show_ikepolicy(ikepolicy['id'])
-        ike_policy = body['ikepolicy']
-        for key, value in six.iteritems(new_ike):
-            self.assertIn(key, ike_policy)
-            self.assertEqual(value, ike_policy[key])
-
-        # Verification of ike policy delete
-        self.client.delete_ikepolicy(ikepolicy['id'])
-        body = self.client.list_ikepolicies()
-        ikepolicies = [ikp['id'] for ikp in body['ikepolicies']]
-        self.assertNotIn(ike_policy['id'], ikepolicies)
-
-    @test.idempotent_id('b5fcf3a3-9407-452d-b8a8-e7c6c32baea8')
-    def test_show_ike_policy(self):
-        # Verifies the details of a ike policy
-        body = self.client.show_ikepolicy(self.ikepolicy['id'])
-        ikepolicy = body['ikepolicy']
-        self.assertEqual(self.ikepolicy['id'], ikepolicy['id'])
-        self.assertEqual(self.ikepolicy['name'], ikepolicy['name'])
-        self.assertEqual(self.ikepolicy['description'],
-                         ikepolicy['description'])
-        self.assertEqual(self.ikepolicy['encryption_algorithm'],
-                         ikepolicy['encryption_algorithm'])
-        self.assertEqual(self.ikepolicy['auth_algorithm'],
-                         ikepolicy['auth_algorithm'])
-        self.assertEqual(self.ikepolicy['tenant_id'],
-                         ikepolicy['tenant_id'])
-        self.assertEqual(self.ikepolicy['pfs'],
-                         ikepolicy['pfs'])
-        self.assertEqual(self.ikepolicy['phase1_negotiation_mode'],
-                         ikepolicy['phase1_negotiation_mode'])
-        self.assertEqual(self.ikepolicy['ike_version'],
-                         ikepolicy['ike_version'])
-
-    @test.idempotent_id('19ea0a2f-add9-44be-b732-ffd8a7b42f37')
-    def test_list_ipsec_policies(self):
-        # Verify the ipsec policy exists in the list of all ipsec policies
-        body = self.client.list_ipsecpolicies()
-        ipsecpolicies = body['ipsecpolicies']
-        self.assertIn(self.ipsecpolicy['id'], [i['id'] for i in ipsecpolicies])
-
-    @test.idempotent_id('9c1701c9-329a-4e5d-930a-1ead1b3f86ad')
-    def test_create_update_delete_ipsec_policy(self):
-        # Creates an ipsec policy
-        ipsec_policy_body = {'name': data_utils.rand_name('ipsec-policy'),
-                             'pfs': 'group5',
-                             'encryption_algorithm': "aes-128",
-                             'auth_algorithm': 'sha1'}
-        resp_body = self.client.create_ipsecpolicy(**ipsec_policy_body)
-        ipsecpolicy = resp_body['ipsecpolicy']
-        self.addCleanup(self._delete_ipsec_policy, ipsecpolicy['id'])
-        self._assertExpected(ipsec_policy_body, ipsecpolicy)
-        # Verification of ipsec policy update
-        new_ipsec = {'description': 'Updated ipsec policy',
-                     'pfs': 'group2',
-                     'name': data_utils.rand_name("New-IPSec"),
-                     'encryption_algorithm': "aes-256",
-                     'lifetime': {'units': "seconds", 'value': '2000'}}
-        body = self.client.update_ipsecpolicy(ipsecpolicy['id'],
-                                              **new_ipsec)
-        updated_ipsec_policy = body['ipsecpolicy']
-        self._assertExpected(new_ipsec, updated_ipsec_policy)
-        # Verification of ipsec policy delete
-        self.client.delete_ipsecpolicy(ipsecpolicy['id'])
-        self.assertRaises(lib_exc.NotFound,
-                          self.client.delete_ipsecpolicy, ipsecpolicy['id'])
-
-    @test.idempotent_id('601f8a05-9d3c-4539-a400-1c4b3a21b03b')
-    def test_show_ipsec_policy(self):
-        # Verifies the details of an ipsec policy
-        body = self.client.show_ipsecpolicy(self.ipsecpolicy['id'])
-        ipsecpolicy = body['ipsecpolicy']
-        self._assertExpected(self.ipsecpolicy, ipsecpolicy)
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 8ec4670..1de20d6 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -420,131 +420,6 @@
         self.data['networks'] = networks
 
 
-class NetworkIpSecPolicyService(NetworkService):
-
-    def list(self):
-        client = self.client
-        ipsecpols = client.list_ipsecpolicies()
-        ipsecpols = ipsecpols['ipsecpolicies']
-        ipsecpols = self._filter_by_tenant_id(ipsecpols)
-        LOG.debug("List count, %s IP Security Policies" % len(ipsecpols))
-        return ipsecpols
-
-    def delete(self):
-        client = self.client
-        ipsecpols = self.list()
-        for ipsecpol in ipsecpols:
-            try:
-                client.delete_ipsecpolicy(ipsecpol['id'])
-            except Exception as e:
-                LOG.exception("Delete IP Securty Policy exception: %s" % e)
-                pass
-
-    def dry_run(self):
-        ipsecpols = self.list()
-        self.data['ip_security_policies'] = ipsecpols
-
-
-class NetworkFwPolicyService(NetworkService):
-
-    def list(self):
-        client = self.client
-        fwpols = client.list_firewall_policies()
-        fwpols = fwpols['firewall_policies']
-        fwpols = self._filter_by_tenant_id(fwpols)
-        LOG.debug("List count, %s Firewall Policies" % len(fwpols))
-        return fwpols
-
-    def delete(self):
-        client = self.client
-        fwpols = self.list()
-        for fwpol in fwpols:
-            try:
-                client.delete_firewall_policy(fwpol['id'])
-            except Exception as e:
-                LOG.exception("Delete Firewall Policy exception: %s" % e)
-                pass
-
-    def dry_run(self):
-        fwpols = self.list()
-        self.data['firewall_policies'] = fwpols
-
-
-class NetworkFwRulesService(NetworkService):
-
-    def list(self):
-        client = self.client
-        fwrules = client.list_firewall_rules()
-        fwrules = fwrules['firewall_rules']
-        fwrules = self._filter_by_tenant_id(fwrules)
-        LOG.debug("List count, %s Firewall Rules" % len(fwrules))
-        return fwrules
-
-    def delete(self):
-        client = self.client
-        fwrules = self.list()
-        for fwrule in fwrules:
-            try:
-                client.delete_firewall_rule(fwrule['id'])
-            except Exception as e:
-                LOG.exception("Delete Firewall Rule exception: %s" % e)
-                pass
-
-    def dry_run(self):
-        fwrules = self.list()
-        self.data['firewall_rules'] = fwrules
-
-
-class NetworkIkePolicyService(NetworkService):
-
-    def list(self):
-        client = self.client
-        ikepols = client.list_ikepolicies()
-        ikepols = ikepols['ikepolicies']
-        ikepols = self._filter_by_tenant_id(ikepols)
-        LOG.debug("List count, %s IKE Policies" % len(ikepols))
-        return ikepols
-
-    def delete(self):
-        client = self.client
-        ikepols = self.list()
-        for ikepol in ikepols:
-            try:
-                client.delete_firewall_rule(ikepol['id'])
-            except Exception as e:
-                LOG.exception("Delete IKE Policy exception: %s" % e)
-                pass
-
-    def dry_run(self):
-        ikepols = self.list()
-        self.data['ike_policies'] = ikepols
-
-
-class NetworkVpnServiceService(NetworkService):
-
-    def list(self):
-        client = self.client
-        vpnsrvs = client.list_vpnservices()
-        vpnsrvs = vpnsrvs['vpnservices']
-        vpnsrvs = self._filter_by_tenant_id(vpnsrvs)
-        LOG.debug("List count, %s VPN Services" % len(vpnsrvs))
-        return vpnsrvs
-
-    def delete(self):
-        client = self.client
-        vpnsrvs = self.list()
-        for vpnsrv in vpnsrvs:
-            try:
-                client.delete_vpnservice(vpnsrv['id'])
-            except Exception as e:
-                LOG.exception("Delete VPN Service exception: %s" % e)
-                pass
-
-    def dry_run(self):
-        vpnsrvs = self.list()
-        self.data['vpn_services'] = vpnsrvs
-
-
 class NetworkFloatingIpService(NetworkService):
 
     def list(self):
@@ -1094,18 +969,6 @@
     if IS_HEAT:
         tenant_services.append(StackService)
     if IS_NEUTRON:
-        if test.is_extension_enabled('vpnaas', 'network'):
-            tenant_services.append(NetworkIpSecPolicyService)
-            tenant_services.append(NetworkIkePolicyService)
-            tenant_services.append(NetworkVpnServiceService)
-        if test.is_extension_enabled('fwaas', 'network'):
-            tenant_services.append(NetworkFwPolicyService)
-            tenant_services.append(NetworkFwRulesService)
-        if test.is_extension_enabled('lbaas', 'network'):
-            tenant_services.append(NetworkHealthMonitorService)
-            tenant_services.append(NetworkMemberService)
-            tenant_services.append(NetworkVipService)
-            tenant_services.append(NetworkPoolService)
         if test.is_extension_enabled('metering', 'network'):
             tenant_services.append(NetworkMeteringLabelRuleService)
             tenant_services.append(NetworkMeteringLabelService)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 5f8d605..fff8a5c 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -934,41 +934,6 @@
 
         return rules
 
-    def _create_pool(self, lb_method, protocol, subnet_id):
-        """Wrapper utility that returns a test pool."""
-        client = self.network_client
-        name = data_utils.rand_name('pool')
-        resp_pool = client.create_pool(protocol=protocol, name=name,
-                                       subnet_id=subnet_id,
-                                       lb_method=lb_method)
-        pool = net_resources.DeletablePool(client=client, **resp_pool['pool'])
-        self.assertEqual(pool['name'], name)
-        self.addCleanup(self.delete_wrapper, pool.delete)
-        return pool
-
-    def _create_member(self, address, protocol_port, pool_id):
-        """Wrapper utility that returns a test member."""
-        client = self.network_client
-        resp_member = client.create_member(protocol_port=protocol_port,
-                                           pool_id=pool_id,
-                                           address=address)
-        member = net_resources.DeletableMember(client=client,
-                                               **resp_member['member'])
-        self.addCleanup(self.delete_wrapper, member.delete)
-        return member
-
-    def _create_vip(self, protocol, protocol_port, subnet_id, pool_id):
-        """Wrapper utility that returns a test vip."""
-        client = self.network_client
-        name = data_utils.rand_name('vip')
-        resp_vip = client.create_vip(protocol=protocol, name=name,
-                                     subnet_id=subnet_id, pool_id=pool_id,
-                                     protocol_port=protocol_port)
-        vip = net_resources.DeletableVip(client=client, **resp_vip['vip'])
-        self.assertEqual(vip['name'], name)
-        self.addCleanup(self.delete_wrapper, vip.delete)
-        return vip
-
     def _ssh_to_server(self, server, private_key):
         ssh_login = CONF.compute.image_ssh_user
         return self.get_remote_client(server,
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
deleted file mode 100644
index 691c7c9..0000000
--- a/tempest/scenario/test_load_balancer_basic.py
+++ /dev/null
@@ -1,321 +0,0 @@
-# Copyright 2014 Mirantis.inc
-# All Rights Reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-
-import tempfile
-import time
-
-import six
-from six.moves.urllib import request as urllib2
-
-from tempest.common import commands
-from tempest import config
-from tempest import exceptions
-from tempest.scenario import manager
-from tempest.services.network import resources as net_resources
-from tempest import test
-
-config = config.CONF
-
-
-class TestLoadBalancerBasic(manager.NetworkScenarioTest):
-
-    """
-    This test checks basic load balancing.
-
-    The following is the scenario outline:
-    1. Create an instance
-    2. SSH to the instance and start two servers
-    3. Create a load balancer with two members and with ROUND_ROBIN algorithm
-       associate the VIP with a floating ip
-    4. Send NUM requests to the floating ip and check that they are shared
-       between the two servers.
-    """
-
-    @classmethod
-    def skip_checks(cls):
-        super(TestLoadBalancerBasic, cls).skip_checks()
-        cfg = config.network
-        if not test.is_extension_enabled('lbaas', 'network'):
-            msg = 'LBaaS Extension is not enabled'
-            raise cls.skipException(msg)
-        if not (cfg.tenant_networks_reachable or cfg.public_network_id):
-            msg = ('Either tenant_networks_reachable must be "true", or '
-                   'public_network_id must be defined.')
-            raise cls.skipException(msg)
-
-    @classmethod
-    def resource_setup(cls):
-        super(TestLoadBalancerBasic, cls).resource_setup()
-        cls.servers_keypairs = {}
-        cls.members = []
-        cls.floating_ips = {}
-        cls.server_ips = {}
-        cls.port1 = 80
-        cls.port2 = 88
-        cls.num = 50
-
-    def setUp(self):
-        super(TestLoadBalancerBasic, self).setUp()
-        self.server_ips = {}
-        self.server_fixed_ips = {}
-        self._create_security_group_for_test()
-        self._set_net_and_subnet()
-
-    def _set_net_and_subnet(self):
-        """
-        Query and set appropriate network and subnet attributes to be used
-        for the test.  Existing tenant networks are used if they are found.
-        The configured private network and associated subnet is used as a
-        fallback in absence of tenant networking.
-        """
-        try:
-            tenant_net = self._list_networks(tenant_id=self.tenant_id)[0]
-        except IndexError:
-            tenant_net = None
-
-        if tenant_net:
-            tenant_subnet = self._list_subnets(tenant_id=self.tenant_id)[0]
-            self.subnet = net_resources.DeletableSubnet(
-                client=self.network_client,
-                **tenant_subnet)
-            self.network = tenant_net
-        else:
-            self.network = self._get_network_by_name(
-                config.compute.fixed_network_name)
-            # TODO(adam_g): We are assuming that the first subnet associated
-            # with the fixed network is the one we want.  In the future, we
-            # should instead pull a subnet id from config, which is set by
-            # devstack/admin/etc.
-            subnet = self._list_subnets(network_id=self.network['id'])[0]
-            self.subnet = net_resources.AttributeDict(subnet)
-
-    def _create_security_group_for_test(self):
-        self.security_group = self._create_security_group(
-            tenant_id=self.tenant_id)
-        self._create_security_group_rules_for_port(self.port1)
-        self._create_security_group_rules_for_port(self.port2)
-
-    def _create_security_group_rules_for_port(self, port):
-        rule = {
-            'direction': 'ingress',
-            'protocol': 'tcp',
-            'port_range_min': port,
-            'port_range_max': port,
-        }
-        self._create_security_group_rule(
-            secgroup=self.security_group,
-            tenant_id=self.tenant_id,
-            **rule)
-
-    def _create_server(self, name):
-        keypair = self.create_keypair()
-        security_groups = [{'name': self.security_group['name']}]
-        create_kwargs = {
-            'networks': [
-                {'uuid': self.network['id']},
-            ],
-            'key_name': keypair['name'],
-            'security_groups': security_groups,
-        }
-        net_name = self.network['name']
-        server = self.create_server(name=name, create_kwargs=create_kwargs)
-        self.servers_keypairs[server['id']] = keypair
-        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(
-                server, public_network_id)
-            self.floating_ips[floating_ip] = server
-            self.server_ips[server['id']] = floating_ip.floating_ip_address
-        else:
-            self.server_ips[server['id']] =\
-                server['addresses'][net_name][0]['addr']
-        self.server_fixed_ips[server['id']] =\
-            server['addresses'][net_name][0]['addr']
-        self.assertTrue(self.servers_keypairs)
-        return server
-
-    def _create_servers(self):
-        for count in range(2):
-            self._create_server(name=("server%s" % (count + 1)))
-        self.assertEqual(len(self.servers_keypairs), 2)
-
-    def _start_servers(self):
-        """
-        Start two backends
-
-        1. SSH to the instance
-        2. Start two http backends listening on ports 80 and 88 respectively
-        """
-        for server_id, ip in six.iteritems(self.server_ips):
-            private_key = self.servers_keypairs[server_id]['private_key']
-            server_name = self.servers_client.get_server(server_id)['name']
-            username = config.scenario.ssh_user
-            ssh_client = self.get_remote_client(
-                server_or_ip=ip,
-                private_key=private_key)
-
-            # Write a backend's response into a file
-            resp = ('echo -ne "HTTP/1.1 200 OK\r\nContent-Length: 7\r\n'
-                    'Connection: close\r\nContent-Type: text/html; '
-                    'charset=UTF-8\r\n\r\n%s"; cat >/dev/null')
-
-            with tempfile.NamedTemporaryFile() as script:
-                script.write(resp % server_name)
-                script.flush()
-                with tempfile.NamedTemporaryFile() as key:
-                    key.write(private_key)
-                    key.flush()
-                    commands.copy_file_to_host(script.name,
-                                               "/tmp/script1",
-                                               ip,
-                                               username, key.name)
-
-            # Start netcat
-            start_server = ('while true; do '
-                            'sudo nc -ll -p %(port)s -e sh /tmp/%(script)s; '
-                            'done > /dev/null &')
-            cmd = start_server % {'port': self.port1,
-                                  'script': 'script1'}
-            ssh_client.exec_command(cmd)
-
-            if len(self.server_ips) == 1:
-                with tempfile.NamedTemporaryFile() as script:
-                    script.write(resp % 'server2')
-                    script.flush()
-                    with tempfile.NamedTemporaryFile() as key:
-                        key.write(private_key)
-                        key.flush()
-                        commands.copy_file_to_host(script.name,
-                                                   "/tmp/script2", ip,
-                                                   username, key.name)
-                cmd = start_server % {'port': self.port2,
-                                      'script': 'script2'}
-                ssh_client.exec_command(cmd)
-
-    def _check_connection(self, check_ip, port=80):
-        def try_connect(ip, port):
-            try:
-                resp = urllib2.urlopen("http://{0}:{1}/".format(ip, port))
-                if resp.getcode() == 200:
-                    return True
-                return False
-            except IOError:
-                return False
-            except urllib2.HTTPError:
-                return False
-        timeout = config.compute.ping_timeout
-        start = time.time()
-        while not try_connect(check_ip, port):
-            if (time.time() - start) > timeout:
-                message = "Timed out trying to connect to %s" % check_ip
-                raise exceptions.TimeoutException(message)
-
-    def _create_pool(self):
-        """Create a pool with ROUND_ROBIN algorithm."""
-        self.pool = super(TestLoadBalancerBasic, self)._create_pool(
-            lb_method='ROUND_ROBIN',
-            protocol='HTTP',
-            subnet_id=self.subnet.id)
-        self.assertTrue(self.pool)
-
-    def _create_members(self):
-        """
-        Create two members.
-
-        In case there is only one server, create both members with the same ip
-        but with different ports to listen on.
-        """
-
-        for server_id, ip in six.iteritems(self.server_fixed_ips):
-            if len(self.server_fixed_ips) == 1:
-                member1 = self._create_member(address=ip,
-                                              protocol_port=self.port1,
-                                              pool_id=self.pool.id)
-                member2 = self._create_member(address=ip,
-                                              protocol_port=self.port2,
-                                              pool_id=self.pool.id)
-                self.members.extend([member1, member2])
-            else:
-                member = self._create_member(address=ip,
-                                             protocol_port=self.port1,
-                                             pool_id=self.pool.id)
-                self.members.append(member)
-        self.assertTrue(self.members)
-
-    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)
-        self.floating_ips.setdefault(vip.id, [])
-        self.floating_ips[vip.id].append(floating_ip)
-        # Check for floating ip status before you check load-balancer
-        self.check_floating_ip_status(floating_ip, "ACTIVE")
-
-    def _create_load_balancer(self):
-        self._create_pool()
-        self._create_members()
-        self.vip = self._create_vip(protocol='HTTP',
-                                    protocol_port=80,
-                                    subnet_id=self.subnet.id,
-                                    pool_id=self.pool.id)
-        self.vip.wait_for_status('ACTIVE')
-        if (config.network.public_network_id and not
-                config.network.tenant_networks_reachable):
-            self._assign_floating_ip_to_vip(self.vip)
-            self.vip_ip = self.floating_ips[
-                self.vip.id][0]['floating_ip_address']
-        else:
-            self.vip_ip = self.vip.address
-
-        # Currently the ovs-agent is not enforcing security groups on the
-        # vip port - see https://bugs.launchpad.net/neutron/+bug/1163569
-        # However the linuxbridge-agent does, and it is necessary to add a
-        # security group with a rule that allows tcp port 80 to the vip port.
-        self.network_client.update_port(
-            self.vip.port_id, security_groups=[self.security_group.id])
-
-    def _check_load_balancing(self):
-        """
-        1. Send NUM requests on the floating ip associated with the VIP
-        2. Check that the requests are shared between the two servers
-        """
-
-        self._check_connection(self.vip_ip)
-        self._send_requests(self.vip_ip, ["server1", "server2"])
-
-    def _send_requests(self, vip_ip, servers):
-        counters = dict.fromkeys(servers, 0)
-        for i in range(self.num):
-            try:
-                server = urllib2.urlopen("http://{0}/".format(vip_ip)).read()
-                counters[server] += 1
-            # HTTP exception means fail of server, so don't increase counter
-            # of success and continue connection tries
-            except urllib2.HTTPError:
-                continue
-        # Assert that each member of the pool gets balanced at least once
-        for member, counter in six.iteritems(counters):
-            self.assertGreater(counter, 0, 'Member %s never balanced' % member)
-
-    @test.idempotent_id('c0c6f1ca-603b-4509-9c0f-2c63f0d838ee')
-    @test.services('compute', 'network')
-    def test_load_balancer_basic(self):
-        self._create_server('server1')
-        self._start_servers()
-        self._create_load_balancer()
-        self._check_load_balancing()
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index e93cc47..4e1388d 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -42,34 +42,18 @@
     def get_uri(self, plural_name):
         # get service prefix from resource name
 
-        # The following list represents resource names that do not require
-        # changing underscore to a hyphen
-        hyphen_exceptions = ["health_monitors", "firewall_rules",
-                             "firewall_policies"]
         # the following map is used to construct proper URI
         # for the given neutron resource
         service_resource_prefix_map = {
             'networks': '',
             'subnets': '',
             'ports': '',
-            'pools': 'lb',
-            'vips': 'lb',
-            'health_monitors': 'lb',
-            'members': 'lb',
-            'ipsecpolicies': 'vpn',
-            'vpnservices': 'vpn',
-            'ikepolicies': 'vpn',
-            'ipsec-site-connections': 'vpn',
             'metering_labels': 'metering',
             'metering_label_rules': 'metering',
-            'firewall_rules': 'fw',
-            'firewall_policies': 'fw',
-            'firewalls': 'fw'
         }
         service_prefix = service_resource_prefix_map.get(
             plural_name)
-        if plural_name not in hyphen_exceptions:
-            plural_name = plural_name.replace("_", "-")
+        plural_name = plural_name.replace("_", "-")
         if service_prefix:
             uri = '%s/%s/%s' % (self.uri_prefix, service_prefix,
                                 plural_name)
@@ -85,11 +69,7 @@
         resource_plural_map = {
             'security_groups': 'security_groups',
             'security_group_rules': 'security_group_rules',
-            'ipsecpolicy': 'ipsecpolicies',
-            'ikepolicy': 'ikepolicies',
-            'ipsec_site_connection': 'ipsec-site-connections',
             'quotas': 'quotas',
-            'firewall_policy': 'firewall_policies'
         }
         return resource_plural_map.get(resource_name, resource_name + 's')
 
@@ -385,29 +365,6 @@
         body = json.loads(body)
         return service_client.ResponseBody(resp, body)
 
-    def associate_health_monitor_with_pool(self, health_monitor_id,
-                                           pool_id):
-        post_body = {
-            "health_monitor": {
-                "id": health_monitor_id,
-            }
-        }
-        body = json.dumps(post_body)
-        uri = '%s/lb/pools/%s/health_monitors' % (self.uri_prefix,
-                                                  pool_id)
-        resp, body = self.post(uri, body)
-        self.expected_success(201, resp.status)
-        body = json.loads(body)
-        return service_client.ResponseBody(resp, body)
-
-    def disassociate_health_monitor_with_pool(self, health_monitor_id,
-                                              pool_id):
-        uri = '%s/lb/pools/%s/health_monitors/%s' % (self.uri_prefix, pool_id,
-                                                     health_monitor_id)
-        resp, body = self.delete(uri)
-        self.expected_success(204, resp.status)
-        return service_client.ResponseBody(resp, body)
-
     def list_router_interfaces(self, uuid):
         uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
         resp, body = self.get(uri)
@@ -428,21 +385,6 @@
         body = json.loads(body)
         return service_client.ResponseBody(resp, body)
 
-    def list_pools_hosted_by_one_lbaas_agent(self, agent_id):
-        uri = '%s/agents/%s/loadbalancer-pools' % (self.uri_prefix, agent_id)
-        resp, body = self.get(uri)
-        self.expected_success(200, resp.status)
-        body = json.loads(body)
-        return service_client.ResponseBody(resp, body)
-
-    def show_lbaas_agent_hosting_pool(self, pool_id):
-        uri = ('%s/lb/pools/%s/loadbalancer-agent' %
-               (self.uri_prefix, pool_id))
-        resp, body = self.get(uri)
-        self.expected_success(200, resp.status)
-        body = json.loads(body)
-        return service_client.ResponseBody(resp, body)
-
     def list_routers_on_l3_agent(self, agent_id):
         uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
         resp, body = self.get(uri)
@@ -494,21 +436,6 @@
         self.expected_success(204, resp.status)
         return service_client.ResponseBody(resp, body)
 
-    def create_ikepolicy(self, name, **kwargs):
-        post_body = {
-            "ikepolicy": {
-                "name": name,
-            }
-        }
-        for key, val in kwargs.items():
-            post_body['ikepolicy'][key] = val
-        body = json.dumps(post_body)
-        uri = '%s/vpn/ikepolicies' % (self.uri_prefix)
-        resp, body = self.post(uri, body)
-        self.expected_success(201, resp.status)
-        body = json.loads(body)
-        return service_client.ResponseBody(resp, body)
-
     def update_extra_routes(self, router_id, nexthop, destination):
         uri = '%s/routers/%s' % (self.uri_prefix, router_id)
         put_body = {
@@ -537,13 +464,6 @@
         body = json.loads(body)
         return service_client.ResponseBody(resp, body)
 
-    def list_lb_pool_stats(self, pool_id):
-        uri = '%s/lb/pools/%s/stats' % (self.uri_prefix, pool_id)
-        resp, body = self.get(uri)
-        self.expected_success(200, resp.status)
-        body = json.loads(body)
-        return service_client.ResponseBody(resp, body)
-
     def add_dhcp_agent_to_network(self, agent_id, network_id):
         post_body = {'network_id': network_id}
         body = json.dumps(post_body)
@@ -552,30 +472,3 @@
         self.expected_success(201, resp.status)
         body = json.loads(body)
         return service_client.ResponseBody(resp, body)
-
-    def insert_firewall_rule_in_policy(self, firewall_policy_id,
-                                       firewall_rule_id, insert_after="",
-                                       insert_before=""):
-        uri = '%s/fw/firewall_policies/%s/insert_rule' % (self.uri_prefix,
-                                                          firewall_policy_id)
-        body = {
-            "firewall_rule_id": firewall_rule_id,
-            "insert_after": insert_after,
-            "insert_before": insert_before
-        }
-        body = json.dumps(body)
-        resp, body = self.put(uri, body)
-        self.expected_success(200, resp.status)
-        body = json.loads(body)
-        return service_client.ResponseBody(resp, body)
-
-    def remove_firewall_rule_from_policy(self, firewall_policy_id,
-                                         firewall_rule_id):
-        uri = '%s/fw/firewall_policies/%s/remove_rule' % (self.uri_prefix,
-                                                          firewall_policy_id)
-        update_body = {"firewall_rule_id": firewall_rule_id}
-        update_body = json.dumps(update_body)
-        resp, body = self.put(uri, update_body)
-        self.expected_success(200, resp.status)
-        body = json.loads(body)
-        return service_client.ResponseBody(resp, body)
