def main():
<EOL>argparser = argparse.ArgumentParser()<EOL>argparser.add_argument('<STR_LIT>', '<STR_LIT>', required=True,<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>argparser.add_argument('<STR_LIT>', '<STR_LIT>', required=True,<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>argparser.add_argument('<STR_LIT>', '<STR_LIT>', required=True,<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>argparser.add_argument('<STR_LIT>', '<STR_LIT>', required=False,<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>argparser.add_argument('<STR_LIT>', '<STR_LIT>', required=False,<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>argparser.add_argument('<STR_LIT>', '<STR_LIT>', required=False,<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>argparser.add_argument('<STR_LIT>', '<STR_LIT>', required=False, action='<STR_LIT:store_true>', default=False,<EOL>help='<STR_LIT>')<EOL>argparser.add_argument('<STR_LIT>', '<STR_LIT>', required=False, action='<STR_LIT:store_true>', default=False,<EOL>help='<STR_LIT>')<EOL>args = argparser.parse_args()<EOL>template_uri = args.uri<EOL>params = args.params<EOL>rgname = args.rg<EOL>location = args.location<EOL>subscription_id = args.sub<EOL>try:<EOL><INDENT>with open('<STR_LIT>') as configfile:<EOL><INDENT>configdata = json.load(configfile)<EOL><DEDENT><DEDENT>except FileNotFoundError:<EOL><INDENT>sys.exit('<STR_LIT>')<EOL><DEDENT>tenant_id = configdata['<STR_LIT>']<EOL>app_id = configdata['<STR_LIT>']<EOL>app_secret = configdata['<STR_LIT>']<EOL>if subscription_id is None:<EOL><INDENT>subscription_id = configdata['<STR_LIT>']<EOL><DEDENT>access_token = azurerm.get_access_token(tenant_id, app_id, app_secret)<EOL>try:<EOL><INDENT>with open(params) as params_file:<EOL><INDENT>param_data = json.load(params_file)<EOL><DEDENT><DEDENT>except FileNotFoundError:<EOL><INDENT>sys.exit('<STR_LIT>' + params + '<STR_LIT>')<EOL><DEDENT>haikunator = Haikunator()<EOL>if args.genparams is not None:<EOL><INDENT>newdict = {}<EOL>genlist = args.genparams.split('<STR_LIT:U+002C>')<EOL>for param in genlist:<EOL><INDENT>newval = haikunator.haikunate(delimiter='<STR_LIT:->').title()<EOL>newdict[param] = {'<STR_LIT:value>': newval}<EOL><DEDENT>params = {**param_data, **newdict}<EOL><DEDENT>else:<EOL><INDENT>params = param_data<EOL><DEDENT>if rgname is None:<EOL><INDENT>rgname = haikunator.haikunate()<EOL>ret = azurerm.create_resource_group(<EOL>access_token, subscription_id, rgname, location)<EOL>print('<STR_LIT>' + rgname +<EOL>'<STR_LIT>', location + '<STR_LIT>', ret)<EOL><DEDENT>deployment_name = haikunator.haikunate()<EOL>start_time = time.time()<EOL>deploy_return = azurerm.deploy_template_uri(<EOL>access_token, subscription_id, rgname, deployment_name, template_uri, params)<EOL>print('<STR_LIT>' + deployment_name +<EOL>'<STR_LIT>', deploy_return)<EOL>if '<STR_LIT>' not in str(deploy_return):<EOL><INDENT>print('<STR_LIT>', deploy_return.text)<EOL>sys.exit('<STR_LIT>')<EOL><DEDENT>if args.debug is True:<EOL><INDENT>print(json.dumps(deploy_return.json(), sort_keys=False,<EOL>indent=<NUM_LIT:2>, separators=('<STR_LIT:U+002C>', '<STR_LIT>')))<EOL><DEDENT>if args.debug is True:<EOL><INDENT>print('<STR_LIT>')<EOL>deploy_return = azurerm.show_deployment(<EOL>access_token, subscription_id, rgname, deployment_name)<EOL>print(json.dumps(deploy_return, sort_keys=False,<EOL>indent=<NUM_LIT:2>, separators=('<STR_LIT:U+002C>', '<STR_LIT>')))<EOL><DEDENT>if args.wait is True:<EOL><INDENT>print('<STR_LIT>')<EOL>provisioning_state = '<STR_LIT>'<EOL>try:<EOL><INDENT>while True:<EOL><INDENT>time.sleep(<NUM_LIT:10>)<EOL>deploy_return = azurerm.show_deployment(<EOL>access_token, subscription_id, rgname, deployment_name) <EOL>provisioning_state = deploy_return['<STR_LIT>']['<STR_LIT>']<EOL>if provisioning_state != '<STR_LIT>':<EOL><INDENT>break<EOL><DEDENT><DEDENT>print('<STR_LIT>', provisioning_state)<EOL><DEDENT>except KeyError:<EOL><INDENT>print('<STR_LIT>', deploy_return)<EOL><DEDENT><DEDENT>elapsed_time = time.time() - start_time<EOL>print('<STR_LIT>', elapsed_time)<EOL>
Main routine.