def _get_dasd_pim(): """ Return a dictionary with bus ids of DASD devices as keys and number of paths as values """ pim_dict = {} # execute lscss -d command = ['lscss', '-d'] out, err, rc = run_command(command) if rc: raise OperationFailed("GINDASD0012E", {'err': err}) if out: try: output_lines = out.splitlines() for line in output_lines[2:]: clms = line.split() pim = clms[-5] bus_id = clms[0] chipid = clms[-2]+" "+clms[-1] binaryval_pam = _hex_to_binary(pim) enabled_chipids = _get_paths(binaryval_pam, chipid) pim_dict[bus_id] = len(enabled_chipids) except Exception as err: raise OperationFailed("GINDASD0013E", {'err': err.message}) return pim_dict
def test_get_paths_invalid_chipid(self): """ unit test to test for a valid scenario for invalid chipids and valid binary value of pam to get the installed paths """ chipid = 'ds0000 00000000' bin_pam = '10000000' out = utils._get_paths(bin_pam, chipid) installed_paths = ['fa'] self.assertNotEqual(installed_paths, out)
def test_get_paths_success(self): """ unit test to test for a valid scenario valid chipids and binary value of pam to get the installed paths """ chipid = 'fa000000 00000000' bin_pam = '10000000' installed_paths = ['fa'] out = utils._get_paths(bin_pam, chipid) self.assertEqual(installed_paths, out)