Ejemplo n.º 1
0
 def test_loadbalancer_update(self, mock_cast):
     old_provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id)
     provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id, admin_state_up=True)
     lb_dict = {'enabled': True}
     self.amp_driver.loadbalancer_update(old_provider_lb, provider_lb)
     payload = {consts.ORIGINAL_LOADBALANCER: old_provider_lb.to_dict(),
                consts.LOAD_BALANCER_UPDATES: lb_dict}
     mock_cast.assert_called_with({}, 'update_load_balancer', **payload)
Ejemplo n.º 2
0
 def test_loadbalancer_update_name(self, mock_cast):
     old_provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id)
     provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id, name='Great LB')
     lb_dict = {'name': 'Great LB'}
     self.amp_driver.loadbalancer_update(old_provider_lb, provider_lb)
     payload = {consts.ORIGINAL_LOADBALANCER: old_provider_lb.to_dict(),
                consts.LOAD_BALANCER_UPDATES: lb_dict}
     mock_cast.assert_called_with({}, 'update_load_balancer', **payload)
Ejemplo n.º 3
0
 def test_loadbalancer_update_qos(self, mock_cast):
     qos_policy_id = uuidutils.generate_uuid()
     old_provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id)
     provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id,
         vip_qos_policy_id=qos_policy_id)
     lb_dict = {'vip': {'qos_policy_id': qos_policy_id}}
     self.amp_driver.loadbalancer_update(old_provider_lb, provider_lb)
     payload = {consts.ORIGINAL_LOADBALANCER: old_provider_lb.to_dict(),
                consts.LOAD_BALANCER_UPDATES: lb_dict}
     mock_cast.assert_called_with({}, 'update_load_balancer', **payload)
Ejemplo n.º 4
0
 def test_loadbalancer_delete(self, mock_cast):
     provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id)
     self.amp_driver.loadbalancer_delete(provider_lb)
     payload = {consts.LOADBALANCER: provider_lb.to_dict(),
                'cascade': False}
     mock_cast.assert_called_with({}, 'delete_load_balancer', **payload)
Ejemplo n.º 5
0
 def test_loadbalancer_create(self, mock_cast):
     provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id)
     self.amp_driver.loadbalancer_create(provider_lb)
     payload = {consts.LOAD_BALANCER_ID: self.sample_data.lb_id,
                consts.FLAVOR: None}
     mock_cast.assert_called_with({}, 'create_load_balancer', **payload)
Ejemplo n.º 6
0
 def test_loadbalancer_create(self, mock_cast):
     provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=self.sample_data.lb_id)
     self.amp_driver.loadbalancer_create(provider_lb)
     payload = {consts.LOADBALANCER: provider_lb.to_dict(),
                consts.FLAVOR: None,
                consts.AVAILABILITY_ZONE: None}
     mock_cast.assert_called_with({}, 'create_load_balancer', **payload)
Ejemplo n.º 7
0
    def _create_lb_model(self, vip=None, vip_network_id=None,
                         admin_state_up=True):
        lb = octavia_data_model.LoadBalancer()
        lb.loadbalancer_id = uuidutils.generate_uuid()

        if vip:
            lb.vip_address = vip
        else:
            lb.vip_address = '10.0.0.4'

        if vip_network_id:
            lb.vip_network_id = vip_network_id
        lb.admin_state_up = admin_state_up
        return lb
Ejemplo n.º 8
0
    def test_to_dict_recursive_partial(self):
        ref_lb = data_models.LoadBalancer(loadbalancer_id=self.loadbalancer_id,
                                          listeners=[self.ref_listener])

        ref_lb_dict_with_listener = {
            'loadbalancer_id': self.loadbalancer_id,
            'listeners': [self.ref_listener_dict]
        }

        # Render with unsets is not set, so remove the Unset description
        ref_lb_dict_with_listener = deepcopy(ref_lb_dict_with_listener)
        ref_lb_dict_with_listener['listeners'][0].pop('description', None)

        ref_lb_converted_to_dict = ref_lb.to_dict(recurse=True)

        self.assertEqual(ref_lb_dict_with_listener, ref_lb_converted_to_dict)
