Beispiel #1
0
 def test_shared_template_modifier_resource_found_name_not_found(self):
     device_templates = self._get_device_templates('tcp',
                                                   'my_secondary_tcp')
     template_type = utils.shared_template_modifier('template-tcp',
                                                    'my_tcp_temp',
                                                    device_templates)
     self.assertEqual('template-tcp-shared', template_type)
Beispiel #2
0
    def set(self, set_method, pool, vthunder, flavor=None, **kwargs):
        pool_args = {'service_group': utils.meta(pool, 'service_group', {})}

        device_templates = self.axapi_client.slb.template.templates.get()

        service_group_temp = {}
        template_server = CONF.service_group.template_server
        if template_server and template_server.lower() != 'none':
            if CONF.a10_global.use_shared_for_template_lookup:
                LOG.warning(
                    'Shared partition template lookup for `[service_group]`'
                    ' is not supported on template `template-server`')
            service_group_temp['template-server'] = template_server

        template_port = CONF.service_group.template_port
        if template_port and template_port.lower() != 'none':
            if CONF.a10_global.use_shared_for_template_lookup:
                LOG.warning(
                    'Shared partition template lookup for `[service_group]`'
                    ' is not supported on template `template-port`')
            service_group_temp['template-port'] = template_port

        template_policy = CONF.service_group.template_policy
        if template_policy and template_policy.lower() != 'none':
            template_key = 'template-policy'
            if vthunder.partition_name != "shared":
                if CONF.a10_global.use_shared_for_template_lookup:
                    template_key = utils.shared_template_modifier(
                        template_key, template_policy, device_templates)
            service_group_temp[template_key] = template_policy

        protocol = openstack_mappings.service_group_protocol(
            self.axapi_client, pool.protocol)
        lb_method = openstack_mappings.service_group_lb_method(
            self.axapi_client, pool.lb_algorithm)

        # Handle options from flavor
        if flavor:
            pool_flavor = flavor.get('service_group')
            if pool_flavor:
                name_exprs = pool_flavor.get('name_expressions')
                parsed_exprs = utils.parse_name_expressions(
                    pool.name, name_exprs)
                pool_flavor.pop('name_expressions', None)
                pool_args['service_group'].update(pool_flavor)
                pool_args['service_group'].update(parsed_exprs)

        set_method(pool.id,
                   protocol=protocol,
                   lb_method=lb_method,
                   service_group_templates=service_group_temp,
                   mem_list=kwargs.get('mem_list'),
                   hm_name=kwargs.get('health_monitor'),
                   **pool_args)
Beispiel #3
0
    def set(self, set_method, pool, vthunder, **kwargs):
        axapi_args = {'service_group': utils.meta(pool, 'service_group', {})}

        device_templates = self.axapi_client.slb.template.templates.get()

        service_group_temp = {}
        template_server = CONF.service_group.template_server
        if template_server and template_server.lower() != 'none':
            if CONF.a10_global.use_shared_for_template_lookup:
                LOG.warning('Shared partition template lookup for `[service_group]`'
                            ' is not supported on template `template-server`')
            service_group_temp['template-server'] = template_server

        template_port = CONF.service_group.template_port
        if template_port and template_port.lower() != 'none':
            if CONF.a10_global.use_shared_for_template_lookup:
                LOG.warning('Shared partition template lookup for `[service_group]`'
                            ' is not supported on template `template-port`')
            service_group_temp['template-port'] = template_port

        template_policy = CONF.service_group.template_policy
        if template_policy and template_policy.lower() != 'none':
            template_key = 'template-policy'
            if vthunder.partition_name != "shared":
                if CONF.a10_global.use_shared_for_template_lookup:
                    template_key = utils.shared_template_modifier(template_key,
                                                                  template_policy,
                                                                  device_templates)
            service_group_temp[template_key] = template_policy

        protocol = openstack_mappings.service_group_protocol(
            self.axapi_client, pool.protocol)
        lb_method = openstack_mappings.service_group_lb_method(
            self.axapi_client, pool.lb_algorithm)
        set_method(pool.id,
                   protocol=protocol,
                   lb_method=lb_method,
                   service_group_templates=service_group_temp,
                   mem_list=kwargs.get('mem_list'),
                   hm_name=kwargs.get('health_monitor'),
                   axapi_args=axapi_args)
