コード例 #1
0
    def find(self, openstack_lbaas_obj):
        loadbalancer = openstack_lbaas_obj.root_loadbalancer
        slb = self.db_operations.get_slb_v2(loadbalancer.id)
        if slb is None:
            # Assign this loadbalancer to an appliance
            appliance = self.select_appliance(openstack_lbaas_obj)
            slb = models.default(
                models.A10SLBV2,
                lbaas_loadbalancer_id=loadbalancer.id,
                a10_appliance=appliance)
            self.db_operations.add(slb)

        return slb.a10_appliance
コード例 #2
0
    def tenant_appliance(self):
        """Chooses the appliance a tenant is already on, or assigns it"""
        tenant_id = self.a10_context.tenant_id
        tenant = self.db_operations.get_tenant_appliance(tenant_id)
        if tenant is None:
            # Assign this tenant to an appliance
            appliance = self.select_tenant_appliance()
            tenant = models.default(
                models.A10TenantAppliance,
                tenant_id=tenant_id,
                a10_appliance=appliance)
            self.db_operations.add(tenant)

        return tenant.a10_appliance
コード例 #3
0
    def test_delete_slb_v2_deletes_slb(self):
        slb = models.default(
            models.A10SLBV2,
            lbaas_loadbalancer_id='lbaas_loadbalancer_id',
            a10_appliance_id='fake-a10-appliance-id'
        )

        operations1 = self.operations()
        operations1.add(slb)
        operations1.session.commit()

        operations2 = self.operations()
        operations2.delete_slb_v2(slb.lbaas_loadbalancer_id)
        operations2.session.commit()

        session = self.open_session()
        slbs = list(session.query(models.A10SLB))

        self.assertEqual([], slbs)
コード例 #4
0
    def test_delete_slb_v1_deletes_slb(self):
        slb = models.default(
            models.A10SLBV1,
            vip_id='fake-vip-id',
            a10_appliance_id='fake-a10-appliance-id'
        )

        operations1 = self.operations()
        operations1.add(slb)
        operations1.session.commit()

        operations2 = self.operations()
        operations2.delete_slb_v1(slb.vip_id)
        operations2.session.commit()

        session = self.open_session()
        slbs = list(session.query(models.A10SLB))

        self.assertEqual([], slbs)
コード例 #5
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)