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 = nova_context.get_admin_context() node = db.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 = db.bm_interface_get_all_by_bm_node_id(ctx, node['id']) for pif in pifs: if not pif['vif_uuid']: db.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 })
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 = nova_context.get_admin_context() node = db.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 = db.bm_interface_get_all_by_bm_node_id(ctx, node['id']) for pif in pifs: if not pif['vif_uuid']: db.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})
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 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 = nova_context.get_admin_context() try: pif = db.bm_interface_get_by_vif_uuid(ctx, vif_uuid) db.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)
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 = nova_context.get_admin_context() try: pif = db.bm_interface_get_by_vif_uuid(ctx, vif_uuid) db.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)