Beispiel #4
0
    def set(self,
            set_method,
            loadbalancer,
            listener,
            vthunder,
            flavor_data=None,
            update_dict=None,
            ssl_template=None):
        listener.load_balancer = loadbalancer
        listener.protocol = openstack_mappings.virtual_port_protocol(
            self.axapi_client, listener.protocol).lower()

        config_data = {
            'ipinip': CONF.listener.ipinip,
            'use_rcv_hop': CONF.listener.use_rcv_hop_for_resp,
            'ha_conn_mirror': CONF.listener.ha_conn_mirror
        }

        status = self.axapi_client.slb.UP
        if not listener.enabled:
            status = self.axapi_client.slb.DOWN
        config_data['status'] = status

        conn_limit = CONF.listener.conn_limit
        if listener.connection_limit != -1:
            conn_limit = listener.connection_limit
        if conn_limit < 1 or conn_limit > 64000000:
            raise Exception('The specified member server connection limit '
                            '(configuration setting: conn-limit) is out of '
                            'bounds with value {0}. Please set to between '
                            '1-64000000.'.format(conn_limit))
        config_data['conn_limit'] = conn_limit

        no_dest_nat = CONF.listener.no_dest_nat
        if no_dest_nat and (
                listener.protocol
                not in a10constants.NO_DEST_NAT_SUPPORTED_PROTOCOL):
            LOG.warning("'no_dest_nat' is not allowed for HTTP," +
                        "HTTPS or TERMINATED_HTTPS listener.")
            no_dest_nat = False
        config_data['no_dest_nat'] = no_dest_nat

        autosnat = CONF.listener.autosnat
        if autosnat and no_dest_nat:
            raise exceptions.SNATConfigurationError()
        config_data['autosnat'] = autosnat

        c_pers, s_pers = utils.get_sess_pers_templates(listener.default_pool)
        device_templates = self.axapi_client.slb.template.templates.get()
        vport_templates = {}
        template_vport = CONF.listener.template_virtual_port
        if template_vport and template_vport.lower() != 'none':
            template_key = 'template-virtual-port'
            if vthunder.partition_name != "shared":
                if CONF.a10_global.use_shared_for_template_lookup:
                    template_key = utils.shared_template_modifier(
                        template_key, template_vport, device_templates)
            vport_templates[template_key] = template_vport

        template_args = {}
        if listener.protocol.upper() in a10constants.HTTP_TYPE:
            if listener.protocol == 'https' and listener.tls_certificate_id:
                # Adding TERMINATED_HTTPS SSL cert, created in previous task
                template_args["template_client_ssl"] = listener.id

            if (update_dict and 'default_tls_container_ref' in update_dict
                    and update_dict["default_tls_container_ref"] is None):
                template_args["template_client_ssl"] = None
            elif listener.protocol == 'https':
                template_args["template_client_ssl"] = listener.id

            template_http = CONF.listener.template_http
            if template_http and template_http.lower() != 'none':
                template_key = 'template-http'
                if vthunder.partition_name != "shared":
                    if CONF.a10_global.use_shared_for_template_lookup:
                        template_key = utils.shared_template_modifier(
                            template_key, template_http, device_templates)
                vport_templates[template_key] = template_http
            """
            if ha_conn_mirror is not None:
                ha_conn_mirror = None
                LOG.warning("'ha_conn_mirror' is not allowed for HTTP "
                            "or TERMINATED_HTTPS listeners.")
            """
        elif listener.protocol == 'tcp':
            template_tcp = CONF.listener.template_tcp
            if template_tcp and template_tcp.lower() != 'none':
                template_key = 'template-tcp'
                if vthunder.partition_name != "shared":
                    if CONF.a10_global.use_shared_for_template_lookup:
                        template_key = utils.shared_template_modifier(
                            template_key, template_tcp, device_templates)
                vport_templates[template_key] = template_tcp

        template_policy = CONF.listener.template_policy
        if template_policy and template_policy.lower() != 'none':
            template_key = 'template-policy'
            if vthunder.partition_name != "shared":
                if CONF.a10_global.use_shared_for_template_lookup:
                    template_key = utils.shared_template_modifier(
                        template_key, template_policy, device_templates)
            vport_templates[template_key] = template_policy

        vport_args = {}
        if flavor_data:
            virtual_port_flavor = flavor_data.get('virtual_port')
            if virtual_port_flavor:
                name_exprs = virtual_port_flavor.get('name_expressions')
                parsed_exprs = utils.parse_name_expressions(
                    listener.name, name_exprs)
                virtual_port_flavor.pop('name_expressions', None)
                virtual_port_flavor.update(parsed_exprs)
                vport_args = {'port': virtual_port_flavor}

            # use default nat-pool pool if pool is not specified
            if 'port' not in vport_args or 'pool' not in vport_args['port']:
                pool_flavor = flavor_data.get('nat_pool')
                if pool_flavor and 'pool_name' in pool_flavor:
                    pool_arg = {}
                    pool_arg['pool'] = pool_flavor['pool_name']
                    if 'port' in vport_args:
                        vport_args['port'].update(pool_arg)
                    else:
                        vport_args['port'] = pool_arg
        config_data.update(template_args)
        config_data.update(vport_args)

        set_method(loadbalancer.id,
                   listener.id,
                   listener.protocol,
                   listener.protocol_port,
                   listener.default_pool_id,
                   s_pers_name=s_pers,
                   c_pers_name=c_pers,
                   virtual_port_templates=vport_templates,
                   **config_data)

        listener.protocol = listener.protocol.upper()
