A corner case in _call_method of vmwareapi_conn.py

Bug #810922 reported by Neeraj Koul
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Medium
Unassigned

Bug Description

In nova/virt/vmwareapi_conn.py 's function "_call_method", there is a corner case which is not taken care of.

(Samples taken from vmwareapi/vmops.py module)

Calls are made either through vim_util's utility functions. e.g

self._session._call_method(vim_util, "get_objects",
   "Datastore", ["summary.type", "summary.name"])

Or

directly say a call like

vm_create_task = self._session._call_method(
   self._session._get_vim(),
   "CreateVM_Task", vm_folder_mor,
   config=config_spec, pool=res_pool_mor)

Now suppose the session we held expires at the vCenter, we get an error and we create say new vim object with a new session id. But in case of the second call,
we still are referring to the old vim object as the module palceholder. We just need to make it point to the latest vim object. Just need to add a line to the
_call_method in the else part. The code would look like this after the change

if not isinstance(module, vim.Vim):
 # If it is not the first try, then get the latest vim
 # object
    if retry_count > 0:
  args = args[1:]
 args = [self.vim] + args
else:
    module = self.vim

Revision history for this message
Neeraj Koul (neeraj-koul) wrote :

I think code formatting was not proper in the bug description. What i meant was that add an else to cover up for the case when module is an instance of vim.Vim..
Add
module = self.vim
in the else part

Revision history for this message
Thierry Carrez (ttx) wrote :

@Neeraj: any chance you could submit your patch as a branch merge proposal ?

Changed in nova:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Neeraj Koul (neeraj-koul) wrote :

I will work with Sateesh (https://launchpad.net/~sateesh-chodapuneedi) to do the same.. Will assist him at the code level and he can submit the branch merge proposal..

Revision history for this message
Hengqing Hu (hudayou) wrote :

This case seems not likely to happen.

Since self._session._get_vim() will return self.vim which is the same as you proposed.

Revision history for this message
Tom Fifield (fifieldt) wrote :

It looks like this fix was never submitted, but looking at the code and @hudayou 's comments, it seems invalid anyway ... especially after all this time has passed.

Changed in nova:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.