Ejemplo n.º 9
0
 def test_db_loadbalancer_to_provider_loadbalancer(self, mock_get_session,
                                                   mock_get_flavor):
     mock_get_flavor.return_value = {'shaved_ice': 'cherry'}
     vip = data_models.Vip(ip_address=self.sample_data.ip_address,
                           network_id=self.sample_data.network_id,
                           port_id=self.sample_data.port_id,
                           subnet_id=self.sample_data.subnet_id)
     test_db_lb = data_models.LoadBalancer(id=1, flavor_id='2', vip=vip)
     provider_lb = utils.db_loadbalancer_to_provider_loadbalancer(
         test_db_lb)
     ref_provider_lb = driver_dm.LoadBalancer(
         loadbalancer_id=1,
         flavor={'shaved_ice': 'cherry'},
         vip_address=self.sample_data.ip_address,
         vip_network_id=self.sample_data.network_id,
         vip_port_id=self.sample_data.port_id,
         vip_subnet_id=self.sample_data.subnet_id)
     self.assertEqual(ref_provider_lb.to_dict(render_unsets=True),
                      provider_lb.to_dict(render_unsets=True))
Ejemplo n.º 10
0
    def test_to_dict_recursive_render_unset(self):
        ref_lb = data_models.LoadBalancer(
            admin_state_up=False,
            description='One great load balancer',
            flavor={'cake': 'chocolate'},
            listeners=[self.ref_listener],
            loadbalancer_id=self.loadbalancer_id,
            project_id=self.project_id,
            vip_address=self.vip_address,
            vip_network_id=self.vip_network_id,
            vip_port_id=self.vip_port_id,
            vip_subnet_id=self.vip_subnet_id,
            vip_qos_policy_id=self.vip_qos_policy_id)

        ref_lb_dict_with_listener = deepcopy(self.ref_lb_dict_with_listener)
        ref_lb_dict_with_listener['pools'] = None
        ref_lb_dict_with_listener['name'] = None
        ref_lb_dict_with_listener['additional_vips'] = None

        ref_lb_converted_to_dict = ref_lb.to_dict(recurse=True,
                                                  render_unsets=True)

        self.assertEqual(ref_lb_dict_with_listener, ref_lb_converted_to_dict)
