def setUpClass(cls):
     if not path.exists("/usr/bin/cinder"):
         raise SkipTest("openstack not installed")
     if 'centos' not in get_platform_string() and 'redhat' not in get_platform_string():
         raise SkipTest("not centos or redhat")
     execute_assert_success(["yum", "install", "-y", "python-devel"])
     execute_assert_success(["rm", "-rf", "dist"])
Esempio n. 2
0
    def copy_deb_to_parts(egg_dir):
        from infi.os_info import get_platform_string

        for debfile in glob.glob(os.path.join(egg_dir, "deb_dist", "*.deb")):
            basename = os.path.basename(debfile.replace("_all", "-" + get_platform_string()))
            basename = basename.replace("_amd64", "-" + get_platform_string())
            basename = basename.replace("_i386", "-" + get_platform_string())
            shutil.copy(debfile, os.path.join("parts", basename))
Esempio n. 3
0
 def uninstall(self):
     if 'centos' in get_platform_string(
     ) or 'redhat' in get_platform_string():
         pkgmgr = infi.pkgmgr.get_package_manager()
         pkgmgr.remove_package('iscsi-initiator-utils')
     if 'ubuntu' in get_platform_string() or 'suse' in get_platform_string(
     ):
         pkgmgr = infi.pkgmgr.get_package_manager()
         pkgmgr.remove_package('open-iscsi')
Esempio n. 4
0
 def install(self):
     if 'centos' in get_platform_string(
     ) or 'redhat' in get_platform_string():
         pkgmgr = infi.pkgmgr.get_package_manager()
         pkgmgr.install_package('iscsi-initiator-utils')
     if 'ubuntu' in get_platform_string() or 'suse' in get_platform_string(
     ):
         pkgmgr = infi.pkgmgr.get_package_manager()
         pkgmgr.install_package('open-iscsi')
         if 'suse-12' in get_platform_string():
             self._execute(['service', 'iscsid', 'start'])
Esempio n. 5
0
 def is_installed(self):
     ''' In linux, return True if iSCSI initiator sw is installed otherwise return False
     '''
     if 'centos' in get_platform_string(
     ) or 'redhat' in get_platform_string():
         pkgmgr = infi.pkgmgr.get_package_manager()
         return pkgmgr.is_package_installed('iscsi-initiator-utils')
     if 'ubuntu' in get_platform_string() or 'suse' in get_platform_string(
     ):
         pkgmgr = infi.pkgmgr.get_package_manager()
         return pkgmgr.is_package_installed('open-iscsi')
Esempio n. 6
0
def is_iscsiadm_installed():
    from infi.os_info import get_platform_string
    if 'centos' in get_platform_string() or 'redhat' in get_platform_string():
        logger.debug("checking if iSCSI sw is installed")
        process = execute(['/bin/rpm', '-q', '--quiet', 'iscsi-initiator-utils'])
        if process.get_returncode() != 0:
            logger.debug("iscsi sw isn't installed")
            return False
        else:
            logger.debug("iscsi sw installed")
            return True
    return False
Esempio n. 7
0
def is_iscsiadm_installed():
    from infi.os_info import get_platform_string
    if 'centos' in get_platform_string() or 'redhat' in get_platform_string():
        logger.debug("checking if iSCSI sw is installed")
        process = execute(
            ['/bin/rpm', '-q', '--quiet', 'iscsi-initiator-utils'])
        if process.get_returncode() != 0:
            logger.debug("iscsi sw isn't installed")
            return False
        else:
            logger.debug("iscsi sw installed")
            return True
    return False
Esempio n. 8
0
 def _get_function(cls):
     # Solaris HBA library exported functions have Sun_fc prefix instead of HBA_, so we add this hack
     if 'solaris' in get_platform_string():
         parameters = cls.get_parameters()
         function = wrap_library_function(cls.__name__.replace("HBA_", "Sun_fc"), cls._get_library(), cls._get_function_type(),
                                          cls.return_value, parameters, cls.get_errcheck())
         return function
     elif 'aix' in get_platform_string():
         parameters = cls.get_parameters()
         function = wrap_library_function(cls.__name__.replace("HBA_", "PyHBA_"), cls._get_library(), cls._get_function_type(),
                                          cls.return_value, parameters, cls.get_errcheck())
         return function
     else:
         return super(HbaApiFunction, cls)._get_function()
