Merge lp:~jk0/nova/lp744833 into lp:~hudson-openstack/nova/trunk

Proposed by Josh Kearney
Status: Merged
Approved by: Josh Kearney
Approved revision: 924
Merged at revision: 924
Proposed branch: lp:~jk0/nova/lp744833
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 53 lines (+13/-5)
2 files modified
nova/virt/vmwareapi/vim.py (+11/-4)
nova/virt/vmwareapi_conn.py (+2/-1)
To merge this branch: bzr merge lp:~jk0/nova/lp744833
Reviewer Review Type Date Requested Status
termie (community) Approve
Rick Clark (community) Approve
Review via email: mp+55604@code.launchpad.net

Description of the change

Avoid any hard dependencies in nova.virt.vmwareapi.vim.

To post a comment you must log in.
Revision history for this message
Rick Clark (dendrobates) wrote :

lgtm

review: Approve
Revision history for this message
Brian Lamar (blamar) wrote :

I feel like this should be headed off at the vim.py level where suds is actually used. Maybe it's just me, but I'd rather:

try:
    import suds
except ImportError:
    suds = None

and then check in the Vim class that suds is not None?

Revision history for this message
Josh Kearney (jk0) wrote :

> I feel like this should be headed off at the vim.py level where suds is
> actually used. Maybe it's just me, but I'd rather:
>
> try:
> import suds
> except ImportError:
> suds = None
>
> and then check in the Vim class that suds is not None?

I actually started off doing it that way, but the problem is that there are a half-dozen or so other imports from suds. All of the import try-excepts felt very dirty.

This way avoids almost all of the refactoring that would otherwise have to be done (which I am a fan of).

Revision history for this message
termie (termie) wrote :

I agree with brian on this one, I think this is the wrong place to address the issue

review: Needs Fixing
lp:~jk0/nova/lp744833 updated
923. By Josh Kearney

Handle in vim.py

924. By Josh Kearney

Whoops

Revision history for this message
termie (termie) wrote :

while technically this should be importing modules not classes, i'll let that slide so you don't have to go change their entire file.

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/virt/vmwareapi/vim.py'
2--- nova/virt/vmwareapi/vim.py 2011-03-24 16:38:31 +0000
3+++ nova/virt/vmwareapi/vim.py 2011-03-30 18:58:35 +0000
4@@ -21,10 +21,14 @@
5
6 import httplib
7
8-from suds import WebFault
9-from suds.client import Client
10-from suds.plugin import MessagePlugin
11-from suds.sudsobject import Property
12+try:
13+ suds = True
14+ from suds import WebFault
15+ from suds.client import Client
16+ from suds.plugin import MessagePlugin
17+ from suds.sudsobject import Property
18+except ImportError:
19+ suds = False
20
21 from nova import flags
22 from nova.virt.vmwareapi import error_util
23@@ -75,6 +79,9 @@
24 protocol: http or https
25 host : ESX IPAddress[:port] or ESX Hostname[:port]
26 """
27+ if not suds:
28+ raise Exception(_("Unable to import suds."))
29+
30 self._protocol = protocol
31 self._host_name = host
32 wsdl_url = FLAGS.vmwareapi_wsdl_loc
33
34=== modified file 'nova/virt/vmwareapi_conn.py'
35--- nova/virt/vmwareapi_conn.py 2011-03-24 16:38:31 +0000
36+++ nova/virt/vmwareapi_conn.py 2011-03-30 18:58:35 +0000
37@@ -47,6 +47,7 @@
38 from nova.virt.vmwareapi import vim_util
39 from nova.virt.vmwareapi.vmops import VMWareVMOps
40
41+
42 LOG = logging.getLogger("nova.virt.vmwareapi_conn")
43
44 FLAGS = flags.FLAGS
45@@ -109,7 +110,7 @@
46 def __init__(self, host_ip, host_username, host_password,
47 api_retry_count, scheme="https"):
48 session = VMWareAPISession(host_ip, host_username, host_password,
49- api_retry_count, scheme=scheme)
50+ api_retry_count, scheme=scheme)
51 self._vmops = VMWareVMOps(session)
52
53 def init_host(self, host):