# Path: os_win/_i18n.py
# _LI = _translators.log_info
# _LW = _translators.log_warning
# _LE = _translators.log_error
# _LC = _translators.log_critical
# 
# Path: os_win/exceptions.py
#     class WindowsError(Exception):
#     class x_wmi(Exception):
#     class x_wmi_timed_out(x_wmi):
# class OSWinException(Exception):
# class NotFound(OSWinException):
# class PciDeviceNotFound(NotFound):
# class HyperVException(OSWinException):
# class VHDResizeException(HyperVException):
# class HyperVAuthorizationException(HyperVException):
# class HyperVVMNotFoundException(NotFound, HyperVException):
# class HyperVPortNotFoundException(NotFound, HyperVException):
# class HyperVvNicNotFound(NotFound, HyperVException):
# class HyperVvSwitchNotFound(NotFound, HyperVException):
# class Invalid(OSWinException):
# class UnsupportedOperation(Invalid):
# class InvalidParameterValue(Invalid):
# class InvalidVMVersion(Invalid):
# class SMBException(OSWinException):
# class Win32Exception(OSWinException):
# class VHDException(OSWinException):
# class VHDWin32APIException(VHDException, Win32Exception):
# class FCException(OSWinException):
# class FCWin32Exception(FCException, Win32Exception):
# class WMIException(OSWinException):
# class WqlException(OSWinException):
# class ISCSITargetException(OSWinException):
# class ISCSITargetWMIException(ISCSITargetException, WMIException):
# class ISCSIInitiatorAPIException(Win32Exception):
# class ISCSILunNotAvailable(ISCSITargetException):
# class Win32IOException(Win32Exception):
# class DiskNotFound(NotFound):
# class HyperVRemoteFXException(HyperVException):
# class HyperVClusterException(HyperVException):
# class DNSException(OSWinException):
# class Timeout(OSWinException):
# class DNSZoneNotFound(NotFound, DNSException):
# class DNSZoneAlreadyExists(DNSException):
# class WMIJobFailed(HyperVException):
# class JobTerminateFailed(HyperVException):
# class ClusterException(OSWinException):
# class ClusterObjectNotFound(NotFound, ClusterException):
# class ClusterWin32Exception(ClusterException, Win32Exception):
# class ClusterGroupMigrationFailed(ClusterException):
# class ClusterGroupMigrationTimeOut(ClusterGroupMigrationFailed):
# class ClusterPropertyRetrieveFailed(ClusterException):
# class ClusterPropertyListEntryNotFound(ClusterPropertyRetrieveFailed):
# class ClusterPropertyListParsingError(ClusterPropertyRetrieveFailed):
# class SCSIPageParsingError(Invalid):
# class SCSIIdDescriptorParsingError(Invalid):
# class ResourceUpdateError(OSWinException):
# class DiskUpdateError(OSWinException):
#         def __init__(self, winerror=None):
#         def __init__(self, info='', com_error=None):
#     def __init__(self, message=None, **kwargs):
#     def __init__(self, message=None, wmi_exc=None):
#     def __init__(self, message=None, **kwargs):
# 
# Path: os_win/utils/_wqlutils.py
# def get_element_associated_class(conn, class_name, element_instance_id=None,
#                                  element_uuid=None, fields=None):
# 
# Path: os_win/utils/baseutils.py
# LOG = logging.getLogger(__name__)
#     _WMI_CONS = {}
# class BaseUtils(object):
# class BaseUtilsVirt(BaseUtils):
# class SynchronizedMeta(type):
#     def _get_wmi_obj(self, moniker, **kwargs):
#     def _get_wmi_conn(self, moniker, **kwargs):
#     def __init__(self, host='.'):
#     def _conn(self):
#     def _compat_conn(self):
#     def _vs_man_svc(self):
#     def _get_wmi_compat_conn(self, moniker, **kwargs):
#     def _get_wmi_obj(self, moniker, compatibility_mode=False, **kwargs):
#     def __init__(cls, cls_name, bases, attrs):
#     def _synchronize(func, cls_name, rlock):
#         def wrapper(*args, **kwargs):


