def test_virtualserver_get_with_tenant_fails(self):
     lb_id, sf_id = self._create_lb_and_sf('1', 'tenant1')
     values = get_fake_virtualserver(sf_id, lb_id)
     virtualserver_ref1 = db_api.virtualserver_create(self.conf, values)
     with self.assertRaises(exception.VirtualServerNotFound):
         db_api.virtualserver_get(self.conf,
             virtualserver_ref1['id'], tenant_id='tenant2')
 def test_virtualserver_destroy(self):
     values = get_fake_virtualserver('1', '1')
     virtualserver = db_api.virtualserver_create(self.conf, values)
     db_api.virtualserver_destroy(self.conf, virtualserver['id'])
     with self.assertRaises(exception.VirtualServerNotFound) as cm:
         db_api.virtualserver_get(self.conf, virtualserver['id'])
     err = cm.exception
     self.assertEqual(err.kwargs, {'virtualserver_id': virtualserver['id']})
 def test_virtualserver_destroy_by_sf_id(self):
     values = get_fake_virtualserver("1", "1")
     virtualserver_ref1 = db_api.virtualserver_create(self.conf, values)
     values = get_fake_virtualserver("2", "1")
     virtualserver_ref2 = db_api.virtualserver_create(self.conf, values)
     db_api.virtualserver_destroy_by_sf_id(self.conf, "1")
     with self.assertRaises(exception.VirtualServerNotFound) as cm:
         db_api.virtualserver_get(self.conf, virtualserver_ref1["id"])
     err = cm.exception
     expected = {"virtualserver_id": virtualserver_ref1["id"]}
     self.assertEqual(err.kwargs, expected)
     virtualserver_ref3 = db_api.virtualserver_get(self.conf, virtualserver_ref2["id"])
     self.assertEqual(dict(virtualserver_ref2.iteritems()), dict(virtualserver_ref3.iteritems()))
 def test_virtualserver_destroy_by_sf_id(self):
     values = get_fake_virtualserver('1', '1')
     virtualserver_ref1 = db_api.virtualserver_create(self.conf, values)
     values = get_fake_virtualserver('2', '1')
     virtualserver_ref2 = db_api.virtualserver_create(self.conf, values)
     db_api.virtualserver_destroy_by_sf_id(self.conf, '1')
     with self.assertRaises(exception.VirtualServerNotFound) as cm:
         db_api.virtualserver_get(self.conf, virtualserver_ref1['id'])
     err = cm.exception
     expected = {'virtualserver_id': virtualserver_ref1['id']}
     self.assertEqual(err.kwargs, expected)
     virtualserver_ref3 = db_api.virtualserver_get(self.conf,
                                                   virtualserver_ref2['id'])
     self.assertEqual(virtualserver_ref3['id'], virtualserver_ref2['id'])
 def test_virtualserver_get(self):
     values = get_fake_virtualserver('1', '1')
     virtualserver_ref1 = db_api.virtualserver_create(self.conf, values)
     virtualserver_ref2 = db_api.virtualserver_get(self.conf,
                                                   virtualserver_ref1['id'])
     self.assertEqual(dict(virtualserver_ref1.iteritems()),
                      dict(virtualserver_ref2.iteritems()))
 def test_virtualserver_get_with_tenant(self):
     lb_id, sf_id = self._create_lb_and_sf('1', 'tenant1')
     values = get_fake_virtualserver(sf_id, lb_id)
     virtualserver_ref1 = db_api.virtualserver_create(self.conf, values)
     virtualserver_ref2 = db_api.virtualserver_get(self.conf,
             virtualserver_ref1['id'], tenant_id='tenant1')
     self.assertEqual(dict(virtualserver_ref1.iteritems()),
                      dict(virtualserver_ref2.iteritems()))
Beispiel #7
0
def lb_delete_vip(conf, lb_id, vip_id):
    logger.debug("Called lb_delete_vip(), conf: %r, lb_id: %s, vip_id: %s",
                 conf, lb_id, vip_id)
    lb_ref = db_api.loadbalancer_get(conf, lb_id)
    vip_ref = db_api.virtualserver_get(conf, vip_id)
    device_driver = drivers.get_device_driver(conf, lb_ref['device_id'])
    with device_driver.request_context() as ctx:
        commands.delete_vip(ctx, vip_ref)
    db_api.virtualserver_destroy(conf, vip_id)
 def show(self, req, lb_id, id):
     LOG.debug("Called show(), req: %r, lb_id: %s, id: %s",
                  req, lb_id, id)
     vip_ref = db_api.virtualserver_get(self.conf, id)
     return {'virtualIp': db_api.unpack_extra(vip_ref)}