def system_stop(self, force=False, ranks=None): """Stop the system. Args: force (bool, optional): whether to force the stop. Defaults to False. ranks (str, optional): comma separated ranks to stop. Defaults to None. Raises: CommandFailure: if the dmg system stop command fails. Returns: dict: a dictionary of host ranks and their unique states. """ self._get_result(("system", "stop"), force=force, ranks=ranks) # Populate a dictionary with host set keys for each unique state, ex: # Rank Operation Result # ---- --------- ------ # 0 stop want Stopped, got Ready data = {} match = re.findall(r"(?:\[*([0-9-,]+)\]*)\s+([A-Za-z]+)\s+(.*)", self.result.stdout) for info in match: for rank in get_numeric_list(info[0]): data[rank] = info[1].strip() return data
def system_start(self, ranks=None): """Start the system. Args: ranks (str, optional): comma separated ranks to stop. Defaults to None. Raises: CommandFailure: if the dmg system start command fails. Returns: dict: a dictionary of host ranks and their unique states. """ self._get_result(("system", "start"), ranks=ranks) # Populate a dictionary with host set keys for each unique state data = {} match = re.findall( r"(?:\[*([0-9-,]+)\]*)\s+([A-Za-z]+)\s+(.*)", self.result.stdout_text) for info in match: for rank in get_numeric_list(info[0]): data[rank] = info[1].strip() return data
def pool_list(self): """List pools. Raises: CommandFailure: if the dmg pool pool list command fails. Returns: dict: a dictionary of pool UUID keys and svc replica values """ self._get_result(("pool", "list")) # Populate a dictionary with svc replicas for each pool UUID key listed # Sample dmg pool list output: # Pool UUID Svc Replicas # --------- ------------ # 43bf2fe8-cb92-46ec-b9e9-9b056725092a 0 # 98736dfe-cb92-12cd-de45-9b09875092cd 1 data = {} match = re.findall( r"(?:([0-9a-fA-F][0-9a-fA-F-]+)\W+([0-9][0-9,-]*))", self.result.stdout_text) for info in match: data[info[0]] = get_numeric_list(info[1]) return data
def system_query(self, ranks=None, verbose=True): """Query system to obtain the status of the servers. Args: ranks (str): Specify specific ranks to obtain it's status. Use comma separated list for multiple ranks. e.g., 0,1. Defaults to None, which means report all available ranks. verbose (bool): To obtain detailed query report Raises: CommandFailure: if the dmg system query command fails. Returns: dict: a dictionary of host ranks and their unique states. """ self._get_result(("system", "query"), ranks=ranks, verbose=verbose) data = {} if re.findall(r"Rank \d+", self.result.stdout): # Process the unique single rank system query output, e.g. # Rank 1 # ------ # address : 10.8.1.11:10001 # uuid : d7a69a41-59a2-4dec-a620-a52217851285 # status : Joined # reason : match = re.findall( r"(?:Rank|address\s+:|uuid\s+:|status\s+:|reason\s+:)\s+(.*)", self.result.stdout) if match: data[int(match[0])] = { "address": match[1].strip(), "uuid": match[2].strip(), "state": match[3].strip(), "reason": match[4].strip(), } elif verbose: # Process the verbose multiple rank system query output, e.g. # Rank UUID Control Address State # ---- ---- --------------- ----- # 0 385af2f9-1863-406c-ae94-bffdcd02f379 10.8.1.10:10001 Joined # 1 d7a69a41-59a2-4dec-a620-a52217851285 10.8.1.11:10001 Joined # Rank UUID Control Address Fault Domain State Reason # ---- ---- --------------- ------------ ----- ------ # 0 <uuid> <address> <domain> Joined system stop # 1 <uuid> <address> <domain> Joined system stop # # Where the above placeholders have values similar to: # <uuid> = 0c21d700-0e2b-46fb-be49-1fca490ce5b0 # <address> = 10.8.1.142:10001 # <domain> = /wolf-142.wolf.hpdd.intel.com # match = re.findall( r"(\d+)\s+([0-9a-f-]+)\s+([0-9.:]+)\s+([/A-Za-z0-9-_.]+)" r"\s+([A-Za-z]+)(.*)", self.result.stdout) for info in match: data[int(info[0])] = { "uuid": info[1], "address": info[2], "domain": info[3], "state": info[4], "reason": info[5].strip(), } else: # Process the non-verbose multiple rank system query output, e.g. # Rank State # ---- ----- # [0-1] Joined match = re.findall(r"(?:\[*([0-9-,]+)\]*)\s+([A-Za-z]+)", self.result.stdout) for info in match: for rank in get_numeric_list(info[0]): data[rank] = {"state": info[1]} self.log.info("system_query data: %s", str(data)) return data