File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -334,6 +334,7 @@ def checkCloudStackName(self, args):
334334 if listAll == 'true' :
335335 apicall .listAll = "true"
336336
337+ found_counter = 0
337338 try :
338339 data = self .cloudstack .marvin_request (apicall )
339340 if (data is None or len (data ) == 0 ) and self .DEBUG == 1 :
@@ -348,17 +349,22 @@ def checkCloudStackName(self, args):
348349 for d in data :
349350 # And make sure it's the correct one
350351 if csname == d .name or csname == d .instancename :
352+ found_counter += 1
351353 if self .DEBUG == 1 :
352- print "Found in loop " + str (d .name )
354+ print "Found in loop " + str (d .name ) + " counter = " + str ( found_counter )
353355
354356 csnameID = d .id
355- break
356357 elif self .DEBUG == 1 :
357- print "Not found in loop " + str (d .name )
358+ print "Not found in loop " + str (d .name ) + " counter = " + str ( found_counter )
358359
359360 if len (csnameID ) < 1 :
360- print "Warning: '%s' could not be located in CloudStack database using '%s' or is not unique -- Exit." % (csname , csApiCall )
361+ print "Warning: '%s' could not be located in CloudStack database using '%s' -- Exit." % (csname , csApiCall )
361362 sys .exit (1 )
363+
364+ if found_counter > 1 :
365+ print "Error: '%s' could not be located in CloudStack database using '%s' because it is not unique -- Exit." % (csname , csApiCall )
366+ sys .exit (1 )
367+
362368 else :
363369 print "Error: '%s' could not be located in CloudStack database using '%s' -- exit!" % (csname , csApiCall )
364370 # Exit if not found
You can’t perform that action at this time.
0 commit comments