Esempio n. 9
0
    def test_06_mutual_chap_login(self):
        if get_platform_string().startswith('solaris'):
            raise SkipTest("iSCSI CHAP on Solaris not supported - INFINIBOX-25831")

        net_space = self._get_system_net_space(self.system_sdk)
        ibox_version = self._get_infinibox_major_version(self.system_sdk)
        host = self._create_host(self.hostname)

        self._assert_discovery_login_logout(net_space, host, self.auth1, ibox_version)
        self._assert_discovery_login_logout(net_space, host, self.auth1, ibox_version)
        if get_platform_string().startswith('windows'):
            self._assert_login_to_two_systems(net_space, host, self.auth1, self.auth1, ibox_version)
        else:
            self._assert_login_to_two_systems(net_space, host, self.auth1, self.auth2, ibox_version)
        self._assert_login_to_two_systems(net_space, host, iscsi_auth.NoAuth(), iscsi_auth.NoAuth(), ibox_version)
Esempio n. 10
0
 def test_021_iscsiapi_reset_source_iqn_linux(self):
     if not get_platform_string().startswith('linux'):
         raise SkipTest("linux test skipping other platforms")
     old_iqn = self.iscsiapi.get_source_iqn()
     self.iscsiapi.reset_source_iqn(
     )  # in linux every run generate a different IQN
     self.assertNotEqual(old_iqn, self.iscsiapi.get_source_iqn())
Esempio n. 11
0
    def test_close_on_upgrade_or_removal(self, close_on_upgrade_or_removal):
        if close_on_upgrade_or_removal is False and 'windows' in get_platform_string():
            # this is not supported on Windows because we cannot override running executables
            raise unittest.SkipTest("Skipping")

        # for debian-based, this decision occurs in the version being upgraded
        self._apply_close_on_upgrade_or_removal('true' if close_on_upgrade_or_removal else 'false')

        self._rebuild_package()
        self.install_package()
        cleanup_buildout_logs()

        # start process and upgrade
        pid = self._run_the_installed_script_in_the_background()
        self._rebuild_package()
        self.install_package()

        # assert on upgrade
        cleanup_buildout_logs()
        pid.poll()
        self.assertEquals(close_on_upgrade_or_removal, pid.is_finished())

        # start process and uninstall
        pid = self._run_the_installed_script_in_the_background()
        self.uninstall_package()

        # assert on removal
        cleanup_buildout_logs()
        pid.poll()
        self.assertEquals(close_on_upgrade_or_removal, pid.is_finished())
Esempio n. 12
0
 def test_07_consistent_login(self):
     if get_platform_string().startswith('windows'):
         raise SkipTest("not available on this platform")
     net_space = self._get_system_net_space(self.system_sdk)
     host = self._create_host(self.hostname)
     ibox_version = self._get_infinibox_major_version(self.system_sdk)
     no_auth = iscsi_auth.NoAuth()
     chap_auth1 = iscsi_auth.ChapAuth(INBOUND_USERNAME, INBOUND_SECRET)
     chap_auth2 = iscsi_auth.ChapAuth(INBOUND_USERNAME2, INBOUND_SECRET2)
     self._assert_discovery_login_logout_consistent(net_space, host, no_auth, ibox_version)
     self._assert_login_to_two_systems_consistent(net_space, host, no_auth, no_auth, ibox_version)
     if not get_platform_string().startswith('solaris'):  # INFINIBOX-25831
         self._assert_discovery_login_logout_consistent(net_space, host, chap_auth1, ibox_version)
         self._assert_discovery_login_logout_consistent(net_space, host, self.auth1, ibox_version)
         self._assert_login_to_two_systems_consistent(net_space, host, chap_auth1, chap_auth2, ibox_version)
         self._assert_login_to_two_systems_consistent(net_space, host, self.auth1, self.auth2, ibox_version)
