Skip to content

Commit

Permalink
fix issue where datastore not being respected
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashby, Jason (IMS) committed Feb 12, 2016
1 parent b70243e commit db807fa
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions ezmomi/ezmomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def clone(self):
resource_pool = cluster.resourcePool

datastore = None
if datastore in ip_settings[0]:
if 'datastore' in ip_settings[0]:
datastore = self.get_obj(
[vim.Datastore],
ip_settings[0]['datastore'])
Expand Down Expand Up @@ -587,13 +587,13 @@ def get_resource_pool(self, cluster, pool_name):
return pool_obj

def get_obj(self, vimtype, name, return_all=False):
"""Get the vsphere object associated with a given text name"""
"""Get the vsphere object associated with a given text name or MOID"""
obj = list()
container = self.content.viewManager.CreateContainerView(
self.content.rootFolder, vimtype, True)

for c in container.view:
if c.name == name:
if name in [c.name, c._GetMoId()]:
if return_all is False:
return c
break
Expand All @@ -606,17 +606,6 @@ def get_obj(self, vimtype, name, return_all=False):
# for backwards-compat
return None

def get_obj_by_moid(self, vimtype, moid):
"""Get the vsphere object associated with a given MoId"""
obj = None
container = self.content.viewManager.CreateContainerView(
self.content.rootFolder, vimtype, True)
for c in container.view:
if c._GetMoId() == moid:
obj = c
break
return obj

def get_host_system(self, name):
return self.get_obj([vim.HostSystem], name)

Expand Down

0 comments on commit db807fa

Please sign in to comment.