• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nailgun.db.sqlalchemy.models.Task的典型用法代码示例。如果您正苦于以下问题:Python Task类的具体用法?Python Task怎么用?Python Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_verify_networks_error_and_notice_are_concatenated

    def test_verify_networks_error_and_notice_are_concatenated(self):
        self.env.create(cluster_kwargs={}, nodes_kwargs=[{"api": False}, {"api": False}])
        cluster_db = self.env.clusters[0]
        node1, node2 = self.env.nodes
        nets = [{"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), "offline": 2}}
        self.db.add(task)
        self.db.flush()

        custom_error = "CustomError"
        kwargs = {
            "task_uuid": task.uuid,
            "status": "error",
            "nodes": self.nodes_message((node1, node2), nets),
            "error": custom_error,
        }

        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        self.db.refresh(task)
        self.assertEqual(task.status, "error")
        offline_notice = (
            "Notice: 2 node(s) were offline during connectivity" " check so they were skipped from the check."
        )
        self.assertEqual(task.message, "\n".join((custom_error, offline_notice)))
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:27,代码来源:test_rpc_consumer.py


示例2: test_proper_progress_calculation

    def test_proper_progress_calculation(self):
        supertask = Task(uuid=str(uuid.uuid4()), name="super", status="running")

        self.db.add(supertask)
        self.db.commit()

        subtask_weight = 0.4
        task_deletion = supertask.create_subtask("node_deletion", weight=subtask_weight)
        task_provision = supertask.create_subtask("provision", weight=subtask_weight)

        subtask_progress = random.randint(1, 20)

        deletion_kwargs = {"task_uuid": task_deletion.uuid, "progress": subtask_progress, "status": "running"}
        provision_kwargs = {"task_uuid": task_provision.uuid, "progress": subtask_progress, "status": "running"}

        self.receiver.provision_resp(**provision_kwargs)
        self.db.commit()
        self.receiver.remove_nodes_resp(**deletion_kwargs)
        self.db.commit()

        self.db.refresh(task_deletion)
        self.db.refresh(task_provision)
        self.db.refresh(supertask)

        calculated_progress = helpers.TaskHelper.calculate_parent_task_progress([task_deletion, task_provision])

        self.assertEqual(supertask.progress, calculated_progress)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:27,代码来源:test_rpc_consumer.py


示例3: test_verify_networks_resp_incomplete_network_data_on_first_node

    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,代码行数:34,代码来源:test_rpc_consumer.py


示例4: test_verify_networks_resp_without_vlans_only_erred

    def test_verify_networks_resp_without_vlans_only_erred(self):
        """Net verification without vlans fails when not all info received"""
        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": [0]}]
        nets_resp = [{"iface": "eth0", "vlans": []}]

        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), nets_resp)}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        self.db.refresh(task)
        self.assertEqual(task.status, "error")
        error_nodes = [
            {
                "uid": node1.id,
                "interface": "eth0",
                "name": node1.name,
                "mac": node1.interfaces[0].mac,
                "absent_vlans": nets_sent[0]["vlans"],
            },
            {
                "uid": node2.id,
                "interface": "eth0",
                "name": node2.name,
                "mac": node2.interfaces[0].mac,
                "absent_vlans": nets_sent[0]["vlans"],
            },
        ]
        self.assertEqual(task.result, error_nodes)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:35,代码来源:test_rpc_consumer.py


示例5: test_verify_networks_resp_forgotten_node_error

    def test_verify_networks_resp_forgotten_node_error(self):
        self.env.create(
            cluster_kwargs={},
            nodes_kwargs=[
                {"api": False, "name": "node1"},
                {"api": False, "name": "node2"},
                {"api": False, "name": "node3"},
            ],
        )
        cluster_db = self.env.clusters[0]
        node1, node2, node3 = 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, node3), nets_sent), "offline": 0}}
        self.db.add(task)
        self.db.commit()

        kwargs = {"task_uuid": task.uuid, "status": "ready", "nodes": self.nodes_message((node1, node2), nets_sent)}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        self.db.refresh(task)
        self.assertEqual(task.status, "error")
        self.assertRegexpMatches(task.message, node3.name)
        self.assertEqual(task.result, {})
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:25,代码来源:test_rpc_consumer.py