Esempio n. 13
0
    def test_close_on_upgrade_or_removal(self, close_on_upgrade_or_removal):
        if close_on_upgrade_or_removal is False and 'windows' in get_platform_string(
        ):
            # this is not supported on Windows because we cannot override running executables
            raise unittest.SkipTest("Skipping")

        # for debian-based, this decision occurs in the version being upgraded
        self._apply_close_on_upgrade_or_removal(
            'true' if close_on_upgrade_or_removal else 'false')

        self._rebuild_package()
        self.install_package()
        cleanup_buildout_logs()

        # start process and upgrade
        pid = self._run_the_installed_script_in_the_background()
        self._rebuild_package()
        self.install_package()

        # assert on upgrade
        cleanup_buildout_logs()
        pid.poll()
        self.assertEqual(close_on_upgrade_or_removal, pid.is_finished())

        # start process and uninstall
        pid = self._run_the_installed_script_in_the_background()
        self.uninstall_package()

        # assert on removal
        cleanup_buildout_logs()
        pid.poll()
        self.assertEqual(close_on_upgrade_or_removal, pid.is_finished())
Esempio n. 14
0
 def _get_local_port(self, adapter_handle, adapter_attributes, port_index):
     port_attributes = self._get_port_attributes(adapter_handle, port_index)
     port = get_port_object(adapter_attributes, port_attributes)
     log.debug("checking local fc port {!r}".format(port.port_wwn))
     self._populate_local_port_hct(port)
     wwn_buffer = self._extract_wwn_buffer_from_port_attributes(
         port_attributes)
     number_of_remote_ports = port_attributes.NumberOfDiscoveredPorts
     remote_ports = self._get_remote_ports(adapter_handle, port_index,
                                           number_of_remote_ports)
     port.discovered_ports = remote_ports
     port_statistics = self._get_local_port_statistics(
         adapter_handle, port_index, wwn_buffer)
     port.statistics = port_statistics
     port.all_port_mappings = self._get_local_port_mappings(
         adapter_handle, wwn_buffer)
     port_mappings = self._mappings_to_dict(port.all_port_mappings)
     for remote_port in port.discovered_ports:
         platform = get_platform_string()
         if "aix" in platform:
             channel, target = 0, int(remote_port.port_wwn._address, 16)
         else:
             channel, target = port_mappings.get(remote_port.port_wwn,
                                                 (-1, -1))
         remote_port.hct = (port.hct[0], channel, target)
     return port
Esempio n. 15
0
 def uninstall(self):
     platform = get_platform_string()
     if any(dist in platform for dist in ('redhat', 'centos', 'oracle')):
         pkgmgr = infi.pkgmgr.get_package_manager()
         pkgmgr.remove_package('iscsi-initiator-utils')
     if any(dist in platform for dist in ('ubuntu', 'suse')):
         pkgmgr = infi.pkgmgr.get_package_manager()
         pkgmgr.remove_package('open-iscsi')
Esempio n. 16
0
 def _get_library(cls):
     library_name = HBAAPI_SHARED_LIBRARY_FILENAMES.get(get_platform_string().split("-")[0], None)
     if library_name is None:
         raise OSError
     try:
         return ctypes.cdll.LoadLibrary(library_name)
     except:
         raise OSError
Esempio n. 17
0
def get_package_manager():
    from infi.os_info import get_platform_string
    platform_name = get_platform_string().split("-")[0]
    if platform_name == 'linux':
        # get distribution
        platform_name = get_platform_string().split("-")[1]
    pkgmgr_dict = {
        'ubuntu': UbuntuPackageManager,
        'redhat': RedHatPackageManager,
        'centos': RedHatPackageManager,
        'suse': SusePackageManager,
        'solaris': SolarisPackageManager
    }
    if platform_name in pkgmgr_dict:
        return pkgmgr_dict.get(platform_name)()
    else:
        raise RuntimeError("Package Manager is not implemented for {}".format(platform_name))
Esempio n. 18
0
 def _get_library(cls):
     library_name = HBAAPI_SHARED_LIBRARY_FILENAMES.get(
         get_platform_string().split("-")[0], None)
     if library_name is None:
         raise OSError
     try:
         return ctypes.cdll.LoadLibrary(library_name)
     except:
         raise OSError
Esempio n. 19
0
 def test_01_iscsi_software(self):
     iscsi_sw = infi.iscsiapi.get_iscsi_software_initiator()
     if get_platform_string().startswith('solaris'):
         raise SkipTest("iSCSI is installed by default on Solaris")
     if not iscsi_sw.is_installed():
         iscsi_sw.install()
         iscsi_sw.uninstall()
         iscsi_sw.install()
     self.assertNotEqual(iscsi_sw.is_installed, True)
 def setUpClass(cls):
     if not path.exists("/opt/stack"):
         raise SkipTest("devstack not installed")
     if 'ubuntu' not in get_platform_string():
         raise SkipTest("not ubuntu")
     execute_assert_success("apt-get install -y python-all python-all-dev python-setuptools debhelper".split(' '))
     execute_assert_success("/usr/bin/easy_install -U setuptools".split(' '))
     execute_assert_success("/usr/bin/easy_install -U stdeb".split(' '))
     execute_assert_success(["rm", "-rf", "dist"])
