示例#1
0
    def plug(self, instance, vif):
        LOG.debug(_("plug: instance_uuid=%(uuid)s vif=%(vif)s")
                  % {'uuid': instance['uuid'], 'vif': vif})
        network, mapping = vif
        vif_uuid = mapping['vif_uuid']
        ctx = context.get_admin_context()
        node = bmdb.bm_node_get_by_instance_uuid(ctx, instance['uuid'])

        # TODO(deva): optimize this database query
        #             this is just searching for a free physical interface
        pifs = bmdb.bm_interface_get_all_by_bm_node_id(ctx, node['id'])
        for pif in pifs:
            if not pif['vif_uuid']:
                bmdb.bm_interface_set_vif_uuid(ctx, pif['id'], vif_uuid)
                LOG.debug(_("pif:%(id)s is plugged (vif_uuid=%(vif_uuid)s)")
                          % {'id': pif['id'], 'vif_uuid': vif_uuid})
                self._after_plug(instance, network, mapping, pif)
                return

        # NOTE(deva): should this really be raising an exception
        #             when there are no physical interfaces left?
        raise exception.NovaException(_(
                "Baremetal node: %(id)s has no available physical interface"
                " for virtual interface %(vif_uuid)s")
                % {'id': node['id'], 'vif_uuid': vif_uuid})
示例#2
0
    def plug(self, instance, vif):
        LOG.debug(
            _("plug: instance_uuid=%(uuid)s vif=%(vif)s") % {
                'uuid': instance['uuid'],
                'vif': vif
            })
        network, mapping = vif
        vif_uuid = mapping['vif_uuid']
        ctx = context.get_admin_context()
        node = bmdb.bm_node_get_by_instance_uuid(ctx, instance['uuid'])

        # TODO(deva): optimize this database query
        #             this is just searching for a free physical interface
        pifs = bmdb.bm_interface_get_all_by_bm_node_id(ctx, node['id'])
        for pif in pifs:
            if not pif['vif_uuid']:
                bmdb.bm_interface_set_vif_uuid(ctx, pif['id'], vif_uuid)
                LOG.debug(
                    _("pif:%(id)s is plugged (vif_uuid=%(vif_uuid)s)") % {
                        'id': pif['id'],
                        'vif_uuid': vif_uuid
                    })
                self._after_plug(instance, network, mapping, pif)
                return

        # NOTE(deva): should this really be raising an exception
        #             when there are no physical interfaces left?
        raise exception.NovaException(
            _("Baremetal node: %(id)s has no available physical interface"
              " for virtual interface %(vif_uuid)s") % {
                  'id': node['id'],
                  'vif_uuid': vif_uuid
              })
示例#3
0
 def test_unique_vif_uuid(self):
     pif1_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
                                      '0x1', 1)
     pif2_id = db.bm_interface_create(self.context, 2, '22:22:22:22:22:22',
                                      '0x2', 2)
     db.bm_interface_set_vif_uuid(self.context, pif1_id, 'AAAA')
     self.assertRaises(exception.DBError, db.bm_interface_set_vif_uuid,
                       self.context, pif2_id, 'AAAA')
示例#4
0
 def test_unique_vif_uuid(self):
     pif1_id = db.bm_interface_create(self.context, 1, '11:11:11:11:11:11',
                                     '0x1', 1)
     pif2_id = db.bm_interface_create(self.context, 2, '22:22:22:22:22:22',
                                      '0x2', 2)
     db.bm_interface_set_vif_uuid(self.context, pif1_id, 'AAAA')
     self.assertRaises(exception.DBError,
                       db.bm_interface_set_vif_uuid,
                       self.context, pif2_id, 'AAAA')
示例#5
0
 def _plug_vifs(self, instance, network_info, context=None):
     if not context:
         context = nova_context.get_admin_context()
     node = _get_baremetal_node_by_instance_uuid(instance['uuid'])
     if node:
         pifs = db.bm_interface_get_all_by_bm_node_id(context, node['id'])
         for pif in pifs:
             if pif['vif_uuid']:
                 db.bm_interface_set_vif_uuid(context, pif['id'], None)
     for (network, mapping) in network_info:
         self.vif_driver.plug(instance, (network, mapping))
 def _plug_vifs(self, instance, network_info, context=None):
     if not context:
         context = nova_context.get_admin_context()
     node = _get_baremetal_node_by_instance_uuid(instance['uuid'])
     if node:
         pifs = db.bm_interface_get_all_by_bm_node_id(context, node['id'])
         for pif in pifs:
             if pif['vif_uuid']:
                 db.bm_interface_set_vif_uuid(context, pif['id'], None)
     for vif in network_info:
         self.vif_driver.plug(instance, vif)
示例#7
0
 def unplug(self, instance, vif):
     LOG.debug(_("unplug: instance_uuid=%(uuid)s vif=%(vif)s"), {"uuid": instance["uuid"], "vif": vif})
     network, mapping = vif
     vif_uuid = mapping["vif_uuid"]
     ctx = context.get_admin_context()
     try:
         pif = bmdb.bm_interface_get_by_vif_uuid(ctx, vif_uuid)
         bmdb.bm_interface_set_vif_uuid(ctx, pif["id"], None)
         LOG.debug(_("pif:%(id)s is unplugged (vif_uuid=%(vif_uuid)s)") % {"id": pif["id"], "vif_uuid": vif_uuid})
         self._after_unplug(instance, network, mapping, pif)
     except exception.NovaException:
         LOG.warn(_("no pif for vif_uuid=%s") % vif_uuid)
