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

Python jsontools.nested_search函数代码示例

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

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



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

示例1: test_210_list_addresses

 def test_210_list_addresses(self):
     label = self.config["nova"]["network_label"]
     r, d = nova.GET("/servers")
     sid = nested_search("/servers/*/name=testing server creation/id", d)[0]
     addrs = nova.GET("/servers/%s/ips" % (sid), code=200)[1]
     if not len(nested_search("/addresses/%s" % (label), addrs)[0]) > 0:
         raise AssertionError("No addresses found for network %s" % (label))
开发者ID:rcbops,项目名称:kong,代码行数:7,代码来源:test_nova_api.py


示例2: test_190_create_server_neutron

    def test_190_create_server_neutron(self):
        network_id = nested_search(
            'networks/*/name=%s/id' % self.config['nova']['network_label'],
            neutron.GET('/%s/networks' % neutron_api_ver, code=200)[1])[0]
        image = nova.GET("/images?name=test-image")[1]['images'][0]['id']
        flavor = nested_search("/flavors/*/name=m1.tiny/id",
                               nova.GET("/flavors")[1])[0]


        r, d = nova.POST("/servers",
                        body={"server": 
                                 {"name": "testing server creation", 
                                 "imageRef": image, "flavorRef": flavor, 
                                 "max_count": 1, "min_count": 1, 
                                 "networks": [{"uuid": network_id}],
                                 "security_groups": [{"name": "test-sec-group"}]
                                 }
                             },
                        code=202) 
        server_id = d['server']['id']
        r, d = nova.GET_with_keys_eq("/servers/%s" % server_id,
                                     {"/server/status": "ACTIVE"},
                                     code=200, timeout=60, delay=5)
        ip = d['server']['addresses'][self.config['nova']['network_label']][0]['addr']

        netns="qdhcp-%s" % network_id
        if not self.ping_host(ip, netns=netns, delay=5, timeout=120):
            raise AssertionError("Server is active but does not ping")
开发者ID:invsblduck,项目名称:notchef_kong,代码行数:28,代码来源:test_nova_api.py


示例3: test_190_create_server_neutron

    def test_190_create_server_neutron(self):
        network_id = nested_search(
            "networks/*/name=%s/id" % self.config["nova"]["network_label"],
            neutron.GET("/%s/networks" % neutron_api_ver, code=200)[1],
        )[0]
        image = nova.GET("/images?name=test-image")[1]["images"][0]["id"]
        flavor = nested_search("/flavors/*/name=m1.tiny/id", nova.GET("/flavors")[1])[0]

        # TODO(brett): Investigate performance.
        # It's now taking 90+ seconds for server to go active on Cent (Havana).
        # Don't see any obvious timeouts or exceptions in cluster.
        r, d = nova.POST(
            "/servers",
            body={
                "server": {
                    "name": "testing server creation",
                    "imageRef": image,
                    "flavorRef": flavor,
                    "max_count": 1,
                    "min_count": 1,
                    "networks": [{"uuid": network_id}],
                    "security_groups": [{"name": "test-sec-group"}],
                }
            },
            code=202,
        )
        server_id = d["server"]["id"]
        r, d = nova.GET_with_keys_eq(
            "/servers/%s" % server_id, {"/server/status": "ACTIVE"}, code=200, timeout=120, delay=5
        )
        ip = d["server"]["addresses"][self.config["nova"]["network_label"]][0]["addr"]

        netns = "qdhcp-%s" % network_id
        if not self.ping_host(ip, netns=netns, delay=5, timeout=120):
            raise AssertionError("Server is active but does not ping")
开发者ID:rcbops,项目名称:kong,代码行数:35,代码来源:test_nova_api.py


