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 image member methods to openstackv2 #1172

Closed

Conversation

vdloo
Copy link
Member

@vdloo vdloo commented Feb 11, 2018

Add list image member methods to openstack v2 driver

includes and depends on #1151

this allows listing image members, see https://developer.openstack.org/api-ref/image/v2/index.html#sharing. in openstack you can share images between tenants. when an image is set to 'shared' other tenants can be added as 'member'. all members of an image can be listed to see which tenants have access and if they have accepted or rejected the membership yet or if it is still pending. this PR adds the new NodeImageMember class which contains image id, member id, state and more.

list image members

In [6]: conn.ex_list_image_members(image.id)
Out[6]: 
[<NodeImageMember: id=016926dff12345e8b10329f24c99745b, image_id=d9a9cd9a-278a-444c-90a6-d24b8c688a63, state=accepted, driver=OpenStack  ...>,
...

In [7]: image_member = conn.ex_list_image_members(image.id)[0]

In [8]: dir(image_member)
Out[8]: 
['__class__',
 '__delattr__',
 '__dict__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__module__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_uuid',
 'created',
 'driver',
 'extra',
 'get_uuid',
 'id',
 'image_id',
 'state',
 'uuid']

In [9]: image_member.extra
Out[9]: 
{'created': u'2018-01-12T12:31:50Z',
 'schema': u'/v2/schemas/member',
 'updated': u'2018-01-12T12:31:54Z'}

list image member:

In [7]: conn.ex_list_image_member(image.id, member.id)
Out[7]: <NodeImageMember: id=016926dff12345e8b10329f24c99745b, image_id=d9a9cd9a-278a-444c-90a6-d24b8c688a63, state=accepted, driver=OpenStack  ...>

Status

  • done, ready for review

@vdloo vdloo force-pushed the add-image-member-methods-to-openstackv2 branch 2 times, most recently from b4e776c to dde3ea2 Compare February 12, 2018 09:14
@pquentin
Copy link
Contributor

Can you please rebase your changes on top of the latest trunk? It would allow to see coverage info, since the latest trunk fixes an issue with sphinx. Thanks!

@vdloo vdloo force-pushed the add-image-member-methods-to-openstackv2 branch from dde3ea2 to 3ccc1d8 Compare February 26, 2018 16:38
@vdloo
Copy link
Member Author

vdloo commented Feb 26, 2018

yes no problem. also please see #1151, this PR depends on and includes that one

@codecov-io
Copy link

Codecov Report

Merging #1172 into trunk will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##            trunk    #1172      +/-   ##
==========================================
+ Coverage   86.13%   86.17%   +0.03%     
==========================================
  Files         348      348              
  Lines       66981    67137     +156     
  Branches     5952     5956       +4     
==========================================
+ Hits        57694    57853     +159     
+ Misses       6857     6853       -4     
- Partials     2430     2431       +1
Impacted Files Coverage Δ
libcloud/compute/base.py 93.04% <100%> (+0.23%) ⬆️
libcloud/test/compute/test_openstack.py 96.22% <100%> (+0.28%) ⬆️
libcloud/compute/drivers/openstack.py 84.29% <100%> (+1.41%) ⬆️
libcloud/test/common/test_openstack_identity.py 97.94% <100%> (ø) ⬆️
libcloud/compute/types.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1eca23b...3ccc1d8. Read the comment docs.


def ex_list_image_member(self, image_id, member_id):
"""
List a member of an image by id
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a good reason to call this operation list and not get?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, has been changed to ex_get_image_member now to conform to the convention

@vdloo vdloo force-pushed the add-image-member-methods-to-openstackv2 branch 2 times, most recently from da8b397 to 35ee494 Compare March 2, 2018 08:27
@vdloo
Copy link
Member Author

vdloo commented Mar 2, 2018

rebased on origin/trunk

@asfgit asfgit closed this in 5231cec Mar 2, 2018
@pquentin
Copy link
Contributor

pquentin commented Mar 2, 2018

Thanks! Merged in trunk. ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants