# Path: neutron/plugins/ml2/drivers/mech_sriov/agent/pci_lib.py
# LOG = logging.getLogger(__name__)
# class LinkState(enum.Enum):
# class PciDeviceIPWrapper(ip_lib.IPWrapper):
#     def __init__(self, dev_name):
#     def get_assigned_macs(self, vf_list):
#     def get_vf_state(self, vf_index):
#     def set_vf_state(self, vf_index, state, auto=False):
#     def set_vf_spoofcheck(self, vf_index, enabled):
#     def set_vf_rate(self, vf_index, rates):


import glob
import os
import re
from neutron_lib.utils import helpers
from oslo_log import log as logging
from neutron._i18n import _
from neutron.agent import rpc as agent_rpc
from neutron.plugins.ml2.drivers.mech_sriov.agent.common \
    import exceptions as exc
from neutron.plugins.ml2.drivers.mech_sriov.agent import pci_lib
    def get_assigned_devices_info(self, phys_net=None):
        """Get all assigned devices.

        Get all assigned devices belongs to given embedded switch
        @param phys_net: physical network, if none get all assigned devices
        @return: set of assigned VFs (mac address, pci slot) pair
        """
        if phys_net:
            eswitch_objects = self.emb_switches_map.get(phys_net, set())
        else:
            eswitch_objects = set()
            for eswitch_list in self.emb_switches_map.values():
                eswitch_objects |= set(eswitch_list)
        assigned_devices = set()
        for embedded_switch in eswitch_objects:
            for device in embedded_switch.get_assigned_devices_info():
                assigned_devices.add(device)
        return assigned_devices

    def get_device_state(self, device_mac, pci_slot):
        """Get device state.

        Get the device state (up/enable, down/disable, or auto)
        @param device_mac: device mac
        @param pci_slot: VF PCI slot
        @return: device state (enable/disable/auto) None if failed
        """
        embedded_switch = self._get_emb_eswitch(device_mac, pci_slot)
        if embedded_switch:
            return embedded_switch.get_device_state(pci_slot)

# Path: neutron/plugins/ml2/drivers/mech_sriov/agent/pci_lib.py
# LOG = logging.getLogger(__name__)
# class LinkState(enum.Enum):
# class PciDeviceIPWrapper(ip_lib.IPWrapper):
#     def __init__(self, dev_name):
#     def get_assigned_macs(self, vf_list):
#     def get_vf_state(self, vf_index):
#     def set_vf_state(self, vf_index, state, auto=False):
#     def set_vf_spoofcheck(self, vf_index, enabled):
#     def set_vf_rate(self, vf_index, rates):


# Path: neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py
import glob
import os
import re
from neutron_lib.utils import helpers
from oslo_log import log as logging
from neutron._i18n import _
from neutron.agent import rpc as agent_rpc
from neutron.plugins.ml2.drivers.mech_sriov.agent.common \
    import exceptions as exc
from neutron.plugins.ml2.drivers.mech_sriov.agent import pci_lib

    def get_assigned_devices_info(self, phys_net=None):
        """Get all assigned devices.

        Get all assigned devices belongs to given embedded switch
        @param phys_net: physical network, if none get all assigned devices
        @return: set of assigned VFs (mac address, pci slot) pair
        """
        if phys_net:
            eswitch_objects = self.emb_switches_map.get(phys_net, set())
        else:
            eswitch_objects = set()
            for eswitch_list in self.emb_switches_map.values():
                eswitch_objects |= set(eswitch_list)
        assigned_devices = set()
        for embedded_switch in eswitch_objects:
            for device in embedded_switch.get_assigned_devices_info():
                assigned_devices.add(device)
        return assigned_devices

    def get_device_state(self, device_mac, pci_slot):
        """Get device state.

        Get the device state (up/enable, down/disable, or auto)
        @param device_mac: device mac
        @param pci_slot: VF PCI slot
        @return: device state (enable/disable/auto) None if failed
        """
        embedded_switch = self._get_emb_eswitch(device_mac, pci_slot)
        if embedded_switch:
            return embedded_switch.get_device_state(pci_slot)

        return pci_lib.LinkState.disable.name