Exemple #1
0
def delete_load_balancer_hard(context, load_balancer_ref):
    try:
        for association_ref in load_balancer_ref.instances:
            db.load_balancer_instance_association_destroy(
                context, load_balancer_ref.id, association_ref.instance_uuid)

        for domain_ref in load_balancer_ref.domains:
            db.load_balancer_domain_destroy(context, domain_ref.id)

        db.load_balancer_config_destroy(context, load_balancer_ref.config.id)
        db.load_balancer_destroy(context, load_balancer_ref.id)
    except Exception, exp:
        raise exception.DeleteLoadBalancerFailed(msg=str(exp))
Exemple #2
0
    def test_update_load_balancer_config(self):
        update_kwargs = copy.deepcopy(self.delete_kwargs)
        update_kwargs['config'] = self.config

        self.mox.StubOutWithMock(db, 'load_balancer_get_by_uuid')
        self.mox.StubOutWithMock(db, 'load_balancer_config_create')
        self.mox.StubOutWithMock(db, 'load_balancer_config_destroy')
        self.mox.StubOutWithMock(db, 'load_balancer_update_state')

        load_balancer_ref = self.lb_ref
        load_balancer_ref.config = self.config_ref
        db.load_balancer_get_by_uuid(
            self.ctxt, self.uuid).AndReturn(load_balancer_ref)
        db.load_balancer_config_destroy(
            self.ctxt, load_balancer_ref.config.id).AndReturn(None)
        db.load_balancer_config_create(
            self.ctxt, self.config).AndReturn(self.config_ref)
        db.load_balancer_update_state(
            self.ctxt, self.uuid, state.UPDATING).AndReturn(None)
        self.mox.ReplayAll()
        r = http.update_load_balancer_config(self.ctxt, **update_kwargs)
        self.mox.VerifyAll()
        self.assertEqual(r, None)
Exemple #3
0
        config_ref = db.load_balancer_config_create(context, config_values)
        # binding instances
        for uuid in kwargs['instance_uuids']:
            association = {
                'load_balancer_id': load_balancer_ref.id,
                'instance_uuid': uuid,
            }
            db.load_balancer_instance_association_create(context, association)
            associated_instances.append(uuid)
    except Exception, exp:
        if load_balancer_ref:
            for instance_uuid in associated_instances:
                db.load_balancer_instance_association_destroy(
                    context, load_balancer_ref.id, instance_uuid)
        if config_ref:
            db.load_balancer_config_destroy(context, config_ref.id)
        if load_balancer_ref:
            db.load_balancer_destroy(context, load_balancer_ref.id)
        raise exception.CreateLoadBalancerFailed(msg=str(exp))

    return {'data': {'uuid': load_balancer_ref.uuid}}


def update_load_balancer_config(context, **kwargs):
    expect_keys = [
        'user_id', 'tenant_id', 'protocol',
        'uuid', 'config',
    ]
    utils.check_input_parameters(expect_keys, **kwargs)

    expect_configs = [