示例6: test_verify_networks_with_dhcp_subtask_erred

    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,代码行数:35,代码来源:test_rpc_consumer.py


示例7: test_verify_networks_resp_error_with_removed_node

    def test_verify_networks_resp_error_with_removed_node(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)}]
        nets_resp = [{"iface": "eth0", "vlans": range(100, 104)}]

        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), nets_resp)}
        self.db.delete(node2)
        self.db.commit()
        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        resp = self.app.get(reverse("TaskHandler", kwargs={"obj_id": task.id}), headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        task = resp.json_body
        self.assertEqual(task["status"], "error")
        error_nodes = [
            {
                "uid": node1.id,
                "interface": "eth0",
                "name": node1.name,
                "absent_vlans": [104],
                "mac": node1.interfaces[0].mac,
            },
            {"uid": node2.id, "interface": "eth0", "name": node2.name, "absent_vlans": [104], "mac": "unknown"},
        ]
        self.assertEqual(task.get("message"), "")
        self.assertEqual(task["result"], error_nodes)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:34,代码来源:test_rpc_consumer.py


示例8: test_verify_networks_resp_error

    def test_verify_networks_resp_error(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)}]
        nets_resp = [{"iface": "eth0", "vlans": range(100, 104)}]

        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), nets_resp)}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        self.db.refresh(task)
        self.assertEqual(task.status, "error")
        error_nodes = []
        for node in self.env.nodes:
            error_nodes.append(
                {
                    "uid": node.id,
                    "interface": "eth0",
                    "name": node.name,
                    "absent_vlans": [104],
                    "mac": node.interfaces[0].mac,
                }
            )
        self.assertEqual(task.message, "")
        self.assertEqual(task.result, error_nodes)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:30,代码来源:test_rpc_consumer.py


示例9: execute

    def execute(self, nodes_to_provision):
        """Run provisioning task on specified nodes
        """
        # locking nodes
        nodes_ids = [node.id for node in nodes_to_provision]
        nodes = objects.NodeCollection.filter_by_list(None, "id", nodes_ids, order_by="id")
        objects.NodeCollection.lock_for_update(nodes).all()

        objects.NodeCollection.update_slave_nodes_fqdn(nodes_to_provision)
        logger.debug("Nodes to provision: {0}".format(" ".join([n.fqdn for n in nodes_to_provision])))

        task_provision = Task(name="provision")
        task_provision.node_ids = nodes_ids
        # node_ids参数在安装成功时候无用,但在安装失败的时候需要用到
        db().add(task_provision)
        db().commit()

        provision_message = self._call_silently(
            task_provision, tasks.InstallosTask, nodes_to_provision, method_name="message"
        )

        task_provision = objects.Task.get_by_uid(task_provision.id, fail_if_not_found=True, lock_for_update=True)
        task_provision.cache = provision_message
        objects.NodeCollection.lock_for_update(nodes).all()

        for node in nodes_to_provision:
            node.pending_addition = False
            node.status = NODE_STATUSES.provisioning
            node.progress = 0

        db().commit()

        rpc.cast("naily", provision_message)
        logger.info(u"消息发送完毕")
        return task_provision
开发者ID:yxh1990,项目名称:fuel-cloudmaster,代码行数:35,代码来源:manager.py