Beispiel #5
0
    def set(self, set_method, loadbalancer, listener, vthunder, ssl_template=None):
        listener.load_balancer = loadbalancer
        listener.protocol = openstack_mappings.virtual_port_protocol(
            self.axapi_client, listener.protocol).lower()

        ipinip = CONF.listener.ipinip
        use_rcv_hop = CONF.listener.use_rcv_hop_for_resp
        ha_conn_mirror = CONF.listener.ha_conn_mirror
        status = self.axapi_client.slb.UP
        if not listener.enabled:
            status = self.axapi_client.slb.DOWN

        conn_limit = CONF.listener.conn_limit
        if listener.connection_limit != -1:
            conn_limit = listener.connection_limit
        if conn_limit < 1 or conn_limit > 64000000:
            LOG.warning('The specified member server connection limit '
                        '(configuration setting: conn-limit) is out of '
                        'bounds with value {0}. Please set to between '
                        '1-64000000. Defaulting to 64000000'.format(conn_limit))

        no_dest_nat = CONF.listener.no_dest_nat
        if no_dest_nat and (
                listener.protocol
                not in a10constants.NO_DEST_NAT_SUPPORTED_PROTOCOL):
            LOG.warning("'no_dest_nat' is not allowed for HTTP," +
                        "HTTPS or TERMINATED_HTTPS listener.")
            no_dest_nat = False

        autosnat = CONF.listener.autosnat
        if autosnat and no_dest_nat:
            raise exceptions.SNATConfigurationError()

        c_pers, s_pers = utils.get_sess_pers_templates(listener.default_pool)
        device_templates = self.axapi_client.slb.template.templates.get()

        vport_templates = {}
        template_vport = CONF.listener.template_virtual_port
        if template_vport and template_vport.lower() != 'none':
            template_key = 'template-virtual-port'
            if vthunder.partition_name != "shared":
                if CONF.a10_global.use_shared_for_template_lookup:
                    template_key = utils.shared_template_modifier(template_key,
                                                                  template_vport,
                                                                  device_templates)
            vport_templates[template_key] = template_vport

        template_args = {}
        if listener.protocol == 'https' and listener.tls_certificate_id:
            # Adding TERMINATED_HTTPS SSL cert, created in previous task
            template_args["template_client_ssl"] = listener.id

        elif listener.protocol.upper() in a10constants.HTTP_TYPE:
            template_http = CONF.listener.template_http
            if template_http and template_http.lower() != 'none':
                template_key = 'template-http'
                if vthunder.partition_name != "shared":
                    if CONF.a10_global.use_shared_for_template_lookup:
                        template_key = utils.shared_template_modifier(template_key,
                                                                      template_http,
                                                                      device_templates)
                vport_templates[template_key] = template_http
            if ha_conn_mirror is not None:
                ha_conn_mirror = None
                LOG.warning("'ha_conn_mirror' is not allowed for HTTP "
                            "or TERMINATED_HTTPS listeners.")

        elif listener.protocol == 'tcp':
            template_tcp = CONF.listener.template_tcp
            if template_tcp and template_tcp.lower() != 'none':
                template_key = 'template-tcp'
                if vthunder.partition_name != "shared":
                    if CONF.a10_global.use_shared_for_template_lookup:
                        template_key = utils.shared_template_modifier(template_key,
                                                                      template_tcp,
                                                                      device_templates)
                vport_templates[template_key] = template_tcp

        template_policy = CONF.listener.template_policy
        if template_policy and template_policy.lower() != 'none':
            template_key = 'template-policy'
            if vthunder.partition_name != "shared":
                if CONF.a10_global.use_shared_for_template_lookup:
                    template_key = utils.shared_template_modifier(template_key,
                                                                  template_policy,
                                                                  device_templates)
            vport_templates[template_key] = template_policy

        set_method(loadbalancer.id,
                   listener.id,
                   listener.protocol,
                   listener.protocol_port,
                   listener.default_pool_id,
                   s_pers_name=s_pers, c_pers_name=c_pers,
                   status=status, no_dest_nat=no_dest_nat,
                   autosnat=autosnat, ipinip=ipinip,
                   ha_conn_mirror=ha_conn_mirror,
                   use_rcv_hop=use_rcv_hop,
                   conn_limit=conn_limit,
                   virtual_port_templates=vport_templates,
                   **template_args)