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

vmware_guest: assign device keys from a sequence generator #57994

Open
wants to merge 3 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@lparkes
Copy link

commented Jun 18, 2019

SUMMARY

This PR adds a new class which contains a staticmethod that generates a sequence of integers for use as temporary client defined keys. I'm not convinced that the current system of ranges of random numbers will cope with assigning keys to disks and disks will need keys when we start using storage policies.

I'm using this PR to help discuss what we want to do.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

vmware_guest

ADDITIONAL INFORMATION
  1. The most important thing is assigning keys to disks. The storage policy API doesn't work if keys aren't specified even though the API doesn't refer to the keys directly.
  2. I kind of like the staticmethod for generating keys because it makes keys that look like the keys made by the VMware client.
  3. I don't care at all what class the staticmethod is part of and there is no good reason for making the new class PyVmomiKeyHelper.
Lloyd Parkes Lloyd Parkes
Add a helper class called PyVmomiKeyHelper that creates unique keys
for use with the VMware API.

Switch all of the current vApp and device code that uses VMware API
keys to use this new helper.

Add keys from this help to all disk devices. This will be needed later
for Storage Policy support.
@ansibot

This comment has been minimized.

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2019

@lparkes, just so you are aware we have a dedicated Working Group for vmware.
You can find other people interested in this in #ansible-vmware on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 18, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/vmware/vmware_guest.py:612:1: E302 expected 2 blank lines, found 1

click here for bot help

@lparkes lparkes changed the title 02.0Add a helper class called PyVmomiKeyHelper that creates unique keys vmware_guest: assign device keys from a sequence generator Jun 18, 2019

@lparkes

This comment has been minimized.

Copy link
Author

commented Jun 18, 2019

I don't recall saving this PR last night. That could easily have been kitten assisted and I have tidied up the text and I'll look at the pep8 failure now.

Lloyd Parkes added some commits Jun 19, 2019

Lloyd Parkes
def next_key():
PyVmomiKeyHelper.current_key -= 1
return PyVmomiKeyHelper.current_key

This comment has been minimized.

Copy link
@goneri

goneri Jun 20, 2019

Contributor

I like the idea, but I'm not sure you need a class for that. e.g:

>>> def foo():
...     if hasattr(foo, 'cpt'):
...         foo.cpt +=1
...     else:
...         foo.cpt = 0
...     return foo.cpt
... 
>>> foo()
0
>>> foo()
1
>>> foo()
2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.