Esempio n. 21
0
 def is_available(cls):
     if get_platform_string().split("-")[0] not in ("windows", "solaris", "aix"):
         return False
     try:
         c_api.HBA_GetVersion._get_function()  # pylint: disable-msg=W0212,E1101
         return True
     except OSError:
         pass
     return False
Esempio n. 22
0
 def test_022_iscsiapi_reset_source_iqn_windows(self):
     from infi.execute import execute_assert_success
     from infi.dtypes.iqn import IQN, InvalidIQN
     if not get_platform_string().startswith('windows'):
         raise SkipTest("windows test skipping other platforms")
     execute_assert_success(['iscsicli', 'NodeName', 'invalid.iqn'])
     self.assertRaises(InvalidIQN, self.iscsiapi.get_source_iqn)
     self.iscsiapi.reset_source_iqn()
     self.assertEqual(IQN, type(self.iscsiapi.get_source_iqn()))
Esempio n. 23
0
 def _get_function(cls):
     # Solaris HBA library exported functions have Sun_fc prefix instead of HBA_, so we add this hack
     if 'solaris' in get_platform_string():
         parameters = cls.get_parameters()
         function = wrap_library_function(
             cls.__name__.replace("HBA_", "Sun_fc"), cls._get_library(),
             cls._get_function_type(), cls.return_value, parameters,
             cls.get_errcheck())
         return function
     elif 'aix' in get_platform_string():
         parameters = cls.get_parameters()
         function = wrap_library_function(
             cls.__name__.replace("HBA_", "PyHBA_"), cls._get_library(),
             cls._get_function_type(), cls.return_value, parameters,
             cls.get_errcheck())
         return function
     else:
         return super(HbaApiFunction, cls)._get_function()
Esempio n. 24
0
 def is_installed(self):
     ''' In linux, return True if iSCSI initiator sw is installed otherwise return False
     '''
     platform = get_platform_string()
     if any(dist in platform for dist in ('redhat', 'centos', 'oracle')):
         pkgmgr = infi.pkgmgr.get_package_manager()
         return pkgmgr.is_package_installed('iscsi-initiator-utils')
     if any(dist in platform for dist in ('ubuntu', 'suse')):
         pkgmgr = infi.pkgmgr.get_package_manager()
         return pkgmgr.is_package_installed('open-iscsi')
Esempio n. 25
0
 def is_installed(self):
     ''' Return True if iSCSI initiator sw is installed otherwise return False
     '''
     if 'solaris' in get_platform_string():
         process1 = execute('pkginfo', '-q', 'SUNWiscsir')
         process2 = execute('pkginfo', '-q', 'SUNWiscsiu')
         if process1.get_returncode() == process2.get_returncode() == 0:
             return True
         else:
             return False
Esempio n. 26
0
 def is_installed(self):
     ''' Return True if iSCSI initiator sw is installed otherwise return False
     '''
     if 'solaris' in get_platform_string():
         process1 = execute('pkginfo', '-q', 'SUNWiscsir')
         process2 = execute('pkginfo', '-q', 'SUNWiscsiu')
         if process1.get_returncode() == process2.get_returncode() == 0:
             return True
         else:
             return False
Esempio n. 27
0
 def install(self):
     platform = get_platform_string()
     if any(dist in platform for dist in ('redhat', 'centos', 'oracle')):
         pkgmgr = infi.pkgmgr.get_package_manager()
         pkgmgr.install_package('iscsi-initiator-utils')
     if any(dist in platform for dist in ('ubuntu', 'suse')):
         pkgmgr = infi.pkgmgr.get_package_manager()
         pkgmgr.install_package('open-iscsi')
         if 'suse-12' in platform:
             self._execute(['service', 'iscsid', 'start'])
