def main():
<EOL>arg_parser = argparse.ArgumentParser()<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', required=True, action='<STR_LIT:store>', help='<STR_LIT:Name>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', required=True, action='<STR_LIT:store>',<EOL>help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', required=True, action='<STR_LIT:store>',<EOL>help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store_true>', default=False,<EOL>help='<STR_LIT>')<EOL>args = arg_parser.parse_args()<EOL>name = args.name<EOL>rgname = args.rgname<EOL>location = args.location<EOL>try:<EOL><INDENT>with open('<STR_LIT>') as config_file:<EOL><INDENT>config_data = json.load(config_file)<EOL><DEDENT><DEDENT>except FileNotFoundError:<EOL><INDENT>sys.exit('<STR_LIT>')<EOL><DEDENT>tenant_id = config_data['<STR_LIT>']<EOL>app_id = config_data['<STR_LIT>']<EOL>app_secret = config_data['<STR_LIT>']<EOL>subscription_id = config_data['<STR_LIT>']<EOL>access_token = azurerm.get_access_token(tenant_id, app_id, app_secret)<EOL>hkn = Haikunator()<EOL>nsg_name = name + '<STR_LIT>'<EOL>print('<STR_LIT>' + nsg_name)<EOL>rmreturn = azurerm.create_nsg(access_token, subscription_id, rgname, nsg_name, location)<EOL>nsg_id = rmreturn.json()['<STR_LIT:id>']<EOL>print('<STR_LIT>' + nsg_id)<EOL>nsg_rule = '<STR_LIT>'<EOL>print('<STR_LIT>' + nsg_rule)<EOL>rmreturn = azurerm.create_nsg_rule(access_token, subscription_id, rgname, nsg_name, nsg_rule,<EOL>description='<STR_LIT>', destination_range='<STR_LIT>')<EOL>print(rmreturn)<EOL>print(json.dumps(rmreturn.json(), sort_keys=False, indent=<NUM_LIT:2>, separators=('<STR_LIT:U+002C>', '<STR_LIT>')))<EOL>vnetname = name + '<STR_LIT>'<EOL>print('<STR_LIT>' + vnetname)<EOL>rmreturn = azurerm.create_vnet(access_token, subscription_id, rgname, vnetname, location,<EOL>nsg_id=nsg_id)<EOL>print(rmreturn)<EOL>subnet_id = rmreturn.json()['<STR_LIT>']['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT:id>']<EOL>print('<STR_LIT>' + subnet_id)<EOL>public_ip_name = name + '<STR_LIT>'<EOL>dns_label = name + '<STR_LIT>'<EOL>print('<STR_LIT>' + public_ip_name)<EOL>rmreturn = azurerm.create_public_ip(access_token, subscription_id, rgname, public_ip_name,<EOL>dns_label, location)<EOL>print(rmreturn)<EOL>ip_id = rmreturn.json()['<STR_LIT:id>']<EOL>print('<STR_LIT>' + ip_id)<EOL>print('<STR_LIT>')<EOL>waiting = True<EOL>while waiting:<EOL><INDENT>ipa = azurerm.get_public_ip(access_token, subscription_id, rgname, public_ip_name)<EOL>if ipa['<STR_LIT>']['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>waiting = False<EOL><DEDENT>time.sleep(<NUM_LIT:1>)<EOL><DEDENT>nic_name = name + '<STR_LIT>'<EOL>print('<STR_LIT>' + nic_name)<EOL>rmreturn = azurerm.create_nic(access_token, subscription_id, rgname, nic_name, ip_id,<EOL>subnet_id, location)<EOL>nic_id = rmreturn.json()['<STR_LIT:id>']<EOL>print('<STR_LIT>')<EOL>waiting = True<EOL>while waiting:<EOL><INDENT>nic = azurerm.get_nic(access_token, subscription_id, rgname, nic_name)<EOL>if nic['<STR_LIT>']['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>waiting = False<EOL><DEDENT>time.sleep(<NUM_LIT:1>)<EOL><DEDENT>vm_name = name<EOL>vm_size = '<STR_LIT>'<EOL>publisher = '<STR_LIT>'<EOL>offer = '<STR_LIT>'<EOL>sku = '<STR_LIT>'<EOL>version = '<STR_LIT>'<EOL>username = '<STR_LIT>'<EOL>password = hkn.haikunate(delimiter='<STR_LIT:U+002C>') <EOL>print('<STR_LIT>' + password)<EOL>print('<STR_LIT>' + vm_name)<EOL>rmreturn = azurerm.create_vm(access_token, subscription_id, rgname, vm_name, vm_size,<EOL>publisher, offer, sku, version, nic_id, location,<EOL>username=username, password=password)<EOL>print(rmreturn)<EOL>print(json.dumps(rmreturn.json(), sort_keys=False, indent=<NUM_LIT:2>, separators=('<STR_LIT:U+002C>', '<STR_LIT>')))<EOL>
Main routine.