def get(self, vibname): cmdline = 'software vib get -n %s' % vibname parser = self.get_parser() handlers = (parser.parse_software_vib_get_n, first) handler = command.UnixBaseCmd.compose_handler(handlers) return command.UnixBaseCmd(cmdline, handler=handler)
def list(self): cmdline = 'storage core path list' parser = self.get_parser() handlers = (parser.parse_storage_core_path_list, ) handler = command.UnixBaseCmd.compose_handler(handlers) return command.UnixBaseCmd(cmdline, handler=handler)
def e(self): '''Creates new command appending '-e' option responsible for "canonicalize by following every symlink in every component of the given name recursively, all components must exist" @return: new command instance with '-e' option @rtype: command.UnixBaseCmd ''' return command.UnixBaseCmd(self.cmdline + " -e", handler=self.handler)
def get_vendor(self, vmhba, executor): handler = comp(*reversed((command.cmdlet.raiseOnNonZeroReturnCode, command.cmdlet.raiseWhenOutputIsNone, command.cmdlet.stripOutput, _parse_vmkchdev_l))) lspci = command.UnixBaseCmd("vmkchdev -l | grep %s" % vmhba, handler=handler) result = executor.process(lspci) result = result.handler(result) return vendors.find_name_by_id_in_hex(result)
def process(self, namespace): '''Builds esxcli command @param namespace: esxcli namespace to execute @type namespace: esxcle.Namespace @return: esxcli command @rtype: command.Cmd ''' handler = comp(namespace.handler, self.handler) cmdline = ' '.join((self.cmdline, namespace.cmdline)) return command.UnixBaseCmd(cmdline, handler=handler)
def get_vendor_by_device_id(self, device_id, executor): '''Returns vendor name by device id @param device_id: id of device in form <domain>:<bus>:<slot> @type device_id: basestring @param executor: instance of a command executor @type executor: command.Executor @return: vendor name @rtype: basestring ''' handler = comp(*reversed((command.cmdlet.raiseOnNonZeroReturnCode, command.cmdlet.raiseWhenOutputIsNone, command.cmdlet.stripOutput, fptools.methodcaller('splitlines'), _parse_lspci))) lspci = command.UnixBaseCmd("lspci -v -m -n -s %s" % device_id, handler=handler) result = executor.process(lspci) return vendors.find_name_by_id_in_hex(result.get('vendor'))
def get_driver_version(self, driverid, exec_): '''Discovers driver version string by provided device id with `lslpp` command @param driverid: driver id string returned either by `fcstat fcx`, `lsdev -vpd -dev fcx` or `lscfg -vpl fcx` commands @type driverid: str @param exec_: callable to execute commands and produce result @type exec_: callable[command.Cmd]->object @return: driver version string @rtype: str ''' cmdline = 'lslpp -l "*%s.rte"' % driverid handlers = (command.UnixBaseCmd.DEFAULT_HANDLERS + (command.raise_on_non_zero_return_code, command.raise_when_output_is_empty, attrgetter('output'), methodcaller('strip'), methodcaller('splitlines'), _parse_driver_version)) handler = command.UnixBaseCmd.compose_handler(handlers) c = command.UnixBaseCmd(cmdline, handler=handler) return exec_(c)
def list(self): cmdline = 'storage san fc list' parser = self.get_parser() handlers = (parser.parse_storage_san_fc_list, ) handler = Cmd.compose_handler(handlers) return command.UnixBaseCmd(cmdline, handler=handler)