コード例 #1
0
def lb_to_vip_obj(lb):
    vip_obj = data_models.VIP()
    if lb.vip_address:
        vip_obj.ip_address = lb.vip_address
    if lb.vip_network_id:
        vip_obj.network_id = lb.vip_network_id
    if lb.vip_port_id:
        vip_obj.port_id = lb.vip_port_id
    if lb.vip_subnet_id:
        vip_obj.subnet_id = lb.vip_subnet_id
    if lb.vip_qos_policy_id:
        vip_obj.qos_policy_id = lb.vip_qos_policy_id
    vip_obj.load_balancer = lb
    return vip_obj
コード例 #2
0
ファイル: driver.py プロジェクト: lingxiankong/octavia
    def create_vip_port(self, loadbalancer_id, project_id, vip_dictionary):
        LOG.debug('Provider %s no-op, create_vip_port loadbalancer %s',
                  self.__class__.__name__, loadbalancer_id)

        self.driverconfig[loadbalancer_id] = (loadbalancer_id, project_id,
                                              vip_dictionary,
                                              'create_vip_port')

        vip_address = vip_dictionary.get('vip_address', '198.0.2.5')
        vip_network_id = vip_dictionary.get('vip_network_id',
                                            uuidutils.generate_uuid())
        vip_port_id = vip_dictionary.get('vip_port_id',
                                         uuidutils.generate_uuid())
        vip_subnet_id = vip_dictionary.get('vip_subnet_id',
                                           uuidutils.generate_uuid())

        return data_models.VIP(vip_address=vip_address,
                               vip_network_id=vip_network_id,
                               vip_port_id=vip_port_id,
                               vip_subnet_id=vip_subnet_id).to_dict()
コード例 #3
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."
        }
コード例 #4
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
        }