def _setup_networking(instance_id, ip='1.2.3.4', flo_addr='1.2.1.2'):
    ctxt = context.get_admin_context()
    network_ref = db.project_get_networks(ctxt,
                                           'fake',
                                           associate=True)[0]
    vif = {'address': '56:12:12:12:12:12',
           'network_id': network_ref['id'],
           'instance_id': instance_id}
    vif_ref = db.virtual_interface_create(ctxt, vif)

    fixed_ip = {'address': ip,
                'network_id': network_ref['id'],
                'virtual_interface_id': vif_ref['id'],
                'allocated': True,
                'instance_id': instance_id}
    db.fixed_ip_create(ctxt, fixed_ip)
    fix_ref = db.fixed_ip_get_by_address(ctxt, ip)
    db.floating_ip_create(ctxt, {'address': flo_addr,
                                 'fixed_ip_id': fix_ref['id']})
Beispiel #2
0
def _setup_networking(instance_id, ip='1.2.3.4', flo_addr='1.2.1.2'):
    ctxt = context.get_admin_context()
    network_ref = db.project_get_networks(ctxt, 'fake', associate=True)[0]
    vif = {
        'address': '56:12:12:12:12:12',
        'network_id': network_ref['id'],
        'instance_id': instance_id
    }
    vif_ref = db.virtual_interface_create(ctxt, vif)

    fixed_ip = {
        'address': ip,
        'network_id': network_ref['id'],
        'virtual_interface_id': vif_ref['id'],
        'allocated': True,
        'instance_id': instance_id
    }
    db.fixed_ip_create(ctxt, fixed_ip)
    fix_ref = db.fixed_ip_get_by_address(ctxt, ip)
    db.floating_ip_create(ctxt, {
        'address': flo_addr,
        'fixed_ip_id': fix_ref['id']
    })
 def test_unreserve(self):
     self.commands.unreserve('192.168.0.100')
     address = db.fixed_ip_get_by_address(context.get_admin_context(),
                                          '192.168.0.100')
     self.assertEqual(address['reserved'], False)