def get_platform_specific_iscsi_service():
    from infi.os_info import get_platform_string
    platform = get_platform_string()
    if platform.startswith('windows'):
        return ISCSIWindowsServiceStates()
    elif platform.startswith('linux'):
        return ISCSILinuxServiceStates()
    elif platform.startswith('solaris'):
        return ISCSISolarisServiceStates()
    else:
        raise ImportError("not supported on this platform")
Esempio n. 29
0
 def _set_url(self):
     from zc.buildout import UserError
     from infi.os_info import get_platform_string
     self.version = self.options.get('version', None)
     if not self.version:
         raise UserError("version option is missing")
     self.download_base = self.options.get('download-base', DOWNLOAD_BASE)
     if not self.download_base:
         raise UserError("download-base option is missing")
     filename = "python-%s-%s.tar.gz" % (self.version, get_platform_string())
     self.url = "/".join([self.download_base, filename])
Esempio n. 30
0
def get_platform_specific_iscsi_service():
    from infi.os_info import get_platform_string
    platform = get_platform_string()
    if platform.startswith('windows'):
        return ISCSIWindowsServiceStates()
    elif platform.startswith('linux'):
        return ISCSILinuxServiceStates()
    elif platform.startswith('solaris'):
        return ISCSISolarisServiceStates()
    else:
        raise ImportError("not supported on this platform")
Esempio n. 31
0
 def is_available(cls):
     if get_platform_string().split('-')[0] not in ('windows', 'solaris',
                                                    'aix'):
         return False
     try:
         c_api.HBA_GetVersion._get_function(
         )  #pylint: disable-msg=W0212,E1101
         return True
     except OSError:
         pass
     return False
Esempio n. 32
0
 def read_multipaths_list(self):
     # On Solaris 11, "mpathadm show lu" shows details for all LUNs, so listing them first ("mpathadm list lu") is
     # redundant. On Solaris 10, "mpathadm show lu" expects a LUN operand, therefore we need to list the LUNs first.
     # Listing all LUNs is run-time heavy, we'd like to avoid that if possible:
     from infi.os_info import get_platform_string
     if 'solaris-11' in get_platform_string():
         # For Solaris 11:
         return self._run_command("mpathadm show lu")
     device_list = self._run_command("mpathadm list lu")
     device_paths = self.MULTIPATH_DEVICE_REGEXP.findall(device_list)
     return self._run_command("mpathadm show lu {}".format(
         " ".join(device_paths)))
Esempio n. 33
0
 def get_library_name(cls):
     if sys.maxsize < 2**32:
         libdir = 'lib'
     else:
         platform_string = get_platform_string()
         if 'x64' in platform_string:
             libdir = 'lib/amd64'
         elif 'sparc' in platform_string:
             libdir = 'lib/sparcv9'
         else:
             return ''
     return '/{}/libkstat.so'.format(libdir)
Esempio n. 34
0
 def get_library_name(cls):
     if sys.maxsize < 2 ** 32:
         libdir = "lib"
     else:
         platform_string = get_platform_string()
         if "x64" in platform_string:
             libdir = "lib/amd64"
         elif "sparc" in platform_string:
             libdir = "lib/sparcv9"
         else:
             return ""
     return "/{}/libkstat.so".format(libdir)
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()
Esempio n. 36
0
 def _set_url(self):
     from zc.buildout import UserError
     from infi.os_info import get_platform_string
     self.version = self.options.get('version', None)
     if not self.version:
         raise UserError("version option is missing")
     self.download_base = self.options.get('download-base', DOWNLOAD_BASE)
     if not self.download_base:
         raise UserError("download-base option is missing")
     filename = "python-%s-%s.tar.gz" % (self.version,
                                         get_platform_string())
     self.url = "/".join([self.download_base, filename])
Esempio n. 37
0
 def get_library_name(cls):
     if sys.maxsize < 2 ** 32:
         libdir = 'lib'
     else:
         platform_string = get_platform_string()
         if 'x64' in platform_string:
             libdir = 'lib/amd64'
         elif 'sparc' in platform_string:
             libdir = 'lib/sparcv9'
         else:
             return ''
     return '/{}/libkstat.so'.format(libdir)
Esempio n. 38
0
def _get_platform_specific_iscsiapi():
    from infi.os_info import get_platform_string
    platform = get_platform_string()
    if platform.startswith('windows'):
        from . import windows
        return windows.WindowsISCSIapi()
    elif platform.startswith('linux'):
        from . import linux
        return linux.LinuxISCSIapi()
    elif platform.startswith('solaris'):
        from . import solaris
        return solaris.SolarisISCSIapi()
    else:
        raise ImportError("not supported on this platform")
