Exemplo n.º 1
0
 def find_disk_drive_by_block_access_path(self, path):
     from infi.storagemodel import get_storage_model
     scsi = get_storage_model().get_scsi()
     multipath = get_storage_model().get_native_multipath()
     storage_device = filter(lambda device: device.get_block_access_path() == path,
                             scsi.get_all_scsi_block_devices() + multipath.get_all_multipath_block_devices())[0]
     return LinuxDiskDrive(storage_device, path)
Exemplo n.º 2
0
 def find_disk_drive_by_block_access_path(self, path):
     from infi.storagemodel import get_storage_model
     scsi = get_storage_model().get_scsi()
     multipath = get_storage_model().get_native_multipath()
     all_devices = scsi.get_all_scsi_block_devices() + multipath.get_all_multipath_block_devices()
     storage_device = [device for device in all_devices if device.get_block_access_path() == path][0]
     return WindowsDiskDrive(storage_device, path)
Exemplo n.º 3
0
        def terminate_connection(cinder_volume, connector):
            from infi.storagemodel import get_storage_model

            for item in connector["wwns"] + connector["wwpns"]:
                assert isinstance(item, basestring)
            cls.volume_driver_by_type[cinder_volume.volume_type].terminate_connection(cinder_volume, connector)
            get_storage_model().refresh()
Exemplo n.º 4
0
def console_script():
    from platform import system
    from sys import stderr
    from logging import DEBUG, basicConfig
    if system() != "Linux":
        print "This script is for Linux only"
    basicConfig(stream=stderr, level=DEBUG)
    from infi.storagemodel import get_storage_model
    get_storage_model().rescan_and_wait_for(wait_on_rescan=True)
Exemplo n.º 5
0
def console_script():
    from platform import system
    from sys import stderr
    from logging import DEBUG, basicConfig
    if system() != "Linux":
        print("This script is for Linux only")
    basicConfig(stream=stderr, level=DEBUG, datefmt='%Y-%m-%d %H:%M:%S %z',
                format='%(asctime)-25s %(levelname)-8s %(name)-50s %(message)s')
    from infi.storagemodel import get_storage_model
    get_storage_model().rescan_and_wait_for(wait_for_completion=True)
Exemplo n.º 6
0
def main():
    from infi.storagemodel import get_storage_model
    print("\nPython Inquiry utility, Version V0.1 (using storagemodel by INFINIDAT)\n")
    print("-----------------------------------------------------------------------------------------------------------------------------------------------")
    print("DEVICE          \t:VEND     \t:PROD            \t:REV   \t:SER NUM                         \t:CAP(kb)            \t:PATHS")
    print("-----------------------------------------------------------------------------------------------------------------------------------------------")

    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger("inq")
    model = get_storage_model()
    scsi = model.get_scsi()
    mpio = model.get_native_multipath()
    mpaths = mpio.get_all_multipath_block_devices()
    block_devices = scsi.get_all_scsi_block_devices()
    non_mp_disks = mpio.filter_non_multipath_scsi_block_devices(block_devices)

    all_devices = non_mp_disks + mpaths

    try:
        all_devices.extend(model.get_veritas_multipath().get_all_multipath_block_devices())
    except:
        logger.exception("an error ocurred when fetching veritas multipath devices")

    for device in all_devices:
        try:
            print_device_details(device)
        except:
            logger.exception("an error ocurred when printing device details")
Exemplo n.º 7
0
 def __call__(self):
     from infi.storagemodel import get_storage_model
     model = get_storage_model()
     scsi = model.get_scsi()
     [device.get_scsi_test_unit_ready() for device in scsi.get_all_storage_controller_devices()]
     [device.get_scsi_test_unit_ready() for device in scsi.get_all_scsi_block_devices()]
     return True
Exemplo n.º 8
0
 def __call__(self):
     from infi.storagemodel import get_storage_model
     model = get_storage_model()
     multipath = model.get_native_multipath()
     [device.get_scsi_test_unit_ready() for device in multipath.get_all_multipath_block_devices()]
     [device.get_scsi_test_unit_ready() for device in multipath.get_all_multipath_storage_controller_devices()]
     return True
Exemplo n.º 9
0
 def test_get_sda(self):
     from infi.storagemodel import get_storage_model
     model = get_storage_model()
     block_devices = model.get_scsi().get_all_scsi_block_devices()
     disk = block_devices[0].get_disk_drive()
     self.assertFalse(disk.is_empty())
     partition_table = disk.get_partition_table()
     self.assertEqual(len(partition_table.get_partitions()), 3)
     size = disk.get_size_in_bytes()