Ejemplo n.º 11
0
    def setUp(self):
        super().setUp()
        self.driver = ovn_driver.OvnProviderDriver()
        add_req_thread = mock.patch.object(ovn_helper.OvnProviderHelper,
                                           'add_request')
        self.member_line = ('member_%s_%s:%s_%s' %
                            (self.member_id, self.member_address,
                             self.member_port, self.member_subnet_id))
        self.ovn_lb = mock.MagicMock()
        self.ovn_lb.name = 'foo_ovn_lb'
        self.ovn_lb.external_ids = {
            ovn_const.LB_EXT_IDS_VIP_KEY: '10.22.33.4',
            'pool_%s' % self.pool_id: self.member_line,
            'listener_%s' % self.listener_id: '80:pool_%s' % self.pool_id
        }
        self.mock_add_request = add_req_thread.start()
        self.project_id = uuidutils.generate_uuid()

        self.fail_member = data_models.Member(
            address='198.51.100.4',
            admin_state_up=True,
            member_id=self.member_id,
            monitor_address="100.200.200.100",
            monitor_port=66,
            name='Amazin',
            pool_id=self.pool_id,
            protocol_port=99,
            subnet_id=self.member_subnet_id,
            weight=55)
        self.ref_member = data_models.Member(address='198.52.100.4',
                                             admin_state_up=True,
                                             member_id=self.member_id,
                                             monitor_address=data_models.Unset,
                                             monitor_port=data_models.Unset,
                                             name='Amazing',
                                             pool_id=self.pool_id,
                                             protocol_port=99,
                                             subnet_id=self.member_subnet_id,
                                             weight=55)
        self.update_member = data_models.Member(
            address='198.53.100.4',
            admin_state_up=False,
            member_id=self.member_id,
            monitor_address=data_models.Unset,
            monitor_port=data_models.Unset,
            name='Amazin',
            pool_id=self.pool_id,
            protocol_port=99,
            subnet_id=self.member_subnet_id,
            weight=55)
        self.ref_update_pool = data_models.Pool(
            admin_state_up=False,
            description='pool',
            name='Peter',
            lb_algorithm=constants.LB_ALGORITHM_SOURCE_IP_PORT,
            loadbalancer_id=self.loadbalancer_id,
            listener_id=self.listener_id,
            members=[self.ref_member],
            pool_id=self.pool_id,
            protocol='TCP',
            session_persistence={'type': 'fix'})
        self.ref_pool = data_models.Pool(
            admin_state_up=True,
            description='pool',
            name='Peter',
            lb_algorithm=constants.LB_ALGORITHM_SOURCE_IP_PORT,
            loadbalancer_id=self.loadbalancer_id,
            listener_id=self.listener_id,
            members=[self.ref_member],
            pool_id=self.pool_id,
            protocol='TCP',
            session_persistence={'type': 'fix'})
        self.ref_http_pool = data_models.Pool(
            admin_state_up=True,
            description='pool',
            lb_algorithm=constants.LB_ALGORITHM_SOURCE_IP_PORT,
            loadbalancer_id=self.loadbalancer_id,
            listener_id=self.listener_id,
            members=[self.ref_member],
            name='Groot',
            pool_id=self.pool_id,
            protocol='HTTP',
            session_persistence={'type': 'fix'})
        self.ref_lc_pool = data_models.Pool(
            admin_state_up=True,
            description='pool',
            lb_algorithm=constants.LB_ALGORITHM_LEAST_CONNECTIONS,
            loadbalancer_id=self.loadbalancer_id,
            listener_id=self.listener_id,
            members=[self.ref_member],
            name='Groot',
            pool_id=self.pool_id,
            protocol='HTTP',
            session_persistence={'type': 'fix'})
        self.ref_listener = data_models.Listener(
            admin_state_up=False,
            connection_limit=5,
            default_pool=self.ref_pool,
            default_pool_id=self.pool_id,
            listener_id=self.listener_id,
            loadbalancer_id=self.loadbalancer_id,
            name='listener',
            protocol='TCP',
            protocol_port=42)
        self.ref_listener_udp = data_models.Listener(
            admin_state_up=False,
            connection_limit=5,
            default_pool=self.ref_pool,
            default_pool_id=self.pool_id,
            listener_id=self.listener_id,
            loadbalancer_id=self.loadbalancer_id,
            name='listener',
            protocol='UDP',
            protocol_port=42)
        self.ref_listener_sctp = data_models.Listener(
            admin_state_up=False,
            connection_limit=5,
            default_pool=self.ref_pool,
            default_pool_id=self.pool_id,
            listener_id=self.listener_id,
            loadbalancer_id=self.loadbalancer_id,
            name='listener',
            protocol='SCTP',
            protocol_port=42)
        self.fail_listener = data_models.Listener(
            admin_state_up=False,
            connection_limit=5,
            default_pool=self.ref_pool,
            default_pool_id=self.pool_id,
            listener_id=self.listener_id,
            loadbalancer_id=self.loadbalancer_id,
            name='listener',
            protocol='http',
            protocol_port=42)
        self.ref_lb_fully_populated = data_models.LoadBalancer(
            admin_state_up=False,
            listeners=[self.ref_listener],
            pools=[self.ref_pool],
            loadbalancer_id=self.loadbalancer_id,
            name='favorite_lb0',
            project_id=self.project_id,
            vip_address=self.vip_address,
            vip_network_id=self.vip_network_id)
        self.ref_lb0 = data_models.LoadBalancer(
            admin_state_up=False,
            listeners=[self.ref_listener],
            loadbalancer_id=self.loadbalancer_id,
            name='favorite_lb0',
            project_id=self.project_id,
            vip_address=self.vip_address,
            vip_network_id=self.vip_network_id)
        self.ref_lb1 = data_models.LoadBalancer(
            admin_state_up=True,
            listeners=[self.ref_listener],
            loadbalancer_id=self.loadbalancer_id,
            name='favorite_lb1',
            project_id=self.project_id,
            vip_address=self.vip_address,
            vip_network_id=self.vip_network_id)
        self.fail_health_monitor = data_models.HealthMonitor(
            admin_state_up=True,
            name='UnHealthy',
            pool_id=self.pool_id,
            healthmonitor_id=self.healthmonitor_id,
            type="not_valid",
            delay=1,
            timeout=2,
            max_retries_down=3,
            max_retries=4)
        self.ref_health_monitor = data_models.HealthMonitor(
            admin_state_up=True,
            name='Healthy',
            pool_id=self.pool_id,
            healthmonitor_id=self.healthmonitor_id,
            type=constants.HEALTH_MONITOR_TCP,
            delay=6,
            timeout=7,
            max_retries_down=5,
            max_retries=3)
        self.ref_update_health_monitor = data_models.HealthMonitor(
            admin_state_up=True,
            name='ReHealthy',
            healthmonitor_id=self.healthmonitor_id,
            delay=16,
            timeout=17,
            max_retries_down=15,
            max_retries=13)
        mock.patch.object(ovn_helper.OvnProviderHelper,
                          '_find_ovn_lbs',
                          side_effect=lambda x, protocol=None: self.ovn_lb
                          if protocol else [self.ovn_lb]).start()
        self.mock_find_lb_pool_key = mock.patch.object(
            ovn_helper.OvnProviderHelper,
            '_find_ovn_lb_with_pool_key',
            return_value=self.ovn_lb).start()
        self.mock_get_subnet_from_pool = mock.patch.object(
            ovn_helper.OvnProviderHelper,
            '_get_subnet_from_pool',
            return_value=None).start()
