diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py index 360d32ebd0..cea1974567 100644 --- a/libcloud/compute/drivers/openstack.py +++ b/libcloud/compute/drivers/openstack.py @@ -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): diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__network.json b/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__network.json index 5686828996..b1b6005700 100644 --- a/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__network.json +++ b/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__network.json @@ -27,6 +27,7 @@ "updated_at": "2016-03-08T20:19:41", "vlan_transparent": false, "description": "", - "is_default": false + "is_default": false, + "tags": ["tag1,tag2"] } } diff --git a/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__network_no_tags.json b/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__network_no_tags.json new file mode 100644 index 0000000000..19e54b6a4f --- /dev/null +++ b/libcloud/test/compute/fixtures/openstack_v1.1/_v2_0__network_no_tags.json @@ -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 + } +} diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py index f81da0cdc7..51506995bc 100644 --- a/libcloud/test/compute/test_openstack.py +++ b/libcloud/test/compute/test_openstack.py @@ -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() @@ -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 ):