示例4: test_901_delete_security_group_rule

 def test_901_delete_security_group_rule(self):
     data = nova.GET("/os-security-groups")[1]
     gid = nested_search("/security_groups/*/name=kongsec/id",
                         data)[0]
     rids = nested_search("/security_groups/*/rules/*/parent_group_id=" +\
                         str(gid) + "/id", data)
     for rid in rids:
         nova.DELETE("/os-security-group-rules/%s" % rid, code=202)
开发者ID:invsblduck,项目名称:notchef_kong,代码行数:8,代码来源:test_nova_api.py


示例5: test_901_delete_security_group_rule_diablo_final

 def test_901_delete_security_group_rule_diablo_final(self):
     data = nova.GET("/os-security-groups")[1]
     gid = nested_search("/security_groups/*/name=kongsec/id", data)[0]
     rids = nested_search("/security_groups/*/rules/*/parent_group_id=" + str(gid) + "/id", data)
     try:
         for rid in rids:
             nova.DELETE("/os-security-group-rules/%s" % rid, code=202)
     except ValueError:
         pass
开发者ID:rcbops,项目名称:kong,代码行数:9,代码来源:test_nova_api.py


示例6: test_920_security_group_rule_delete

    def test_920_security_group_rule_delete(self):
        secgroup_id = nested_search(
            "security_groups/*/name=test-sec-group/id",
            neutron.GET("/%s/security-groups" % neutron_api_ver, code=200)[1],
        )[0]
        resp, body = neutron.GET("/%s/security-groups/%s" % (neutron_api_ver, secgroup_id))

        try:
            secgroup_rule_id = nested_search("security_group/security_group_rules/*/protocol=icmp/id", body)[0]
            neutron.DELETE("/%s/security-group-rules/%s.json" % (neutron_api_ver, secgroup_rule_id), code=204)
        except IndexError:
            pass
开发者ID:rcbops,项目名称:kong,代码行数:12,代码来源:test_nova_api.py


示例7: test_026_security_group_rule_show

    def test_026_security_group_rule_show(self):
        secgroup_id = nested_search(
            'security_groups/*/name=test-sec-group/id',
            neutron.GET('/%s/security-groups' % api_ver, code=200)[1])[0]
        resp, body = neutron.GET(
            '/%s/security-groups/%s'
            % (api_ver, secgroup_id))

        secgroup_rule_id = nested_search(
            'security_group/security_group_rules/*/protocol=icmp/id', body)[0]

        neutron.GET(
            '/%s/security-group-rules/%s.json' % (api_ver, secgroup_rule_id))
开发者ID:AsherBond,项目名称:kong,代码行数:13,代码来源:test_neutron.py


示例8: test_045_security_group_rule_delete

    def test_045_security_group_rule_delete(self):
        secgroup_id = nested_search(
            'security_groups/*/name=test-sec-group/id',
            neutron.GET('/%s/security-groups' % api_ver, code=200)[1])[0]
        resp, body = neutron.GET(
            '/%s/security-groups/%s' % (api_ver, secgroup_id))

        try:
            secgroup_rule_id = nested_search(
                'security_group/security_group_rules/*/protocol=icmp/id',
                body)[0]
            neutron.DELETE(
                '/%s/security-group-rules/%s.json'
                % (api_ver, secgroup_rule_id), code=204)
        except IndexError:
            pass
开发者ID:AsherBond,项目名称:kong,代码行数:16,代码来源:test_neutron.py


