Best Python code snippet using lisa_python
nvme.py
Source:nvme.py
...32 def enabled(self) -> bool:33 return True34 def get_devices(self) -> List[str]:35 devices_list = []36 self._get_device_from_ls()37 for row in self._ls_devices.splitlines():38 matched_result = self._device_pattern.match(row)39 if matched_result:40 devices_list.append(matched_result.group("device_name"))41 return devices_list42 def get_namespaces(self) -> List[str]:43 namespaces = []44 self._get_device_from_ls()45 for row in self._ls_devices.splitlines():46 matched_result = self._namespace_pattern.match(row)47 if matched_result:48 namespaces.append(matched_result.group("namespace"))49 return namespaces50 def get_namespaces_from_cli(self) -> List[str]:51 namespaces_cli = []52 nvme_cli = self._node.tools[Nvmecli]53 nvme_list = nvme_cli.run("list", shell=True, sudo=True)54 for row in nvme_list.stdout.splitlines():55 matched_result = self._namespace_cli_pattern.match(row)56 if matched_result:57 namespaces_cli.append(matched_result.group("namespace"))58 return namespaces_cli59 def get_devices_from_lspci(self) -> List[PciDevice]:60 devices_from_lspci = []61 lspci_tool = self._node.tools[Lspci]62 device_list = lspci_tool.get_devices()63 devices_from_lspci = [64 x for x in device_list if self._pci_device_name == x.device_class65 ]66 return devices_from_lspci67 def get_raw_data_disks(self) -> List[str]:68 return self.get_namespaces()69 def _get_device_from_ls(self, force_run: bool = False) -> None:70 if (not self._ls_devices) or force_run:71 execute_results = self._node.execute(72 "ls -l /dev/nvme*", shell=True, sudo=True73 )74 self._ls_devices = execute_results.stdout75@dataclass_json()76@dataclass()77class NvmeSettings(FeatureSettings):78 type: str = "Nvme"79 disk_count: search_space.CountSpace = field(80 default=search_space.IntRange(min=0),81 metadata=field_metadata(decoder=search_space.decode_count_space),82 )83 def __eq__(self, o: object) -> bool:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!