def storage_reset(hosts, user=None, hugepages="4096", insecure=True): """Execute prepare reset command through dmg tool to servers provided. Args: hosts (list): list of servers to run prepare on. user (str, optional): User with priviledges. Defaults to False. hugepages (str, optional): Hugepages to allocate. Defaults to "4096". Returns: Avocado CmdResult object that contains exit status, stdout information. """ # Create and setup the command dmg = DmgCommand(get_file_path("bin/dmg")) dmg.insecure.value = insecure dmg.hostlist.value = hosts dmg.request.value = "storage" dmg.action.value = "prepare" dmg.get_action_command() dmg.action_command.nvmeonly.value = True dmg.action_command.targetuser.value = getpass.getuser() \ if user is None else user dmg.action_command.hugepages.value = hugepages dmg.action_command.reset.value = True dmg.action_command.force.value = True try: result = dmg.run() except CommandFailure as details: print("<dmg> command failed: {}".format(details)) return None return result
def unittest_runner(self, unit_testname): """ Common unitetest runner function. Unit tests needs to be run on local machine incase of server start required For other unit tests, which does not required to start server,it needs to be run on server where /mnt/daos mounted. Args: unit_testname: unittest name. return: None """ name = self.params.get("testname", '/run/UnitTest/{0}/'.format(unit_testname)) server = self.params.get("test_machines", "/run/hosts/*") bin_path = get_file_path(name, "install/bin") cmd = ("ssh {} {}".format(server[0], bin_path[0])) return_code = process.system(cmd, ignore_status=True, allow_output_check="both") if return_code != 0: self.fail("{0} unittest failed with return code={1}.\n".format( unit_testname, return_code))
def storage_format(hosts, insecure=True): """ Execute format command through dmg tool to servers provided. Args: hosts (list): list of servers to run format on. Returns: Avocado CmdResult object that contains exit status, stdout information. """ # Create and setup the command dmg = DmgCommand(get_file_path("bin/dmg")) dmg.insecure.value = insecure dmg.hostlist.value = hosts dmg.request.value = "storage" dmg.action.value = "format" dmg.get_action_command() dmg.action_command.force.value = True try: result = dmg.run(sudo=True) except CommandFailure as details: print("<dmg> command failed: {}".format(details)) return None return result
def storage_prepare(hosts, user, device_type): """Prepare storage on servers using the DAOS server's yaml settings file. Args: hosts (str): a string of comma-separated host names user (str): username for file permissions device_type (str): storage type - scm or nvme Raises: ServerFailed: if server failed to prepare storage """ # Get the daos_server from the install path. Useful for testing # with daos built binaries. dev_param = "" device_args = "" daos_srv_bin = get_file_path("bin/daos_server") if device_type == "dcpm": dev_param = "-s" elif device_type == "dcpm_nvme": device_args = " --hugepages=4096" elif device_type == "ram_nvme" or device_type == "nvme": dev_param = "-n" device_args = " --hugepages=4096" else: raise ServerFailed("Invalid device type") cmd = ("sudo {} storage prepare {} -u \"{}\" {} -f".format( daos_srv_bin[0], dev_param, user, device_args)) result = pcmd(hosts, cmd, timeout=120) if len(result) > 1 or 0 not in result: raise ServerFailed("Error preparing NVMe storage")
def storage_reset(hosts): """ Reset the Storage on servers using the DAOS server's yaml settings file. Args: hosts (str): a string of comma-separated host names Raises: ServerFailed: if server failed to reset storage """ daos_srv_bin = get_file_path("bin/daos_server") cmd = "sudo {} storage prepare -n --reset -f".format(daos_srv_bin[0]) result = pcmd(hosts, cmd) if len(result) > 1 or 0 not in result: raise ServerFailed("Error resetting NVMe storage")
def storage_prepare(hosts, user): """ Prepare the storage on servers using the DAOS server's yaml settings file. Args: hosts (str): a string of comma-separated host names Raises: ServerFailed: if server failed to prepare storage """ daos_srv_bin = get_file_path("bin/daos_server") cmd = ("sudo {} storage prepare -n -u \"{}\" --hugepages=4096 -f" .format(daos_srv_bin[0], user)) result = pcmd(hosts, cmd, timeout=120) if len(result) > 1 or 0 not in result: raise ServerFailed("Error preparing NVMe storage")
def unittest_runner(self, unit_testname): """ Common unitetest runner function. Args: unit_testname: unittest name. return: None """ name = self.params.get("testname", '/run/UnitTest/{0}/' .format(unit_testname)) bin_path = get_file_path(name, "install/bin") cmd = ("{0}".format(bin_path[0])) return_code = process.system(cmd) if return_code is not 0: self.fail("{0} unittest failed with return code={1}.\n" .format(unit_testname, return_code))
def storage_reset(hosts): """Reset the Storage on servers using the DAOS server's yaml settings file. NOTE: Don't enhance this method to reset SCM. SCM will not be in a useful state for running next tests. Args: hosts (str): a string of comma-separated host names Raises: ServerFailed: if server failed to reset storage """ daos_srv_bin = get_file_path("bin/daos_server") cmd = "sudo {} storage prepare -n --reset -f".format(daos_srv_bin[0]) result = pcmd(hosts, cmd) if len(result) > 1 or 0 not in result: raise ServerFailed("Error resetting NVMe storage")