コード例 #1
0
def get_instance(context, pvm_uuid):
    """Get an instance, if there is one, that corresponds to the PVM UUID

    Not finding the instance can be a pretty normal case when handling events.
    Don't log exceptions for those cases.

    :param pvm_uuid: PowerVM UUID
    :return: OpenStack instance or None
    """
    uuid = pvm_uuid.lower()

    def get_inst():
        try:
            return objects.Instance.get_by_uuid(context, uuid)
        except exception.InstanceNotFound:
            return objects.Instance.get_by_uuid(context,
                                                _uuid_set_high_bit(uuid))

    try:
        return get_inst()
    except exception.InstanceNotFound:
        pass
    except Exception as e:
        LOG.debug('PowerVM UUID not found. %s', e)
    return None
コード例 #2
0
ファイル: vm.py プロジェクト: adreznec/nova-powervm
def get_instance(context, pvm_uuid):
    """Get an instance, if there is one, that corresponds to the PVM UUID

    Not finding the instance can be a pretty normal case when handling events.
    Don't log exceptions for those cases.

    :param pvm_uuid: PowerVM UUID
    :return: OpenStack instance or None
    """
    uuid = pvm_uuid.lower()

    def get_inst():
        try:
            return objects.Instance.get_by_uuid(context, uuid)
        except exception.InstanceNotFound:
            return objects.Instance.get_by_uuid(context,
                                                _uuid_set_high_bit(uuid))

    try:
        return get_inst()
    except exception.InstanceNotFound:
        pass
    except Exception as e:
        LOG.debug('PowerVM UUID not found. %s', e)
    return None