Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions cloudstackops/cloudstackops.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def checkCloudStackName(self, args):
if listAll == 'true':
apicall.listAll = "true"

found_counter = 0
try:
data = self.cloudstack.marvin_request(apicall)
if (data is None or len(data) == 0) and self.DEBUG == 1:
Expand All @@ -348,17 +349,22 @@ def checkCloudStackName(self, args):
for d in data:
# And make sure it's the correct one
if csname == d.name or csname == d.instancename:
found_counter += 1
if self.DEBUG == 1:
print "Found in loop " + str(d.name)
print "Found in loop " + str(d.name) + " counter = " + str(found_counter)

csnameID = d.id
break
elif self.DEBUG == 1:
print "Not found in loop " + str(d.name)
print "Not found in loop " + str(d.name) + " counter = " + str(found_counter)

if len(csnameID) < 1:
print "Warning: '%s' could not be located in CloudStack database using '%s' or is not unique -- Exit." % (csname, csApiCall)
print "Warning: '%s' could not be located in CloudStack database using '%s' -- Exit." % (csname, csApiCall)
sys.exit(1)

if found_counter >1:
print "Error: '%s' could not be located in CloudStack database using '%s' because it is not unique -- Exit." % (csname, csApiCall)
sys.exit(1)

else:
print "Error: '%s' could not be located in CloudStack database using '%s' -- exit!" % (csname, csApiCall)
# Exit if not found
Expand Down