Ejemplo n.º 12
0
    def setUp(self):
        super(TestNsxProviderDriver, self).setUp()
        global code_ok
        if not code_ok:
            return
        # init the NSX driver without the RPC & certificate
        with mock.patch(DRIVER + '._init_rpc_messaging'), \
            mock.patch(DRIVER + '._init_rpc_listener'), \
            mock.patch(DRIVER + '._init_cert_manager'):
            self.driver = driver.NSXOctaviaDriver()
            self.driver.client = mock.Mock()

        self.loadbalancer_id = uuidutils.generate_uuid()
        self.vip_address = '192.0.2.10'
        self.vip_network_id = uuidutils.generate_uuid()
        self.vip_port_id = uuidutils.generate_uuid()
        self.vip_subnet_id = uuidutils.generate_uuid()
        self.listener_id = uuidutils.generate_uuid()
        self.pool_id = uuidutils.generate_uuid()
        self.member_id = uuidutils.generate_uuid()
        self.member_subnet_id = uuidutils.generate_uuid()
        self.healthmonitor_id = uuidutils.generate_uuid()
        self.l7policy_id = uuidutils.generate_uuid()
        self.l7rule_id = uuidutils.generate_uuid()
        self.project_id = uuidutils.generate_uuid()
        self.default_tls_container_ref = uuidutils.generate_uuid()
        self.sni_container_ref_1 = uuidutils.generate_uuid()
        self.sni_container_ref_2 = uuidutils.generate_uuid()

        self.ref_member = data_models.Member(
            address='198.51.100.4',
            admin_state_up=True,
            member_id=self.member_id,
            monitor_address='203.0.113.2',
            monitor_port=66,
            name='jacket',
            pool_id=self.pool_id,
            protocol_port=99,
            subnet_id=self.member_subnet_id,
            weight=55)

        self.ref_healthmonitor = data_models.HealthMonitor(
            admin_state_up=False,
            delay=2,
            expected_codes="500",
            healthmonitor_id=self.healthmonitor_id,
            http_method='TRACE',
            max_retries=1,
            max_retries_down=0,
            name='doc',
            pool_id=self.pool_id,
            timeout=3,
            type='PHD',
            url_path='/index.html')

        self.ref_pool = data_models.Pool(
            admin_state_up=True,
            description='Olympic swimming pool',
            healthmonitor=self.ref_healthmonitor,
            lb_algorithm='A_Fast_One',
            loadbalancer_id=self.loadbalancer_id,
            members=[self.ref_member],
            name='Osborn',
            pool_id=self.pool_id,
            protocol='avian',
            session_persistence={'type': 'glue'})

        self.ref_l7rule = data_models.L7Rule(
            admin_state_up=True,
            compare_type='store_brand',
            invert=True,
            key='board',
            l7policy_id=self.l7policy_id,
            l7rule_id=self.l7rule_id,
            type='strict',
            value='gold')

        self.ref_l7policy = data_models.L7Policy(
            action='packed',
            admin_state_up=False,
            description='Corporate policy',
            l7policy_id=self.l7policy_id,
            listener_id=self.listener_id,
            name='more_policy',
            position=1,
            redirect_pool_id=self.pool_id,
            redirect_url='/hr',
            rules=[self.ref_l7rule])

        self.ref_listener = data_models.Listener(
            admin_state_up=False,
            connection_limit=5,
            default_pool=self.ref_pool,
            default_pool_id=self.pool_id,
            default_tls_container_data='default_cert_data',
            default_tls_container_ref=self.default_tls_container_ref,
            description='The listener',
            insert_headers={'X-Forwarded-For': 'true'},
            l7policies=[self.ref_l7policy],
            listener_id=self.listener_id,
            loadbalancer_id=self.loadbalancer_id,
            name='super_listener',
            protocol='avian',
            protocol_port=42,
            sni_container_data=['sni_cert_data_1', 'sni_cert_data_2'],
            sni_container_refs=[self.sni_container_ref_1,
                                self.sni_container_ref_2])

        self.ref_lb = data_models.LoadBalancer(
            admin_state_up=False,
            description='One great load balancer',
            flavor={'cake': 'chocolate'},
            listeners=[self.ref_listener],
            loadbalancer_id=self.loadbalancer_id,
            name='favorite_lb',
            project_id=self.project_id,
            vip_address=self.vip_address,
            vip_network_id=self.vip_network_id,
            vip_port_id=self.vip_port_id,
            vip_subnet_id=self.vip_subnet_id)

        # start DB mocks
        mock.patch('octavia.db.api.get_session').start()
        mock.patch("octavia.api.drivers.utils.db_pool_to_provider_pool",
                   return_value=self.ref_pool).start()
