Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some extra fields in the OpenStack Network Object: #2015 #2016

Merged
merged 7 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per codecov comment (#2016 (comment)) could you please add additional test cases so all the new code paths are covered?

This includes tests for all those fields being present and not being present (so both the explicit "if" and implicit "else" code branches are covered).

Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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):
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
1 change: 1 addition & 0 deletions libcloud/test/compute/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,7 @@ 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)

def test_ex_list_subnets(self):
subnets = self.driver.ex_list_subnets()
Expand Down
Loading