示例10: test_verify_networks_resp_forgotten_node_error

    def test_verify_networks_resp_forgotten_node_error(self):
        self.env.create(
            cluster_kwargs={},
            nodes_kwargs=[
                {"api": False, 'name': 'node1'},
                {"api": False, 'name': 'node2'},
                {"api": False, 'name': 'node3'}
            ]
        )
        cluster_db = self.env.clusters[0]
        node1, node2, node3 = 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, node3), nets_sent)
            }
        }
        self.db.add(task)
        self.db.commit()

        kwargs = {'task_uuid': task.uuid,
                  'status': 'ready',
                  'nodes': self.nodes_message((node1, node2),
                                              nets_sent)}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        self.db.refresh(task)
        self.assertEqual(task.status, "error")
        self.assertRegexpMatches(task.message, node3.name)
        self.assertEqual(task.result, {})
开发者ID:TorstenS73,项目名称:fuel-web,代码行数:35,代码来源:test_rpc_consumer.py


示例11: test_verify_networks_resp

    def test_verify_networks_resp(self):
        self.env.create(
            cluster_kwargs={},
            nodes_kwargs=[
                {"api": False},
                {"api": False}
            ]
        )
        cluster_db = self.env.clusters[0]
        node1, node2 = self.env.nodes
        nets = [{'iface': 'eth0', 'vlans': range(100, 105)}]

        task = Task(
            name="verify_networks",
            cluster_id=cluster_db.id
        )
        task.cache = {
            "args": {
                "nodes": [{'uid': node1.id, 'networks': nets},
                          {'uid': node2.id, 'networks': nets}]
            }
        }
        self.db.add(task)
        self.db.commit()

        kwargs = {'task_uuid': task.uuid,
                  'status': 'ready',
                  'nodes': [{'uid': node1.id, 'networks': nets},
                            {'uid': node2.id, 'networks': nets}]}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.refresh(task)
        self.assertEqual(task.status, "ready")
        self.assertEqual(task.message, '')
开发者ID:e0ne,项目名称:fuel-web,代码行数:33,代码来源:test_rpc_consumer.py


示例12: test_verify_networks_resp_extra_nodes_error

    def test_verify_networks_resp_extra_nodes_error(self):
        self.env.create(
            cluster_kwargs={},
            nodes_kwargs=[
                {"api": False},
                {"api": False}
            ]
        )
        cluster_db = self.env.clusters[0]
        node1, node2 = self.env.nodes
        node3 = self.env.create_node(api=False)
        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, node3),
                                              nets_sent)}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        self.db.refresh(task)
        self.assertEqual(task.status, "ready")
        self.assertEqual(task.message, '')
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:35,代码来源:test_rpc_consumer.py


示例13: test_task_contains_field_parent

    def test_task_contains_field_parent(self):
        parent_task = Task(
            name=consts.TASK_NAMES.deployment,
            cluster=self.cluster_db,
            status=consts.TASK_STATUSES.running,
            progress=10
        )
        child_task = parent_task.create_subtask(
            name=consts.TASK_NAMES.deployment,
            status=consts.TASK_STATUSES.running,
            progress=10
        )

        cluster_tasks = self.app.get(
            reverse(
                'TaskCollectionHandler',
                kwargs={'cluster_id': self.cluster_db.id}
            ),
            headers=self.default_headers
        ).json_body

        child_task_data = next(
            t for t in cluster_tasks if t['id'] == child_task.id
        )

        self.assertEqual(parent_task.id, child_task_data['parent_id'])
        parent_task_data = next(
            t for t in cluster_tasks if t['id'] == parent_task.id
        )
        self.assertIsNone(parent_task_data['parent_id'])
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:30,代码来源:test_task_handler.py


示例14: test_verify_networks_resp_partially_without_vlans

    def test_verify_networks_resp_partially_without_vlans(self):
        """Verify that network verification partially without vlans passes
        """
        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': [0]},
                     {'iface': 'eth1', 'vlans': range(100, 104)}]

        task = Task(
            name="super",
            cluster_id=cluster_db.id
        )
        task.cache = {
            "args": {
                'nodes': [{'uid': node1.id, 'networks': nets_sent},
                          {'uid': node2.id, 'networks': nets_sent}]
            }
        }
        self.db.add(task)
        self.db.commit()

        kwargs = {'task_uuid': task.uuid,
                  'status': 'ready',
                  'nodes': [{'uid': node1.id, 'networks': nets_sent},
                            {'uid': node2.id, 'networks': nets_sent}]}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.refresh(task)
        self.assertEqual(task.status, "ready")