Exemplo n.º 10
0
    def get_disk_drive(self):  # pragma: no cover
        """
        Returns a `infi.storagemodel.base.disk.DiskDrive` instance.

        Raises `infi.storagemodel.base.disk.NoSuchDisk` if not found.
        """
        from infi.storagemodel import get_storage_model
        model = get_storage_model().get_disk()
        return model.find_disk_drive_by_block_access_path(self.get_block_access_path())
Exemplo n.º 11
0
 def test_cached_methods(self):
     raise unittest.SkipTest("Skipping this test because _create_disk_model is not implemented on Windows and Linux for now")
     from infi.pyutils.lazy import populate_cache
     from infi.storagemodel import get_storage_model
     model = get_storage_model()
     scsi = model.get_scsi()
     native_multipath = model.get_native_multipath()
     devices = scsi.get_all_scsi_block_devices() + native_multipath.get_all_multipath_block_devices()
     for device in devices:
         populate_cache(device)
Exemplo n.º 12
0
 def _get_volume(self):
     from infi.wioctl.api import WindowsException
     from infi.storagemodel import get_storage_model
     from infi.diskmanagement.disk import Volume
     func = gevent_wrapper.defer(Volume.get_from_disk_and_partition)
     try:
         return func(self._partition_object._disk, self._partition_object,
                     get_storage_model()._create_mount_manager().mount_manager)
     except WindowsException:
         logger.exception("get_volume caught WindowsException")
         raise RescanIsNeeded()
Exemplo n.º 13
0
 def __call__(self):
     from .. import get_storage_model
     model = get_storage_model()
     block_devices = model.get_scsi().get_all_scsi_block_devices()
     mp_devices = model.get_native_multipath().get_all_multipath_block_devices()
     non_mp_devices = model.get_native_multipath().filter_non_multipath_scsi_block_devices(block_devices)
     devices = mp_devices + non_mp_devices
     for device in devices:
         device.get_scsi_test_unit_ready()
     return any([device.get_scsi_serial_number() == self.scsi_serial_number \
                 for device in devices])
def veritas_multipathing_context(output):
    if "windows" in get_platform_string():
        raise SkipTest
    with patch('infi.storagemodel.unix.veritas_multipath.VeritasMultipathClient.read_paths_list') as read_paths_list:
        with patch('infi.storagemodel.linux.sysfs.Sysfs.find_scsi_disk_by_hctl') as find_scsi_disk_by_hctl:
            with patch('infi.storagemodel.base.scsi.SCSIModel.find_scsi_block_device_by_block_access_path') as find_func:
                find_func.return_value = MockSCSIBlockDevice(None)
                find_scsi_disk_by_hctl.return_value = None
                read_paths_list.return_value = output
                sm = get_storage_model()
                clear_cache(sm)
                yield sm.get_veritas_multipath()
Exemplo n.º 15
0
 def test_cached_methods(self):
     raise unittest.SkipTest(
         "Skipping this test because _create_disk_model is not implemented on Windows and Linux for now"
     )
     from infi.pyutils.lazy import populate_cache
     from infi.storagemodel import get_storage_model
     model = get_storage_model()
     scsi = model.get_scsi()
     native_multipath = model.get_native_multipath()
     devices = scsi.get_all_scsi_block_devices(
     ) + native_multipath.get_all_multipath_block_devices()
     for device in devices:
         populate_cache(device)
Exemplo n.º 16
0
 def __call__(self):
     from infi.storagemodel import get_storage_model
     model = get_storage_model()
     scsi = model.get_scsi()
     [
         device.get_scsi_test_unit_ready()
         for device in scsi.get_all_storage_controller_devices()
     ]
     [
         device.get_scsi_test_unit_ready()
         for device in scsi.get_all_scsi_block_devices()
     ]
     return True
Exemplo n.º 17
0
 def __call__(self):
     from infi.storagemodel import get_storage_model
     model = get_storage_model()
     multipath = model.get_native_multipath()
     [
         device.get_scsi_test_unit_ready()
         for device in multipath.get_all_multipath_block_devices()
     ]
     [
         device.get_scsi_test_unit_ready() for device in
         multipath.get_all_multipath_storage_controller_devices()
     ]
     return True