Ejemplo n.º 13
0
    def setUp(self):
        super().setUp()
        self.driver = driver.NoopProviderDriver()

        self.loadbalancer_id = uuidutils.generate_uuid()
        self.vip_address = '192.0.2.10'
        self.vip_network_id = uuidutils.generate_uuid()
        self.vip_port_id = uuidutils.generate_uuid()
        self.vip_subnet_id = uuidutils.generate_uuid()
        self.listener_id = uuidutils.generate_uuid()
        self.pool_id = uuidutils.generate_uuid()
        self.member_id = uuidutils.generate_uuid()
        self.member_subnet_id = uuidutils.generate_uuid()
        self.healthmonitor_id = uuidutils.generate_uuid()
        self.l7policy_id = uuidutils.generate_uuid()
        self.l7rule_id = uuidutils.generate_uuid()
        self.project_id = uuidutils.generate_uuid()
        self.default_tls_container_ref = uuidutils.generate_uuid()
        self.sni_container_ref_1 = uuidutils.generate_uuid()
        self.sni_container_ref_2 = uuidutils.generate_uuid()

        self.ref_vip = data_models.VIP(vip_address=self.vip_address,
                                       vip_network_id=self.vip_network_id,
                                       vip_port_id=self.vip_port_id,
                                       vip_subnet_id=self.vip_subnet_id)

        self.ref_member = data_models.Member(address='198.51.100.4',
                                             admin_state_up=True,
                                             member_id=self.member_id,
                                             monitor_address='203.0.113.2',
                                             monitor_port=66,
                                             name='jacket',
                                             pool_id=self.pool_id,
                                             protocol_port=99,
                                             subnet_id=self.member_subnet_id,
                                             weight=55)

        self.ref_healthmonitor = data_models.HealthMonitor(
            admin_state_up=False,
            delay=2,
            expected_codes="500",
            healthmonitor_id=self.healthmonitor_id,
            http_method='TRACE',
            max_retries=1,
            max_retries_down=0,
            name='doc',
            pool_id=self.pool_id,
            timeout=3,
            type='PHD',
            url_path='/index.html')

        self.ref_pool = data_models.Pool(admin_state_up=True,
                                         description='Olympic swimming pool',
                                         healthmonitor=self.ref_healthmonitor,
                                         lb_algorithm='A_Fast_One',
                                         loadbalancer_id=self.loadbalancer_id,
                                         listener_id=self.listener_id,
                                         members=[self.ref_member],
                                         name='Osborn',
                                         pool_id=self.pool_id,
                                         protocol='avian',
                                         session_persistence={'type': 'glue'})

        self.ref_l7rule = data_models.L7Rule(admin_state_up=True,
                                             compare_type='store_brand',
                                             invert=True,
                                             key='board',
                                             l7policy_id=self.l7policy_id,
                                             l7rule_id=self.l7rule_id,
                                             type='strict',
                                             value='gold')

        self.ref_l7policy = data_models.L7Policy(
            action='packed',
            admin_state_up=False,
            description='Corporate policy',
            l7policy_id=self.l7policy_id,
            listener_id=self.listener_id,
            name='more_policy',
            position=1,
            redirect_pool_id=self.pool_id,
            redirect_url='/hr',
            rules=[self.ref_l7rule])

        self.ref_listener = data_models.Listener(
            admin_state_up=False,
            connection_limit=5,
            default_pool=self.ref_pool,
            default_pool_id=self.pool_id,
            default_tls_container_data='default_cert_data',
            default_tls_container_ref=self.default_tls_container_ref,
            description='The listener',
            insert_headers={'X-Forwarded-For': 'true'},
            l7policies=[self.ref_l7policy],
            listener_id=self.listener_id,
            loadbalancer_id=self.loadbalancer_id,
            name='super_listener',
            protocol='avian',
            protocol_port=42,
            sni_container_data=['sni_cert_data_1', 'sni_cert_data_2'],
            sni_container_refs=[
                self.sni_container_ref_1, self.sni_container_ref_2
            ])

        self.ref_lb = data_models.LoadBalancer(
            admin_state_up=False,
            description='One great load balancer',
            flavor={'cake': 'chocolate'},
            listeners=[self.ref_listener],
            loadbalancer_id=self.loadbalancer_id,
            name='favorite_lb',
            project_id=self.project_id,
            vip_address=self.vip_address,
            vip_network_id=self.vip_network_id,
            vip_port_id=self.vip_port_id,
            vip_subnet_id=self.vip_subnet_id)

        self.ref_flavor_metadata = {
            "amp_image_tag":
            "The glance image tag "
            "to use for this load balancer."
        }
        self.ref_availability_zone_metadata = {
            "compute_zone":
            "The compute availability zone to use for this "
            "loadbalancer."
        }