开发者ID:e0ne,项目名称:fuel-web,代码行数:35,代码来源:test_rpc_consumer.py


示例15: test_verify_networks_resp_without_vlans_only

    def test_verify_networks_resp_without_vlans_only(self):
        """Verify that network verification without vlans passes
        when there only iface without vlans configured
        """
        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': [0]},
                     {'iface': 'eth1', 'vlans': [0]}]

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

        kwargs = {'task_uuid': task.uuid,
                  'status': 'ready',
                  'nodes': self.nodes_message((node1, node2), nets_sent)}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.flush()
        self.db.refresh(task)
        self.assertEqual(task.status, "ready")
开发者ID:TorstenS73,项目名称:fuel-web,代码行数:35,代码来源:test_rpc_consumer.py


示例16: execute

    def execute(self, nodes_to_deployment):
        TaskHelper.update_slave_nodes_fqdn(nodes_to_deployment)
        logger.debug('Nodes to deploy: {0}'.format(
            ' '.join([n.fqdn for n in nodes_to_deployment])))
        task_deployment = Task(name='deployment', cluster=self.cluster)
        db().add(task_deployment)
        db().commit()

        deployment_message = self._call_silently(
            task_deployment,
            tasks.DeploymentTask,
            nodes_to_deployment,
            method_name='message')

        db().refresh(task_deployment)

        task_deployment.cache = deployment_message

        for node in nodes_to_deployment:
            node.status = 'deploying'
            node.progress = 0

        db().commit()
        rpc.cast('naily', deployment_message)

        return task_deployment
开发者ID:MsiRgb,项目名称:fuel-web,代码行数:26,代码来源:manager.py


示例17: test_verify_networks_resp_empty_nodes_custom_error

    def test_verify_networks_resp_empty_nodes_custom_error(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="super",
            cluster_id=cluster_db.id
        )
        task.cache = {
            "args": {
                'nodes': [{'uid': node1.id, 'networks': nets_sent},
                          {'uid': node2.id, 'networks': nets_sent}]
            }
        }
        self.db.add(task)
        self.db.commit()

        error_msg = 'Custom error message.'
        kwargs = {'task_uuid': task.uuid,
                  'status': 'ready',
                  'nodes': [],
                  'error': error_msg}
        self.receiver.verify_networks_resp(**kwargs)
        self.db.refresh(task)
        self.assertEqual(task.status, "error")
        self.assertEqual(task.message, error_msg)
开发者ID:e0ne,项目名称:fuel-web,代码行数:34,代码来源:test_rpc_consumer.py


示例18: execute

    def execute(self, nodes_to_provision):
        """Run provisioning task on specified nodes
        """
        objects.NodeCollection.update_slave_nodes_fqdn(nodes_to_provision)

        logger.debug('Nodes to provision: {0}'.format(
            ' '.join([n.fqdn for n in nodes_to_provision])))

        task_provision = Task(name='provision', cluster=self.cluster)
        db().add(task_provision)
        db().commit()

        provision_message = self._call_silently(
            task_provision,
            tasks.ProvisionTask,
            nodes_to_provision,
            method_name='message'
        )
        db().refresh(task_provision)

        task_provision.cache = provision_message

        for node in nodes_to_provision:
            node.pending_addition = False
            node.status = 'provisioning'
            node.progress = 0

        db().commit()

        rpc.cast('naily', provision_message)

        return task_provision
开发者ID:iberezovskiy,项目名称:fuel-web,代码行数:32,代码来源:manager.py


