Skip to content

Commit

Permalink
Merge branch 'trunk' into dependabot/pip/tox-4.15.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kami authored Jun 17, 2024
2 parents a197d7d + 624879d commit 15364d3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
6 changes: 6 additions & 0 deletions libcloud/compute/drivers/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3160,6 +3160,12 @@ def _to_network(self, obj):
extra["router:external"] = obj.get("router:external")
if obj.get("subnets", None):
extra["subnets"] = obj.get("subnets")
if obj.get("tags", None):
extra["tags"] = obj.get("tags")
if obj.get("is_default", None) is not None:
extra["is_default"] = obj.get("is_default")
if obj.get("description", None) is not None:
extra["description"] = obj.get("description")
return OpenStackNetwork(id=obj["id"], name=obj["name"], cidr=None, driver=self, extra=extra)

def ex_list_networks(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"updated_at": "2016-03-08T20:19:41",
"vlan_transparent": false,
"description": "",
"is_default": false
"is_default": false,
"tags": ["tag1,tag2"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"network": {
"admin_state_up": true,
"availability_zone_hints": [],
"availability_zones": [
"nova"
],
"created_at": "2016-03-08T20:19:41",
"dns_domain": "my-domain.org.",
"id": "e4e207ac-6707-432b-82b9-244f6859c394",
"ipv4_address_scope": null,
"ipv6_address_scope": null,
"l2_adjacency": false,
"mtu": 1500,
"name": "net2",
"port_security_enabled": true,
"project_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
"qos_policy_id": "bfdb6c39f71e4d44b1dfbda245c50819",
"revision_number": 3,
"router:external": false,
"shared": false,
"status": "ACTIVE",
"subnets": [
"08eae331-0402-425a-923c-34f7cfe39c1b"
],
"tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
"updated_at": "2016-03-08T20:19:41",
"vlan_transparent": false
}
}
22 changes: 22 additions & 0 deletions libcloud/test/compute/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,15 @@ def test_ex_get_network(self):
self.assertEqual(network.id, "cc2dad14-827a-feea-416b-f13e50511a0a")
self.assertTrue(isinstance(network, OpenStackNetwork))
self.assertEqual(network.name, "net2")
self.assertEqual(network.extra["is_default"], False)
self.assertEqual(network.extra["tags"], ["tag1,tag2"])

network = self.driver.ex_get_network("e4e207ac-6707-432b-82b9-244f6859c394")

self.assertEqual(network.id, "e4e207ac-6707-432b-82b9-244f6859c394")
self.assertTrue(isinstance(network, OpenStackNetwork))
self.assertEqual(network.name, "net2")
self.assertNotIn("tags", network.extra)

def test_ex_list_subnets(self):
subnets = self.driver.ex_list_subnets()
Expand Down Expand Up @@ -3405,6 +3414,19 @@ def _v2_1337_v2_0_networks_cc2dad14_827a_feea_416b_f13e50511a0a(
)
raise NotImplementedError()

def _v2_1337_v2_0_networks_e4e207ac_6707_432b_82b9_244f6859c394(
self, method, url, body, headers
):
if method == "GET":
body = self.fixtures.load("_v2_0__network_no_tags.json")
return (
httplib.OK,
body,
self.json_content_headers,
httplib.responses[httplib.OK],
)
raise NotImplementedError()

def _v2_1337_v2_0_networks_d32019d3_bc6e_4319_9c1d_6722fc136a22(
self, method, url, body, headers
):
Expand Down

0 comments on commit 15364d3

Please sign in to comment.