from oslo_log import log as logging
from os_win._i18n import _
from os_win import exceptions
from os_win.utils import _wqlutils
from os_win.utils import baseutils
        from os_win import utilsfactory
        return [v for v in all_metrics if
                v.MetricDefinitionId == metrics_def.Id]

    def _get_vm_resources(self, vm_name, resource_class):
        setting_data = self._get_vm_setting_data(vm_name)
        return _wqlutils.get_element_associated_class(
            self._conn, resource_class,
            element_instance_id=setting_data.InstanceID)

    def _get_vm(self, vm_name):
        vms = self._conn.Msvm_ComputerSystem(ElementName=vm_name)
        return self._unique_result(vms, vm_name)

    def _get_switch_port(self, port_name):
        ports = self._conn.Msvm_EthernetPortAllocationSettingData(
            ElementName=port_name)
        return self._unique_result(ports, port_name)

    def _get_vm_setting_data(self, vm_name):
        vssds = self._conn.Msvm_VirtualSystemSettingData(
            ElementName=vm_name)
        return self._unique_result(vssds, vm_name)

    @staticmethod
    def _unique_result(objects, resource_name):
        n = len(objects)
        if n == 0:
            raise exceptions.NotFound(resource=resource_name)
        elif n > 1:
            raise exceptions.OSWinException(

# Path: os_win/_i18n.py
# _LI = _translators.log_info
# _LW = _translators.log_warning
# _LE = _translators.log_error
# _LC = _translators.log_critical
# 
# Path: os_win/exceptions.py
#     class WindowsError(Exception):
#     class x_wmi(Exception):
#     class x_wmi_timed_out(x_wmi):
# class OSWinException(Exception):
# class NotFound(OSWinException):
# class PciDeviceNotFound(NotFound):
# class HyperVException(OSWinException):
# class VHDResizeException(HyperVException):
# class HyperVAuthorizationException(HyperVException):
# class HyperVVMNotFoundException(NotFound, HyperVException):
# class HyperVPortNotFoundException(NotFound, HyperVException):
# class HyperVvNicNotFound(NotFound, HyperVException):
# class HyperVvSwitchNotFound(NotFound, HyperVException):
# class Invalid(OSWinException):
# class UnsupportedOperation(Invalid):
# class InvalidParameterValue(Invalid):
# class InvalidVMVersion(Invalid):
# class SMBException(OSWinException):
# class Win32Exception(OSWinException):
# class VHDException(OSWinException):
# class VHDWin32APIException(VHDException, Win32Exception):
# class FCException(OSWinException):
# class FCWin32Exception(FCException, Win32Exception):
# class WMIException(OSWinException):
# class WqlException(OSWinException):
# class ISCSITargetException(OSWinException):
# class ISCSITargetWMIException(ISCSITargetException, WMIException):
# class ISCSIInitiatorAPIException(Win32Exception):
# class ISCSILunNotAvailable(ISCSITargetException):
# class Win32IOException(Win32Exception):
# class DiskNotFound(NotFound):
# class HyperVRemoteFXException(HyperVException):
# class HyperVClusterException(HyperVException):
# class DNSException(OSWinException):
# class Timeout(OSWinException):
# class DNSZoneNotFound(NotFound, DNSException):
# class DNSZoneAlreadyExists(DNSException):
# class WMIJobFailed(HyperVException):
# class JobTerminateFailed(HyperVException):
# class ClusterException(OSWinException):
# class ClusterObjectNotFound(NotFound, ClusterException):
# class ClusterWin32Exception(ClusterException, Win32Exception):
# class ClusterGroupMigrationFailed(ClusterException):
# class ClusterGroupMigrationTimeOut(ClusterGroupMigrationFailed):
# class ClusterPropertyRetrieveFailed(ClusterException):
# class ClusterPropertyListEntryNotFound(ClusterPropertyRetrieveFailed):
# class ClusterPropertyListParsingError(ClusterPropertyRetrieveFailed):
# class SCSIPageParsingError(Invalid):
# class SCSIIdDescriptorParsingError(Invalid):
# class ResourceUpdateError(OSWinException):
# class DiskUpdateError(OSWinException):
#         def __init__(self, winerror=None):
#         def __init__(self, info='', com_error=None):
#     def __init__(self, message=None, **kwargs):
#     def __init__(self, message=None, wmi_exc=None):
#     def __init__(self, message=None, **kwargs):
# 
# Path: os_win/utils/_wqlutils.py
# def get_element_associated_class(conn, class_name, element_instance_id=None,
#                                  element_uuid=None, fields=None):
# 
# Path: os_win/utils/baseutils.py
# LOG = logging.getLogger(__name__)
#     _WMI_CONS = {}
# class BaseUtils(object):
# class BaseUtilsVirt(BaseUtils):
# class SynchronizedMeta(type):
#     def _get_wmi_obj(self, moniker, **kwargs):
#     def _get_wmi_conn(self, moniker, **kwargs):
#     def __init__(self, host='.'):
#     def _conn(self):
#     def _compat_conn(self):
#     def _vs_man_svc(self):
#     def _get_wmi_compat_conn(self, moniker, **kwargs):
#     def _get_wmi_obj(self, moniker, compatibility_mode=False, **kwargs):
#     def __init__(cls, cls_name, bases, attrs):
#     def _synchronize(func, cls_name, rlock):
#         def wrapper(*args, **kwargs):


# Path: os_win/utils/metrics/metricsutils.py
from oslo_log import log as logging
from os_win._i18n import _
from os_win import exceptions
from os_win.utils import _wqlutils
from os_win.utils import baseutils
        from os_win import utilsfactory

        return [v for v in all_metrics if
                v.MetricDefinitionId == metrics_def.Id]

    def _get_vm_resources(self, vm_name, resource_class):
        setting_data = self._get_vm_setting_data(vm_name)
        return _wqlutils.get_element_associated_class(
            self._conn, resource_class,
            element_instance_id=setting_data.InstanceID)

    def _get_vm(self, vm_name):
        vms = self._conn.Msvm_ComputerSystem(ElementName=vm_name)
        return self._unique_result(vms, vm_name)

    def _get_switch_port(self, port_name):
        ports = self._conn.Msvm_EthernetPortAllocationSettingData(
            ElementName=port_name)
        return self._unique_result(ports, port_name)

    def _get_vm_setting_data(self, vm_name):
        vssds = self._conn.Msvm_VirtualSystemSettingData(
            ElementName=vm_name)
        return self._unique_result(vssds, vm_name)

    @staticmethod
    def _unique_result(objects, resource_name):
        n = len(objects)
        if n == 0:
            raise exceptions.NotFound(resource=resource_name)
        elif n > 1:
            raise exceptions.OSWinException(

                _('Duplicate resource name found: %s') % resource_name)