예제 #1
0
파일: vif.py 프로젝트: andymcc/nova
    def unplug(self, instance, vif):
        vif_type = vif['type']

        # instance.display_name could be unicode
        instance_repr = utils.get_obj_repr_unicode(instance)
        LOG.debug('vif_type=%(vif_type)s instance=%(instance)s '
                  'vif=%(vif)s',
                  {'vif_type': vif_type, 'instance': instance_repr,
                   'vif': vif})

        if vif_type is None:
            msg = _("vif_type parameter must be present for this vif_driver "
                    "implementation")
            raise exception.InternalError(msg)

        # Try os-vif codepath first
        vif_obj = os_vif_util.nova_to_osvif_vif(vif)
        if vif_obj is not None:
            self._unplug_os_vif(instance, vif_obj)
            return

        # Legacy non-os-vif codepath
        vif_slug = self._normalize_vif_type(vif_type)
        func = getattr(self, 'unplug_%s' % vif_slug, None)
        if not func:
            msg = _("Unexpected vif_type=%s") % vif_type
            raise exception.InternalError(msg)
        func(instance, vif)
예제 #2
0
파일: vif.py 프로젝트: andymcc/nova
    def get_config(self, instance, vif, image_meta,
                   inst_type, virt_type, host):
        vif_type = vif['type']
        vnic_type = vif['vnic_type']

        # instance.display_name could be unicode
        instance_repr = utils.get_obj_repr_unicode(instance)
        LOG.debug('vif_type=%(vif_type)s instance=%(instance)s '
                  'vif=%(vif)s virt_type=%(virt_type)s',
                  {'vif_type': vif_type, 'instance': instance_repr,
                   'vif': vif, 'virt_type': virt_type})

        if vif_type is None:
            raise exception.InternalError(
                _("vif_type parameter must be present "
                  "for this vif_driver implementation"))

        # Try os-vif codepath first
        vif_obj = os_vif_util.nova_to_osvif_vif(vif)
        if vif_obj is not None:
            return self._get_config_os_vif(instance, vif_obj, image_meta,
                                           inst_type, virt_type, host,
                                           vnic_type)

        # Legacy non-os-vif codepath
        vif_slug = self._normalize_vif_type(vif_type)
        func = getattr(self, 'get_config_%s' % vif_slug, None)
        if not func:
            raise exception.InternalError(
                _("Unexpected vif_type=%s") % vif_type)
        return func(instance, vif, image_meta,
                    inst_type, virt_type, host)
예제 #3
0
파일: vif.py 프로젝트: andymcc/nova
    def plug(self, instance, vif):
        vif_type = vif['type']

        # instance.display_name could be unicode
        instance_repr = utils.get_obj_repr_unicode(instance)
        LOG.debug('vif_type=%(vif_type)s instance=%(instance)s '
                  'vif=%(vif)s',
                  {'vif_type': vif_type, 'instance': instance_repr,
                   'vif': vif})

        if vif_type is None:
            raise exception.VirtualInterfacePlugException(
                _("vif_type parameter must be present "
                  "for this vif_driver implementation"))

        # Try os-vif codepath first
        vif_obj = os_vif_util.nova_to_osvif_vif(vif)
        if vif_obj is not None:
            self._plug_os_vif(instance, vif_obj)
            return

        # Legacy non-os-vif codepath
        vif_slug = self._normalize_vif_type(vif_type)
        func = getattr(self, 'plug_%s' % vif_slug, None)
        if not func:
            raise exception.VirtualInterfacePlugException(
                _("Plug vif failed because of unexpected "
                  "vif_type=%s") % vif_type)
        func(instance, vif)
