分享

restful 接口 {nova-url}/v2/{project_id}/os-networks 不能如文档描述返回数据

alphatan 发表于 2015-8-27 17:32:59 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 6 11050
1. 测试环境:

        1. OpenStack 版本:Juno,

        2. API 版本:

            identity v3
            nova v2
            neutron v2

2. 命令与返回

        root@ATUBT64:~# curl -i -H "Accept: application/json" -H "X-Auth-Token: 7994997796d74491b051254b32fadf3f" -X GET  http://10.161.128.38:8774/v2/f58 ... f839400/os-networks ; echo
        HTTP/1.1 200 OK
        Content-Type: application/json
        Content-Length: 1945
        X-Compute-Request-Id: req-5a8a34f9-a50a-4c37-bccc-7300f5b92ee6
        Date: Thu, 27 Aug 2015 09:18:58 GMT

        {"networks": [{"bridge": null, "vpn_public_port": null, "dhcp_start": null, "bridge_interface": , "share_address": null, "updated_at": null, "id": "d36e1e70-2d40-40f8-b98f-722d95feec70", "cidr_: null, "deleted_at": null, "gateway": null, "rxtx_base": null, "label": "test001-net", "null, "project_id": null, "vpn_private_address": null, "deleted": null, "vlan": null, "broadcast": ull, "netmask": null, "injected": null, "cidr": null, "vpn_public_address": null, "multi_host": , "enable_dhcp": null, "dns2": null, "created_at": null, "host": null, "mtu": null, "gateway_v6": ll, "netmask_v6": null, "dhcp_server": null, "dns1": null}, {"bridge": null, "vpn_public_port": , "dhcp_start": null, "bridge_interface": null, "share_address": null, "updated_at": null, "id": "c8bb14-f15c-4767-9dc0-239275f77831", "cidr_v6": null, "deleted_at": null, "gateway": null, "rxtx_e": null, "label": "demo-net", "priority": null, "project_id": null, "vpn_private_address": null, "eleted": null, "vlan": null, "broadcast": null, "netmask": null, "injected": null, "cidr": null, "n_public_address": null, "multi_host": null, "enable_dhcp": null, "dns2": null, "created_at": null,"host": null, "mtu": null, "gateway_v6": null, "netmask_v6": null, "dhcp_server": null, "dns1": null}, {"bridge": null, "vpn_public_port": null, "dhcp_start": null, "bridge_interface": null, "share_dress": null, "updated_at": null, "id": "b0366df6-7dbf-49ad-841e-5dd51a650b8a", "cidr_v6": null, "deleted_at": null, "gateway": null, "rxtx_base": null, "label": "ext-net", "priority": null, "project_id": null, "vpn_private_address": null, "deleted": null, "vlan": null, "broadcast": null, "netmask": null, "injected": null, "cidr": null, "vpn_public_address": null, "multi_host": null, "enable_dhcp": null, "dns2": null, "created_at": null, "host": null, "mtu": null, "gateway_v6": null, "netmask_v6": null, "dhcp_server": null, "dns1": null}]}

        格式化后的内容如下:
        {
                "networks":[
                        {
                                "bridge":null,
                                "vpn_public_port":null,
                                "dhcp_start":null,
                                "bridge_interface":,
                                "share_address":null,
                                "updated_at":null,
                                "id":"d36e1e70-2d40-40f8-b98f-722d95feec70",
                                "cidr_: null,
                                "deleted_at": null,
                                "gateway": null,
                                "rxtx_base": null,
                                "label": "test001-net",
                                "project_id":null,
                                "vpn_private_address":null,
                                "deleted":null,
                                "vlan":null,
                                "broadcast":ull,
                                "netmask":null,
                                "injected":null,
                                "cidr":null,
                                "vpn_public_address":null,
                                "multi_host":,
                                "enable_dhcp":null,
                                "dns2":null,
                                "created_at":null,
                                "host":null,
                                "mtu":null,
                                "gateway_v6":ll,
                                "netmask_v6":null,
                                "dhcp_server":null,
                                "dns1":null
                        },
                        {
                                "bridge":null,
                                "vpn_public_port":,
                                "dhcp_start":null,
                                "bridge_interface":null,
                                "share_address":null,
                                "updated_at":null,
                                "id":"c8bb14-f15c-4767-9dc0-239275f77831",
                                "cidr_v6":null,
                                "deleted_at":null,
                                "gateway":null,
                                "rxtx_e":null,
                                "label":"demo-net",
                                "priority":null,
                                "project_id":null,
                                "vpn_private_address":null,
                                "eleted":null,
                                "vlan":null,
                                "broadcast":null,
                                "netmask":null,
                                "injected":null,
                                "cidr":null,
                                "n_public_address":null,
                                "multi_host":null,
                                "enable_dhcp":null,
                                "dns2":null,
                                "created_at":null,
                                "host":null,
                                "mtu":null,
                                "gateway_v6":null,
                                "netmask_v6":null,
                                "dhcp_server":null,
                                "dns1":null
                        },
                        {
                                "bridge":null,
                                "vpn_public_port":null,
                                "dhcp_start":null,
                                "bridge_interface":null,
                                "share_dress":null,
                                "updated_at":null,
                                "id":"b0366df6-7dbf-49ad-841e-5dd51a650b8a",
                                "cidr_v6":null,
                                "deleted_at":null,
                                "gateway":null,
                                "rxtx_base":null,
                                "label":"ext-net",
                                "priority":null,
                                "project_id":null,
                                "vpn_private_address":null,
                                "deleted":null,
                                "vlan":null,
                                "broadcast":null,
                                "netmask":null,
                                "injected":null,
                                "cidr":null,
                                "vpn_public_address":null,
                                "multi_host":null,
                                "enable_dhcp":null,
                                "dns2":null,
                                "created_at":null,
                                "host":null,
                                "mtu":null,
                                "gateway_v6":null,
                                "netmask_v6":null,
                                "dhcp_server":null,
                                "dns1":null
                        }
                ]
        }

        注意,只有 id 跟label 字段是有值返回的。这跟
        http://developer.openstack.org/a ... t.html#ListNetworks
        描述的返回差别很远。


