def _get_unconfigured_devices(key=None): """ :param key: key for which value is unique :return:Returns list of all the un-configured device info if key is None Else returns dictionary of un-configured OSA device info with key as value of key passed """ wok_log.info('Retrieving un-configured devices using znetconf -u') cmd = [ZNETCONF_CMD, '-u'] output, err, rc = run_command(cmd) if rc: err = err.strip().replace('znetconf:', '').strip() wok_log.error('Failed to run \"znetconf -u\" command. Error: %s' % err) raise OperationFailed("GS390XCMD0001E", { 'command': cmd, 'rc': rc, 'reason': err }) device_pattern = r'(\d\.\d\.[0-9a-fA-F]{4},' \ r'\d\.\d\.[0-9a-fA-F]{4},' \ r'\d\.\d\.[0-9a-fA-F]{4})\s+' \ r'(\w+\/\w+)\s+' \ r'(OSA\s+\(\w+\))\s+' \ r'([0-9a-fA-F]{2})\s+' \ r'(qeth)\s{0,}$' wok_log.info('parsing znetconf -u output') if key: unconfigured_devices = utils.get_rows_info( cmd_output=output, hdr_pattern=UNCONF_HDR_PATTERN, unique_col=key, val_pattern=device_pattern, format_data=_format_znetconf, hdr_index=1, val_start_index=3) else: unconfigured_devices = utils.get_rows_info( cmd_output=output, hdr_pattern=UNCONF_HDR_PATTERN, val_pattern=device_pattern, format_data=_format_znetconf, hdr_index=1, val_start_index=3) wok_log.info('successfully retrieved and parsed un-configured devices') return unconfigured_devices
def _get_configured_devices(key=None): """ :param key: key for which value is unique :return:Returns list of all the configured device info if key is None Else returns dictionary of configured OSA device info with key as value of key passed """ wok_log.info('Retrieving configured devices using znetconf -c') cmd = [ZNETCONF_CMD, '-c'] output, err, rc = run_command(cmd) if rc: err = err.strip().replace('znetconf:', '').strip() wok_log.error('Failed to run \"znetconf -c\" command. Error: %s' % err) raise OperationFailed("GS390XCMD0001E", {'command': cmd, 'rc': rc, 'reason': err}) device_pattern = r'(\d\.\d\.[0-9a-fA-F]{4},' \ r'\d\.\d\.[0-9a-fA-F]{4},' \ r'\d\.\d\.[0-9a-fA-F]{4})\s+' \ r'(\w+\/\w+)\s+' \ r'(\w+)\s+' \ r'([0-9a-fA-F]{2})\s+' \ r'(qeth)\s+' \ r'(\w+\d\.\d\.[0-9a-fA-F]{4})\s+' \ r'(\w+)\s{0,}$' wok_log.info('parsing znetconf -c output') if key: configured_devices = utils.get_rows_info( cmd_output=output, hdr_pattern=CONF_HDR_PATTERN, unique_col=key, val_pattern=device_pattern, format_data=_format_znetconf, hdr_index=0, val_start_index=2) else: configured_devices = utils.get_rows_info( cmd_output=output, hdr_pattern=CONF_HDR_PATTERN, val_pattern=device_pattern, format_data=_format_znetconf, hdr_index=0, val_start_index=2) wok_log.info('successfully retrieved and parsed configured devices') return configured_devices
def get_list(self, _type=None): """ :param _type: supported types are dasd-eckd, zfcp. Based on this devices will be retrieved :return: device data list. """ device_paths = [] if _type is None: device_paths.extend(utils.get_directories(syspath_eckd)) device_paths.extend(utils.get_directories(syspath_zfcp)) elif _type == DEV_TYPES[0]: device_paths = utils.get_directories(syspath_eckd) elif _type == DEV_TYPES[1]: device_paths = utils.get_directories(syspath_zfcp) else: wok_log.error("Invalid _type given. _type: %s" % _type) raise InvalidParameter("GS390XINVTYPE", {'supported_type': DEV_TYPES}) if not device_paths: return [] command = [lscss] msg = 'The command executed is "%s" ' % command wok_log.debug(msg) out, err, rc = run_command(command) if rc: err = err.strip().replace("lscss:", '').strip() wok_log.error(err) raise OperationFailed("GS390XCMD0001E", { 'command': command, 'rc': rc, 'reason': err }) device_pattern = r'(\d\.\d\.[0-9a-fA-F]{4})\s+' \ r'(\d\.\d\.[0-9a-fA-F]{4})\s+' \ r'(\w+\/\w+)\s+' \ r'(\w+\/\w+)\s' \ r'(\s{3}|yes)\s+' \ r'([0-9a-fA-F]{2})\s+' \ r'([0-9a-fA-F]{2})\s+' \ r'([0-9a-fA-F]{2})\s+' \ r'(\w+\s\w+)' devices = utils.get_rows_info(out, HEADER_PATTERN, device_pattern, unique_col='device', format_data=_format_lscss) device_data_list = _list_devicesinfo(devices, device_paths) return device_data_list
def get_list(self, _type=None): """ :param _type: supported types are dasd-eckd, zfcp. Based on this devices will be retrieved :return: device data list. """ device_paths = [] if _type is None: device_paths.extend(utils.get_directories(syspath_eckd)) device_paths.extend(utils.get_directories(syspath_zfcp)) elif _type == DEV_TYPES[0]: device_paths = utils.get_directories(syspath_eckd) elif _type == DEV_TYPES[1]: device_paths = utils.get_directories(syspath_zfcp) else: wok_log.error("Invalid _type given. _type: %s" % _type) raise InvalidParameter("GS390XINVTYPE", {'supported_type': DEV_TYPES}) if not device_paths: return [] command = [lscss] msg = 'The command executed is "%s" ' % command wok_log.debug(msg) out, err, rc = run_command(command) if rc: err = err.strip().replace("lscss:", '').strip() wok_log.error(err) raise OperationFailed("GS390XCMD0001E", {'command': command, 'rc': rc, 'reason': err}) device_pattern = r'(\d\.\d\.[0-9a-fA-F]{4})\s+' \ r'(\d\.\d\.[0-9a-fA-F]{4})\s+' \ r'(\w+\/\w+)\s+' \ r'(\w+\/\w+)\s' \ r'(\s{3}|yes)\s+' \ r'([0-9a-fA-F]{2})\s+' \ r'([0-9a-fA-F]{2})\s+' \ r'([0-9a-fA-F]{2})\s+' \ r'(\w+\s\w+)' devices = utils.get_rows_info(out, HEADER_PATTERN, device_pattern, unique_col='device', format_data=_format_lscss) device_data_list = _list_devicesinfo(devices, device_paths) return device_data_list