コード例 #1
0
    def _set(self, set_method, c, context, lb):
        status = c.client.slb.UP
        if not lb.admin_state_up:
            status = c.client.slb.DOWN

        try:
            vip_meta = self.meta(lb, 'virtual_server', {})
            vip_args = a10_common._virtual_server(vip_meta, c.device_cfg)
            set_method(
                self._meta_name(lb),
                lb.vip_address,
                status,
                axapi_args=vip_args)
        except acos_errors.Exists:
            pass
コード例 #2
0
    def create(self, context, vip):
        with a10.A10WriteStatusContext(self, context, vip) as c:
            status = c.client.slb.UP
            if not vip['admin_state_up']:
                status = c.client.slb.DOWN

            pool_name = self._pool_name(context, vip['pool_id'])

            p = PersistHandler(c, context, vip, self._meta_name(vip))
            p.create()

            templates = self.meta(vip, "template", {})

            if 'client_ssl' in templates:
                args = {'client_ssl_template': templates['client_ssl']}
                try:
                    c.client.slb.template.client_ssl.create(
                        '', '', '',
                        axapi_args=args)
                except acos_errors.Exists:
                    pass

            if 'server_ssl' in templates:
                args = {'server_ssl_template': templates['server_ssl']}
                try:
                    c.client.slb.template.server_ssl.create(
                        '', '', '',
                        axapi_args=args)
                except acos_errors.Exists:
                    pass

            vport_list = None
            try:
                vip_meta = self.meta(vip, 'virtual_server', {})
                vport_list = vip_meta.pop('vport_list', None)
                vip_args = a10_common._virtual_server(vip_meta, c.device_cfg)
                c.client.slb.virtual_server.create(
                    self._meta_name(vip),
                    vip['address'],
                    status,
                    axapi_args=vip_args)
            except acos_errors.Exists:
                pass

            LOG.debug("VPORT_LIST = %s", vport_list)
            if vport_list is None:
                vport_list = [self.vport_meta(vip)]
            for vport, i in zip(vport_list, range(len(vport_list))):
                try:
                    vport_name = str(i) if i else ''
                    vport_args = a10_common._vport(vport, c.device_cfg)
                    c.client.slb.virtual_server.vport.create(
                        self._meta_name(vip),
                        self._meta_name(vip) + '_VPORT' + vport_name,
                        protocol=a10_os.vip_protocols(c, vip['protocol']),
                        port=vip['protocol_port'],
                        service_group_name=pool_name,
                        s_pers_name=p.s_persistence(),
                        c_pers_name=p.c_persistence(),
                        status=status,
                        axapi_args=vport_args)
                except acos_errors.Exists:
                    pass

            slb = models.default(
                models.A10SLBV1,
                vip_id=vip['id'],
                a10_appliance=c.appliance)
            c.db_operations.add(slb)
            self.hooks.after_vip_create(c, context, vip)