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

Python utils.reverse函数代码示例

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

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



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

示例1: test_roles_failed_to_delete_assigned

    def test_roles_failed_to_delete_assigned(self):
        self.env.create(
            nodes_kwargs=[
                {"status": "ready", "roles": ["controller"]}
            ]
        )
        resp = self.app.get(
            reverse('ReleaseCollectionHandler'),
            headers=self.default_headers
        )

        release_json = resp.json_body[0]

        old_roles = set(release_json["roles"])
        old_roles.remove("controller")
        release_json["roles"] = list(old_roles)

        resp = self.app.put(
            reverse(
                'ReleaseHandler',
                kwargs={
                    "obj_id": release_json["id"]
                }
            ),
            jsonutils.dumps(release_json),
            headers=self.default_headers,
            expect_errors=True
        )
        self.assertEqual(resp.status_code, 400)
        self.assertEqual(
            resp.json_body["message"],
            "Cannot delete roles already assigned to nodes: controller"
        )
开发者ID:blkart,项目名称:fuel-web,代码行数:33,代码来源:test_roles.py


示例2: test_attributes_set_defaults

 def test_attributes_set_defaults(self):
     cluster = self.env.create_cluster(api=True)
     cluster_db = self.env.clusters[0]
     # Change editable attributes.
     resp = self.app.put(
         reverse(
             'ClusterAttributesHandler',
             kwargs={'cluster_id': cluster['id']}),
         params=jsonutils.dumps({
             'editable': {
                 "foo": "bar"
             },
         }),
         headers=self.default_headers,
         expect_errors=True
     )
     self.assertEqual(200, resp.status_code, resp.body)
     attrs = objects.Cluster.get_attributes(cluster_db)
     self.assertEqual("bar", attrs.editable["foo"])
     # Set attributes to defaults.
     resp = self.app.put(
         reverse(
             'ClusterAttributesDefaultsHandler',
             kwargs={'cluster_id': cluster['id']}),
         headers=self.default_headers
     )
     self.assertEqual(200, resp.status_code)
     release = self.db.query(Release).get(
         cluster['release_id']
     )
     self._compare_editable(
         release.attributes_metadata['editable'],
         resp.json_body['editable'],
         cluster_db
     )
开发者ID:thomasgoirand,项目名称:fuel-nailgun,代码行数:35,代码来源:test_attributes.py


示例3: test_network_changing_adds_pending_changes

 def test_network_changing_adds_pending_changes(self):
     cluster = self.env.create_cluster(api=True)
     cluster_db = self.env.clusters[0]
     objects.Cluster.clear_pending_changes(cluster_db)
     all_changes = self.db.query(ClusterChanges).all()
     self.assertEqual(len(all_changes), 0)
     resp = self.app.get(
         reverse(
             'NovaNetworkConfigurationHandler',
             kwargs={'cluster_id': cluster['id']}),
         headers=self.default_headers
     )
     net_id = resp.json_body['networks'][0]["id"]
     resp = self.app.put(
         reverse(
             'NovaNetworkConfigurationHandler',
             kwargs={'cluster_id': cluster['id']}),
         jsonutils.dumps({'networks': [{
             "id": net_id, "gateway": "10.0.0.1"}
         ]}),
         headers=self.default_headers
     )
     pending_changes = self.db.query(ClusterChanges).filter_by(
         name="networks"
     ).all()
     self.assertEqual(len(pending_changes), 1)
开发者ID:SergK,项目名称:fuel-web,代码行数:26,代码来源:test_changes_model.py


