def test_create_vip_1(self, mock_f1, mock_f2):
     """Exception"""
     cmd.create_vip(self.ctx, self.vip, self.server_farm)
     rollback_fn = self.ctx.add_rollback.call_args[0][0]
     rollback_fn(False)
     self.assertTrue(mock_f2.called)
     mock_f2.assert_called_once_with(self.ctx, self.vip)
Example #2
0
def lb_add_vip(conf, tenant_id, lb_id, vip_dict):
    LOG.debug("Called lb_add_vip(), conf: %r, lb_id: %s, vip_dict: %r",
                 conf, lb_id, vip_dict)
    lb_ref = db_api.loadbalancer_get(conf, lb_id, tenant_id=tenant_id)
    # NOTE(akscram): server farms are really only create problems than
    #                they solve multiply use of the virtual IPs.
    try:
        sf_ref = db_api.serverfarm_get_all_by_lb_id(conf, lb_ref['id'])[0]
    except IndexError:
        raise exc.ServerFarmNotFound

    values = db_api.virtualserver_pack_extra(vip_dict)
    values['lb_id'] = lb_ref['id']
    values['sf_id'] = sf_ref['id']
    # XXX(akscram): Set default protocol from LoadBalancer to
    #               VirtualServer if it is not present.
    if not values.get('extra'):
        values['extra'] = {'protocol': lb_ref['protocol']}
    elif 'protocol' not in values['extra']:
        values['extra']['protocol'] = lb_ref['protocol']
    vip_ref = db_api.virtualserver_create(conf, values)
    device_driver = drivers.get_device_driver(conf, lb_ref['device_id'])
    with device_driver.request_context() as ctx:
        commands.create_vip(ctx, vip_ref, sf_ref)
    return db_api.unpack_extra(vip_ref)
 def test_create_vip_0(self, mock_f1, mock_f2):
     """No exception"""
     cmd.create_vip(self.ctx, self.vip, self.server_farm)
     self.assertTrue(self.ctx.device.create_virtual_ip.called)
     self.assertTrue(mock_f1.called)
     self.assertFalse(mock_f2.called)
     mock_f1.assert_called_once_with(self.ctx.conf, self.vip['id'],
             {'deployed': True})
Example #4
0
def lb_add_vip(conf, lb_id, vip_dict):
    logger.debug("Called lb_add_vip(), conf: %r, lb_id: %s, vip_dict: %r",
                 conf, lb_id, vip_dict)
    lb_ref = db_api.loadbalancer_get(conf, lb_id)
    # NOTE(akscram): server farms are really only create problems than
    #                they solve multiply use of the virtual IPs.
    try:
        sf_ref = db_api.serverfarm_get_all_by_lb_id(conf, lb_ref['id'])[0]
    except IndexError:
        raise exc.ServerFarmNotFound

    values = db_api.virtualserver_pack_extra(vip_dict)
    values['lb_id'] = lb_ref['id']
    values['sf_id'] = sf_ref['id']
    vip_ref = db_api.virtualserver_create(conf, values)
    device_driver = drivers.get_device_driver(conf, lb_ref['device_id'])
    with device_driver.request_context() as ctx:
        commands.create_vip(ctx, vip_ref, sf_ref)
    return db_api.unpack_extra(vip_ref)
 def test_create_vip_0(self, mock_f1, mock_f2):
     """No exception"""
     cmd.create_vip(self.ctx, self.vip, self.server_farm)
     self.assertTrue(self.ctx.device.create_virtual_ip.called)
     self.assertTrue(mock_f1.called)