def test_sticky_destroy_by_sf_id(self): values = get_fake_sticky('1') sticky_ref1 = db_api.sticky_create(self.conf, values) values = get_fake_sticky('2') sticky_ref2 = db_api.sticky_create(self.conf, values) db_api.sticky_destroy_by_sf_id(self.conf, '1') stickies = db_api.sticky_get_all(self.conf) self.assertEqual(len(stickies), 1)
def test_sticky_destroy_by_sf_id(self): values = get_fake_sticky("1") sticky_ref1 = db_api.sticky_create(self.conf, values) values = get_fake_sticky("2") sticky_ref2 = db_api.sticky_create(self.conf, values) db_api.sticky_destroy_by_sf_id(self.conf, "1") stickies = db_api.sticky_get_all(self.conf) self.assertEqual([dict(sticky_ref2.iteritems())], [dict(st.iteritems()) for st in stickies])
def removeFromDB(self): lb_id = self.lb['id'] sf_id = self.sf['id'] db_api.loadbalancer_destroy(self.conf, lb_id) db_api.serverfarm_destroy(self.conf, sf_id) db_api.predictor_destroy_by_sf_id(self.conf, sf_id) db_api.server_destroy_by_sf_id(self.conf, sf_id) db_api.probe_destroy_by_sf_id(self.conf, sf_id) db_api.virtualserver_destroy_by_sf_id(self.conf, sf_id) db_api.sticky_destroy_by_sf_id(self.conf, sf_id)
def delete_lb(conf, tenant_id, lb_id): lb_ref = db_api.loadbalancer_get(conf, lb_id, tenant_id=tenant_id) sf_ref = db_api.serverfarm_get_all_by_lb_id(conf, lb_ref['id'])[0] vips = db_api.virtualserver_get_all_by_sf_id(conf, sf_ref['id']) servers = db_api.server_get_all_by_sf_id(conf, sf_ref['id']) probes = db_api.probe_get_all_by_sf_id(conf, sf_ref['id']) stickies = db_api.sticky_get_all_by_sf_id(conf, sf_ref['id']) device_driver = drivers.get_device_driver(conf, lb_ref['device_id']) with device_driver.request_context() as ctx: commands.delete_loadbalancer(ctx, sf_ref, vips, servers, probes, stickies) db_api.probe_destroy_by_sf_id(conf, sf_ref['id']) db_api.sticky_destroy_by_sf_id(conf, sf_ref['id']) db_api.server_destroy_by_sf_id(conf, sf_ref['id']) db_api.virtualserver_destroy_by_sf_id(conf, sf_ref['id']) db_api.predictor_destroy_by_sf_id(conf, sf_ref['id']) db_api.serverfarm_destroy(conf, sf_ref['id']) db_api.loadbalancer_destroy(conf, lb_ref['id'])
def delete_loadbalancer(ctx, lb): sf = db_api.serverfarm_get_all_by_lb_id(ctx.conf, lb['id'])[0] vips = db_api.virtualserver_get_all_by_sf_id(ctx.conf, sf['id']) rs = db_api.server_get_all_by_sf_id(ctx.conf, sf['id']) probes = db_api.probe_get_all_by_sf_id(ctx.conf, sf['id']) stickies = db_api.sticky_get_all_by_sf_id(ctx.conf, sf['id']) for vip in vips: delete_vip(ctx, vip) for rserver in rs: delete_rserver_from_server_farm(ctx, sf, rserver) delete_rserver(ctx, rserver) for probe in probes: remove_probe_from_server_farm(ctx, sf, probe) delete_probe(ctx, probe) for sticky in stickies: delete_sticky(ctx, sticky) delete_server_farm(ctx, sf) db_api.predictor_destroy_by_sf_id(ctx.conf, sf['id']) db_api.server_destroy_by_sf_id(ctx.conf, sf['id']) db_api.probe_destroy_by_sf_id(ctx.conf, sf['id']) db_api.virtualserver_destroy_by_sf_id(ctx.conf, sf['id']) db_api.sticky_destroy_by_sf_id(ctx.conf, sf['id']) db_api.serverfarm_destroy(ctx.conf, sf['id']) db_api.loadbalancer_destroy(ctx.conf, lb['id'])