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


Python Task.result[0]["absent_vlans"]方法代码示例

本文整理汇总了Python中nailgun.db.sqlalchemy.models.Task.result[0]["absent_vlans"]方法的典型用法代码示例。如果您正苦于以下问题:Python Task.result[0]["absent_vlans"]方法的具体用法?Python Task.result[0]["absent_vlans"]怎么用?Python Task.result[0]["absent_vlans"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nailgun.db.sqlalchemy.models.Task的用法示例。


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

示例1: test_verify_networks_resp_incomplete_network_data_on_first_node

# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import result[0]["absent_vlans"] [as 别名]
    def test_verify_networks_resp_incomplete_network_data_on_first_node(self):
        """First node network data incompletion causes task fail"""
        self.env.create(
            cluster_kwargs={}, nodes_kwargs=[{"api": False, "name": "node1"}, {"api": False, "name": "node2"}]
        )
        cluster_db = self.env.clusters[0]
        node1, node2 = self.env.nodes
        nets_sent = [{"iface": "eth0", "vlans": range(100, 105)}]

        task = Task(name="super", cluster_id=cluster_db.id)
        task.cache = {"args": {"nodes": self.nodes_message((node1, node2), nets_sent), "offline": 0}}

        self.db.add(task)
        self.db.commit()

        kwargs = {"task_uuid": task.uuid, "status": "ready", "nodes": self.nodes_message((node1, node2), [])}
        kwargs["nodes"][1]["networks"] = nets_sent
        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        self.db.refresh(task)
        self.assertEqual(task.status, "error")
        self.assertEqual(task.message, "")
        error_nodes = [
            {
                "uid": node1.id,
                "interface": "eth0",
                "name": node1.name,
                "mac": node1.interfaces[0].mac,
                "absent_vlans": sorted(nets_sent[0]["vlans"]),
            }
        ]
        task.result[0]["absent_vlans"] = sorted(task.result[0]["absent_vlans"])

        self.assertEqual(task.result, error_nodes)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:36,代码来源:test_rpc_consumer.py

示例2: test_verify_networks_with_dhcp_subtask_erred

# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import result[0]["absent_vlans"] [as 别名]
    def test_verify_networks_with_dhcp_subtask_erred(self):
        self.env.create(cluster_kwargs={}, nodes_kwargs=[{"api": False}, {"api": False}])
        cluster_db = self.env.clusters[0]
        node1, node2 = self.env.nodes
        nets_sent = [{"iface": "eth0", "vlans": range(100, 105)}]

        task = Task(name="verify_networks", cluster_id=cluster_db.id)
        task.cache = {"args": {"nodes": self.nodes_message((node1, node2), nets_sent), "offline": 0}}
        self.db.add(task)
        self.db.commit()
        dhcp_subtask = Task(
            name="check_dhcp", cluster_id=cluster_db.id, parent_id=task.id, status="error", message="DHCP ERROR"
        )
        self.db.add(dhcp_subtask)
        self.db.commit()
        kwargs = {"task_uuid": task.uuid, "status": "ready", "nodes": self.nodes_message((node1, node2), [])}
        kwargs["nodes"][0]["networks"] = nets_sent
        self.receiver.verify_networks_resp(**kwargs)

        self.assertEqual(task.status, "error")
        self.assertEqual(task.message, u"DHCP ERROR")

        task.result[0]["absent_vlans"] = sorted(task.result[0]["absent_vlans"])
        self.assertEqual(
            task.result,
            [
                {
                    u"absent_vlans": [100, 101, 102, 103, 104],
                    u"interface": "eth0",
                    u"mac": node2.interfaces[0].mac,
                    u"name": "Untitled ({0})".format(node2.mac[-5:].lower()),
                    u"uid": node2.id,
                }
            ],
        )
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:37,代码来源:test_rpc_consumer.py


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