Skip to content

Commit 275314f

Browse files
tyzhnenkodisplague
authored andcommitted
Add support empty Facility for IPAddress
In case fetch ips for a project with `state=all` a server returns objects with null facility. It happens when IP in Pending status. Signed-off-by: Dmitry Tyzhnenko <[email protected]>
1 parent 33bc6b1 commit 275314f

File tree

3 files changed

+187
-0
lines changed

3 files changed

+187
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{"ip_addresses": [{
2+
"id": "99d5d741-3756-4ebe-a014-34ea7a2e2be1",
3+
"address_family": 4,
4+
"netmask": "255.255.255.254",
5+
"created_at": "2019-07-18T08:46:38Z",
6+
"details": null,
7+
"tags": [],
8+
"public": true,
9+
"cidr": 31,
10+
"management": true,
11+
"manageable": true,
12+
"enabled": true,
13+
"global_ip": null,
14+
"customdata": {},
15+
"project": {},
16+
"project_lite": {},
17+
"facility": {
18+
"id": "8e6470b3-b75e-47d1-bb93-45b225750975",
19+
"name": "Amsterdam, NL",
20+
"code": "ams1",
21+
"features": [
22+
"baremetal",
23+
"storage",
24+
"global_ipv4",
25+
"backend_transfer",
26+
"layer_2"
27+
],
28+
"address": {
29+
"href": "#0688e909-647e-4b21-bdf2-fc056d993fc5"
30+
},
31+
"ip_ranges": [
32+
"2604:1380:2000::/36",
33+
"147.75.204.0/23",
34+
"147.75.100.0/22",
35+
"147.75.80.0/22",
36+
"147.75.32.0/23"
37+
]
38+
},
39+
"assigned_to": {
40+
"href": "/devices/54ffd20d-d972-4c8d-8628-9da18e67ae17"
41+
},
42+
"interface": {
43+
"href": "/ports/02ea0556-df04-4554-b339-760a0d227b44"
44+
},
45+
"network": "147.75.84.94",
46+
"address": "147.75.84.95",
47+
"gateway": "147.75.84.94",
48+
"href": "/ips/99d5d741-3756-4ebe-a014-34ea7a2e2be1"
49+
},
50+
{
51+
"id": "99d5d741-3756-4ebe-a014-34ea7a2e2be2",
52+
"address_family": 4,
53+
"netmask": "255.255.255.254",
54+
"created_at": "2019-07-18T08:46:38Z",
55+
"details": null,
56+
"tags": [],
57+
"public": true,
58+
"cidr": 31,
59+
"management": true,
60+
"manageable": true,
61+
"enabled": true,
62+
"global_ip": null,
63+
"customdata": {},
64+
"project": {},
65+
"project_lite": {},
66+
"facility": {
67+
"id": "8e6470b3-b75e-47d1-bb93-45b225750975",
68+
"name": "Amsterdam, NL",
69+
"code": "ams1",
70+
"features": [
71+
"baremetal",
72+
"storage",
73+
"global_ipv4",
74+
"backend_transfer",
75+
"layer_2"
76+
],
77+
"address": {
78+
"href": "#0688e909-647e-4b21-bdf2-fc056d993fc5"
79+
},
80+
"ip_ranges": [
81+
"2604:1380:2000::/36",
82+
"147.75.204.0/23",
83+
"147.75.100.0/22",
84+
"147.75.80.0/22",
85+
"147.75.32.0/23"
86+
]
87+
},
88+
"assigned_to": {
89+
"href": "/devices/54ffd20d-d972-4c8d-8628-9da18e67ae17"
90+
},
91+
"interface": {
92+
"href": "/ports/02ea0556-df04-4554-b339-760a0d227b44"
93+
},
94+
"network": "147.75.84.94",
95+
"address": "147.75.84.95",
96+
"gateway": "147.75.84.94",
97+
"href": "/ips/99d5d741-3756-4ebe-a014-34ea7a2e2be1"
98+
}]}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{"ip_addresses": [{
2+
"id": "99d5d741-3756-4ebe-a014-34ea7a2e2be1",
3+
"address_family": 4,
4+
"netmask": "255.255.255.254",
5+
"created_at": "2019-07-18T08:46:38Z",
6+
"details": null,
7+
"tags": [],
8+
"public": true,
9+
"cidr": 31,
10+
"management": true,
11+
"manageable": true,
12+
"enabled": true,
13+
"global_ip": null,
14+
"customdata": {},
15+
"project": {},
16+
"project_lite": {},
17+
"facility": null,
18+
"assigned_to": {
19+
"href": "/devices/54ffd20d-d972-4c8d-8628-9da18e67ae17"
20+
},
21+
"interface": {
22+
"href": "/ports/02ea0556-df04-4554-b339-760a0d227b44"
23+
},
24+
"network": "147.75.84.94",
25+
"address": "147.75.84.95",
26+
"gateway": "147.75.84.94",
27+
"href": "/ips/99d5d741-3756-4ebe-a014-34ea7a2e2be1"
28+
},
29+
{
30+
"id": "99d5d741-3756-4ebe-a014-34ea7a2e2be2",
31+
"address_family": 4,
32+
"netmask": "255.255.255.254",
33+
"created_at": "2019-07-18T08:46:38Z",
34+
"details": null,
35+
"tags": [],
36+
"public": true,
37+
"cidr": 31,
38+
"management": true,
39+
"manageable": true,
40+
"enabled": true,
41+
"global_ip": null,
42+
"customdata": {},
43+
"project": {},
44+
"project_lite": {},
45+
"facility": {
46+
"id": "8e6470b3-b75e-47d1-bb93-45b225750975",
47+
"name": "Amsterdam, NL",
48+
"code": "ams1",
49+
"features": [
50+
"baremetal",
51+
"storage",
52+
"global_ipv4",
53+
"backend_transfer",
54+
"layer_2"
55+
],
56+
"address": {
57+
"href": "#0688e909-647e-4b21-bdf2-fc056d993fc5"
58+
},
59+
"ip_ranges": [
60+
"2604:1380:2000::/36",
61+
"147.75.204.0/23",
62+
"147.75.100.0/22",
63+
"147.75.80.0/22",
64+
"147.75.32.0/23"
65+
]
66+
},
67+
"assigned_to": {
68+
"href": "/devices/54ffd20d-d972-4c8d-8628-9da18e67ae17"
69+
},
70+
"interface": {
71+
"href": "/ports/02ea0556-df04-4554-b339-760a0d227b44"
72+
},
73+
"network": "147.75.84.94",
74+
"address": "147.75.84.95",
75+
"gateway": "147.75.84.94",
76+
"href": "/ips/99d5d741-3756-4ebe-a014-34ea7a2e2be1"
77+
}]}

test/test_packet.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,18 @@ def test_list_device_ips(self):
229229
ips = self.manager.list_device_ips("e123s")
230230
self.assertIsNotNone(ips)
231231

232+
def test_list_projects_ips(self):
233+
ips = self.manager.list_project_ips("438659f0")
234+
self.assertIsNotNone(ips)
235+
for ip in ips:
236+
self.assertIsInstance(ip.facility, packet.Facility)
237+
238+
def test_list_projects_ips_state_all(self):
239+
ips = self.manager.list_project_ips("438659f1", params={"state": "all"})
240+
self.assertIsNotNone(ips)
241+
self.assertIsNone(ips[0].facility)
242+
self.assertIsInstance(ips[1].facility, packet.Facility)
243+
232244

233245
class PacketMockManager(packet.Manager):
234246
def call_api(self, method, type="GET", params=None):

0 commit comments

Comments
 (0)