在网上查了一下,一天下来并没有相关的资料。不知道我还可以做些什么事情使
这个接口可以使用?还是说我必须直接调用 network 服务的接口?

谢谢。

已有(6)人评论

跳转到指定楼层
s060403072 发表于 2015-8-27 22:54:53
肯定不一样的,你的数据库可能跟它的不一样,而且数据一样的可能性也不大。
这就是大家都执行
select * from table
官网执行是一个结果
你本地执行肯定是另外一个结果
回复

使用道具 举报

alphatan 发表于 2015-8-28 08:34:53
s060403072 发表于 2015-8-27 22:54
肯定不一样的,你的数据库可能跟它的不一样,而且数据一样的可能性也不大。
这就是大家都执行
select *  ...

不好意思,在之前的贴中没有说清楚。

我的意思是,调用返回的数据跟实际的网络数据不同。
如:cidr 之类的域是肯定有的。

调用 network (neutron, 9696) 的 "/v2.0/networks", "/v2.0/subnets" 的结果如下:


1. /v2.0/networks

        root@ATUBT64:~# curl -i -H "Accept: application/json" -H "X-Auth-Token: 3103514cca7345f4ae1446eeaad3afc5" -X GET  http://10.161.128.38:9696/v2.0/n ... f8-b98f722d95feec70 ; echo

        HTTP/1.1 200 OK
        Content-Type: application/json; charset=UTF-8
        Content-Length: 369
        X-Openstack-Request-Id: req-7d54f372-61ac-49c3-a555-10be02fceff6
        Date: Fri, 28 Aug 2015 00:22:31 GMT

        {"network": {"status": "ACTIVE", "subnets": ["232c51d9-2d56-4e63-9400-6ae7a0444390"], "name": "test001-net", "provider:physical_network": null, "admin_state_up": true, "tenant_id": "f582880f9de7451a9d667cc5af839400", "provider:network_type": "gre", "router:external": false, "shared": false, "id": "d36e1e70-2d40-40f8-b98f-722d95feec70", "provider:segmentation_id": 2}}

        格式化后的结果:
    {
            "network":{
                    "status":"ACTIVE",
                    "subnets":[
                            "232c51d9-2d56-4e63-9400-6ae7a0444390"
                    ],
                    "name":"test001-net",
                    "provider:physical_network":null,
                    "admin_state_up":true,
                    "tenant_id":"f582880f9de7451a9d667cc5af839400",
                    "provider:network_type":"gre",
                    "router:external":false,
                    "shared":false,
                    "id":"d36e1e70-2d40-40f8-b98f-722d95feec70",
                    "provider:segmentation_id":2
            }
    }