示例9: _init_keystone

 def _init_keystone(self, service, target):
     (url, user, password, tenantname, region) = self.get_config()
     body = {"auth": {"passwordCredentials": {"username": user,
             "password": password}, "tenantName": tenantname}}
     request_t = []
     response_t = []
     try:
         response, data = self.POST(url, body=body, code=200)
     except AssertionError:
         try:
             response, data = self.POST(url, body=body['auth'], code=200)
             data['access'] = data['auth']
         except:
             request_t = [print_curl_request]
             response_t = [print_it]
             print "Failed to auth.  Trying once more with verbosity"
             response, data = self.POST(url, body=body, code=200, 
                                        request_transformers=request_t,
                                        response_transformers=response_t)
     services = nested_get("/access/serviceCatalog", data)
     try:
         endpoint = nested_search(
             "/access/serviceCatalog/*/type=%s/endpoints/*/region=%s/%s" %
             (service, region, target), data)[0]
     except IndexError:
         endpoint = []
     finally:
         if endpoint == []:
             raise ValueError(('No endpoint found for service "%s" in'
                              + ' region "%s" with target "%s"\n'
                              + 'service catalog: "%s"') %
                              (service, region, target, services))
     token = nested_get("/access/token/id", data)
     return endpoint, token, services, data
开发者ID:AsherBond,项目名称:kong,代码行数:34,代码来源:kongrequester.py


示例10: test_200_create_server

 def test_200_create_server(self):
     image = nova.GET("/images?name=test-image")[1]["images"][0]["id"]
     flavor = nested_search("/flavors/*/name=m1.tiny/id", nova.GET("/flavors")[1])[0]
     r, d = nova.POST(
         "/servers",
         body={
             "server": {
                 "name": "testing server creation",
                 "flavorRef": flavor,
                 "imageRef": image,
                 "security_groups": [{"name": "kongsec"}],
             }
         },
         code=202,
     )
     server_id = d["server"]["id"]
     r, d = nova.GET_with_keys_eq(
         "/servers/%s" % server_id, {"/server/status": "ACTIVE"}, code=200, timeout=60, delay=5
     )
     net = d["server"]["addresses"][self.config["nova"]["network_label"]]
     good = False
     for i in net:
         if self.ping_host(i["addr"], delay=5, timeout=200):
             good = True
     if not good:
         raise AssertionError("Server is active but does not ping")
开发者ID:rcbops,项目名称:kong,代码行数:26,代码来源:test_nova_api.py


示例11: test_161_security_group_rule_create

    def test_161_security_group_rule_create(self):
        secgroup_id = nested_search(
            "security_groups/*/name=test-sec-group/id",
            neutron.GET("/%s/security-groups" % neutron_api_ver, code=200)[1],
        )[0]

        resp, body = neutron.POST(
            "/%s/security-group-rules.json" % neutron_api_ver,
            body={
                "security_group_rule": {
                    "ethertype": "IPv4",
                    "direction": "ingress",
                    "protocol": "ICMP",
                    "security_group_id": "%s" % secgroup_id,
                }
            },
        )

        secgroup_rule_id = body["security_group_rule"]["id"]

        resp, body = neutron.GET_with_keys_eq(
            "/%s/security-group-rules/%s.json" % (neutron_api_ver, secgroup_rule_id),
            {"/security_group_rule/protocol": "icmp"},
            code=200,
        )
开发者ID:rcbops,项目名称:kong,代码行数:25,代码来源:test_nova_api.py


示例12: test_nova_list_flavors

 def test_nova_list_flavors(self):
     r, d = nova.GET("/flavors", code=200)
     if len(d['flavors']) == 0:
         raise AssertionError("No flavors configured in openstack")
     if len(nested_search("/flavors/*/name=m1.tiny",
                          nova.GET("/flavors")[1])) == 0:
         raise AssertionError("No flavor m1.tiny found.")
开发者ID:invsblduck,项目名称:notchef_kong,代码行数:7,代码来源:test_nova_api.py


示例13: test_008_net_show

    def test_008_net_show(self):
        network_id = nested_search('networks/*/name=test-network/id',
                                   neutron.GET(
                                       '/%s/networks' % api_ver,
                                       code=200)
                                   [1])[0]

        neutron.GET('/%s/networks/%s' % (api_ver, network_id), code=200)
开发者ID:AsherBond,项目名称:kong,代码行数:8,代码来源:test_neutron.py


