当前位置: 首页>>代码示例>>Python>>正文


Python Workspace.check_workspace_exists方法代码示例

本文整理汇总了Python中infrasim.workspace.Workspace.check_workspace_exists方法的典型用法代码示例。如果您正苦于以下问题:Python Workspace.check_workspace_exists方法的具体用法?Python Workspace.check_workspace_exists怎么用?Python Workspace.check_workspace_exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在infrasim.workspace.Workspace的用法示例。


在下文中一共展示了Workspace.check_workspace_exists方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_stop_stop

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def test_stop_stop(self):
        """
        CLI test: stop a node will hint it's already stopped
        """
        output_start = run_command("infrasim node start")
        self.assertEqual(output_start[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        output_stop_1 = run_command("infrasim node stop")
        self.assertEqual(output_stop_1[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        output_stop_2 = run_command("infrasim node stop")
        self.assertEqual(output_stop_2[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        assert "{}-socat is running".format(self.node_name) in output_start[1]
        assert "{}-bmc is running".format(self.node_name) in output_start[1]
        assert "{}-node is running".format(self.node_name) in output_start[1]

        assert "{}-socat is stopped".format(self.node_name) in output_stop_1[1]
        assert "{}-bmc is stopped".format(self.node_name) in output_stop_1[1]
        assert "{}-node is stopped".format(self.node_name) in output_stop_1[1]

        assert "{}-node is stopped".format(self.node_name) in output_stop_2[1]
        assert "{}-bmc is stopped".format(self.node_name) in output_stop_2[1]
        assert "{}-socat is stopped".format(self.node_name) in output_stop_2[1]
开发者ID:JuneZhou19,项目名称:infrasim-compute,代码行数:29,代码来源:test_cli_commands.py

示例2: test_start_status_restart_status_destroy_status

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def test_start_status_restart_status_destroy_status(self):
        """
        CLI test: start, restart and destroy a node and check status respectively
        """
        output_status = {}

        output_start = run_command("infrasim node start")
        self.assertEqual(output_start[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        output_status["start"] = run_command("infrasim node status")
        self.assertEqual(output_status["start"][0], 0)

        output_restart = run_command("infrasim node restart")
        self.assertEqual(output_restart[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        output_status["restart"] = run_command("infrasim node status")
        self.assertEqual(output_status["restart"][0], 0)

        output_destroy = run_command("infrasim node destroy")
        self.assertEqual(output_destroy[0], 0)
        self.assertFalse(Workspace.check_workspace_exists(self.node_name))

        output_status["destroy"] = run_command("infrasim node status")
        self.assertEqual(output_status["destroy"][0], 0)

        assert "{}-socat is running".format(self.node_name) in output_start[1]
        assert "{}-bmc is running".format(self.node_name) in output_start[1]
        assert "{}-node is running".format(self.node_name) in output_start[1]

        assert "{}-socat is running".format(self.node_name) in output_status["start"][1]
        assert "{}-bmc is running".format(self.node_name) in output_status["start"][1]
        assert "{}-node is running".format(self.node_name) in output_status["start"][1]

        assert "{}-socat is stopped".format(self.node_name) in output_restart[1]
        assert "{}-bmc is stopped".format(self.node_name) in output_restart[1]
        assert "{}-node is stopped".format(self.node_name) in output_restart[1]

        assert "{}-socat is running".format(self.node_name) in output_restart[1]
        assert "{}-bmc is running".format(self.node_name) in output_restart[1]
        assert "{}-node is running".format(self.node_name) in output_restart[1]

        assert "{}-socat is running".format(self.node_name) in output_status["restart"][1]
        assert "{}-bmc is running".format(self.node_name) in output_status["restart"][1]
        assert "{}-node is running".format(self.node_name) in output_status["restart"][1]

        assert "Node {} runtime workspace is destroyed".format(self.node_name) in output_destroy[1]

        assert "Node {} runtime workspace doesn't exist".format(self.node_name) in output_status["destroy"][1]
开发者ID:JuneZhou19,项目名称:infrasim-compute,代码行数:52,代码来源:test_cli_commands.py

示例3: test_init

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def test_init(self):
        """
        CLI test: test init "-f" which will remove existing workspace
        """
        output_info = {}
        output_start = run_command("infrasim node start")
        self.assertEqual(output_start[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))
        output_info['start'] = run_command("infrasim node info")
        self.assertEqual(output_info['start'][0], 0)

        self.assertRaises(CommandRunFailed, run_command,
                          cmd="infrasim init -s", shell=True,
                          stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        run_command("infrasim init -s -f")
        self.assertEqual(len(os.listdir(config.infrasim_home)), 1)

        # Verify if it will reinstall packages when user confirmed 'Y'
        result = run_command_with_user_input("infrasim init", True, subprocess.PIPE, subprocess.PIPE, subprocess.PIPE, "Y\nY\nY\n")
        assert "downloading Infrasim_Qemu" in result[1]
        assert "downloading OpenIpmi" in result[1]
        assert "downloading Seabios" in result[1]

        result = run_command_with_user_input("infrasim init", True, subprocess.PIPE, subprocess.PIPE, subprocess.PIPE, "Y\nyes\nn\n")
        assert "downloading Infrasim_Qemu" in result[1]
        assert "downloading OpenIpmi" in result[1]
        assert "downloading Seabios" not in result[1]

        result = run_command_with_user_input("infrasim init", True, subprocess.PIPE, subprocess.PIPE, subprocess.PIPE, "no\nN\nY\n")
        assert "downloading Infrasim_Qemu" not in result[1]
        assert "downloading OpenIpmi" not in result[1]
        assert "downloading Seabios" in result[1]
开发者ID:JuneZhou19,项目名称:infrasim-compute,代码行数:35,代码来源:test_cli_commands.py

示例4: destroy

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
 def destroy(self, node_name):
     if Workspace.check_workspace_exists(node_name):
         try:
             node_info = Workspace.get_node_info_in_workspace(node_name)
         except InfraSimError, e:
             print e.value
             logger_cmd.error("cmd res: {}".format(e.value))
             return
开发者ID:turtle-fly,项目名称:infrasim-compute,代码行数:10,代码来源:cli.py

示例5: test_start_destroy

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def test_start_destroy(self):
        """
        CLI test: start, then destroy the node directly
        """
        output_start = run_command("infrasim node start")
        self.assertEqual(output_start[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        output_destroy = run_command("infrasim node destroy")
        self.assertEqual(output_destroy[0], 0)
        self.assertFalse(Workspace.check_workspace_exists(self.node_name))

        assert "{}-socat is running".format(self.node_name) in output_start[1]
        assert "{}-bmc is running".format(self.node_name) in output_start[1]
        assert "{}-node is running".format(self.node_name) in output_start[1]

        assert "Node {} runtime workspace is destroyed".format(self.node_name) in output_destroy[1]
开发者ID:JuneZhou19,项目名称:infrasim-compute,代码行数:19,代码来源:test_cli_commands.py

示例6: test_destory_destroy

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def test_destory_destroy(self):
        """
        CLI test: fail to destroy a destroyed node
        """
        output_start = run_command("infrasim node start")
        self.assertEqual(output_start[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        output_destroy_1 = run_command("infrasim node destroy")
        self.assertEqual(output_destroy_1[0], 0)
        self.assertFalse(Workspace.check_workspace_exists(self.node_name))

        output_destroy_2 = run_command("infrasim node destroy")
        self.assertEqual(output_destroy_2[0], 0)
        self.assertFalse(Workspace.check_workspace_exists(self.node_name))

        assert "Node {} runtime workspace is destroyed".format(self.node_name) in output_destroy_1[1]
        assert "Node {} runtime workspace is not found".format(self.node_name) in output_destroy_2[1]
开发者ID:JuneZhou19,项目名称:infrasim-compute,代码行数:20,代码来源:test_cli_commands.py

示例7: test_start_start

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def test_start_start(self):
        """
        CLI test: start a started node will hint it's running
        """
        output_start_1 = run_command("infrasim node start")
        self.assertEqual(output_start_1[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        output_start_2 = run_command("infrasim node start")
        self.assertEqual(output_start_2[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))

        assert "{}-socat starts to run".format(self.node_name) in output_start_1[1]
        assert "{}-bmc starts to run".format(self.node_name) in output_start_1[1]
        assert "{}-node is running".format(self.node_name) in output_start_1[1]

        assert "{}-socat is already running".format(self.node_name) in output_start_2[1]
        assert "{}-bmc is already running".format(self.node_name) in output_start_2[1]
        assert "{}-node is running".format(self.node_name) in output_start_2[1]
开发者ID:turtle-fly,项目名称:infrasim-compute,代码行数:21,代码来源:test_cli_commands.py

示例8: test_start_info_destroy_info

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def test_start_info_destroy_info(self):
        """
        CLI test: start and destroy a node, and get node_info respectively
        """
        output_info = {}
        output_start = run_command("infrasim node start")
        self.assertEqual(output_start[0], 0)
        self.assertTrue(Workspace.check_workspace_exists(self.node_name))
        output_info['start'] = run_command("infrasim node info")
        self.assertEqual(output_info['start'][0], 0)

        output_destroy = run_command("infrasim node destroy")
        self.assertEqual(output_destroy[0], 0)
        self.assertFalse(Workspace.check_workspace_exists(self.node_name))

        output_info['destroy'] = run_command("infrasim node info")
        self.assertEqual(output_info['destroy'][0], 0)

        assert "{}-socat is running".format(self.node_name) in output_start[1]
        assert "{}-bmc is running".format(self.node_name) in output_start[1]
        assert "{}-node is running".format(self.node_name) in output_start[1]

        assert "node name:          {}".format(self.node_name) in output_info['start'][1]
        assert "type:" in output_info['start'][1]
        assert "memory size:" in output_info['start'][1]
        assert "sol_enable:" in output_info['start'][1]
        assert "cpu quantities:" in output_info['start'][1]
        assert "cpu type:" in output_info['start'][1]
        assert "network(s):" in output_info['start'][1]
        assert "device" in output_info['start'][1]
        assert "mode" in output_info['start'][1]
        assert "name " in output_info['start'][1]
        assert "storage backend:" in output_info['start'][1]
        assert "type " in output_info['start'][1]
        assert "max drive" in output_info['start'][1]
        assert "drive size" in output_info['start'][1]

        assert "Node {} runtime workspace is destroyed".format(self.node_name) in output_destroy[1]

        assert "Node {} runtime workspace doesn't exist".format(self.node_name) in output_info['destroy'][1]
开发者ID:JuneZhou19,项目名称:infrasim-compute,代码行数:42,代码来源:test_cli_commands.py

示例9: start

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def start(self, node_name):
        try:
            if Workspace.check_workspace_exists(node_name):
                node_info = Workspace.get_node_info_in_workspace(node_name)
            else:
                node_info = nm.get_node_info(node_name)
            node = model.CNode(node_info)
            self._node_preinit(node)

        except InfraSimError, e:
            print e.value
            logger_cmd.error("cmd res: {}".format(e.value))
            return
开发者ID:turtle-fly,项目名称:infrasim-compute,代码行数:15,代码来源:cli.py

示例10: edit

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
    def edit(self, node_name):
        if node_name not in nm.get_name_list():
            print "Fail to find node {0} configuration. It is not registered. Check by:\n" \
                  "    infrasim config list".format(node_name)
            logger_cmd.warning("cmd res: Fail to find node {0} configuration. It is not registered. Check by:\n"
                               "    infrasim config list".format(node_name))
            return

        editor = os.environ.get('EDITOR', 'vi')
        config_path = os.path.join(nm.get_mapping_folder(),
                                   "{}.yml".format(node_name))
        try:
            os.system("{} {}".format(editor, config_path))
            if Workspace.check_workspace_exists(node_name):
                print "Warning: " \
                      "\033[93mPlease destroy node {}\033[0m " \
                      "before start or restart, " \
                      "or this edit won't work." .format(node_name)
            logger_cmd.info("cmd res: edit node {} OK".format(node_name))
        except OSError, e:
            print e
            logger_cmd.error("cmd res: {}".format(e))
开发者ID:turtle-fly,项目名称:infrasim-compute,代码行数:24,代码来源:cli.py

示例11: terminate_workspace

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
 def terminate_workspace(self):
     if Workspace.check_workspace_exists(self.__node_name):
         shutil.rmtree(self.workspace.get_workspace())
     self.__logger.info("[Node] Node {} runtime workspcace is destroyed".
                        format(self.__node_name))
     print "Node {} runtime workspace is destroyed.".format(self.__node_name)
开发者ID:JuneZhou19,项目名称:infrasim-compute,代码行数:8,代码来源:node.py

示例12: init_env

# 需要导入模块: from infrasim.workspace import Workspace [as 别名]
# 或者: from infrasim.workspace.Workspace import check_workspace_exists [as 别名]
def init_env(instance):
    """
    This is to sync ipmi-console with runtime vBMC configuration.
    Initial version capture infrasim instance name by infrasim-main status, while we
    have a plan to give instance name to ipmi-console so that it can be attached to
    target vBMC instance.
    """
    # Threading quit flag initilization
    env.local_env.quit_flag = False

    # Verify node instance runtime
    cur_path = os.environ["PATH"]
    os.environ["PATH"] = "{}/bin:{}".format(os.environ.get("PYTHONPATH"), cur_path)
    if not Workspace.check_workspace_exists(instance):
        logger.error("Warning: there is no node {} workspace. "
                     "Please start node {} first.".format(instance, instance))
        raise IpmiError(
            "Warning: there is no node {} workspace. "
            "Please start node {} first.".format(instance, instance))

    try:
        with open("{}/{}/.{}-bmc.pid".format(
                config.infrasim_home, instance, instance), "r") as f:
            pid = f.readline().strip()
            if not os.path.exists("/proc/{}".format(pid)):
                raise Exception
    except Exception:
        logger.error("Warning: node {} has not started BMC. "
                     "Please start node {} first.".format(instance, instance))
        raise IpmiError(
            "Warning: node {} has not started BMC. "
            "Please start node {} first.".format(instance, instance))

    logger.info("Init ipmi-console environment for infrasim instance: {}".
                format(instance))

    # Get runtime vbmc.conf
    vbmc_conf_path = os.path.join(config.infrasim_home, instance, "etc", "vbmc.conf")
    if not os.path.exists(vbmc_conf_path):
        msg = "{} vBMC configuration is not defined at {}".format(instance, vbmc_conf_path)
        logger.error(msg)
        raise Exception(msg)
    else:
        msg = "Target vbmc to attach is: {}".format(vbmc_conf_path)
        logger.info(msg)

    # Get runtime infrasim.yml
    infrasim_yml_path = os.path.join(config.infrasim_home, instance, "etc", "infrasim.yml")
    if not os.path.exists(infrasim_yml_path):
        msg = "{} infrasim instance is not defined at {}".format(instance, infrasim_yml_path)
        logger.error(msg)
        raise Exception(msg)
    else:
        msg = "Target infrasim instance to attach is: {}".format(infrasim_yml_path)
        logger.info(msg)

    # Get variable and set to ipmi-console env
    # - PORT_TELNET_TO_VBMC
    # - VBMC_IP
    # - VBMC_PORT
    with open(vbmc_conf_path, 'r') as fp:
        conf = fp.read()

        p_telnet = re.compile(r"^\s*console\s*[\d:\.]+\s+(?P<port_telnet_to_vbmc>\d+)",
                              re.MULTILINE)
        s_telnet = p_telnet.search(conf)
        if s_telnet:
            env.PORT_TELNET_TO_VBMC = int(s_telnet.group("port_telnet_to_vbmc"))
            logger.info("PORT_TELNET_TO_VBMC: {}".format(env.PORT_TELNET_TO_VBMC))
        else:
            logger.error("PORT_TELNET_TO_VBMC is not found")
            raise Exception("PORT_TELNET_TO_VBMC is not found")

        p_vbmc = re.compile(r"^\s*addr\s*(?P<vbmc_ip>[\d:\.]+)\s*(?P<vbmc_port>\d+)",
                            re.MULTILINE)
        s_vbmc = p_vbmc.search(conf)
        if s_vbmc:
            ip = s_vbmc.group("vbmc_ip")
            if ip == "::" or ip == "0.0.0.0":
                env.VBMC_IP = "localhost"
            else:
                env.VBMC_IP = ip
            logger.info("VBMC_IP: {}".format(env.VBMC_IP))
            env.VBMC_PORT = int(s_vbmc.group("vbmc_port"))
            logger.info("VBMC_PORT: {}".format(env.VBMC_PORT))
        else:
            logger.error("VBMC_IP and VBMC_PORT is not found")
            raise Exception("VBMC_IP and VBMC_PORT is not found")

    # Get variable and set to ipmi-console env
    # - PORT_SSH_FOR_CLIENT
    with open(infrasim_yml_path, 'r') as fp:
        conf = fp.read()

        p_port = re.compile(r"^\s*ipmi_console_ssh:\s*(?P<port_ssh_for_client>\d+)",
                            re.MULTILINE)
        s_port = p_port.search(conf)
        if s_port:
            env.PORT_SSH_FOR_CLIENT = int(s_port.group("port_ssh_for_client"))
        else:
#.........这里部分代码省略.........
开发者ID:InfraSIM,项目名称:infrasim-compute,代码行数:103,代码来源:common.py


注:本文中的infrasim.workspace.Workspace.check_workspace_exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。