示例4: test_network_assignment_when_node_added

    def test_network_assignment_when_node_added(self):
        cluster = self.env.create_cluster(
            api=True,
            editable_attributes={'public_network_assignment': {
                'assign_to_all_nodes': {'value': True}}})
        mac = self.env.generate_random_mac()
        meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(
            meta,
            [{'name': 'eth0', 'mac': mac},
             {'name': 'eth1', 'mac': self.env.generate_random_mac()}])
        node = self.env.create_node(api=True, meta=meta, mac=mac)
        resp = self.app.put(
            reverse('NodeCollectionHandler'),
            jsonutils.dumps([{'id': node['id'], 'cluster_id': cluster['id']}]),
            headers=self.default_headers
        )
        self.assertEqual(resp.status_code, 200)

        resp = self.app.get(
            reverse('NodeNICsHandler', kwargs={'node_id': node['id']}),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        response = resp.json_body
        for resp_nic in response:
            net_names = [net['name'] for net in resp_nic['assigned_networks']]
            if resp_nic['mac'] == mac:
                self.assertIn("fuelweb_admin", net_names)
            else:
                self.assertIn("public", net_names)
            self.assertGreater(len(resp_nic['assigned_networks']), 0)
开发者ID:openstack,项目名称:fuel-web,代码行数:31,代码来源:test_node_nic_assignment.py


示例5: test_failing_attributes_put

 def test_failing_attributes_put(self):
     cluster_id = self.env.create_cluster(api=True)['id']
     resp = self.app.get(
         reverse(
             'ClusterAttributesHandler',
             kwargs={'cluster_id': cluster_id}),
         headers=self.default_headers
     )
     self.assertEqual(200, resp.status_code)
     resp = self.app.patch(
         reverse(
             'ClusterAttributesHandler',
             kwargs={'cluster_id': cluster_id}),
         params=jsonutils.dumps({
             'editable': {
                 'storage': {
                     'osd_pool_size': {
                         'description': 'desc',
                         'label': 'OSD Pool Size',
                         'type': 'text',
                         'value': True,
                         'weight': 80,
                     },
                 },
             },
         }),
         headers=self.default_headers,
         expect_errors=True
     )
     self.assertEqual(400, resp.status_code)
开发者ID:thomasgoirand,项目名称:fuel-nailgun,代码行数:30,代码来源:test_attributes.py


示例6: test_nic_adds_by_agent

    def test_nic_adds_by_agent(self):
        meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(meta, [
            {'name': 'eth0', 'mac': '00:00:00:00:00:00', 'current_speed': 1,
             'pxe': True, 'state': 'up'}])
        node = self.env.create_node(api=True, meta=meta)

        meta['interfaces'].append({
            'name': 'new_nic', 'mac': '00:00:00:00:00:01'})
        node_data = {'mac': node['mac'], 'meta': meta}
        resp = self.app.put(
            reverse('NodeAgentHandler'),
            jsonutils.dumps(node_data),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)

        resp = self.app.get(
            reverse('NodeNICsHandler', kwargs={'node_id': node['id']}),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(len(resp.json_body), len(meta['interfaces']))
        for nic in meta['interfaces']:
            filtered_nics = filter(
                lambda i: i['mac'] == nic['mac'],
                resp.json_body
            )
            resp_nic = filtered_nics[0]
            self.assertEqual(resp_nic['mac'], nic['mac'])
            self.assertEqual(resp_nic['current_speed'],
                             nic.get('current_speed'))
            self.assertEqual(resp_nic['max_speed'], nic.get('max_speed'))
            self.assertEqual(resp_nic['state'], nic.get('state'))
            for conn in ('assigned_networks', ):
                self.assertEqual(resp_nic[conn], [])
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:34,代码来源:test_node_nic_handler.py


示例7: test_openstack_config_upload_override_multinode

    def test_openstack_config_upload_override_multinode(self):
        data = {
            'cluster_id': self.clusters[0].id,
            'node_ids': [self.nodes[1].id, self.nodes[2].id],
            'configuration': {
                'nova_config': 'overridden_value'
            }
        }
        resp = self.app.post(
            reverse('OpenstackConfigCollectionHandler'),
            jsonutils.dumps(data),
            headers=self.default_headers)

        self.assertEqual(resp.status_code, 201)
        configs = resp.json_body
        self.assertEqual(configs[0]['node_id'], self.nodes[1].id)
        self.assertEqual(configs[1]['node_id'], self.nodes[2].id)

        resp = self.app.get(
            reverse('OpenstackConfigHandler',
                    {'obj_id': self.configs[1].id}),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.json_body['is_active'], False)

        resp = self.app.get(
            reverse('OpenstackConfigHandler',
                    {'obj_id': self.configs[2].id}),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(resp.json_body['is_active'], False)
开发者ID:ekorekin,项目名称:fuel-web,代码行数:31,代码来源:test_openstack_config_handler.py


示例8: test_network_assignment_when_node_added

    def test_network_assignment_when_node_added(self):
        cluster = self.env.create_cluster(
            api=True, editable_attributes={"public_network_assignment": {"assign_to_all_nodes": {"value": True}}}
        )
        mac = self.env.generate_random_mac()
        meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(
            meta, [{"name": "eth0", "mac": mac}, {"name": "eth1", "mac": self.env.generate_random_mac()}]
        )
        node = self.env.create_node(api=True, meta=meta, mac=mac)
        resp = self.app.put(
            reverse("NodeCollectionHandler"),
            jsonutils.dumps([{"id": node["id"], "cluster_id": cluster["id"]}]),
            headers=self.default_headers,
        )
        self.assertEqual(resp.status_code, 200)

        resp = self.app.get(reverse("NodeNICsHandler", kwargs={"node_id": node["id"]}), headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        response = resp.json_body
        for resp_nic in response:
            net_names = [net["name"] for net in resp_nic["assigned_networks"]]
            if resp_nic["mac"] == mac:
                self.assertTrue("fuelweb_admin" in net_names)
            else:
                self.assertTrue("public" in net_names)
            self.assertGreater(len(resp_nic["assigned_networks"]), 0)
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:27,代码来源:test_node_nic_assignment.py


示例9: launch_verify_networks

    def launch_verify_networks(self, data=None):
        if self.clusters:
            net_urls = {
                "nova_network": {
                    "config": "NovaNetworkConfigurationHandler",
                    "verify": "NovaNetworkConfigurationVerifyHandler",
                },
                "neutron": {
                    "config": "NeutronNetworkConfigurationHandler",
                    "verify": "NeutronNetworkConfigurationVerifyHandler",
                },
            }
            provider = self.clusters[0].net_provider
            if data:
                nets = jsonutils.dumps(data)
            else:
                resp = self.app.get(
                    reverse(net_urls[provider]["config"], kwargs={"cluster_id": self.clusters[0].id}),
                    headers=self.default_headers,
                )
                self.tester.assertEqual(200, resp.status_code)
                nets = resp.body

            resp = self.app.put(
                reverse(net_urls[provider]["verify"], kwargs={"cluster_id": self.clusters[0].id}),
                nets,
                headers=self.default_headers,
            )
            task_uuid = resp.json_body["uuid"]
            return self.db.query(Task).filter_by(uuid=task_uuid).first()
        else:
            raise NotImplementedError("Nothing to verify - try creating cluster")
开发者ID:thefuyang,项目名称:fuel-web,代码行数:32,代码来源:base.py


示例10: test_log_entry_collection_handler

    def test_log_entry_collection_handler(self):
        node_ip = "10.20.30.40"
        log_entries = [
            [time.strftime(settings.UI_LOG_DATE_FORMAT), "LEVEL111", "text1"],
            [time.strftime(settings.UI_LOG_DATE_FORMAT), "LEVEL222", "text2"],
        ]
        self.env.create_cluster()
        cluster = self.env.clusters[0]
        node = self.env.create_node(cluster_id=cluster.id, ip=node_ip)
        self._create_logfile_for_node(settings.LOGS[0], log_entries)
        self._create_logfile_for_node(settings.LOGS[1], log_entries, node)

        resp = self.app.get(
            reverse("LogEntryCollectionHandler"),
            params={"source": settings.LOGS[0]["id"]},
            headers=self.default_headers,
        )
        self.assertEqual(200, resp.status_code)
        response = resp.json_body
        response["entries"].reverse()
        self.assertEqual(response["entries"], log_entries)

        resp = self.app.get(
            reverse("LogEntryCollectionHandler"),
            params={"node": node.id, "source": settings.LOGS[1]["id"]},
            headers=self.default_headers,
        )
        self.assertEqual(200, resp.status_code)
        response = resp.json_body
        response["entries"].reverse()
        self.assertEqual(response["entries"], log_entries)
开发者ID:naveenzhang,项目名称:fuel-web,代码行数:31,代码来源:test_logs_handlers.py


示例11: test_cluster_node_list_update

    def test_cluster_node_list_update(self):
        node1 = self.env.create_node(api=False, hostname='name1')
        cluster = self.env.create_cluster(api=False)
        resp = self.app.put(
            reverse('ClusterHandler', kwargs={'obj_id': cluster.id}),
            jsonutils.dumps({'nodes': [node1.id]}),
            headers=self.default_headers,
            expect_errors=True
        )
        self.assertEqual(resp.status_code, 200)
        node2 = self.env.create_node(api=False, hostname='name1')

        nodes = self.db.query(Node).filter(Node.cluster == cluster).all()
        self.assertEqual(1, len(nodes))
        self.assertEqual(nodes[0].id, node1.id)

        resp = self.app.put(
            reverse('ClusterHandler', kwargs={'obj_id': cluster.id}),
            jsonutils.dumps({'nodes': [node2.id]}),
            headers=self.default_headers
        )
        self.assertEqual(resp.status_code, 200)

        self.assertEqual('node-{0}'.format(node1.id), node1.hostname)

        nodes = self.db.query(Node).filter(Node.cluster == cluster)
        self.assertEqual(1, nodes.count())
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:27,代码来源:test_cluster_handler.py


示例12: test_partial_user_contacts_info

    def test_partial_user_contacts_info(self):
        resp = self.app.get(
            reverse("MasterNodeSettingsHandler"),
            headers=self.default_headers)
        self.assertEqual(200, resp.status_code)
        data = resp.json_body

        # emulate user enabled contact info sending to support team
        data["settings"]["statistics"]["user_choice_saved"]["value"] = True
        data["settings"]["statistics"]["send_user_info"]["value"] = \
            True
        name = "user"
        email = "[email protected]"
        data["settings"]["statistics"]["name"]["value"] = name
        data["settings"]["statistics"]["email"]["value"] = email
        resp = self.app.put(
            reverse("MasterNodeSettingsHandler"),
            headers=self.default_headers,
            params=jsonutils.dumps(data)
        )
        self.assertEqual(200, resp.status_code)
        self.assertDictEqual(
            InstallationInfo().get_installation_info()['user_information'],
            {
                'contact_info_provided': True,
                'name': name,
                'email': email,
                'company': ''
            }
        )
开发者ID:dnikishov,项目名称:fuel-web,代码行数:30,代码来源:test_master_node_settings_handler.py


示例13: test_get_notification_status

    def test_get_notification_status(self):
        resp = self.app.get(
            reverse(
                'NotificationCollectionStatsHandler',
            ),
            headers=self.default_headers
        )
        self.assertEqual({'total': 0, 'read': 0, 'unread': 0}, resp.json_body)
        self.assertEqual(200, resp.status_code)

        self.env.create_notification()
        resp = self.app.get(
            reverse(
                'NotificationCollectionStatsHandler',
            ),
            headers=self.default_headers
        )
        self.assertEqual({'total': 1, 'read': 0, 'unread': 1}, resp.json_body)

        self.env.create_notification(status='read')
        self.env.create_notification(status='read')
        resp = self.app.get(
            reverse(
                'NotificationCollectionStatsHandler',
            ),
            headers=self.default_headers
        )
        self.assertEqual({'total': 3, 'read': 2, 'unread': 1}, resp.json_body)
开发者ID:openstack,项目名称:fuel-web,代码行数:28,代码来源:test_notification_handler.py


示例14: test_roles_add_duplicated_to_db_directly

    def test_roles_add_duplicated_to_db_directly(self):
        self.env.create_release()
        resp = self.app.get(
            reverse('ReleaseCollectionHandler'),
            headers=self.default_headers
        )
        release_json = resp.json_body[0]
        old_roles = list(release_json["roles"])

        role = Role(name=old_roles[0],
                    release_id=release_json["id"])
        added = True
        try:
            self.db.add(role)
            self.db.commit()
        except IntegrityError:
            self.db.rollback()
            added = False
        self.assertFalse(added)

        resp = self.app.get(
            reverse('ReleaseCollectionHandler'),
            headers=self.default_headers
        )
        release_json = resp.json_body[0]
        new_roles = list(release_json["roles"])
        self.assertEqual(old_roles, new_roles)
开发者ID:blkart,项目名称:fuel-web,代码行数:27,代码来源:test_roles.py


示例15: test_deletion_during_deployment

    def test_deletion_during_deployment(self):
        self.env.create(
            cluster_kwargs={
                "name": u"Вася"
            },
            nodes_kwargs=[
                {"status": "ready", "pending_addition": True},
            ]
        )
        cluster_id = self.env.clusters[0].id
        self.app.put(
            reverse(
                'ClusterChangesHandler',
                kwargs={'cluster_id': cluster_id}),
            headers=self.default_headers
        )
        self.app.delete(
            reverse(
                'ClusterHandler',
                kwargs={'obj_id': cluster_id}),
            headers=self.default_headers
        )
        timeout = 10
        timer = time.time()
        while True:
            cluster = self.db.query(Cluster).filter_by(id=cluster_id).first()
            if not cluster:
                break
            if (time.time() - timer) > timeout:
                raise Exception("Cluster deletion timeout")
            time.sleep(0.24)

        self.assertIsNone(cluster)
开发者ID:MoArif,项目名称:fuel-web,代码行数:33,代码来源:test_charset_issues.py


示例16: test_update_node_with_wrong_ip

    def test_update_node_with_wrong_ip(self):
        node = self.env.create_node(
            api=False, ip='10.20.0.2',
            status=consts.NODE_STATUSES.deploying)

        ipaddress = '192.168.0.10'
        self.app.put(
            reverse('NodeAgentHandler'),
            jsonutils.dumps({'id': node.id,
                             'ip': ipaddress,
                             'status': consts.NODE_STATUSES.discover}),
            headers=self.default_headers)

        self.assertEqual(node.ip, ipaddress)
        self.assertEqual(node.status, consts.NODE_STATUSES.error)
        notif = self.db.query(Notification).filter_by(
            node_id=node.id,
            topic='error'
        ).first()
        self.assertRegexpMatches(notif.message,
                                 "that does not match any Admin network")

        admin_ng = objects.NetworkGroup.get_admin_network_group(node)
        ipaddress = str(netaddr.IPRange(admin_ng.ip_ranges[0].first,
                                        admin_ng.ip_ranges[0].last)[1])
        self.app.put(
            reverse('NodeAgentHandler'),
            jsonutils.dumps({'id': node.id,
                             'ip': ipaddress}),
            headers=self.default_headers)

        self.assertEqual(node.ip, ipaddress)
        self.assertEqual(node.status, consts.NODE_STATUSES.discover)
开发者ID:ogelbukh,项目名称:fuel-web,代码行数:33,代码来源:test_node_handler.py


示例17: test_NIC_updates_by_agent

    def test_NIC_updates_by_agent(self):
        meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(meta, [
            {'name': 'eth0', 'mac': '00:00:00:00:00:00', 'current_speed': 1,
             'state': 'up'}])
        node = self.env.create_node(api=True, meta=meta)
        new_meta = self.env.default_metadata()
        self.env.set_interfaces_in_meta(new_meta, [
            {'name': 'new_nic', 'mac': '00:00:00:00:00:00',
             'current_speed': 10, 'max_speed': 10, 'state': 'down'}])
        node_data = {'mac': node['mac'], 'meta': new_meta}
        resp = self.app.put(
            reverse('NodeAgentHandler'),
            jsonutils.dumps(node_data),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)

        resp = self.app.get(
            reverse('NodeNICsHandler', kwargs={'node_id': node['id']}),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(len(resp.json_body), 1)
        resp_nic = resp.json_body[0]
        nic = new_meta['interfaces'][0]
        self.assertEqual(resp_nic['mac'], nic['mac'])
        self.assertEqual(resp_nic['current_speed'], nic['current_speed'])
        self.assertEqual(resp_nic['max_speed'], nic['max_speed'])
        self.assertEqual(resp_nic['state'], nic['state'])
        for conn in ('assigned_networks', ):
            self.assertEqual(resp_nic[conn], [])
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:30,代码来源:test_node_nic_handler.py


示例18: test_enable_sriov_failed_with_non_kvm_hypervisor

    def test_enable_sriov_failed_with_non_kvm_hypervisor(self):
        node = self.env.create_node(api=True, roles=['compute'])
        self.env.create_cluster(
            api=True,
            nodes=[node['id']],
            editable_attributes={
                'common': {
                    'libvirt_type': {
                        'value': consts.HYPERVISORS.qemu
                    }
                }
            }
        )

        resp = self.app.get(
            reverse('NodeNICsHandler',
                    kwargs={'node_id': node['id']}),
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 200)
        nics = resp.json_body
        nics[0]['interface_properties']['sriov']['enabled'] = True

        resp = self.app.put(
            reverse("NodeNICsHandler",
                    kwargs={"node_id": node['id']}),
            jsonutils.dumps(nics),
            expect_errors=True,
            headers=self.default_headers)
        self.assertEqual(resp.status_code, 400)
        self.assertEqual(
            "Only KVM hypervisor works with SR-IOV.",
            resp.json_body['message']
        )
开发者ID:huyupeng,项目名称:fuel-web,代码行数:33,代码来源:test_node_nic_handler.py


示例19: test_get_handler_with_incompleted_iface_data

    def test_get_handler_with_incompleted_iface_data(self):
        meta = self.env.default_metadata()
        meta["interfaces"] = []
        node = self.env.create_node(api=True, meta=meta)
        meta_clean_list = [
            {'interfaces': [{'name': '', 'mac': '00:00:00:00:00:00'}]},
            {'interfaces': [{'mac': '00:00:00:00:00:00'}]},
            {'interfaces': [{'name': 'eth0'}]}
        ]

        for nic_meta in meta_clean_list:
            meta = self.env.default_metadata()
            meta.update(nic_meta)
            node_data = {'mac': node['mac'], 'meta': meta}
            resp = self.app.put(
                reverse('NodeAgentHandler'),
                jsonutils.dumps(node_data),
                expect_errors=True,
                headers=self.default_headers
            )
            self.assertEqual(resp.status_code, 200)
            resp = self.app.get(
                reverse('NodeNICsHandler', kwargs={'node_id': node['id']}),
                headers=self.default_headers
            )
            self.assertEqual(resp.json_body, [])
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:26,代码来源:test_node_nic_handler.py


示例20: test_change_mac_of_assigned_nics

    def test_change_mac_of_assigned_nics(self):
        def get_nodes():
            resp = self.app.get(
                reverse('NodeCollectionHandler',
                        kwargs={'cluster_id': cluster.id}),
                headers=self.default_headers,
            )
            return resp.json_body

        meta = self.env.default_metadata()
        meta["interfaces"] = [
            {'name': 'eth0', 'mac': self.env.generate_random_mac(),
             'pxe': True},
            {'name': 'eth1', 'mac': self.env.generate_random_mac()},
            {'name': 'eth2', 'mac': self.env.generate_random_mac()},
            {'name': 'eth3', 'mac': self.env.generate_random_mac()},
            {'name': 'eth4', 'mac': self.env.generate_random_mac()},
        ]
        cluster = self.env.create(nodes_kwargs=[{'api': True, 'meta': meta}])

        # check all possible handlers
        for handler in ('NodeAgentHandler',
                        'NodeHandler',
                        'NodeCollectionHandler'):

            # create node and check it availability
            nodes_data = get_nodes()
            self.assertEqual(len(nodes_data), 1)

            node_db = objects.Node.get_by_uid(nodes_data[0]['id'])

            # change mac address of interfaces except admin one
            adm_eth = self.env.network_manager._get_interface_by_network_name(
                node_db, 'fuelweb_admin')
            for iface in nodes_data[0]['meta']['interfaces']:
                if iface['name'] != adm_eth.name:
                    iface['mac'] = self.env.generate_random_mac()

            # prepare put request
            data = {
                'id': nodes_data[0]['id'],
                'meta': nodes_data[0]['meta'],
            }
            if handler in ('NodeCollectionHandler', ):
                data = [data]

            if handler in ('NodeHandler', ):
                endpoint = reverse(handler, kwargs={'obj_id': data['id']})
            else:
                endpoint = reverse(handler)

            self.app.put(
                endpoint,
                jsonutils.dumps(data),
                headers=self.default_headers,
            )

            # check the node is visible for api
            nodes_data = get_nodes()
            self.assertEqual(len(nodes_data), 1)
开发者ID:huyupeng,项目名称:fuel-web,代码行数:60,代码来源:test_node_nic_handler.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.traverse函数代码示例发布时间:2022-05-27
下一篇:
Python utils.dict_merge函数代码示例发布时间: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