def main():
<EOL>arg_parser = argparse.ArgumentParser()<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', required=True,<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', required=True,<EOL>dest='<STR_LIT>', action='<STR_LIT:store>', help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>',<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT:-c>', dest='<STR_LIT>',<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>',<EOL>action='<STR_LIT:store>', type=int, help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>',<EOL>action='<STR_LIT:store>', type=int, help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', dest='<STR_LIT>',<EOL>action='<STR_LIT:store>', help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store_true>',<EOL>default=False, help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', '<STR_LIT>', action='<STR_LIT:store_true>',<EOL>default=False, help='<STR_LIT>')<EOL>arg_parser.add_argument('<STR_LIT>', dest='<STR_LIT>', action='<STR_LIT:store_true>',<EOL>default=False, help='<STR_LIT>')<EOL>args = arg_parser.parse_args()<EOL>noprompt = args.noprompt<EOL>nowait = args.nowait  <EOL>verbose = args.verbose  <EOL>vmssname = args.vmssname<EOL>resource_group = args.resource_group<EOL>if args.newversion is not None:<EOL><INDENT>newversion = args.newversion<EOL>storagemode = '<STR_LIT>'<EOL><DEDENT>elif args.customuri is not None:<EOL><INDENT>customuri = args.customuri<EOL>storagemode = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>arg_parser.error(<EOL>'<STR_LIT>')<EOL><DEDENT>if args.updatedomain is not None:<EOL><INDENT>updatedomain = args.updatedomain<EOL>upgrademode = '<STR_LIT>'<EOL><DEDENT>elif args.vmid is not None:<EOL><INDENT>vmid = args.vmid<EOL>upgrademode = '<STR_LIT>'<EOL><DEDENT>elif args.vmlist is not None:<EOL><INDENT>vmlist = args.vmlist<EOL>upgrademode = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>arg_parser.error(<EOL>'<STR_LIT>')<EOL><DEDENT>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>print("<STR_LIT>")<EOL>sys.exit()<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>vmssmodel = azurerm.get_vmss(<EOL>access_token, subscription_id, resource_group, vmssname)<EOL>if storagemode == '<STR_LIT>':<EOL><INDENT>imgref =vmssmodel['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']<EOL>print('<STR_LIT>')<EOL>print(json.dumps(imgref, sort_keys=False, indent=<NUM_LIT:2>, separators=('<STR_LIT:U+002C>', '<STR_LIT>')))<EOL>if imgref['<STR_LIT:version>'] == newversion:<EOL><INDENT>print('<STR_LIT>' +<EOL>newversion + '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if not noprompt:<EOL><INDENT>response = input(<EOL>'<STR_LIT>' + newversion + '<STR_LIT>')<EOL>if response.lower() != '<STR_LIT:y>':<EOL><INDENT>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>vmssmodel['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT:version>'] = newversion<EOL>updateresult = azurerm.update_vmss(<EOL>access_token, subscription_id, resource_group, vmssname, json.dumps(vmssmodel))<EOL>if verbose:<EOL><INDENT>print(updateresult)<EOL><DEDENT>print('<STR_LIT>' + newversion +<EOL>'<STR_LIT>' + vmssname)<EOL><DEDENT><DEDENT>else:  <EOL><INDENT>oldimageuri =vmssmodel['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT:image>']['<STR_LIT>']<EOL>print('<STR_LIT>' + oldimageuri)<EOL>if oldimageuri == customuri:<EOL><INDENT>print('<STR_LIT>' +<EOL>customuri + '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if not noprompt:<EOL><INDENT>response = input('<STR_LIT>' +<EOL>customuri + '<STR_LIT>')<EOL>if response.lower() != '<STR_LIT:y>':<EOL><INDENT>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>vmssmodel['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT>']['<STR_LIT:image>']['<STR_LIT>'] = customuri<EOL>updateresult = azurerm.update_vmss(<EOL>access_token, subscription_id, resource_group, vmssname, json.dumps(vmssmodel))<EOL>if verbose:<EOL><INDENT>print(updateresult)<EOL><DEDENT>print('<STR_LIT>' + customuri +<EOL>'<STR_LIT>' + vmssname)<EOL><DEDENT><DEDENT>if upgrademode == '<STR_LIT>':<EOL><INDENT>print('<STR_LIT>')<EOL>udinstancelist = get_vm_ids_by_ud(<EOL>access_token, subscription_id, resource_group, vmssname, updatedomain)<EOL>print('<STR_LIT>' + str(updatedomain) + '<STR_LIT>')<EOL>print(udinstancelist)<EOL>vmids = json.dumps(udinstancelist)<EOL>print('<STR_LIT>' + str(updatedomain))<EOL><DEDENT>elif upgrademode == '<STR_LIT>':<EOL><INDENT>vmids = json.dumps([str(vmid)])<EOL>print('<STR_LIT>' + str(vmid))<EOL><DEDENT>else:  <EOL><INDENT>vmids = vmlist<EOL>print('<STR_LIT>' + vmlist)<EOL><DEDENT>upgraderesult = azurerm.upgrade_vmss_vms(<EOL>access_token, subscription_id, resource_group, vmssname, vmids)<EOL>print(upgraderesult)<EOL>if not nowait:<EOL><INDENT>updatecomplete = False<EOL>provisioningstate = '<STR_LIT>'<EOL>while not updatecomplete:<EOL><INDENT>vmssinstance_view = azurerm.get_vmss_instance_view(<EOL>access_token, subscription_id, resource_group, vmssname)<EOL>for status in vmssinstance_view['<STR_LIT>']:<EOL><INDENT>provisioningstate = status['<STR_LIT:code>']<EOL>if provisioningstate == '<STR_LIT>':<EOL><INDENT>updatecomplete = True<EOL><DEDENT><DEDENT>if verbose:<EOL><INDENT>print(provisioningstate)<EOL><DEDENT>time.sleep(<NUM_LIT:5>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>
main routine