help= "the domain ID associated with the async job. If used with the account parameter, returns async jobs for the account in the specified domain." ) parser.add_argument("--keyword", dest="keyword", help="List by keyword") parser.add_argument("--startdate", dest="startdate", help="the start date of the async job") args = parser.parse_args() #Transform args to key=value list options = [ "%s=%s" % (key, value) for key, value in vars(args).items() if not value is None ] command = "listAsyncJobs" formatted_url = hu.format_url(command=command, option_list=options, url=url, apikey=apikey, secretkey=secretkey) try: response = urllib2.urlopen(formatted_url).read() xmldoc = minidom.parseString(response) print xmldoc.toprettyxml() except Exception, e: print 'Error !', e
import pprint import urllib2 from xml.dom import minidom if __name__ == "__main__": apikey=hu.getenv_apikey() secretkey=hu.getenv_secretkey() url=hu.getenv_url() parser = argparse.ArgumentParser(description="Deletes an ISO file.") parser.add_argument("id",help="the ID of the ISO file") parser.add_argument("--zoneid",dest="zoneid",help="the ID of the zone of the ISO file. If not specified, the ISO will be deleted from all the zones") args = parser.parse_args() #Transform args to key=value list options = [ "%s=%s" % (key , value) for key, value in vars(args).items() if not value is None] command = "deleteIso" formatted_url = hu.format_url(command=command, option_list=options,url=url, apikey=apikey, secretkey=secretkey) try: response = urllib2.urlopen(formatted_url).read() xmldoc = minidom.parseString(response) print xmldoc.toprettyxml() except Exception, e: print 'Error !', e