Esempio n. 39
0
def _get_platform_specific_iscsi_software_initiator():
    from infi.os_info import get_platform_string
    platform = get_platform_string()
    if platform.startswith('windows'):
        from . import windows
        return windows.MicrosoftSoftwareInitiator()
    elif platform.startswith('linux'):
        from . import linux
        return linux.LinuxSoftwareInitiator()
    elif platform.startswith('solaris'):
        from . import solaris
        return solaris.SolarisSoftwareInitiator()
    else:
        raise ImportError("not supported on this platform")
Esempio n. 40
0
def _get_platform_specific_mountmanager_class():
    from .base import MountManager as PlatformMountManager
    from brownie.importing import import_string
    plat = get_platform_string().split('-')[0]
    platform_module_string = "{}.{}".format(__name__, plat)
    platform_module = import_string(platform_module_string)
    try:
        PlatformMountManager = getattr(
            platform_module, "{}MountManager".format(plat.capitalize()))
    except AttributeError:
        msg = "Failed to import platform-specific mount manager"
        logger.exception(msg)
        raise chain(ImportError(msg))
    return PlatformMountManager
 def read_multipaths_list(self):
     # On Solaris 11, "mpathadm show lu" shows details for all LUNs, so listing them first ("mpathadm list lu") is
     # redundant. On Solaris 10, "mpathadm show lu" expects a LUN operand, therefore we need to list the LUNs first.
     # Listing all LUNs is run-time heavy, we'd like to avoid that if possible:
     from infi.os_info import get_platform_string
     if 'solaris-11' in get_platform_string():
         # For Solaris 11:
         return self._run_command("mpathadm show lu")
     device_list = self._run_command("mpathadm list lu")
     device_paths = self.MULTIPATH_DEVICE_REGEXP.findall(device_list)
     if not device_paths:    # no devices
         logger.debug("no device paths found")
         return ''
     return self._run_command("mpathadm show lu {}".format(" ".join(device_paths)))
Esempio n. 42
0
 def test_020_iscsiapi_set_source_iqn(self):
     from infi.dtypes.iqn import IQN, InvalidIQN
     if get_platform_string().startswith('windows'):
         self.iscsiapi.reset_source_iqn()
     new_iqn_string = 'iqn.1991-05.com.microsoft:asdasd'
     invalid_iqn_type_a = '1'
     invalid_iqn_type_b = ''
     original_iqn = self.iscsiapi.get_source_iqn()
     self.iscsiapi.set_source_iqn(new_iqn_string)
     self.assertEqual(type(self.iscsiapi.get_source_iqn()), IQN)
     self.assertEqual(str(self.iscsiapi.get_source_iqn()), new_iqn_string)
     self.assertRaises(InvalidIQN, self.iscsiapi.set_source_iqn, invalid_iqn_type_a)
     self.assertRaises(InvalidIQN, self.iscsiapi.set_source_iqn, invalid_iqn_type_b)
     self.iscsiapi.set_source_iqn(str(original_iqn))
     self.assertEqual(str(self.iscsiapi.get_source_iqn()), original_iqn)
Esempio n. 43
0
    def test_05_chap_login(self):
        if get_platform_string().startswith('solaris'):
            raise SkipTest("iSCSI CHAP on Solaris not supported - INFINIBOX-25831")

        net_space = self._get_system_net_space(self.system_sdk)
        ibox_version = self._get_infinibox_major_version(self.system_sdk)
        host = self._create_host(self.hostname)
        auth1 = iscsi_auth.ChapAuth(INBOUND_USERNAME, INBOUND_SECRET)
        auth2 = iscsi_auth.ChapAuth(INBOUND_USERNAME2, INBOUND_SECRET2)

        self._assert_discovery_login_logout(net_space, host, auth1, ibox_version)
        self._assert_discovery_login_logout(net_space, host, auth1, ibox_version)

        self._assert_login_to_two_systems(net_space, host, auth1, auth2, ibox_version)
        self._assert_login_to_two_systems(net_space, host, iscsi_auth.NoAuth(), iscsi_auth.NoAuth(), ibox_version)