2. /v2.0/subnets

        root@ATUBT64:~# curl -i -H "Accept: application/json" -H "X-Auth-Token: 3103514cca7345f4ae1446eeaad3afc5" -X GET  http://10.161.128.38:9696/v2.0/s ... 63-9400-ae7a0444390 ; echo

        HTTP/1.1 200 OK
        Content-Type: application/json; charset=UTF-8
        Content-Length: 433
        X-Openstack-Request-Id: req-8cf0a076-7da4-48e6-b148-bb17e866935d
        Date: Fri, 28 Aug 2015 00:29:13 GMT

        {"subnet": {"name": "n1", "enable_dhcp": true, "network_id": "d36e1e70-2d40-40f8-b98f-722d95feec70", "tenant_id": "f582880f9de7451a9d667cc5af839400", "dns_nameservers": [], "gateway_ip": "192.168.2.254", "ipv6_ra_mode": null, "allocation_pools": [{"start": "192.168.2.1", "end": "192.168.2.253"}], "host_routes": [], "ip_version": 4, "ipv6_address_mode": null, "cidr": "192.168.2.0/24", "id": "232c51d9-2d56-4e63-9400-6ae7a0444390"}}

        格式化后的结果:
    {
            "subnet":{
                    "name":"n1",
                    "enable_dhcp":true,
                    "network_id":"d36e1e70-2d40-40f8-b98f-722d95feec70",
                    "tenant_id":"f582880f9de7451a9d667cc5af839400",
                    "dns_nameservers":[
                           
                    ],
                    "gateway_ip":"192.168.2.254",
                    "ipv6_ra_mode":null,
                    "allocation_pools":[
                            {
                                    "start":"192.168.2.1",
                                    "end":"192.168.2.253"
                            }
                    ],
                    "host_routes":[
                           
                    ],
                    "ip_version":4,
                    "ipv6_address_mode":null,
                    "cidr":"192.168.2.0/24",
                    "id":"232c51d9-2d56-4e63-9400-6ae7a0444390"
            }
    }
回复

使用道具 举报

s060403072 发表于 2015-8-28 14:48:57
alphatan 发表于 2015-8-28 08:34
不好意思,在之前的贴中没有说清楚。

我的意思是,调用返回的数据跟实际的网络数据不同。

楼主是否验证过,跟shell命令是否一致
回复

使用道具 举报

alphatan 发表于 2015-8-28 14:55:45
s060403072 发表于 2015-8-28 14:48
楼主是否验证过,跟shell命令是否一致

restful api 的输出跟命令行的输出是一致的,但跟官方文档的输出不一致。


回复

使用道具 举报

s060403072 发表于 2015-8-28 15:25:00
alphatan 发表于 2015-8-28 14:55
restful api 的输出跟命令行的输出是一致的,但跟官方文档的输出不一致。

shell与rest一致就没有问题,不必执着于官方。还有你说的是哪里不一致,
回复

使用道具 举报

alphatan 发表于 2015-8-30 08:09:16
s060403072 发表于 2015-8-28 15:25
shell与rest一致就没有问题,不必执着于官方。还有你说的是哪里不一致,

官网的描述中, compute 的 os-networks 起码应该返回 cidr 等值,但实际上都为 null, 只有 id 与  name 是有值的。

而直接调用 network (neutron) 的 networks, subnets, ports 接口都可以返回正确的值。

os-networks 不能工作的话,使用 network 组件的接口也可以实现相应的功能,只是比较麻烦而已。我是觉得既然是 release 版本(icehouse 跟 juno 都有同样的问题),起码应该测试过承诺的东西。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条