예제 #4
0
파일: vif.py 프로젝트: yirenjie/TestNova
    def unplug(self, instance, vif):
        vif_type = vif['type']

        # instance.display_name could be unicode
        instance_repr = utils.get_obj_repr_unicode(instance)
        LOG.debug('vif_type=%(vif_type)s instance=%(instance)s '
                  'vif=%(vif)s',
                  {'vif_type': vif_type, 'instance': instance_repr,
                   'vif': vif})

        if vif_type is None:
            msg = _("vif_type parameter must be present for this vif_driver "
                    "implementation")
            raise exception.InternalError(msg)

        # Try os-vif codepath first
        vif_obj = os_vif_util.nova_to_osvif_vif(vif)
        if vif_obj is not None:
            self._unplug_os_vif(instance, vif_obj)
            return

        # Legacy non-os-vif codepath
        vif_slug = self._normalize_vif_type(vif_type)
        func = getattr(self, 'unplug_%s' % vif_slug, None)
        if not func:
            msg = _("Unexpected vif_type=%s") % vif_type
            raise exception.InternalError(msg)
        func(instance, vif)
예제 #5
0
파일: vif.py 프로젝트: yirenjie/TestNova
    def plug(self, instance, vif):
        vif_type = vif['type']

        # instance.display_name could be unicode
        instance_repr = utils.get_obj_repr_unicode(instance)
        LOG.debug('vif_type=%(vif_type)s instance=%(instance)s '
                  'vif=%(vif)s',
                  {'vif_type': vif_type, 'instance': instance_repr,
                   'vif': vif})

        if vif_type is None:
            raise exception.VirtualInterfacePlugException(
                _("vif_type parameter must be present "
                  "for this vif_driver implementation"))

        # Try os-vif codepath first
        vif_obj = os_vif_util.nova_to_osvif_vif(vif)
        if vif_obj is not None:
            self._plug_os_vif(instance, vif_obj)
            return

        # Legacy non-os-vif codepath
        vif_slug = self._normalize_vif_type(vif_type)
        func = getattr(self, 'plug_%s' % vif_slug, None)
        if not func:
            raise exception.VirtualInterfacePlugException(
                _("Plug vif failed because of unexpected "
                  "vif_type=%s") % vif_type)
        func(instance, vif)
예제 #6
0
파일: vif.py 프로젝트: yirenjie/TestNova
    def get_config(self, instance, vif, image_meta,
                   inst_type, virt_type, host):
        vif_type = vif['type']
        vnic_type = vif['vnic_type']

        # instance.display_name could be unicode
        instance_repr = utils.get_obj_repr_unicode(instance)
        LOG.debug('vif_type=%(vif_type)s instance=%(instance)s '
                  'vif=%(vif)s virt_type=%(virt_type)s',
                  {'vif_type': vif_type, 'instance': instance_repr,
                   'vif': vif, 'virt_type': virt_type})

        if vif_type is None:
            raise exception.InternalError(
                _("vif_type parameter must be present "
                  "for this vif_driver implementation"))

        # Try os-vif codepath first
        vif_obj = os_vif_util.nova_to_osvif_vif(vif)
        if vif_obj is not None:
            return self._get_config_os_vif(instance, vif_obj, image_meta,
                                           inst_type, virt_type, host,
                                           vnic_type)

        # Legacy non-os-vif codepath
        vif_slug = self._normalize_vif_type(vif_type)
        func = getattr(self, 'get_config_%s' % vif_slug, None)
        if not func:
            raise exception.InternalError(
                _("Unexpected vif_type=%s") % vif_type)
        return func(instance, vif, image_meta,
                    inst_type, virt_type, host)
예제 #7
0
 def test_get_obj_repr_unicode(self):
     instance = instance_obj.Instance()
     instance.display_name = u'\u00CD\u00F1st\u00E1\u00F1c\u00E9'
     # should be a bytes string if python2 before conversion
     self.assertIs(str, type(repr(instance)))
     self.assertIs(six.text_type,
                   type(utils.get_obj_repr_unicode(instance)))
