def _do_report_luns(self, device_name): from infi.asi.executers import aix as aix_executer from infi.asi.coroutines.sync_adapter import sync_wait as _sync_wait from infi.asi.cdb.report_luns import ReportLunsCommand device = "/dev/{}" + device_name select_report = 0 with aix_executer(device) as executer: command = ReportLunsCommand(select_report=int(select_report)) result = _sync_wait(command.execute(executer)) return result.lun_list
def test_report_luns_command(): from infi.asi.unix import UnixFile import os if not os.path.exists("/dev/sg1"): 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 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 do_report_luns(sg_device): from infi.asi.cdb.report_luns import ReportLunsCommand cdb = ReportLunsCommand(select_report=0) return do_scsi_cdb(sg_device, cdb)