Skip to content

Commit

Permalink
Fixed 2 bugs reported by Alain Spineux (see topic/pysphere/ntLqYvlL9yI)
Browse files Browse the repository at this point in the history
  • Loading branch information
argos83 committed Mar 20, 2013
1 parent be9d36f commit 825efb9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pysphere/vi_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ def relocate(self, sync_run=True, priority='default', datastore=None,

def get_snapshots(self):
"""Returns a list of VISnapshot instances of this VM"""
self.refresh_snapshot_list()
return self._snapshot_list[:]

def get_current_snapshot_name(self):
Expand Down Expand Up @@ -950,7 +951,7 @@ def delete_snapshot_by_path(self, path, index=0, remove_children=False,

def refresh_snapshot_list(self):
"""Refreshes the internal list of snapshots of this VM"""
self.__update_properties()
self.__update_properties()

#--------------------------#
#-- VMWARE TOOLS METHODS --#
Expand Down Expand Up @@ -1698,7 +1699,6 @@ def __delete_snapshot(self, mor, remove_children, sync_run):
raise VIException(vi_task.get_error_message(),
FaultTypes.TASK_ERROR)
return

return vi_task

except (VI.ZSI.FaultException), e:
Expand Down Expand Up @@ -1757,6 +1757,7 @@ def update_devices(devices):
self._devices[dev.key] = d

def update_disks(disks):
new_disks = []
for disk in disks:
files = []
committed = 0
Expand All @@ -1771,14 +1772,15 @@ def update_disks(disks):
store = f['name']
dev = self._devices[disk.key]

self._disks.append({
new_disks.append({
'device': dev,
'files': files,
'capacity': dev['capacityInKB'],
'committed': committed/1024,
'descriptor': store,
'label': dev['label'],
})
self._disks = new_disks

def update_files(files):
for file_info in files:
Expand Down Expand Up @@ -1848,17 +1850,19 @@ def update_files(files):
#----------------------#
#-- UPDATE SNAPSHOTS --#

root_snapshots = []
if hasattr(self.properties, "snapshot"):
if hasattr(self.properties.snapshot, "currentSnapshot"):
self.__current_snapshot = \
self.properties.snapshot.currentSnapshot._obj

self._root_snapshots = []

for root_snap in self.properties.snapshot.rootSnapshotList:
root = VISnapshot(root_snap)
self._root_snapshots.append(root)
self.__create_snapshot_list()

root_snapshots.append(root)
self._root_snapshots = root_snapshots
self.__create_snapshot_list()

#-----------------------#
#-- SET RESOURCE POOL --#
if hasattr(self.properties, "resourcePool"):
Expand Down

0 comments on commit 825efb9

Please sign in to comment.