Exemplo n.º 18
0
 def __call__(self):
     from .. import get_storage_model
     model = get_storage_model()
     self._build_product()
     logger.debug("Working on: {!r}".format(self))
     logger.debug("Looking for all scsi block devices")
     logger.debug("Expecting to find {} matches".format(len(self._expected_mappings)))
     for device in self._get_chain_of_devices(model):
         logger.debug("Found device: {!r}".format(device))
         if self._is_fc_connectivity_a_match(device):
             logger.debug("Connectivity matches, only {} more to go".format(self._expected_mappings))
     for device in model.get_native_multipath().get_all_multipath_block_devices():
         logger.debug("Found device: {!r}".format(device))
         for path in device.get_paths():
             if self._is_fc_connectivity_a_match(path):
                 logger.debug("Connectivity matches, only {} more to go".format(self._expected_mappings))
     if self._expected_mappings:
         logger.debug("Did not find all the mappings, {} missing".format(len(self._expected_mappings)))
         return False
     logger.debug("Found all expected mappings")
     return True
Exemplo n.º 19
0
 def __call__(self):
     from .. import get_storage_model
     model = get_storage_model()
     self._build_product()
     initial_count = len(self._expected_mappings)
     logger.debug("Working on: {!r}".format(self))
     logger.debug("Looking for all scsi block devices")
     logger.debug("Expecting to not find {} matches".format(initial_count))
     for device in self._get_chain_of_devices(model):
         logger.debug("Found device: {!r}".format(device))
         if self._is_fc_connectivity_a_match(device):
             logger.debug("Found a connectivity match I wasn't supposed to find")
             return False
     for device in model.get_native_multipath().get_all_multipath_block_devices():
         logger.debug("Found device: {!r}".format(device))
         for path in device.get_paths():
             if self._is_fc_connectivity_a_match(path):
                 logger.debug("Found a connectivity match I wasn't supposed to find")
                 return False
     logger.debug("Did not find any of the expected mappings")
     return True
Exemplo n.º 20
0
def main():
    from infi.storagemodel import get_storage_model

    print("\nPython Inquiry utility, Version V0.1 (using storagemodel by INFINIDAT)\n")
    print("-----------------------------------------------------------------------------------------------------------------------------------------------")
    print("DEVICE          \t:VEND     \t:PROD            \t:REV   \t:SER NUM                         \t:CAP(kb)            \t:PATHS")
    print("-----------------------------------------------------------------------------------------------------------------------------------------------")

    model = get_storage_model()
    scsi = model.get_scsi()
    mpio = model.get_native_multipath()
    mpaths = mpio.get_all_multipath_block_devices()
    block_devices = scsi.get_all_scsi_block_devices()
    non_mp_disks = mpio.filter_non_multipath_scsi_block_devices(block_devices)

    all_devices = non_mp_disks + mpaths

    for device in all_devices:
        try:
            print_device_details(device)
        except:
            pass
Exemplo n.º 21
0
 def __call__(self):
     from .. import get_storage_model
     model = get_storage_model()
     self._build_product()
     initial_count = len(self._expected_mappings)
     logger.debug("Working on: {!r}".format(self))
     logger.debug("Looking for all scsi block devices")
     logger.debug("Expecting to not find {} matches".format(initial_count))
     for device in self._get_chain_of_devices(model):
         logger.debug("Found device: {!r}".format(device))
         if self._is_fc_connectivity_a_match(device):
             logger.debug(
                 "Found a connectivity match I wasn't supposed to find")
             return False
     for device in model.get_native_multipath(
     ).get_all_multipath_block_devices():
         logger.debug("Found device: {!r}".format(device))
         for path in device.get_paths():
             if self._is_fc_connectivity_a_match(path):
                 logger.debug(
                     "Found a connectivity match I wasn't supposed to find")
                 return False
     logger.debug("Did not find any of the expected mappings")
     return True
