def _from_phy_host(instance_id, tenant_id):
    LOG.debug('_from_phy_host(instance_id=%s,tenant_id=%s)', instance_id, tenant_id)
    ctx = context.get_admin_context()
    info = []
    for vif in db.virtual_interface_get_by_instance(ctx, instance_id):
        LOG.debug('vif=%s', vif.__dict__)
        mac = vif.address
        network_ref = vif.network
        if not network_ref:
            LOG.warn('vif.network is None')
            continue
        LOG.debug('vif.network=%s', network_ref.__dict__)
        network_uuid = network_ref.uuid
        if not network_uuid:
            LOG.warn('network_uuid is None')
            continue
        vifinfo_uuid = _get_vifinfo_uuid(tenant_id, vif.uuid)
        LOG.debug('vifinfo_uuid=%s', vifinfo_uuid)
        if not vifinfo_uuid:
            continue
        fixed_ip = db.fixed_ip_get_by_virtual_interface(ctx, vif.id)
        if not fixed_ip:
            LOG.warn('fixed_ip is None')
            continue
        addrs = [ fip.address for fip in fixed_ip ]
        info.append( (vifinfo_uuid, network_uuid, mac, addrs) )
    LOG.debug('_from_phy_host(instance_id=%s,tenant_id=%s) end: info=%s', instance_id, tenant_id, info)
    return info
Ejemplo n.º 2
0
 def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
     """Returns a list of IPv4 address strings associated with
        the specified virtual interface, based on the fixed_ips table.
     """
     vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
     fixed_ips = db.fixed_ip_get_by_virtual_interface(
         context, vif_rec['id'])
     return [fixed_ip['address'] for fixed_ip in fixed_ips]
Ejemplo n.º 3
0
 def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
     """Returns a list of IPv4 address strings associated with
        the specified virtual interface, based on the fixed_ips table.
     """
     vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
     fixed_ips = db.fixed_ip_get_by_virtual_interface(context,
                                                      vif_rec['id'])
     return [fixed_ip['address'] for fixed_ip in fixed_ips]
 def test_multi_nic(self):
     """
     Multinic - Verify that nics as specified in the database are created
     in the guest
     """
     vifs = db.virtual_interface_get_by_instance(context.get_admin_context(),
                                                 instance_info.local_id)
     for vif in vifs:
         fixed_ip = db.fixed_ip_get_by_virtual_interface(context.get_admin_context(),
                                                         vif['id'])
         vz_ip = get_vz_ip_for_device(instance_info.local_id,
                                      vif['network']['bridge_interface'])
         assert_equal(vz_ip, fixed_ip[0]['address'])
Ejemplo n.º 5
0
 def test_multi_nic(self):
     """
     Multinic - Verify that nics as specified in the database are created
     in the guest
     """
     admin_context = context.get_admin_context()
     vifs = db.virtual_interface_get_by_instance(admin_context(),
                                                 instance_info.local_id)
     for vif in vifs:
         fixed_ip = db.fixed_ip_get_by_virtual_interface(
             admin_context(), vif['id'])
         vz_ip = get_vz_ip_for_device(instance_info.local_id,
                                      vif['network']['bridge_interface'])
         assert_equal(vz_ip, fixed_ip[0]['address'])
Ejemplo n.º 6
0
 def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
     """Deallocate all fixed IPs associated with the specified
        virtual interface.
     """
     try:
         admin_context = context.elevated()
         fixed_ips = db.fixed_ip_get_by_virtual_interface(admin_context,
                                                          vif_ref['id'])
         for fixed_ip in fixed_ips:
             db.fixed_ip_update(admin_context, fixed_ip['address'],
                                {'allocated': False,
                                 'virtual_interface_id': None})
     except exception.FixedIpNotFoundForInstance:
         LOG.error(_('No fixed IPs to deallocate for vif %s' %
                         vif_ref['id']))
Ejemplo n.º 7
0
 def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
     """Deallocate all fixed IPs associated with the specified
        virtual interface.
     """
     try:
         admin_context = context.elevated()
         fixed_ips = db.fixed_ip_get_by_virtual_interface(
             admin_context, vif_ref['id'])
         for fixed_ip in fixed_ips:
             db.fixed_ip_update(admin_context, fixed_ip['address'], {
                 'allocated': False,
                 'virtual_interface_id': None
             })
     except exception.FixedIpNotFoundForInstance:
         LOG.error(
             _('No fixed IPs to deallocate for vif %s' % vif_ref['id']))