示例19: test_node_deletion_subtask_progress

    def test_node_deletion_subtask_progress(self):
        supertask = Task(
            uuid=str(uuid.uuid4()),
            name="super",
            status="running"
        )

        self.db.add(supertask)
        self.db.commit()

        task_deletion = supertask.create_subtask("node_deletion")
        task_provision = supertask.create_subtask("provision", weight=0.4)

        subtask_progress = random.randint(1, 20)

        deletion_kwargs = {'task_uuid': task_deletion.uuid,
                           'progress': subtask_progress}
        provision_kwargs = {'task_uuid': task_provision.uuid,
                            'progress': subtask_progress}

        def progress_difference():
            self.receiver.provision_resp(**provision_kwargs)

            self.db.refresh(task_provision)
            self.assertEqual(task_provision.progress, subtask_progress)

            self.db.refresh(supertask)
            progress_before_delete_subtask = supertask.progress

            self.receiver.remove_nodes_resp(**deletion_kwargs)

            self.db.refresh(task_deletion)
            self.assertEqual(task_deletion.progress, subtask_progress)

            self.db.refresh(supertask)
            progress_after_delete_subtask = supertask.progress

            return abs(progress_after_delete_subtask -
                       progress_before_delete_subtask)

        without_coeff = progress_difference()

        task_deletion.progress = 0
        task_deletion.weight = 0.5
        self.db.merge(task_deletion)

        task_provision.progress = 0
        self.db.merge(task_provision)

        supertask.progress = 0
        self.db.merge(supertask)

        self.db.commit()

        with_coeff = progress_difference()

        # some freaking magic is here but haven't found
        # better way to test what is already working
        self.assertTrue((without_coeff / with_coeff) < 2)
开发者ID:Mellanox,项目名称:fuel-web,代码行数:59,代码来源:test_rpc_consumer.py


示例20: test_verify_networks_resp_incomplete_network_data_error

    def test_verify_networks_resp_incomplete_network_data_error(self):
        # One node has single interface
        meta = self.env.default_metadata()
        mac = '02:07:43:78:4F:58'
        self.env.set_interfaces_in_meta(
            meta, [{'name': 'eth0', 'mac': mac}])

        self.env.create(
            cluster_kwargs={},
            nodes_kwargs=[
                {"api": False, 'name': 'node1'},
                {"api": False, 'name': 'node2', 'meta': meta},
                {"api": False, 'name': 'node3'}
            ]
        )
        cluster_db = self.env.clusters[0]
        node1, node2, node3 = self.env.nodes

        nets_sent = [{'iface': 'eth0', 'vlans': range(100, 105)},
                     {'iface': 'eth1', 'vlans': [106]},
                     {'iface': 'eth2', 'vlans': [107]}]

        task = Task(
            name="super",
            cluster_id=cluster_db.id
        )
        task.cache = {
            "args": {
                'nodes': [{'uid': node1.id, 'networks': nets_sent},
                          {'uid': node2.id, 'networks': nets_sent},
                          {'uid': node3.id, 'networks': nets_sent}]
            }
        }
        self.db.add(task)
        self.db.commit()

        kwargs = {'task_uuid': task.uuid,
                  'status': 'ready',
                  'nodes': [{'uid': node1.id, 'networks': nets_sent},
                            {'uid': node2.id, 'networks': []},
                            {'uid': node3.id, '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': node2.id, 'interface': 'eth0',
                        'name': node2.name, 'mac': node2.interfaces[0].mac,
                        'absent_vlans': nets_sent[0]['vlans']},
                       {'uid': node2.id, 'interface': 'eth1',
                        'name': node2.name, 'mac': 'unknown',
                        'absent_vlans': nets_sent[1]['vlans']},
                       {'uid': node2.id, 'interface': 'eth2',
                        'name': node2.name, 'mac': 'unknown',
                        'absent_vlans': nets_sent[2]['vlans']}
                       ]

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python checker.NetworkCheck类代码示例发布时间:2022-05-27
下一篇:
Python db.query函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap