Exemplo n.º 1
0
    def execute(self, member, vthunder, pool, member_count_ip, member_count_ip_port_protocol):
        server_name = '{}_{}'.format(member.project_id[:5], member.ip_address.replace('.', '_'))
        try:
            self.axapi_client.slb.service_group.member.delete(
                pool.id, server_name, member.protocol_port)
            LOG.debug("Successfully dissociated member %s from pool %s", member.id, pool.id)
        except (acos_errors.ACOSException, exceptions.ConnectionError) as e:
            LOG.exception("Failed to dissociate member %s from pool %s",
                          member.id, pool.id)
            raise e

        try:
            if member_count_ip <= 1:
                self.axapi_client.slb.server.delete(server_name)
                LOG.debug("Successfully deleted member %s from pool %s", member.id, pool.id)
            elif member_count_ip_port_protocol <= 1:
                protocol = openstack_mappings.service_group_protocol(
                    self.axapi_client, pool.protocol)
                self.axapi_client.slb.server.port.delete(server_name, member.protocol_port,
                                                         protocol)
                LOG.debug("Successfully deleted port for member %s from pool %s",
                          member.id, pool.id)
        except (acos_errors.ACOSException, exceptions.ConnectionError) as e:
            LOG.exception("Failed to delete member/port: %s", member.id)
            raise e
Exemplo n.º 2
0
    def execute(self, member, vthunder, pool, member_count_ip,
                member_count_ip_port_protocol):
        try:
            server_name = _get_server_name(self.axapi_client, member)
            self.axapi_client.slb.service_group.member.delete(
                pool.id, server_name, member.protocol_port)
            LOG.debug("Successfully dissociated member %s from pool %s",
                      member.id, pool.id)
        except acos_errors.NotFound:
            LOG.debug("Unable to find member %s in pool %s", member.id,
                      pool.id)
            return
        except (acos_errors.ACOSException, exceptions.ConnectionError) as e:
            LOG.exception("Failed to dissociate member %s from pool %s",
                          member.id, pool.id)
            raise e

        try:
            if member_count_ip <= 1:
                self.axapi_client.slb.server.delete(server_name)
                LOG.debug("Successfully deleted member %s from pool %s",
                          member.id, pool.id)
            elif member_count_ip_port_protocol <= 1:
                protocol = openstack_mappings.service_group_protocol(
                    self.axapi_client, pool.protocol)
                self.axapi_client.slb.server.port.delete(
                    server_name, member.protocol_port, protocol)
                LOG.debug(
                    "Successfully deleted port for member %s from pool %s",
                    member.id, pool.id)
        except (acos_errors.ACOSException, exceptions.ConnectionError) as e:
            LOG.exception("Failed to delete member/port: %s", member.id)
            raise e
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def set(self, set_method, pool):

        axapi_args = {'service_group': utils.meta(pool, 'service_group', {})}
        service_group_temp = {}
        service_group_temp['template-server'] = CONF.service_group.template_server
        service_group_temp['template-port'] = CONF.service_group.template_port
        service_group_temp['template-policy'] = CONF.service_group.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,
                   axapi_args=axapi_args)
Exemplo n.º 5
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)