Skip to content

Commit 81b669f

Browse files
committed
BaseVM: simplify .vdi_uuids() by telling XAPI not to show VBDs
Previous xe command was outputing a mix of VDI,VBD,VDI,VBD and forced to skip those unwanted VBDs. Just avoid getting them in the first place. Originally-by: Damien Thenot <[email protected]> Signed-off-by: Yann Dirson <[email protected]>
1 parent 89e8c5d commit 81b669f

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

lib/basevm.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def vdi_uuids(self, sr_uuid=None):
4343
if output == '':
4444
return []
4545

46-
all_uuids = output.split(',') # Split based on commas
47-
# Select only every alternate UUID (even index positions)
48-
vdis = all_uuids[0::2] # Start at 0, step by 2
46+
vdis = output.split(',')
4947

5048
if sr_uuid is None:
5149
return vdis

lib/snapshot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
class Snapshot(BaseVM):
66
def _disk_list(self):
7-
return self.host.xe('snapshot-disk-list', {'uuid': self.uuid}, minimal=True)
7+
return self.host.xe('snapshot-disk-list', {'uuid': self.uuid, 'vbd-params': ''},
8+
minimal=True)
89

910
def destroy(self, verify=False):
1011
logging.info("Delete snapshot " + self.uuid)

lib/vm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def unpause(self):
159159
self.host.xe('vm-unpause', {'uuid': self.uuid})
160160

161161
def _disk_list(self):
162-
return self.host.xe('vm-disk-list', {'uuid': self.uuid}, minimal=True)
162+
return self.host.xe('vm-disk-list', {'uuid': self.uuid, 'vbd-params': ''}, minimal=True)
163163

164164
def _destroy(self):
165165
self.host.xe('vm-destroy', {'uuid': self.uuid})

0 commit comments

Comments
 (0)