Exemplo n.º 22
0
def devlist():
    # pylint: disable=R912

    from infi.storagemodel import get_storage_model
    from infi.storagemodel.vendor.infinidat.infinibox import vid_pid as infinibox_vid_pid
    model = get_storage_model()

    scsi_block_devices = model.get_scsi().get_all_scsi_block_devices()
    mp_devices = model.get_native_multipath().get_all_multipath_block_devices()
    non_mp_devices = model.get_native_multipath(
    ).filter_non_multipath_scsi_block_devices(scsi_block_devices)

    def print_header(header):
        print("%s\n%s" % (header, '=' * len(header)))

    print_header("Multipath Devices")

    def print_infinidat_device(device):
        print("skipping")

    def print_multipath_device(device):
        from infi.storagemodel.base.multipath import FailoverOnly, WeightedPaths, RoundRobinWithSubset
        print("{name}\t{size}MB\t{vid}\t{pid}\t{policy}\t{path_count}".format(
            name=device.get_display_name(),
            size=device.get_size_in_bytes() / 1024 / 1024,
            vid=device.get_scsi_vendor_id(),
            pid=device.get_scsi_product_id(),
            policy=device.get_policy().get_display_name(),
            path_count=len(device.get_paths())))
        for path in device.get_paths():
            print("\t\t{id}\t{state}\t{hctl!r}".format(
                id=path.get_display_name(),
                state=path.get_state(),
                hctl=path.get_hctl())),
            if isinstance(device.get_policy(), FailoverOnly):
                print("\t" +
                      ("Active" if path.get_path_id() ==
                       device.get_policy().active_path_id else "Standby"))
            elif isinstance(device.get_policy(), RoundRobinWithSubset):
                print("\t" +
                      ("Active" if path.get_path_id() in
                       device.get_policy().active_path_ids else "Standby"))
            elif isinstance(device.get_policy(), WeightedPaths):
                print("\t" + "Weight " +
                      str(device.get_policy().weights[path.get_path_id()]))
            else:
                print('')
            print("\t\t\t{} <--> {}".format(
                path.get_connectivity().get_initiator_wwn(),
                path.get_connectivity().get_target_wwn()))

    for device in model.get_native_multipath().filter_vendor_specific_devices(
            mp_devices, infinibox_vid_pid):
        print_multipath_device(device)
        print_infinidat_device(device)
        mp_devices.remove(device)

    for device in mp_devices:
        print_multipath_device(device)

    def print_non_multipath_device(device):
        from infi.storagemodel.connectivity import FCConnectivity
        print("{name}\t{size}MB\t{vid}\t{pid}\t{hctl}".format(
            name=device.get_display_name(),
            size=device.get_size_in_bytes() / 1024 / 1024,
            vid=device.get_scsi_vendor_id(),
            pid=device.get_scsi_product_id(),
            hctl=device.get_hctl()))
        if isinstance(device.get_connectivity(), FCConnectivity):
            print("\t{} <-->".format(
                device.get_connectivity().get_initiator_wwn(),
                device.get_connectivity().get_target_wwn()))

    print_header("Non-Multipath Devices")

    for device in model.get_scsi().filter_vendor_specific_devices(
            non_mp_devices, infinibox_vid_pid):
        print_non_multipath_device(device)
        print_infinidat_device(device)
        non_mp_devices.remove(device)

    for device in non_mp_devices:
        print_non_multipath_device(device)
Exemplo n.º 23
0
 def test_rescan__wait_for_completion(self):
     from infi.storagemodel import get_storage_model
     get_storage_model().rescan_and_wait_for(wait_on_rescan=True)
Exemplo n.º 24
0
 def test_rescan__timeout(self):
     from infi.storagemodel import get_storage_model
     from infi.storagemodel.errors import TimeoutError
     from infi.storagemodel.predicates import DiskExists
     self.assertRaises(TimeoutError, get_storage_model().rescan_and_wait_for, *(DiskExists("fooBar"), 1))
Exemplo n.º 25
0
 def setUp(self):
     try:
         self.model = get_storage_model()
     except ImportError:
         raise unittest.SkipTest()
     self.scsi = self.model.get_scsi()
Exemplo n.º 26
0
 def test_rescan__nothing(self):
     from infi.storagemodel import get_storage_model
     get_storage_model().rescan_and_wait_for()
Exemplo n.º 27
0
 def get_disk_drive(self): # pragma: no cover
     """:returns: a :class:`.DiskDevice` object
     :raises: NoSuchDisk"""
     from infi.storagemodel import get_storage_model
     model = get_storage_model().get_disk()
     return model.find_disk_drive_by_block_access_path(self.get_block_access_path())
Exemplo n.º 28
0
 def test_rescan__wait_for_completion(self):
     from infi.storagemodel import get_storage_model
     get_storage_model().rescan_and_wait_for(wait_for_completion=True)
Exemplo n.º 29
0
 def setUp(self):
     from infi.storagemodel import get_storage_model
     try:
         _ = get_storage_model()
     except ImportError:
         raise unittest.SkipTest("Unsupported Platform")
Exemplo n.º 30
0
 def setUp(self):
     from infi.storagemodel import get_storage_model
     try:
         _ = get_storage_model()
     except ImportError:
         raise unittest.SkipTest("Unsupported Platform")
