Skip to content

Commit 5ee5d4d

Browse files
committed
use xe instead of xl as behaviour changed
XenServer 6.5 uses 'xl vm-list' whereas the same on XenServer 6.2 used to be 'xl list-vm'. This closes #13
1 parent dd6b1ad commit 5ee5d4d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

cloudstackops/cloudstackopsssh.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ def getHeartbeatStatus(self, hostname):
8686

8787
# Get xapi vm count
8888
def getXapiVmCount(self, hostname):
89-
remoteCmd = "xl list-vm | grep -v UUID | wc -l"
89+
remoteCmd = "xe vm-list resident-on=$(xe host-list params=uuid \
90+
name-label=$HOSTNAME --minimal) \
91+
params=name-label,memory-static-max is-control-domain=false | \
92+
tr '\\n' ' ' | sed 's/name-label/\\n/g' | \
93+
awk {'print $4 \",\" $8'} | sed '/^,$/d'| wc -l"
9094
return self.runSSHCommand(hostname, remoteCmd)
9195

9296
# Migrate vm via xapi

cloudstackops/xenserver.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ def host_reboot(self, host):
207207
def host_get_vms(self, host):
208208
try:
209209
with settings(host_string=self.ssh_user + "@" + host.ipaddress):
210-
return fab.run("xl list-vm | grep -v UUID | wc -l")
210+
return fab.run("xe vm-list resident-on=$(xe host-list params=uuid \
211+
name-label=$HOSTNAME --minimal) \
212+
params=name-label,memory-static-max is-control-domain=false | \
213+
tr '\\n' ' ' | sed 's/name-label/\\n/g' | \
214+
awk {'print $4 \",\" $8'} | sed '/^,$/d'| wc -l")
211215
except:
212216
return False
213217

0 commit comments

Comments
 (0)