-
Notifications
You must be signed in to change notification settings - Fork 85
feat2RFC(vcd_vapp_vm_nic): Do a module invocation better #131
base: master
Are you sure you want to change the base?
feat2RFC(vcd_vapp_vm_nic): Do a module invocation better #131
Conversation
1. Do complete validation needed NIC by nic_id and add if his not are presents 2. Do a 3-steps way - I. Verififaction (meta) - read_nics() and return states, if no are adapters presents on exec, add the first one. II. Check and manage wants state - "present" as default by the way - go add NIC only if his not in read_nics returned list III. Operation (validate): Last third invocation which operate NICs and "operation" key have for validation flow value = "validate" - it's say module go to validate_nics(), - gathering results, merge and view executed earlier steps (I,II)
@westsouthnight, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding
|
Please, dear community and all devs! Please, if it possible look to this, really, little but big problem - which we can resolve now and close Issue faster then speed of light - merge that PR. No want stack on stuck after so long investigation, asking to your hearts, please without regredness. ASAP! |
@westsouthnight thanks for the PR. I have looked into the PR and would like to request two things,
|
In each type of api request which we ask vcloud director about something (vm, vm_nic, vm_disc, etc) - in each module firsts you must split invocation to 3 times: Read, Validate, Perform. On this 'pipe' of asks and responses to itself object you must detect cases when library pyvcloud (SDK) trow uncatchable exception, you need know this cases for each over, and implement it. So like for example im describe and explain in my RFC request. Yes, you need and must (i hope you can with help refactor this modules to perfect level) add this functionality to current have in repository module, by the way im only try to show you correct way for able every time to get a good exits instead of unhandled exceptions after known types of api requests and know list of possible exceptions. You can use my code for example. Sometimes without good output we lost a basic code navigation, which give misunderstanding invocation pipe. |
|
||
module = VappVMNIC(argument_spec=argument_spec, supports_check_mode=True) | ||
|
||
if module.params.get('verification'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remark one: SPLIT TO
PIPE Read, Validate, Perform.
-
.manage_meta() - get the whole object, - and try must exit from any possible case, because all this cases are knows by PyVcloud SDK interface which we use for operate object - this is classes Vapp & VM which we use in modules. Basicly must every time out, if nothing happen : simple "No data"'
-
.manage_state() - by reason getted from previous step (mange_meta()) this function perform needed tasks and calls, for able this module exit correct in must of cases.
-
.mange_operation() - based, on my example i call to this by 'validate' - at that place we can go around with some method like back to meta with other thing, for able run from first module step with cointain information what we need if first are go down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[THIS ONLY FOR EXAMPLE HOW YOU CAN SPLIT INSIDE, BUT WORKS] @mukultaneja
f7e20c5
to
a2ab41a
Compare
@mukultaneja so because parent fix are a merged in pyvcloud library in next week i have a few days of free dev time, and do some couple of fixes for current issues. |
0709d92
to
ab2779b
Compare
Issue details, RFC
Pre conditions and Info:
Module need to be refactored - vcd_vapp_vm_nic
Module role example must to be relevant and updated which we update the modules, not after few mouth after make changes: Folder & Role tasks
We must so much possible do threads are is parts of invocation in module shortly, simplificated on data target operations for update / get / set, without "between" temporary vars and workarounds such as run external executes module - itself. for able check / validate / update something in VM, vApp, vNetwork or other resource, in our target case that correct use as example - [Role tasks] (https://github.com/vmware/ansible-module-vcloud-director/blob/master/roles/vcd_vapp_vm_nic/tasks/main.yml)
Currently, in parent library - pyvcloud possible (but im find them and already checked) module contains presents Issue, which not give able work updated and proposed module directly complete success now, because itself pyvcloud library contain bug, - when we add the first adapter and try to return list of nics, we get Exception with message "primary_index referenced before assigment", but NIC will be added (see at Currently Results Screens).
Example and describes:
When i have a presented vApp with one VM, and after adding second VM maked from other "Template VM Image" (possible that template no have any adapter when his have on born as template, in process of convert), - we wants have network, for that we will be need add/validate Network adapters and check/perform attaching they to second VM, - but in invocations running with differents behaviors, and types of parameters we everytime get exceptions with big precent of happens of anything, what not can be possible to use on production codebase.
Way which proposed in this module example is not are native and need to multiple calls, save the temporary between tasks results for able check what we need do next. In initial works with VM NICs we need try to use one call check for prevents no needed time leak, strange and not native for most people way for do a simple thing.
Expected and wants results:
Currently results:
Pull Request wants:
Resolve parent pyvcloud library Issue, because its blocks mainstream fix of ansible module - When we add_nic() are first, after successful complete adding module fail with error about referenced variable which called before assigment.
Replace/add the code with validation by one call to ansible-module-vcloud-director after cleans PR/changes/updates on stages which supposed in that RFC about PR.
Have an updated examples and documentation.
Usage after (in test case i'm used local copy of VM class with my fix of primary_index)
Short way for conversate in raw way:
telegram - @westsouthnight