Skip to content

Commit ae905f0

Browse files
committed
Merge pull request #33 from lttmtins/master
Include domain on HA worker listing
2 parents 9409a97 + 9814f3a commit ae905f0

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

cloudstackops/cloudstacksql.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def getHAWorkerData(self, hypervisorName):
8383
hypervisorNameWhere = ""
8484

8585
cursor = self.conn.cursor()
86-
cursor.execute("SELECT vm.name, \
86+
cursor.execute("SELECT \
87+
d.name AS domain, \
88+
vm.name AS vmname, \
8789
ha.type, \
8890
vm.state, \
8991
ha.created, \
@@ -96,9 +98,10 @@ def getHAWorkerData(self, hypervisorName):
9698
LEFT JOIN cloud.mshost ms ON ms.msid=ha.mgmt_server_id \
9799
LEFT JOIN cloud.vm_instance vm ON vm.id=ha.instance_id \
98100
LEFT JOIN cloud.host ON host.id=ha.host_id \
101+
LEFT JOIN cloud.domain d ON vm.domain_id = d.id \
99102
WHERE ha.created > DATE_SUB(NOW(), INTERVAL 1 DAY) " +
100103
hypervisorNameWhere + " \
101-
ORDER BY ha.created desc \
104+
ORDER BY domain,ha.created desc \
102105
;")
103106
result = cursor.fetchall()
104107
cursor.close()

listHAWorkers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def handleArguments(argv):
131131
haworkers = s.getHAWorkerData(hypervisorName)
132132
counter = 0
133133
t = PrettyTable([
134+
"Domain",
134135
"VM",
135136
"Type",
136137
"VM state",
@@ -147,7 +148,7 @@ def handleArguments(argv):
147148
t.header = False
148149
t.padding_width = 1
149150

150-
for (vmname, vm_type, state, created, taken, step, hypervisor, mgtname,
151+
for (domain,vmname, vm_type, state, created, taken, step, hypervisor, mgtname,
151152
hastate) in haworkers:
152153
if onlyNonRunning == 1 and state == "Running":
153154
continue
@@ -156,6 +157,7 @@ def handleArguments(argv):
156157
counter = counter + 1
157158
displayname = (vmname[:28] + '..') if len(vmname) >= 31 else vmname
158159
t.add_row([
160+
domain,
159161
displayname,
160162
vm_type,
161163
state,

0 commit comments

Comments
 (0)