Exemplo n.º 31
0
 def test_rescan__nothing(self):
     from infi.storagemodel import get_storage_model
     get_storage_model().rescan_and_wait_for()
Exemplo n.º 32
0
def devlist():
    # pylint: disable=R912

    from infi.storagemodel import get_storage_model
    from infi.storagemodel.vendor.infinidat.infinibox import vid_pid as infinibox_vid_pid
    model = get_storage_model()

    scsi_block_devices = model.get_scsi().get_all_scsi_block_devices()
    mp_devices = model.get_native_multipath().get_all_multipath_block_devices()
    non_mp_devices = model.get_native_multipath().filter_non_multipath_scsi_block_devices(scsi_block_devices)

    def print_header(header):
        print "%s\n%s" % (header, '=' * len(header))

    print_header("Multipath Devices")

    def print_infinidat_device(device):
        print "skipping"

    def print_multipath_device(device):
        from infi.storagemodel.base.multipath import FailoverOnly, WeightedPaths, RoundRobinWithSubset
        print "{name}\t{size}MB\t{vid}\t{pid}\t{policy}\t{path_count}".format(name=device.get_display_name(),
                    size=device.get_size_in_bytes() / 1024 / 1024,
                    vid=device.get_scsi_vendor_id(), pid=device.get_scsi_product_id(),
                    policy=device.get_policy().get_display_name(), path_count=len(device.get_paths()))
        for path in device.get_paths():
            print "\t\t{id}\t{state}\t{hctl!r}".format(id=path.get_display_name(), state=path.get_state(),
                                                       hctl=path.get_hctl()),
            if isinstance(device.get_policy(), FailoverOnly):
                print "\t" + ("Active" if path.get_path_id() == device.get_policy().active_path_id else "Standby")
            elif isinstance(device.get_policy(), RoundRobinWithSubset):
                print "\t" + ("Active" if path.get_path_id() in device.get_policy().active_path_ids else "Standby")
            elif isinstance(device.get_policy(), WeightedPaths):
                print "\t" + "Weight " + str(device.get_policy().weights[path.get_path_id()])
            else:
                print ''
            print "\t\t\t{} <--> {}".format(path.get_connectivity().get_initiator_wwn(),
                                          path.get_connectivity().get_target_wwn())

    for device in model.get_native_multipath().filter_vendor_specific_devices(mp_devices, infinibox_vid_pid):
        print_multipath_device(device)
        print_infinidat_device(device)
        mp_devices.remove(device)

    for device in mp_devices:
        print_multipath_device(device)

    def print_non_multipath_device(device):
        from infi.storagemodel.connectivity import FCConnectivity
        print "{name}\t{size}MB\t{vid}\t{pid}\t{hctl}".format(name=device.get_display_name(),
                    size=device.get_size_in_bytes() / 1024 / 1024,
                    vid=device.get_scsi_vendor_id(), pid=device.get_scsi_product_id(),
                    hctl=device.get_hctl())
        if isinstance(device.get_connectivity(), FCConnectivity):
            print "\t{} <-->".format(device.get_connectivity().get_initiator_wwn(),
                                     device.get_connectivity().get_target_wwn())

    print_header("Non-Multipath Devices")

    for device in model.get_scsi().filter_vendor_specific_devices(non_mp_devices, infinibox_vid_pid):
        print_non_multipath_device(device)
        print_infinidat_device(device)
        non_mp_devices.remove(device)

    for device in non_mp_devices:
        print_non_multipath_device(device)
Exemplo n.º 33
0
 def get_disk_drive(self):
     """Returns a `infi.storagemodel.base.disk.DiskDrive` object, or raises `infi.storagemodel.base.disk.NoSuchDisk`"""
     from infi.storagemodel import get_storage_model
     model = get_storage_model().get_disk()
     return model.find_disk_drive_by_block_access_path(self.get_block_access_path())
 def setUp(self):
     try:
         self.model = get_storage_model()
     except ImportError:
         raise unittest.SkipTest()
     self.scsi = self.model.get_scsi()
Exemplo n.º 35
0
 def get_disk_drive(self):
     """Returns a `infi.storagemodel.base.disk.DiskDrive` object, or raises `infi.storagemodel.base.disk.NoSuchDisk`"""
     from infi.storagemodel import get_storage_model
     model = get_storage_model().get_disk()
     return model.find_disk_drive_by_block_access_path(
         self.get_block_access_path())