Ejemplo n.º 14
0
    def test_to_dict_partial(self):
        ref_lb = data_models.LoadBalancer(loadbalancer_id=self.loadbalancer_id)
        ref_lb_dict = {'loadbalancer_id': self.loadbalancer_id}
        ref_lb_converted_to_dict = ref_lb.to_dict()

        self.assertEqual(ref_lb_dict, ref_lb_converted_to_dict)
Ejemplo n.º 15
0
    def setUp(self):
        super(TestProviderDataModels, self).setUp()

        self.loadbalancer_id = uuidutils.generate_uuid()
        self.project_id = uuidutils.generate_uuid()
        self.vip_address = '192.0.2.83'
        self.vip_network_id = uuidutils.generate_uuid()
        self.vip_port_id = uuidutils.generate_uuid()
        self.vip_subnet_id = uuidutils.generate_uuid()
        self.listener_id = uuidutils.generate_uuid()
        self.vip_qos_policy_id = uuidutils.generate_uuid()
        self.default_tls_container_ref = uuidutils.generate_uuid()
        self.sni_container_ref_1 = uuidutils.generate_uuid()
        self.sni_container_ref_2 = uuidutils.generate_uuid()
        self.pool_id = uuidutils.generate_uuid()
        self.session_persistence = {
            "cookie_name": "sugar",
            "type": "APP_COOKIE"
        }
        self.member_id = uuidutils.generate_uuid()
        self.mem_subnet_id = uuidutils.generate_uuid()
        self.healthmonitor_id = uuidutils.generate_uuid()
        self.l7policy_id = uuidutils.generate_uuid()
        self.l7rule_id = uuidutils.generate_uuid()

        self.ref_l7rule = data_models.L7Rule(admin_state_up=True,
                                             compare_type='STARTS_WITH',
                                             invert=True,
                                             key='cookie',
                                             l7policy_id=self.l7policy_id,
                                             l7rule_id=self.l7rule_id,
                                             type='COOKIE',
                                             project_id=self.project_id,
                                             value='chocolate')

        self.ref_l7policy = data_models.L7Policy(
            action='REJECT',
            admin_state_up=False,
            description='A L7 Policy',
            l7policy_id=self.l7policy_id,
            listener_id=self.listener_id,
            name='l7policy',
            position=1,
            redirect_pool_id=self.pool_id,
            redirect_url='/test',
            rules=[self.ref_l7rule],
            project_id=self.project_id,
            redirect_prefix='http://example.com',
            redirect_http_code=301)

        self.ref_listener = data_models.Listener(
            admin_state_up=True,
            connection_limit=5000,
            default_pool=None,
            default_pool_id=None,
            default_tls_container_data='default_cert_data',
            default_tls_container_ref=self.default_tls_container_ref,
            description=data_models.Unset,
            insert_headers={'X-Forwarded-For': 'true'},
            l7policies=[self.ref_l7policy],
            listener_id=self.listener_id,
            loadbalancer_id=self.loadbalancer_id,
            name='super_listener',
            project_id=self.project_id,
            protocol='avian',
            protocol_port=42,
            sni_container_data=['sni_cert_data_1', 'sni_cert_data_2'],
            sni_container_refs=[
                self.sni_container_ref_1, self.sni_container_ref_2
            ],
            timeout_client_data=3,
            timeout_member_connect=4,
            timeout_member_data=5,
            timeout_tcp_inspect=6,
            client_authentication=None,
            client_ca_tls_container_data=None,
            client_ca_tls_container_ref=None,
            client_crl_container_data=None,
            client_crl_container_ref=None,
            allowed_cidrs=None)

        self.ref_lb = data_models.LoadBalancer(
            admin_state_up=False,
            description='One great load balancer',
            flavor={'cake': 'chocolate'},
            listeners=[self.ref_listener],
            loadbalancer_id=self.loadbalancer_id,
            name='favorite_lb',
            project_id=self.project_id,
            vip_address=self.vip_address,
            vip_network_id=self.vip_network_id,
            vip_port_id=self.vip_port_id,
            vip_subnet_id=self.vip_subnet_id,
            vip_qos_policy_id=self.vip_qos_policy_id)

        self.ref_vip = data_models.VIP(
            vip_address=self.vip_address,
            vip_network_id=self.vip_network_id,
            vip_port_id=self.vip_port_id,
            vip_subnet_id=self.vip_subnet_id,
            vip_qos_policy_id=self.vip_qos_policy_id)

        self.ref_member = data_models.Member(address='192.0.2.10',
                                             admin_state_up=True,
                                             member_id=self.member_id,
                                             monitor_address='192.0.2.11',
                                             monitor_port=8888,
                                             name='member',
                                             pool_id=self.pool_id,
                                             project_id=self.project_id,
                                             protocol_port=80,
                                             subnet_id=self.mem_subnet_id,
                                             weight=1,
                                             backup=False)

        self.ref_healthmonitor = data_models.HealthMonitor(
            admin_state_up=False,
            delay=1,
            expected_codes='200,202',
            healthmonitor_id=self.healthmonitor_id,
            http_method='GET',
            max_retries=2,
            max_retries_down=3,
            name='member',
            pool_id=self.pool_id,
            project_id=self.project_id,
            timeout=4,
            type='HTTP',
            url_path='/test',
            http_version=1.1,
            domain_name='testdomainname.com')

        self.ref_pool = data_models.Pool(
            admin_state_up=True,
            description='A pool',
            healthmonitor=None,
            lb_algorithm='fast',
            loadbalancer_id=self.loadbalancer_id,
            members=[self.ref_member],
            name='pool',
            pool_id=self.pool_id,
            project_id=self.project_id,
            listener_id=self.listener_id,
            protocol='avian',
            session_persistence=self.session_persistence)

        self.ref_l7rule_dict = {
            'admin_state_up': True,
            'compare_type': 'STARTS_WITH',
            'invert': True,
            'key': 'cookie',
            'l7policy_id': self.l7policy_id,
            'l7rule_id': self.l7rule_id,
            'type': 'COOKIE',
            'project_id': self.project_id,
            'value': 'chocolate'
        }

        self.ref_l7policy_dict = {
            'action': 'REJECT',
            'admin_state_up': False,
            'description': 'A L7 Policy',
            'l7policy_id': self.l7policy_id,
            'listener_id': self.listener_id,
            'name': 'l7policy',
            'position': 1,
            'project_id': self.project_id,
            'redirect_pool_id': self.pool_id,
            'redirect_url': '/test',
            'rules': [self.ref_l7rule_dict],
            'redirect_prefix': 'http://example.com',
            'redirect_http_code': 301
        }

        self.ref_lb_dict = {
            'project_id': self.project_id,
            'flavor': {
                'cake': 'chocolate'
            },
            'vip_network_id': self.vip_network_id,
            'admin_state_up': False,
            'loadbalancer_id': self.loadbalancer_id,
            'vip_port_id': self.vip_port_id,
            'vip_address': self.vip_address,
            'description': 'One great load balancer',
            'vip_subnet_id': self.vip_subnet_id,
            'name': 'favorite_lb',
            'vip_qos_policy_id': self.vip_qos_policy_id
        }

        self.ref_listener_dict = {
            'admin_state_up':
            True,
            'connection_limit':
            5000,
            'default_pool':
            None,
            'default_pool_id':
            None,
            'default_tls_container_data':
            'default_cert_data',
            'default_tls_container_ref':
            self.default_tls_container_ref,
            'description':
            None,
            'insert_headers': {
                'X-Forwarded-For': 'true'
            },
            'listener_id':
            self.listener_id,
            'l7policies': [self.ref_l7policy_dict],
            'loadbalancer_id':
            self.loadbalancer_id,
            'name':
            'super_listener',
            'project_id':
            self.project_id,
            'protocol':
            'avian',
            'protocol_port':
            42,
            'sni_container_data': ['sni_cert_data_1', 'sni_cert_data_2'],
            'sni_container_refs':
            [self.sni_container_ref_1, self.sni_container_ref_2],
            'timeout_client_data':
            3,
            'timeout_member_connect':
            4,
            'timeout_member_data':
            5,
            'timeout_tcp_inspect':
            6,
            'client_authentication':
            None,
            'client_ca_tls_container_data':
            None,
            'client_ca_tls_container_ref':
            None,
            'client_crl_container_data':
            None,
            'client_crl_container_ref':
            None,
            'allowed_cidrs':
            None,
        }

        self.ref_lb_dict_with_listener = {
            'admin_state_up': False,
            'description': 'One great load balancer',
            'flavor': {
                'cake': 'chocolate'
            },
            'listeners': [self.ref_listener_dict],
            'loadbalancer_id': self.loadbalancer_id,
            'name': 'favorite_lb',
            'project_id': self.project_id,
            'vip_address': self.vip_address,
            'vip_network_id': self.vip_network_id,
            'vip_port_id': self.vip_port_id,
            'vip_subnet_id': self.vip_subnet_id,
            'vip_qos_policy_id': self.vip_qos_policy_id
        }

        self.ref_vip_dict = {
            'vip_address': self.vip_address,
            'vip_network_id': self.vip_network_id,
            'vip_port_id': self.vip_port_id,
            'vip_subnet_id': self.vip_subnet_id,
            'vip_qos_policy_id': self.vip_qos_policy_id
        }

        self.ref_member_dict = {
            'address': '192.0.2.10',
            'admin_state_up': True,
            'member_id': self.member_id,
            'monitor_address': '192.0.2.11',
            'monitor_port': 8888,
            'name': 'member',
            'pool_id': self.pool_id,
            'project_id': self.project_id,
            'protocol_port': 80,
            'subnet_id': self.mem_subnet_id,
            'weight': 1,
            'backup': False
        }

        self.ref_healthmonitor_dict = {
            'admin_state_up': False,
            'delay': 1,
            'expected_codes': '200,202',
            'healthmonitor_id': self.healthmonitor_id,
            'http_method': 'GET',
            'max_retries': 2,
            'max_retries_down': 3,
            'name': 'member',
            'pool_id': self.pool_id,
            'project_id': self.project_id,
            'timeout': 4,
            'type': 'HTTP',
            'url_path': '/test',
            'http_version': 1.1,
            'domain_name': 'testdomainname.com'
        }

        self.ref_pool_dict = {
            'admin_state_up': True,
            'description': 'A pool',
            'healthmonitor': self.ref_healthmonitor_dict,
            'lb_algorithm': 'fast',
            'loadbalancer_id': self.loadbalancer_id,
            'members': [self.ref_member_dict],
            'name': 'pool',
            'pool_id': self.pool_id,
            'project_id': self.project_id,
            'listener_id': self.listener_id,
            'protocol': 'avian',
            'session_persistence': self.session_persistence
        }