예제 #8
0
    def get_config(self, instance, vif, image_meta, inst_type, virt_type,
                   host):
        vif_type = vif['type']
        vnic_type = vif['vnic_type']

        # instance.display_name could be unicode
        instance_repr = utils.get_obj_repr_unicode(instance)
        LOG.debug(
            'vif_type=%(vif_type)s instance=%(instance)s '
            'vif=%(vif)s virt_type=%(virt_type)s', {
                'vif_type': vif_type,
                'instance': instance_repr,
                'vif': vif,
                'virt_type': virt_type
            })

        if vif_type is None:
            raise exception.InternalError(
                _("vif_type parameter must be present "
                  "for this vif_driver implementation"))

        # Try os-vif codepath first
        vif_obj = os_vif_util.nova_to_osvif_vif(vif)
        if vif_obj is not None:
            return self._get_config_os_vif(instance, vif_obj, image_meta,
                                           inst_type, virt_type, host,
                                           vnic_type)

        # Legacy non-os-vif codepath
        args = (instance, vif, image_meta, inst_type, virt_type, host)
        if vif_type == network_model.VIF_TYPE_IOVISOR:
            return self.get_config_iovisor(*args)
        elif vif_type == network_model.VIF_TYPE_BRIDGE:
            return self.get_config_bridge(*args)
        elif vif_type == network_model.VIF_TYPE_802_QBG:
            return self.get_config_802qbg(*args)
        elif vif_type == network_model.VIF_TYPE_802_QBH:
            return self.get_config_802qbh(*args)
        elif vif_type == network_model.VIF_TYPE_HW_VEB:
            return self.get_config_hw_veb(*args)
        elif vif_type == network_model.VIF_TYPE_HOSTDEV:
            return self.get_config_hostdev_physical(*args)
        elif vif_type == network_model.VIF_TYPE_MACVTAP:
            return self.get_config_macvtap(*args)
        elif vif_type == network_model.VIF_TYPE_MIDONET:
            return self.get_config_midonet(*args)
        elif vif_type == network_model.VIF_TYPE_TAP:
            return self.get_config_tap(*args)
        elif vif_type == network_model.VIF_TYPE_IB_HOSTDEV:
            return self.get_config_ib_hostdev(*args)

        raise exception.InternalError(_('Unexpected vif_type=%s') % vif_type)
예제 #9
0
파일: vif.py 프로젝트: YLTiny/nova
    def unplug(self, instance, vif):
        vif_type = vif['type']

        # instance.display_name could be unicode
        instance_repr = utils.get_obj_repr_unicode(instance)
        LOG.debug('vif_type=%(vif_type)s instance=%(instance)s '
                  'vif=%(vif)s', {
                      'vif_type': vif_type,
                      'instance': instance_repr,
                      'vif': vif
                  })

        if vif_type is None:
            msg = _("vif_type parameter must be present for this vif_driver "
                    "implementation")
            raise exception.InternalError(msg)

        # Try os-vif codepath first
        vif_obj = os_vif_util.nova_to_osvif_vif(vif)
        if vif_obj is not None:
            self._unplug_os_vif(instance, vif_obj)
            return

        # Legacy non-os-vif codepath
        if vif_type == network_model.VIF_TYPE_IB_HOSTDEV:
            self.unplug_ib_hostdev(instance, vif)
        elif vif_type == network_model.VIF_TYPE_HW_VEB:
            self.unplug_hw_veb(instance, vif)
        elif vif_type == network_model.VIF_TYPE_MIDONET:
            self.unplug_midonet(instance, vif)
        elif vif_type == network_model.VIF_TYPE_IOVISOR:
            self.unplug_iovisor(instance, vif)
        elif vif_type == network_model.VIF_TYPE_TAP:
            self.unplug_tap(instance, vif)
        elif vif_type in {
                network_model.VIF_TYPE_802_QBG, network_model.VIF_TYPE_802_QBH,
                network_model.VIF_TYPE_HOSTDEV, network_model.VIF_TYPE_MACVTAP
        }:
            # These are no-ops
            pass
        else:
            # TODO(stephenfin): This should probably raise
            # VirtualInterfaceUnplugException
            raise exception.InternalError(
                _("Unplug VIF failed because of unexpected "
                  "vif_type=%s") % vif_type)