示例14: test_002_agent_show

 def test_002_agent_show(self):
     agent_id = nested_search(
         'agents/*/id',
         neutron.GET(
             '/%s/agents' % api_ver,
             code=200)
         [1])[0]
     neutron.GET('/%s/agents/%s' % (api_ver, agent_id), code=200)
开发者ID:AsherBond,项目名称:kong,代码行数:8,代码来源:test_neutron.py


示例15: test_020_quota_list

    def test_020_quota_list(self):
        tenant_id = neutron.GET(
            '/%s/quotas/tenant.json' % api_ver)[1]['tenant']['tenant_id']

        resp, body = neutron.GET('/%s/quotas.json' % api_ver, code=200)

        our_quota = nested_search(
            'quotas/*/tenant_id=%s/tenant_id' % tenant_id, body)[0]
        assert our_quota == tenant_id
开发者ID:AsherBond,项目名称:kong,代码行数:9,代码来源:test_neutron.py


示例16: test_keystone_v2_02_create_tenant_user

 def test_keystone_v2_02_create_tenant_user(self):
     response, data = admin.GET("/tenants")
     kong_tenant = nested_search("/tenants/*/name=kongtenant/id", data)[0]
     user = {"user": {
                          "name": "kongadmin",
                          "password": "kongsecrete",
                          "tenantid": kong_tenant,
                          "email": ""}}
     admin.POST("/users", body=user, code=200)
开发者ID:AsherBond,项目名称:kong,代码行数:9,代码来源:test_keystone_api.py


示例17: test_151_create_security_group_rule

 def test_151_create_security_group_rule(self):
     gid = nested_search("/security_groups/*/name=kongsec/id",
                         nova.GET("/os-security-groups")[1])[0]
     nova.POST("/os-security-group-rules",
               body={"security_group_rule":
                     {"from_port": "-1", "to_port": "-1",
                      "parent_group_id": "%s" % gid,
                      "cidr": "0.0.0.0/0", "ip_protocol": "icmp"}},
                      code=200)
开发者ID:invsblduck,项目名称:notchef_kong,代码行数:9,代码来源:test_nova_api.py


示例18: test_013_delete_volume

    def test_013_delete_volume(self):
        volume_id = nested_search(
            '/volumes/*/display_name=test-volume/id',
            cinder.GET('/volumes/detail')[1])[0]

        resp, body = cinder.DELETE(
            '/volumes/%s' % volume_id, code=202)

        resp, body = cinder.GET(
            '/volumes/%s' % volume_id,
            code=404, timeout=80, delay=5)
开发者ID:Apsu,项目名称:kong,代码行数:11,代码来源:test_cinder_api.py


示例19: test_100_delete_container

    def test_100_delete_container(self):
        # need to get a list of objects in the container and delete them
        response, body = swift.GET(('/%s?format=json') % (CONTAINER), code=200)
        # pull the objects out of the returned json
        objects = nested_search('*/name', body)
        # delete the objects one by one
        for obj in objects:
            swift.DELETE('%s/%s' % (CONTAINER, obj), code=204)

        # now we can delete the container
        swift.DELETE('/%s?format=json' % (CONTAINER), code=204)
开发者ID:CiscoSystems,项目名称:kong,代码行数:11,代码来源:test_swift_api.py


示例20: test_203_update_server

 def test_203_update_server(self):
     r, d = nova.GET("/servers/detail")
     sid = nested_search("/servers/*/name=testing server creation/id", d)[0]
     name = "updated"
     nova.PUT_with_keys_eq(
         "/servers/%s" % sid,
         {"/server/name": name},
         body={"server": {"name": name}},
         code=200)
     nova.PUT("/servers/%s" % sid,
              body={"server":
                    {"name": "testing server creation"}})
开发者ID:invsblduck,项目名称:notchef_kong,代码行数:12,代码来源:test_nova_api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python result.Result类代码示例发布时间:2022-05-26
下一篇:
Python restricted.RestrictedError类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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