Esempio n. 44
0
def test_report_luns_command():
    from infi.os_info import get_platform_string
    from infi.asi.unix import UnixFile
    import os
    if 'ubuntu' not in get_platform_string() or not os.path.exists("/dev/sg1"):
        # on some of our other environments, sg0 is the cdrom and sg1 is the local disk, and on others it's the
        # other way around. just test this on Ubuntu only.
        return
    from infi.asi.coroutines.sync_adapter import sync_wait
    from infi.asi.cdb.report_luns import ReportLunsCommand
    from infi.asi import create_platform_command_executer
    handle = UnixFile(os.open("/dev/sg1", os.O_RDWR))
    executer = create_platform_command_executer(handle)
    cdb = ReportLunsCommand(select_report=0)
    result = sync_wait(cdb.execute(executer))
    assert result.lun_list != []
    assert 0 in result.lun_list
Esempio n. 45
0
def test_report_luns_command():
    from infi.os_info import get_platform_string
    from infi.asi.unix import UnixFile
    import os
    if 'ubuntu' not in get_platform_string() or not os.path.exists("/dev/sg1"):
        # on some of our other environments, sg0 is the cdrom and sg1 is the local disk, and on others it's the
        # other way around. just test this on Ubuntu only.
        return
    from infi.asi.coroutines.sync_adapter import sync_wait
    from infi.asi.cdb.report_luns import ReportLunsCommand
    from infi.asi import create_platform_command_executer
    handle = UnixFile(os.open("/dev/sg1", os.O_RDWR))
    executer = create_platform_command_executer(handle)
    cdb = ReportLunsCommand(select_report=0)
    result = sync_wait(cdb.execute(executer))
    assert result.lun_list != []
    assert 0 in result.lun_list
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:
                with patch('infi.storagemodel.linux.scsi.is_sg_module_loaded') as is_sg_module_loaded:
                        with patch("infi.storagemodel.get_storage_model") as get_storage_model:
                            from infi.storagemodel.linux import LinuxStorageModel
                            find_func.return_value = MockSCSIBlockDevice(None)
                            find_scsi_disk_by_hctl.return_value = None
                            read_paths_list.return_value = output
                            is_sg_module_loaded.return_value = True
                            sm = LinuxStorageModel()
                            get_storage_model.return_value = sm
                            yield sm.get_veritas_multipath()
Esempio n. 47
0
 def _get_local_port(self, adapter_handle, adapter_attributes, port_index):
     port_attributes = self._get_port_attributes(adapter_handle, port_index)
     port = get_port_object(adapter_attributes, port_attributes)
     log.debug("checking local fc port {!r}".format(port.port_wwn))
     self._populate_local_port_hct(port)
     wwn_buffer = self._extract_wwn_buffer_from_port_attributes(port_attributes)
     number_of_remote_ports = port_attributes.NumberOfDiscoveredPorts
     remote_ports = self._get_remote_ports(adapter_handle, port_index, number_of_remote_ports)
     port.discovered_ports = remote_ports
     port_statistics = self._get_local_port_statistics(adapter_handle, port_index, wwn_buffer)
     port.statistics = port_statistics
     port.all_port_mappings = self._get_local_port_mappings(adapter_handle, wwn_buffer)
     port_mappings = self._mappings_to_dict(port.all_port_mappings)
     for remote_port in port.discovered_ports:
         platform = get_platform_string()
         if "aix" in platform:
             channel, target = 0, int(remote_port.port_wwn._address, 16)
         else:
             channel, target = port_mappings.get(remote_port.port_wwn, (-1, -1))
         remote_port.hct = (port.hct[0], channel, target)
     return port
Esempio n. 48
0
def get_platform_name():
    from infi.os_info import get_platform_string
    return get_platform_string().split('-')[0]
Esempio n. 49
0
def get_platform_name():
    from infi.os_info import get_platform_string
    return get_platform_string().split('-')[0]
Esempio n. 50
0
 def should_run(cls):
     return 'solaris' in get_platform_string()
Esempio n. 51
0
 def should_run(cls):
     return 'ubuntu' in get_platform_string() or 'debian' in get_platform_string()
 def test_platform_string(self, test_subject):
     expected = test_subject.pop('expected')
     self.assertEquals(
         expected, get_platform_string(FakePlatformMorule(**test_subject)))