示例#8
0
 def unplug(self, instance, vif):
     LOG.debug("unplug: instance_uuid=%s vif=%s", instance['uuid'], vif)
     network, mapping = vif
     ctx = context.get_admin_context()
     pif = bmdb.bm_interface_get_by_vif_uuid(ctx, mapping['vif_uuid'])
     if pif:
         bmdb.bm_interface_set_vif_uuid(ctx, pif['id'], None)
         LOG.debug("pif:%s is unplugged (vif_uuid=%s)",
                   pif['id'], mapping.get('vif_uuid'))
         self._after_unplug(instance, network, mapping, pif)
     else:
         LOG.warn("no pif for vif_uuid=%s" % mapping['vif_uuid'])
示例#9
0
 def unplug(self, instance, vif):
     LOG.debug("unplug: instance_uuid=%s vif=%s", instance['uuid'], vif)
     network, mapping = vif
     ctx = context.get_admin_context()
     pif = bmdb.bm_interface_get_by_vif_uuid(ctx, mapping['vif_uuid'])
     if pif:
         bmdb.bm_interface_set_vif_uuid(ctx, pif['id'], None)
         LOG.debug("pif:%s is unplugged (vif_uuid=%s)", pif['id'],
                   mapping.get('vif_uuid'))
         self._after_unplug(instance, network, mapping, pif)
     else:
         LOG.warn("no pif for vif_uuid=%s" % mapping['vif_uuid'])
示例#10
0
文件: vif_driver.py 项目: CLisa/nova
 def unplug(self, instance, vif):
     LOG.debug("unplug: instance_uuid=%(uuid)s vif=%(vif)s",
               {'uuid': instance['uuid'], 'vif': vif})
     vif_uuid = vif['id']
     ctx = context.get_admin_context()
     try:
         pif = bmdb.bm_interface_get_by_vif_uuid(ctx, vif_uuid)
         bmdb.bm_interface_set_vif_uuid(ctx, pif['id'], None)
         LOG.debug("pif:%(id)s is unplugged (vif_uuid=%(vif_uuid)s)",
                   {'id': pif['id'], 'vif_uuid': vif_uuid})
         self._after_unplug(instance, vif, pif)
     except exception.NovaException:
         LOG.warn(_("no pif for vif_uuid=%s") % vif_uuid)
示例#11
0
 def unplug(self, instance, vif):
     LOG.debug("unplug: instance_uuid=%(uuid)s vif=%(vif)s", {
         'uuid': instance['uuid'],
         'vif': vif
     })
     vif_uuid = vif['id']
     ctx = context.get_admin_context()
     try:
         pif = bmdb.bm_interface_get_by_vif_uuid(ctx, vif_uuid)
         bmdb.bm_interface_set_vif_uuid(ctx, pif['id'], None)
         LOG.debug("pif:%(id)s is unplugged (vif_uuid=%(vif_uuid)s)", {
             'id': pif['id'],
             'vif_uuid': vif_uuid
         })
         self._after_unplug(instance, vif, pif)
     except exception.NovaException:
         LOG.warn(_("no pif for vif_uuid=%s") % vif_uuid)
示例#12
0
 def plug(self, instance, vif):
     LOG.debug("plug: instance_uuid=%s vif=%s", instance['uuid'], vif)
     network, mapping = vif
     ctx = context.get_admin_context()
     node = bmdb.bm_node_get_by_instance_uuid(ctx, instance['uuid'])
     if not node:
         return
     pifs = bmdb.bm_interface_get_all_by_bm_node_id(ctx, node['id'])
     for pif in pifs:
         if not pif['vif_uuid']:
             bmdb.bm_interface_set_vif_uuid(ctx, pif['id'],
                                            mapping.get('vif_uuid'))
             LOG.debug("pif:%s is plugged (vif_uuid=%s)",
                       pif['id'], mapping.get('vif_uuid'))
             self._after_plug(instance, network, mapping, pif)
             return
     raise exception.NovaException(
             "baremetalnode:%s has no vacant pif for vif_uuid=%s"
             % (node['id'], mapping['vif_uuid']))
示例#13
0
 def plug(self, instance, vif):
     LOG.debug("plug: instance_uuid=%s vif=%s", instance['uuid'], vif)
     network, mapping = vif
     ctx = context.get_admin_context()
     node = bmdb.bm_node_get_by_instance_uuid(ctx, instance['uuid'])
     if not node:
         return
     pifs = bmdb.bm_interface_get_all_by_bm_node_id(ctx, node['id'])
     for pif in pifs:
         if not pif['vif_uuid']:
             bmdb.bm_interface_set_vif_uuid(ctx, pif['id'],
                                            mapping.get('vif_uuid'))
             LOG.debug("pif:%s is plugged (vif_uuid=%s)", pif['id'],
                       mapping.get('vif_uuid'))
             self._after_plug(instance, network, mapping, pif)
             return
     raise exception.NovaException(
         "baremetalnode:%s has no vacant pif for vif_uuid=%s" %
         (node['id'], mapping['vif_uuid']))