Validate job, pool and template JSON (#2)

Adds JSON schemas for the following files (hooked up to file extensions of the form `.<something>.json`):

* Jobs (.job.json)
* Job templates (.jobtemplate.json)
* Application templates (.applicationtemplate.json)
* Pools (.pool.json)
* Pool templates (.pooltemplate.json)
This commit is contained in:
itowlson 2017-07-05 13:21:22 +12:00 коммит произвёл GitHub
Родитель 35d4250623
Коммит 1e1257de26
11 изменённых файлов: 8114 добавлений и 3 удалений

Просмотреть файл

@ -7,3 +7,5 @@ src/**
.gitignore
tsconfig.json
vsc-extension-quickstart.md
out/tools/**
tools/**

Просмотреть файл

@ -107,7 +107,29 @@
"when": "view == azure.batch.explorer && viewItem == azure.batch.resource"
}
]
}
},
"jsonValidation": [
{
"fileMatch": "*.job.json",
"url": "./schema/job.schema.json"
},
{
"fileMatch": "*.pool.json",
"url": "./schema/pool.schema.json"
},
{
"fileMatch": "*.jobtemplate.json",
"url": "./schema/jobtemplate.schema.json"
},
{
"fileMatch": "*.pooltemplate.json",
"url": "./schema/pooltemplate.schema.json"
},
{
"fileMatch": "*.applicationtemplate.json",
"url": "./schema/applicationtemplate.schema.json"
}
]
},
"scripts": {
"vscode:prepublish": "tsc -p ./",

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1690
schema/job.schema.json Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

688
schema/pool.schema.json Normal file
Просмотреть файл

@ -0,0 +1,688 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "pool",
"description": "An Azure Batch pool",
"type": "object",
"$ref": "#/definitions/PoolAddParameter",
"definitions": {
"PoolAddParameter": {
"properties": {
"id": {
"type": "string",
"title": "A string that uniquely identifies the pool within the account.",
"description": "A string that uniquely identifies the pool within the account."
},
"displayName": {
"type": "string",
"title": "The display name for the pool.",
"description": "The display name for the pool."
},
"vmSize": {
"type": "string",
"title": "The size of virtual machines in the pool. All virtual machines in a pool are the same size.",
"description": "The size of virtual machines in the pool. All virtual machines in a pool are the same size."
},
"cloudServiceConfiguration": {
"$ref": "#/definitions/CloudServiceConfiguration",
"title": "The cloud service configuration for the pool.",
"description": "The cloud service configuration for the pool."
},
"virtualMachineConfiguration": {
"$ref": "#/definitions/VirtualMachineConfiguration",
"title": "The virtual machine configuration for the pool.",
"description": "The virtual machine configuration for the pool."
},
"resizeTimeout": {
"type": "string",
"format": "duration",
"title": "The timeout for allocation of compute nodes to the pool.",
"description": "The timeout for allocation of compute nodes to the pool."
},
"targetDedicatedNodes": {
"type": "integer",
"format": "int32",
"title": "The desired number of dedicated compute nodes in the pool.",
"description": "The desired number of dedicated compute nodes in the pool."
},
"targetLowPriorityNodes": {
"type": "integer",
"format": "int32",
"title": "The desired number of low-priority compute nodes in the pool.",
"description": "The desired number of low-priority compute nodes in the pool."
},
"enableAutoScale": {
"type": "boolean",
"title": "Whether the pool size should automatically adjust over time.",
"description": "Whether the pool size should automatically adjust over time."
},
"autoScaleFormula": {
"type": "string",
"title": "A formula for the desired number of compute nodes in the pool.",
"description": "A formula for the desired number of compute nodes in the pool."
},
"autoScaleEvaluationInterval": {
"type": "string",
"format": "duration",
"title": "The time interval at which to automatically adjust the pool size according to the autoscale formula.",
"description": "The time interval at which to automatically adjust the pool size according to the autoscale formula."
},
"enableInterNodeCommunication": {
"type": "boolean",
"title": "Whether the pool permits direct communication between nodes.",
"description": "Whether the pool permits direct communication between nodes."
},
"networkConfiguration": {
"$ref": "#/definitions/NetworkConfiguration",
"title": "The network configuration for the pool.",
"description": "The network configuration for the pool."
},
"startTask": {
"$ref": "#/definitions/StartTask",
"title": "A task specified to run on each compute node as it joins the pool.",
"description": "A task specified to run on each compute node as it joins the pool."
},
"certificateReferences": {
"type": "array",
"items": {
"$ref": "#/definitions/CertificateReference"
},
"title": "The list of certificates to be installed on each compute node in the pool.",
"description": "The list of certificates to be installed on each compute node in the pool."
},
"applicationPackageReferences": {
"type": "array",
"items": {
"$ref": "#/definitions/ApplicationPackageReference"
},
"title": "The list of application packages to be installed on each compute node in the pool.",
"description": "The list of application packages to be installed on each compute node in the pool."
},
"applicationLicenses": {
"type": "array",
"items": {
"type": "string"
},
"title": "The list of application licenses the Batch service will make available on each compute node in the pool.",
"description": "The list of application licenses the Batch service will make available on each compute node in the pool."
},
"maxTasksPerNode": {
"type": "integer",
"format": "int32",
"title": "The maximum number of tasks that can run concurrently on a single compute node in the pool.",
"description": "The maximum number of tasks that can run concurrently on a single compute node in the pool."
},
"taskSchedulingPolicy": {
"$ref": "#/definitions/TaskSchedulingPolicy",
"title": "How the Batch service distributes tasks between compute nodes in the pool.",
"description": "How the Batch service distributes tasks between compute nodes in the pool."
},
"userAccounts": {
"type": "array",
"items": {
"$ref": "#/definitions/UserAccount"
},
"title": "The list of user accounts to be created on each node in the pool.",
"description": "The list of user accounts to be created on each node in the pool."
},
"metadata": {
"type": "array",
"items": {
"$ref": "#/definitions/MetadataItem"
},
"title": "A list of name-value pairs associated with the pool as metadata.",
"description": "A list of name-value pairs associated with the pool as metadata."
},
"packageReferences": {
"type": "array",
"items": {
"$ref": "#/definitions/PackageReference"
},
"title": "A collection of packages to be added from external package managers to each node in the pool.",
"description": "A collection of packages to be added from external package managers to each node in the pool."
}
},
"required": [
"id",
"vmSize"
],
"title": "A pool in the Azure Batch service to add.",
"oneOf": [
{
"required": [
"cloudServiceConfiguration"
]
},
{
"required": [
"virtualMachineConfiguration"
]
}
],
"dependencies": {
"autoScaleFormula": [
"enableAutoScale"
],
"autoScaleEvaluationInterval": [
"enableAutoScale"
]
}
},
"CloudServiceConfiguration": {
"properties": {
"osFamily": {
"type": "string",
"title": "The Azure Guest OS family to be installed on the virtual machines in the pool.",
"description": "The Azure Guest OS family to be installed on the virtual machines in the pool."
},
"targetOSVersion": {
"type": "string",
"title": "The Azure Guest OS version to be installed on the virtual machines in the pool.",
"description": "The Azure Guest OS version to be installed on the virtual machines in the pool."
},
"currentOSVersion": {
"type": "string",
"title": "The Azure Guest OS Version currently installed on the virtual machines in the pool.",
"description": "The Azure Guest OS Version currently installed on the virtual machines in the pool."
}
},
"required": [
"osFamily"
],
"title": "The configuration for nodes in a pool based on the Azure Cloud Services platform."
},
"VirtualMachineConfiguration": {
"properties": {
"imageReference": {
"$ref": "#/definitions/ImageReference",
"title": "A reference to the Azure Virtual Machines Marketplace image to use.",
"description": "A reference to the Azure Virtual Machines Marketplace image to use."
},
"osDisk": {
"$ref": "#/definitions/OSDisk",
"title": "A reference to the OS disk image to use.",
"description": "A reference to the OS disk image to use."
},
"nodeAgentSKUId": {
"type": "string",
"title": "The SKU of the Batch node agent to be provisioned on compute nodes in the pool.",
"description": "The SKU of the Batch node agent to be provisioned on compute nodes in the pool."
},
"windowsConfiguration": {
"$ref": "#/definitions/WindowsConfiguration",
"title": "Windows operating system settings on the virtual machine.",
"description": "Windows operating system settings on the virtual machine."
}
},
"required": [
"nodeAgentSKUId"
],
"title": "The configuration for compute nodes in a pool based on the Azure Virtual Machines infrastructure.",
"oneOf": [
{
"required": [
"imageReference"
]
},
{
"required": [
"osDisk"
]
}
]
},
"ImageReference": {
"properties": {
"publisher": {
"type": "string",
"title": "The publisher of the Azure Virtual Machines Marketplace image.",
"description": "The publisher of the Azure Virtual Machines Marketplace image."
},
"offer": {
"type": "string",
"title": "The offer type of the Azure Virtual Machines Marketplace image.",
"description": "The offer type of the Azure Virtual Machines Marketplace image."
},
"sku": {
"type": "string",
"title": "The SKU of the Azure Virtual Machines Marketplace image.",
"description": "The SKU of the Azure Virtual Machines Marketplace image."
},
"version": {
"type": "string",
"title": "The version of the Azure Virtual Machines Marketplace image.",
"description": "The version of the Azure Virtual Machines Marketplace image."
}
},
"required": [
"publisher",
"offer",
"sku"
],
"title": "A reference to an Azure Virtual Machines Marketplace image. To get the list of all imageReferences verified by Azure Batch, see the 'List supported node agent SKUs' operation."
},
"OSDisk": {
"properties": {
"imageUris": {
"type": "array",
"items": {
"type": "string"
},
"title": "The collection of Virtual Hard Disk (VHD) URIs.",
"description": "The collection of Virtual Hard Disk (VHD) URIs."
},
"caching": {
"type": "string",
"title": "The type of caching to enable for the OS disk.",
"description": "The type of caching to enable for the OS disk.",
"enum": [
"none",
"readOnly",
"readWrite"
],
"x-ms-enum": {
"name": "CachingType",
"modelAsString": false
}
}
},
"required": [
"imageUris"
],
"title": "A reference to an OS disk image."
},
"WindowsConfiguration": {
"properties": {
"enableAutomaticUpdates": {
"type": "boolean",
"title": "Whether automatic updates are enabled on the virtual machine.",
"description": "Whether automatic updates are enabled on the virtual machine."
}
},
"title": "Windows operating system settings to apply to the virtual machine."
},
"NetworkConfiguration": {
"properties": {
"subnetId": {
"type": "string",
"title": "The ARM resource identifier of the virtual network subnet which the compute nodes of the pool will join. This is of the form /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.",
"description": "The ARM resource identifier of the virtual network subnet which the compute nodes of the pool will join. This is of the form /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.",
"externalDocs": {
"url": "https://azure.microsoft.com/en-us/documentation/articles/role-based-access-built-in-roles/#classic-virtual-machine-contributor",
"description": "Setting up RBAC for Azure Batch VNETs"
}
}
},
"description": "The network configuration for a pool."
},
"StartTask": {
"properties": {
"commandLine": {
"type": "string",
"title": "The command line of the start task.",
"description": "The command line of the start task."
},
"resourceFiles": {
"type": "array",
"items": {
"$ref": "#/definitions/ResourceFile"
},
"title": "A list of files that the Batch service will download to the compute node before running the command line.",
"description": "A list of files that the Batch service will download to the compute node before running the command line."
},
"environmentSettings": {
"type": "array",
"items": {
"$ref": "#/definitions/EnvironmentSetting"
},
"title": "A list of environment variable settings for the start task.",
"description": "A list of environment variable settings for the start task."
},
"userIdentity": {
"$ref": "#/definitions/UserIdentity",
"title": "The user identity under which the start task runs.",
"description": "The user identity under which the start task runs."
},
"maxTaskRetryCount": {
"type": "integer",
"format": "int32",
"title": "The maximum number of times the task may be retried.",
"description": "The maximum number of times the task may be retried."
},
"waitForSuccess": {
"type": "boolean",
"title": "Whether the Batch service should wait for the start task to complete successfully (that is, to exit with exit code 0) before scheduling any tasks on the compute node.",
"description": "Whether the Batch service should wait for the start task to complete successfully (that is, to exit with exit code 0) before scheduling any tasks on the compute node."
}
},
"required": [
"commandLine"
],
"title": "A task which is run when a compute node joins a pool in the Azure Batch service, or when the compute node is rebooted or reimaged."
},
"ResourceFile": {
"properties": {
"blobSource": {
"type": "string",
"title": "The URL of the file within Azure Blob Storage.",
"description": "The URL of the file within Azure Blob Storage."
},
"filePath": {
"type": "string",
"title": "The location on the compute node to which to download the file, relative to the task's working directory.",
"description": "The location on the compute node to which to download the file, relative to the task's working directory."
},
"fileMode": {
"type": "string",
"title": "The file permission mode attribute in octal format.",
"description": "The file permission mode attribute in octal format."
},
"source": {
"type": "object",
"$ref": "#/definitions/ResourceFileSource",
"title": "A source for files to be downloaded before running the task command line.",
"description": "A source for files to be downloaded before running the task command line."
}
},
"required": [],
"title": "A file to be downloaded from Azure blob storage to a compute node.",
"oneOf": [
{
"required": [
"source"
]
},
{
"required": [
"blobSource"
]
}
]
},
"ResourceFileSource": {
"properties": {
"fileGroup": {
"type": "string",
"title": "The file group in the linked storage account from which to download files.",
"description": "The file group in the linked storage account from which to download files."
},
"prefix": {
"type": "string",
"title": "A prefix with which to filter the files to download.",
"description": "A prefix with which to filter the files to download."
}
},
"required": [
"fileGroup"
]
},
"EnvironmentSetting": {
"properties": {
"name": {
"type": "string",
"title": "The name of the environment variable.",
"description": "The name of the environment variable."
},
"value": {
"type": "string",
"title": "The value of the environment variable.",
"description": "The value of the environment variable."
}
},
"required": [
"name"
],
"title": "An environment variable to be set on a task process."
},
"UserIdentity": {
"properties": {
"username": {
"type": "string",
"x-ms-client-name": "userName",
"title": "The name of the user identity under which the task is run.",
"description": "The name of the user identity under which the task is run."
},
"autoUser": {
"$ref": "#/definitions/AutoUserSpecification",
"title": "The auto user under which the task is run.",
"description": "The auto user under which the task is run."
}
},
"title": "The definition of the user identity under which the task is run.",
"description": "Specify either the userName or autoUser property, but not both."
},
"AutoUserSpecification": {
"properties": {
"scope": {
"type": "string",
"title": "The scope for the auto user",
"description": "The scope for the auto user",
"enum": [
"task",
"pool"
],
"x-ms-enum": {
"name": "AutoUserScope",
"modelAsString": false
}
},
"elevationLevel": {
"title": "The elevation level of the auto user.",
"description": "The elevation level of the auto user.",
"$ref": "#/definitions/ElevationLevel"
}
},
"title": "Specifies the parameters for the auto user that runs a task on the Batch service."
},
"ElevationLevel": {
"type": "string",
"title": "The elevation level of the user.",
"description": "nonAdmin - The user is a standard user without elevated access. admin - The user is a user with elevated access and operates with full Administrator permissions.",
"enum": [
"nonAdmin",
"admin"
],
"x-ms-enum": {
"name": "ElevationLevel",
"modelAsString": false
}
},
"CertificateReference": {
"properties": {
"thumbprint": {
"type": "string",
"title": "The thumbprint of the certificate.",
"description": "The thumbprint of the certificate."
},
"thumbprintAlgorithm": {
"type": "string",
"title": "The algorithm with which the thumbprint is associated. This must be sha1.",
"description": "The algorithm with which the thumbprint is associated. This must be sha1."
},
"storeLocation": {
"type": "string",
"title": "The location of the certificate store on the compute node into which to install the certificate.",
"description": "The location of the certificate store on the compute node into which to install the certificate.",
"enum": [
"currentUser",
"localMachine"
],
"x-ms-enum": {
"name": "CertificateStoreLocation",
"modelAsString": false
}
},
"storeName": {
"type": "string",
"title": "The name of the certificate store on the compute node into which to install the certificate.",
"description": "The name of the certificate store on the compute node into which to install the certificate."
},
"visibility": {
"type": "array",
"items": {
"type": "string",
"x-nullable": false,
"enum": [
"startTask",
"task",
"remoteUser"
],
"x-ms-enum": {
"name": "CertificateVisibility",
"modelAsString": false
}
},
"title": "Which user accounts on the compute node should have access to the private data of the certificate.",
"description": "Which user accounts on the compute node should have access to the private data of the certificate."
}
},
"required": [
"thumbprint",
"thumbprintAlgorithm"
],
"title": "A reference to a certificate to be installed on compute nodes in a pool."
},
"ApplicationPackageReference": {
"properties": {
"applicationId": {
"type": "string",
"title": "The ID of the application to deploy.",
"description": "The ID of the application to deploy."
},
"version": {
"type": "string",
"title": "The version of the application to deploy. If omitted, the default version is deployed.",
"description": "The version of the application to deploy. If omitted, the default version is deployed."
}
},
"required": [
"applicationId"
],
"title": "A reference to an application package to be deployed to compute nodes."
},
"TaskSchedulingPolicy": {
"properties": {
"nodeFillType": {
"type": "string",
"title": "How tasks should be distributed across compute nodes.",
"enum": [
"spread",
"pack"
],
"x-ms-enum": {
"name": "ComputeNodeFillType",
"modelAsString": false
},
"description": "How tasks should be distributed across compute nodes."
}
},
"required": [
"nodeFillType"
],
"title": "Specifies how tasks should be distributed across compute nodes."
},
"UserAccount": {
"properties": {
"name": {
"type": "string",
"title": "The name of the user account.",
"description": "The name of the user account."
},
"password": {
"type": "string",
"title": "The password for the user account.",
"description": "The password for the user account."
},
"elevationLevel": {
"title": "The elevation level of the user account.",
"description": "The elevation level of the user account.",
"$ref": "#/definitions/ElevationLevel"
},
"linuxUserConfiguration": {
"title": "The Linux-specific user configuration for the user account.",
"description": "The Linux-specific user configuration for the user account.",
"$ref": "#/definitions/LinuxUserConfiguration"
}
},
"required": [
"name",
"password"
],
"title": "Properties used to create a user used to execute tasks on an Azure Batch node."
},
"LinuxUserConfiguration": {
"properties": {
"uid": {
"type": "integer",
"format": "int32",
"title": "The user ID of the user account.",
"description": "The user ID of the user account."
},
"gid": {
"type": "integer",
"format": "int32",
"title": "The group ID for the user account.",
"description": "The group ID for the user account."
},
"sshPrivateKey": {
"type": "string",
"title": "The SSH private key for the user account.",
"description": "The SSH private key for the user account."
}
},
"title": "Properties used to create a user account on a Linux node."
},
"MetadataItem": {
"properties": {
"name": {
"type": "string",
"title": "The name of the metadata item.",
"description": "The name of the metadata item."
},
"value": {
"type": "string",
"title": "The value of the metadata item.",
"description": "The value of the metadata item."
}
},
"required": [
"name",
"value"
],
"title": "A name-value pair associated with a Batch service resource.",
"description": "The Batch service does not assign any meaning to this metadata; it is solely for the use of user code."
},
"PackageReference": {
"properties": {
"type": {
"type": "string",
"title": "The type of package - aptPackage, chocolateyPackage, or yumPackage",
"description": "The type of package - aptPackage, chocolateyPackage, or yumPackage"
},
"id": {
"type": "string",
"title": "The name or ID of the package to be installed as identified according to the package repository.",
"description": "The name or ID of the package to be installed as identified according to the package repository."
},
"version": {
"type": "string",
"title": "The version of the package to be installed.",
"description": "The version of the package to be installed."
},
"allowEmptyChecksums": {
"type": "boolean",
"title": "Whether Chocolatey will install packages without a checksum for validation.",
"description": "Whether Chocolatey will install packages without a checksum for validation."
},
"disableExcludes": {
"type": "string",
"title": "Packages that might otherwise be excluded by VM configuration (e.g. kernel packages).",
"description": "Packages that might otherwise be excluded by VM configuration (e.g. kernel packages)."
}
},
"required": [
"type",
"id"
]
}
}
}

Просмотреть файл

@ -0,0 +1,893 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "pooltemplate",
"description": "An Azure Batch pool template",
"type": "object",
"$ref": "#/definitions/PoolTemplate",
"definitions": {
"PoolTemplate": {
"properties": {
"parameters": {
"type": "object",
"additionalProperties": {
"type": "object",
"$ref": "#/definitions/BatchTemplateParameter"
},
"title": "The parameters whose values may be supplied each time the template is used.",
"description": "The parameters whose values may be supplied each time the template is used."
},
"pool": {
"type": "object",
"$ref": "#/definitions/PoolTemplatePool",
"title": "The resource to be created from the template.",
"description": "The resource to be created from the template."
}
},
"required": [
"pool"
],
"title": "An Azure Batch pool template."
},
"BatchTemplateParameter": {
"properties": {
"type": {
"type": "string",
"enum": [
"int",
"string",
"bool"
],
"title": "The data type of the parameter.",
"description": "The data type of the parameter."
},
"defaultValue": {
"title": "The default value of the parameter.",
"description": "The default value of the parameter."
},
"allowedValues": {
"type": "array",
"title": "The allowed values of the parameter.",
"description": "The allowed values of the parameter."
},
"minValue": {
"type": "integer",
"title": "The minimum value of the parameter.",
"description": "The minimum value of the parameter."
},
"maxValue": {
"type": "integer",
"title": "The maximum value of the parameter.",
"description": "The maximum value of the parameter."
},
"minLength": {
"type": "integer",
"title": "The minimum length of the parameter value.",
"description": "The minimum length of the parameter value."
},
"maxLength": {
"type": "integer",
"title": "The maximum length of the parameter value.",
"description": "The maximum length of the parameter value."
},
"metadata": {
"type": "object",
"$ref": "#/definitions/BatchTemplateParameterMetadata",
"title": "Additional data about the parameter.",
"description": "Additional data about the parameter."
}
},
"required": [
"type"
]
},
"BatchTemplateParameterMetadata": {
"properties": {
"description": {
"type": "string",
"title": "A description of the parameter, suitable for display in a user interface.",
"description": "A description of the parameter, suitable for display in a user interface."
}
},
"title": "Additional data about an Azure Batch template parameter."
},
"PoolTemplatePool": {
"properties": {
"type": {
"type": "string",
"title": "The type of Azure Batch resource to create. Must be 'Microsoft.Batch/batchAccounts/pools'.",
"enum": [
"Microsoft.Batch/batchAccounts/pools"
],
"description": "The type of Azure Batch resource to create. Must be 'Microsoft.Batch/batchAccounts/pools'."
},
"apiVersion": {
"type": "string",
"title": "The Azure Batch API version against which the template is written. Must be '2017-05-01.5.0'.",
"enum": [
"2017-05-01.5.0"
],
"description": "The Azure Batch API version against which the template is written. Must be '2017-05-01.5.0'."
},
"properties": {
"type": "object",
"$ref": "#/definitions/PoolAddParameter",
"title": "The pool to be created from the template.",
"description": "The pool to be created from the template."
}
},
"required": [
"type",
"apiVersion",
"properties"
],
"title": "The resource to be created from an Azure Batch template."
},
"PoolAddParameter": {
"properties": {
"id": {
"type": "string",
"title": "A string that uniquely identifies the pool within the account.",
"description": "A string that uniquely identifies the pool within the account."
},
"displayName": {
"type": "string",
"title": "The display name for the pool.",
"description": "The display name for the pool."
},
"vmSize": {
"type": "string",
"title": "The size of virtual machines in the pool. All virtual machines in a pool are the same size.",
"description": "The size of virtual machines in the pool. All virtual machines in a pool are the same size."
},
"cloudServiceConfiguration": {
"$ref": "#/definitions/CloudServiceConfiguration",
"title": "The cloud service configuration for the pool.",
"description": "The cloud service configuration for the pool."
},
"virtualMachineConfiguration": {
"$ref": "#/definitions/VirtualMachineConfiguration",
"title": "The virtual machine configuration for the pool.",
"description": "The virtual machine configuration for the pool."
},
"resizeTimeout": {
"type": "string",
"format": "duration",
"title": "The timeout for allocation of compute nodes to the pool.",
"description": "The timeout for allocation of compute nodes to the pool."
},
"targetDedicatedNodes": {
"format": "int32",
"title": "The desired number of dedicated compute nodes in the pool.",
"description": "The desired number of dedicated compute nodes in the pool.",
"anyOf": [
{
"type": "integer"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"targetLowPriorityNodes": {
"format": "int32",
"title": "The desired number of low-priority compute nodes in the pool.",
"description": "The desired number of low-priority compute nodes in the pool.",
"anyOf": [
{
"type": "integer"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"enableAutoScale": {
"title": "Whether the pool size should automatically adjust over time.",
"description": "Whether the pool size should automatically adjust over time.",
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"autoScaleFormula": {
"type": "string",
"title": "A formula for the desired number of compute nodes in the pool.",
"description": "A formula for the desired number of compute nodes in the pool."
},
"autoScaleEvaluationInterval": {
"type": "string",
"format": "duration",
"title": "The time interval at which to automatically adjust the pool size according to the autoscale formula.",
"description": "The time interval at which to automatically adjust the pool size according to the autoscale formula."
},
"enableInterNodeCommunication": {
"title": "Whether the pool permits direct communication between nodes.",
"description": "Whether the pool permits direct communication between nodes.",
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"networkConfiguration": {
"$ref": "#/definitions/NetworkConfiguration",
"title": "The network configuration for the pool.",
"description": "The network configuration for the pool."
},
"startTask": {
"$ref": "#/definitions/StartTask",
"title": "A task specified to run on each compute node as it joins the pool.",
"description": "A task specified to run on each compute node as it joins the pool."
},
"certificateReferences": {
"type": "array",
"items": {
"$ref": "#/definitions/CertificateReference"
},
"title": "The list of certificates to be installed on each compute node in the pool.",
"description": "The list of certificates to be installed on each compute node in the pool."
},
"applicationPackageReferences": {
"type": "array",
"items": {
"$ref": "#/definitions/ApplicationPackageReference"
},
"title": "The list of application packages to be installed on each compute node in the pool.",
"description": "The list of application packages to be installed on each compute node in the pool."
},
"applicationLicenses": {
"type": "array",
"items": {
"type": "string"
},
"title": "The list of application licenses the Batch service will make available on each compute node in the pool.",
"description": "The list of application licenses the Batch service will make available on each compute node in the pool."
},
"maxTasksPerNode": {
"format": "int32",
"title": "The maximum number of tasks that can run concurrently on a single compute node in the pool.",
"description": "The maximum number of tasks that can run concurrently on a single compute node in the pool.",
"anyOf": [
{
"type": "integer"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"taskSchedulingPolicy": {
"$ref": "#/definitions/TaskSchedulingPolicy",
"title": "How the Batch service distributes tasks between compute nodes in the pool.",
"description": "How the Batch service distributes tasks between compute nodes in the pool."
},
"userAccounts": {
"type": "array",
"items": {
"$ref": "#/definitions/UserAccount"
},
"title": "The list of user accounts to be created on each node in the pool.",
"description": "The list of user accounts to be created on each node in the pool."
},
"metadata": {
"type": "array",
"items": {
"$ref": "#/definitions/MetadataItem"
},
"title": "A list of name-value pairs associated with the pool as metadata.",
"description": "A list of name-value pairs associated with the pool as metadata."
},
"packageReferences": {
"type": "array",
"items": {
"$ref": "#/definitions/PackageReference"
},
"title": "A collection of packages to be added from external package managers to each node in the pool.",
"description": "A collection of packages to be added from external package managers to each node in the pool."
}
},
"required": [
"id",
"vmSize"
],
"title": "A pool in the Azure Batch service to add.",
"oneOf": [
{
"required": [
"cloudServiceConfiguration"
]
},
{
"required": [
"virtualMachineConfiguration"
]
}
],
"dependencies": {
"autoScaleFormula": [
"enableAutoScale"
],
"autoScaleEvaluationInterval": [
"enableAutoScale"
]
}
},
"CloudServiceConfiguration": {
"properties": {
"osFamily": {
"type": "string",
"title": "The Azure Guest OS family to be installed on the virtual machines in the pool.",
"description": "The Azure Guest OS family to be installed on the virtual machines in the pool."
},
"targetOSVersion": {
"type": "string",
"title": "The Azure Guest OS version to be installed on the virtual machines in the pool.",
"description": "The Azure Guest OS version to be installed on the virtual machines in the pool."
},
"currentOSVersion": {
"type": "string",
"title": "The Azure Guest OS Version currently installed on the virtual machines in the pool.",
"description": "The Azure Guest OS Version currently installed on the virtual machines in the pool."
}
},
"required": [
"osFamily"
],
"title": "The configuration for nodes in a pool based on the Azure Cloud Services platform."
},
"VirtualMachineConfiguration": {
"properties": {
"imageReference": {
"$ref": "#/definitions/ImageReference",
"title": "A reference to the Azure Virtual Machines Marketplace image to use.",
"description": "A reference to the Azure Virtual Machines Marketplace image to use."
},
"osDisk": {
"$ref": "#/definitions/OSDisk",
"title": "A reference to the OS disk image to use.",
"description": "A reference to the OS disk image to use."
},
"nodeAgentSKUId": {
"type": "string",
"title": "The SKU of the Batch node agent to be provisioned on compute nodes in the pool.",
"description": "The SKU of the Batch node agent to be provisioned on compute nodes in the pool."
},
"windowsConfiguration": {
"$ref": "#/definitions/WindowsConfiguration",
"title": "Windows operating system settings on the virtual machine.",
"description": "Windows operating system settings on the virtual machine."
}
},
"required": [
"nodeAgentSKUId"
],
"title": "The configuration for compute nodes in a pool based on the Azure Virtual Machines infrastructure.",
"oneOf": [
{
"required": [
"imageReference"
]
},
{
"required": [
"osDisk"
]
}
]
},
"ImageReference": {
"properties": {
"publisher": {
"type": "string",
"title": "The publisher of the Azure Virtual Machines Marketplace image.",
"description": "The publisher of the Azure Virtual Machines Marketplace image."
},
"offer": {
"type": "string",
"title": "The offer type of the Azure Virtual Machines Marketplace image.",
"description": "The offer type of the Azure Virtual Machines Marketplace image."
},
"sku": {
"type": "string",
"title": "The SKU of the Azure Virtual Machines Marketplace image.",
"description": "The SKU of the Azure Virtual Machines Marketplace image."
},
"version": {
"type": "string",
"title": "The version of the Azure Virtual Machines Marketplace image.",
"description": "The version of the Azure Virtual Machines Marketplace image."
}
},
"required": [
"publisher",
"offer",
"sku"
],
"title": "A reference to an Azure Virtual Machines Marketplace image. To get the list of all imageReferences verified by Azure Batch, see the 'List supported node agent SKUs' operation."
},
"OSDisk": {
"properties": {
"imageUris": {
"type": "array",
"items": {
"type": "string"
},
"title": "The collection of Virtual Hard Disk (VHD) URIs.",
"description": "The collection of Virtual Hard Disk (VHD) URIs."
},
"caching": {
"type": "string",
"title": "The type of caching to enable for the OS disk.",
"description": "The type of caching to enable for the OS disk.",
"enum": [
"none",
"readOnly",
"readWrite"
],
"x-ms-enum": {
"name": "CachingType",
"modelAsString": false
}
}
},
"required": [
"imageUris"
],
"title": "A reference to an OS disk image."
},
"WindowsConfiguration": {
"properties": {
"enableAutomaticUpdates": {
"title": "Whether automatic updates are enabled on the virtual machine.",
"description": "Whether automatic updates are enabled on the virtual machine.",
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
}
},
"title": "Windows operating system settings to apply to the virtual machine."
},
"NetworkConfiguration": {
"properties": {
"subnetId": {
"type": "string",
"title": "The ARM resource identifier of the virtual network subnet which the compute nodes of the pool will join. This is of the form /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.",
"description": "The ARM resource identifier of the virtual network subnet which the compute nodes of the pool will join. This is of the form /subscriptions/{subscription}/resourceGroups/{group}/providers/{provider}/virtualNetworks/{network}/subnets/{subnet}.",
"externalDocs": {
"url": "https://azure.microsoft.com/en-us/documentation/articles/role-based-access-built-in-roles/#classic-virtual-machine-contributor",
"description": "Setting up RBAC for Azure Batch VNETs"
}
}
},
"description": "The network configuration for a pool."
},
"StartTask": {
"properties": {
"commandLine": {
"type": "string",
"title": "The command line of the start task.",
"description": "The command line of the start task."
},
"resourceFiles": {
"type": "array",
"items": {
"$ref": "#/definitions/ResourceFile"
},
"title": "A list of files that the Batch service will download to the compute node before running the command line.",
"description": "A list of files that the Batch service will download to the compute node before running the command line."
},
"environmentSettings": {
"type": "array",
"items": {
"$ref": "#/definitions/EnvironmentSetting"
},
"title": "A list of environment variable settings for the start task.",
"description": "A list of environment variable settings for the start task."
},
"userIdentity": {
"$ref": "#/definitions/UserIdentity",
"title": "The user identity under which the start task runs.",
"description": "The user identity under which the start task runs."
},
"maxTaskRetryCount": {
"format": "int32",
"title": "The maximum number of times the task may be retried.",
"description": "The maximum number of times the task may be retried.",
"anyOf": [
{
"type": "integer"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"waitForSuccess": {
"title": "Whether the Batch service should wait for the start task to complete successfully (that is, to exit with exit code 0) before scheduling any tasks on the compute node.",
"description": "Whether the Batch service should wait for the start task to complete successfully (that is, to exit with exit code 0) before scheduling any tasks on the compute node.",
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
}
},
"required": [
"commandLine"
],
"title": "A task which is run when a compute node joins a pool in the Azure Batch service, or when the compute node is rebooted or reimaged."
},
"ResourceFile": {
"properties": {
"blobSource": {
"type": "string",
"title": "The URL of the file within Azure Blob Storage.",
"description": "The URL of the file within Azure Blob Storage."
},
"filePath": {
"type": "string",
"title": "The location on the compute node to which to download the file, relative to the task's working directory.",
"description": "The location on the compute node to which to download the file, relative to the task's working directory."
},
"fileMode": {
"type": "string",
"title": "The file permission mode attribute in octal format.",
"description": "The file permission mode attribute in octal format."
},
"source": {
"type": "object",
"$ref": "#/definitions/ResourceFileSource",
"title": "A source for files to be downloaded before running the task command line.",
"description": "A source for files to be downloaded before running the task command line."
}
},
"required": [],
"title": "A file to be downloaded from Azure blob storage to a compute node.",
"oneOf": [
{
"required": [
"source"
]
},
{
"required": [
"blobSource"
]
}
]
},
"ResourceFileSource": {
"properties": {
"fileGroup": {
"type": "string",
"title": "The file group in the linked storage account from which to download files.",
"description": "The file group in the linked storage account from which to download files."
},
"prefix": {
"type": "string",
"title": "A prefix with which to filter the files to download.",
"description": "A prefix with which to filter the files to download."
}
},
"required": [
"fileGroup"
]
},
"EnvironmentSetting": {
"properties": {
"name": {
"type": "string",
"title": "The name of the environment variable.",
"description": "The name of the environment variable."
},
"value": {
"type": "string",
"title": "The value of the environment variable.",
"description": "The value of the environment variable."
}
},
"required": [
"name"
],
"title": "An environment variable to be set on a task process."
},
"UserIdentity": {
"properties": {
"username": {
"type": "string",
"x-ms-client-name": "userName",
"title": "The name of the user identity under which the task is run.",
"description": "The name of the user identity under which the task is run."
},
"autoUser": {
"$ref": "#/definitions/AutoUserSpecification",
"title": "The auto user under which the task is run.",
"description": "The auto user under which the task is run."
}
},
"title": "The definition of the user identity under which the task is run.",
"description": "Specify either the userName or autoUser property, but not both."
},
"AutoUserSpecification": {
"properties": {
"scope": {
"type": "string",
"title": "The scope for the auto user",
"description": "The scope for the auto user",
"enum": [
"task",
"pool"
],
"x-ms-enum": {
"name": "AutoUserScope",
"modelAsString": false
}
},
"elevationLevel": {
"title": "The elevation level of the auto user.",
"description": "The elevation level of the auto user.",
"$ref": "#/definitions/ElevationLevel"
}
},
"title": "Specifies the parameters for the auto user that runs a task on the Batch service."
},
"ElevationLevel": {
"type": "string",
"title": "The elevation level of the user.",
"description": "nonAdmin - The user is a standard user without elevated access. admin - The user is a user with elevated access and operates with full Administrator permissions.",
"enum": [
"nonAdmin",
"admin"
],
"x-ms-enum": {
"name": "ElevationLevel",
"modelAsString": false
}
},
"CertificateReference": {
"properties": {
"thumbprint": {
"type": "string",
"title": "The thumbprint of the certificate.",
"description": "The thumbprint of the certificate."
},
"thumbprintAlgorithm": {
"type": "string",
"title": "The algorithm with which the thumbprint is associated. This must be sha1.",
"description": "The algorithm with which the thumbprint is associated. This must be sha1."
},
"storeLocation": {
"type": "string",
"title": "The location of the certificate store on the compute node into which to install the certificate.",
"description": "The location of the certificate store on the compute node into which to install the certificate.",
"enum": [
"currentUser",
"localMachine"
],
"x-ms-enum": {
"name": "CertificateStoreLocation",
"modelAsString": false
}
},
"storeName": {
"type": "string",
"title": "The name of the certificate store on the compute node into which to install the certificate.",
"description": "The name of the certificate store on the compute node into which to install the certificate."
},
"visibility": {
"type": "array",
"items": {
"type": "string",
"x-nullable": false,
"enum": [
"startTask",
"task",
"remoteUser"
],
"x-ms-enum": {
"name": "CertificateVisibility",
"modelAsString": false
}
},
"title": "Which user accounts on the compute node should have access to the private data of the certificate.",
"description": "Which user accounts on the compute node should have access to the private data of the certificate."
}
},
"required": [
"thumbprint",
"thumbprintAlgorithm"
],
"title": "A reference to a certificate to be installed on compute nodes in a pool."
},
"ApplicationPackageReference": {
"properties": {
"applicationId": {
"type": "string",
"title": "The ID of the application to deploy.",
"description": "The ID of the application to deploy."
},
"version": {
"type": "string",
"title": "The version of the application to deploy. If omitted, the default version is deployed.",
"description": "The version of the application to deploy. If omitted, the default version is deployed."
}
},
"required": [
"applicationId"
],
"title": "A reference to an application package to be deployed to compute nodes."
},
"TaskSchedulingPolicy": {
"properties": {
"nodeFillType": {
"type": "string",
"title": "How tasks should be distributed across compute nodes.",
"enum": [
"spread",
"pack"
],
"x-ms-enum": {
"name": "ComputeNodeFillType",
"modelAsString": false
},
"description": "How tasks should be distributed across compute nodes."
}
},
"required": [
"nodeFillType"
],
"title": "Specifies how tasks should be distributed across compute nodes."
},
"UserAccount": {
"properties": {
"name": {
"type": "string",
"title": "The name of the user account.",
"description": "The name of the user account."
},
"password": {
"type": "string",
"title": "The password for the user account.",
"description": "The password for the user account."
},
"elevationLevel": {
"title": "The elevation level of the user account.",
"description": "The elevation level of the user account.",
"$ref": "#/definitions/ElevationLevel"
},
"linuxUserConfiguration": {
"title": "The Linux-specific user configuration for the user account.",
"description": "The Linux-specific user configuration for the user account.",
"$ref": "#/definitions/LinuxUserConfiguration"
}
},
"required": [
"name",
"password"
],
"title": "Properties used to create a user used to execute tasks on an Azure Batch node."
},
"LinuxUserConfiguration": {
"properties": {
"uid": {
"format": "int32",
"title": "The user ID of the user account.",
"description": "The user ID of the user account.",
"anyOf": [
{
"type": "integer"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"gid": {
"format": "int32",
"title": "The group ID for the user account.",
"description": "The group ID for the user account.",
"anyOf": [
{
"type": "integer"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"sshPrivateKey": {
"type": "string",
"title": "The SSH private key for the user account.",
"description": "The SSH private key for the user account."
}
},
"title": "Properties used to create a user account on a Linux node."
},
"MetadataItem": {
"properties": {
"name": {
"type": "string",
"title": "The name of the metadata item.",
"description": "The name of the metadata item."
},
"value": {
"type": "string",
"title": "The value of the metadata item.",
"description": "The value of the metadata item."
}
},
"required": [
"name",
"value"
],
"title": "A name-value pair associated with a Batch service resource.",
"description": "The Batch service does not assign any meaning to this metadata; it is solely for the use of user code."
},
"PackageReference": {
"properties": {
"type": {
"type": "string",
"title": "The type of package - aptPackage, chocolateyPackage, or yumPackage",
"description": "The type of package - aptPackage, chocolateyPackage, or yumPackage"
},
"id": {
"type": "string",
"title": "The name or ID of the package to be installed as identified according to the package repository.",
"description": "The name or ID of the package to be installed as identified according to the package repository."
},
"version": {
"type": "string",
"title": "The version of the package to be installed.",
"description": "The version of the package to be installed."
},
"allowEmptyChecksums": {
"title": "Whether Chocolatey will install packages without a checksum for validation.",
"description": "Whether Chocolatey will install packages without a checksum for validation.",
"anyOf": [
{
"type": "boolean"
},
{
"type": "string",
"pattern": "\\[parameters\\('\\w+'\\)\\]"
}
]
},
"disableExcludes": {
"type": "string",
"title": "Packages that might otherwise be excluded by VM configuration (e.g. kernel packages).",
"description": "Packages that might otherwise be excluded by VM configuration (e.g. kernel packages)."
}
},
"required": [
"type",
"id"
]
}
}
}

Просмотреть файл

@ -395,7 +395,7 @@ function getParameterTypeName(value : any) : string {
async function viewnodeGet(node : azurebatchtree.AzureBatchTreeNode) {
if (!node) {
// TODO: handle this more politely
vscode.window.showErrorMessage("This command may be used only from the Azure Batch explorer.")
vscode.window.showErrorMessage("This command may be used only from the Azure Batch explorer.");
return;
}
if (azurebatchtree.isResourceNode(node)) {
@ -407,7 +407,7 @@ async function viewnodeGet(node : azurebatchtree.AzureBatchTreeNode) {
async function viewnodeGetAsTemplate(node : azurebatchtree.AzureBatchTreeNode) {
if (!node) {
// TODO: handle this more politely
vscode.window.showErrorMessage("This command may be used only from the Azure Batch explorer.")
vscode.window.showErrorMessage("This command may be used only from the Azure Batch explorer.");
return;
}
if (azurebatchtree.isResourceNode(node)) {

Просмотреть файл

@ -0,0 +1,69 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "applicationtemplate",
"description": "An Azure Batch application template",
"type": "object",
"$ref": "#/definitions/BatchApplicationTemplate",
"definitions": {
"BatchApplicationTemplate": {
"properties": {
"templateMetadata": {
"type": "object",
"$ref": "#/definitions/BatchApplicationTemplateMetadata",
"title": "Additional information about the template itself."
},
"parameters": {
"type": "object",
"additionalProperties": {
"type": "object",
"$ref": "#/definitions/BatchApplicationTemplateParameter"
},
"title": "The parameters whose values may be supplied each time the template is used."
}
}
},
"BatchApplicationTemplateMetadata": {
"properties": {
"description": {
"type": "string",
"title": "A simple description of the functionality provided by the template."
},
"author": {
"type": "string",
"title": "The name or email address of the template author."
},
"dateUpdated": {
"type": "string",
"title": "A human readable message (a date or a version number) for when the template was last modified."
}
}
},
"BatchApplicationTemplateParameter": {
"properties": {
"type": {
"type": "string",
"enum": [ "int", "string", "bool" ],
"title": "The data type of the parameter."
},
"defaultValue": {
"title": "The default value of the parameter."
},
"metadata": {
"type": "object",
"$ref": "#/definitions/BatchApplicationTemplateParameterMetadata",
"title": "Additional data about the parameter."
}
},
"required": ["type"]
},
"BatchApplicationTemplateParameterMetadata": {
"properties": {
"description": {
"type": "string",
"title": "A description of the parameter, suitable for display in a user interface."
}
},
"title": "Additional data about an Azure Batch template parameter."
}
}
}

Просмотреть файл

@ -0,0 +1,196 @@
{
"JobAddParameter": {
"properties": {
"taskFactory" : {
"type": "object",
"title": "A specification for the tasks to be added to the job.",
"$ref": "#/definitions/TaskFactory"
},
"applicationTemplateInfo" : {
"type": "object",
"title": "An application template from which to create the job.",
"$ref": "#/definitions/ApplicationTemplateInfo"
}
}
},
"PoolAddParameter": {
"properties": {
"packageReferences" : {
"type": "array",
"items": {
"$ref": "#/definitions/PackageReference"
},
"title": "A collection of packages to be added from external package managers to each node in the pool."
}
}
},
"PoolSpecification": {
"properties": {
"packageReferences" : {
"type": "array",
"items": {
"$ref": "#/definitions/PackageReference"
},
"title": "A collection of packages to be added from external package managers to each node in the pool."
}
}
},
"TaskAddParameter": {
"properties": {
"packageReferences" : {
"type": "array",
"items": {
"$ref": "#/definitions/PackageReference"
},
"title": "A collection of packages from external package managers to be added to the node where the task runs."
}
}
},
"OutputFileDestination": {
"properties": {
"autoStorage": {
"type": "object",
"$ref": "#/definitions/OutputFileAutoStorageDestination",
"title": "A destination in the linked storage account to which to persist output files."
}
}
},
"PackageReference": {
"properties":{
"type": {
"type": "string",
"title": "The type of package - aptPackage, chocolateyPackage, or yumPackage"
},
"id": {
"type": "string",
"title": "The name or ID of the package to be installed as identified according to the package repository."
},
"version": {
"type": "string",
"title": "The version of the package to be installed."
},
"allowEmptyChecksums": {
"type": "boolean",
"title": "Whether Chocolatey will install packages without a checksum for validation."
},
"disableExcludes": {
"type": "string",
"title": "Packages that might otherwise be excluded by VM configuration (e.g. kernel packages)."
}
},
"required": ["type", "id"]
},
"TaskFactory": {
"properties":{
"type": {
"type": "string",
"title": "The type of task factory - taskCollection, parametricSweep or taskPerFile"
},
"tasks": {
"type": "array",
"items": {
"$ref": "#/definitions/TaskAddParameter"
},
"title": "The tasks that make up the job."
},
"parameterSets": {
"type": "array",
"items": {
"$ref": "#/definitions/ParametricSweepParameterSet"
},
"title": "The parameter or parameters whose values will be varied over the parametric sweep."
},
"repeatTask": {
"type": "object",
"$ref": "#/definitions/RepeatTask",
"title": "The task that is to be repeated for each value."
},
"source": {
"type": "object",
"$ref": "#/definitions/TaskPerFileSource",
"title": "The source of the files for which to create tasks."
}
}
},
"ParametricSweepParameterSet": {
"properties": {
"start": {
"type": "integer",
"title": "The start of the parametric sweep range."
},
"end": {
"type": "integer",
"title": "The end of the parametric sweep range."
},
"step": {
"type": "integer",
"title": "The increment step between values of the parameter."
}
},
"required": ["start", "end"]
},
"TaskPerFileSource": {
"properties": {
"fileGroup": {
"type": "string",
"title": "The file group in the linked storage account from which to take files."
},
"containerUrl": {
"type": "string",
"title": "The URL of an Azure Storage blob container from which to take files, including any required Shared Access Signature (SAS)."
},
"prefix": {
"type": "string",
"title": "A prefix with which to filter the files from which to create tasks."
}
}
},
"ApplicationTemplateInfo": {
"properties":{
"filePath": {
"type": "string",
"title": "The path to the application template file."
},
"parameters": {
"type": "object",
"title": "The values to assign to the application template parameters."
}
}
},
"ResourceFile": {
"properties": {
"source": {
"type": "object",
"$ref": "#/definitions/ResourceFileSource",
"title": "A source for files to be downloaded before running the task command line."
}
}
},
"ResourceFileSource": {
"properties": {
"fileGroup": {
"type": "string",
"title": "The file group in the linked storage account from which to download files."
},
"prefix": {
"type": "string",
"title": "A prefix with which to filter the files to download."
}
},
"required": ["fileGroup"]
},
"OutputFileAutoStorageDestination": {
"properties": {
"fileGroup": {
"type": "string",
"title": "The file group in the linked storage account to which to save files."
},
"path": {
"type": "string",
"title": "The path within the file group to which output files will be uploaded."
}
},
"required": ["fileGroup"]
}
}

439
tools/swaggatron.ts Normal file
Просмотреть файл

@ -0,0 +1,439 @@
import * as https from 'https';
import * as http from 'http';
import * as batch from '../src/batch';
import * as path from 'path';
import * as fs from 'fs';
writeResourceSchemas().then(() => {console.log('done');});
const implicitExtensionTypes = [
{
"name": "RepeatTask",
"basedOn": "TaskAddParameter",
"removing": ["id", "dependsOn"]
}
];
// Additional JSON Schema elements to be merged with the specified definitions -
// refer to JSON Schema documentation for semantics. These capture information which
// is only in documentation in the Swagger spec.
const enrichments : any = {
PoolInformation: {
oneOf: [
{ required: ["poolId"] },
{ required: ["autoPoolSpecification"] }
]
},
PoolAddParameter: {
oneOf: [
{ required: ["cloudServiceConfiguration"] },
{ required: ["virtualMachineConfiguration"] }
// TODO: is there a nice way in JSON Schema to express independent oneOfs (specifically for targetDedicated and autoScaleFormula independently of the CSC/VMC alternate)
],
dependencies: {
autoScaleFormula: ["enableAutoScale"],
autoScaleEvaluationInterval: ["enableAutoScale"]
// TODO: would like to express e.g. "ASF depends on EAS being present **and true**" - JSON Schema may be able to do this but the VS Code validator doesn't seem to handle it yet
}
},
PoolSpecification: {
oneOf: [
{ required: ["cloudServiceConfiguration"] },
{ required: ["virtualMachineConfiguration"] }
// TODO: is there a nice way in JSON Schema to express independent oneOfs (specifically for targetDedicated and autoScaleFormula independently of the CSC/VMC alternate)
],
dependencies: {
autoScaleFormula: ["enableAutoScale"],
autoScaleEvaluationInterval: ["enableAutoScale"]
}
},
VirtualMachineConfiguration: {
oneOf: [
{ required: ["imageReference"] },
{ required: ["osDisk"] }
]
},
ResourceFile: {
oneOf: [
{ required: ["source"] },
{ required: ["blobSource"] }
],
required: []
}
};
async function writeResourceSchemas() {
await writeResourceSchema('job');
await writeResourceSchema('pool');
await writeTemplateSchema('job');
await writeTemplateSchema('pool');
await writeApplicationTemplateSchema();
}
async function writeResourceSchema(resourceType : batch.BatchResourceType) : Promise<void> {
const schema = await createResourceSchema(resourceType);
const schemaText = JSON.stringify(schema, null, 2);
const schemaFilePath = path.join(__dirname, `../../schema/${resourceType}.schema.json`);
fs.writeFileSync(schemaFilePath, schemaText);
}
async function writeTemplateSchema(resourceType: batch.BatchResourceType) : Promise<void> {
const schema = await createTemplateSchema(resourceType);
const schemaText = JSON.stringify(schema, null, 2);
const schemaFilePath = path.join(__dirname, `../../schema/${resourceType}template.schema.json`);
fs.writeFileSync(schemaFilePath, schemaText);
}
const applicationTemplateableProperties = [
"jobManagerTask",
"jobPreparationTask",
"jobReleaseTask",
"commonEnvironmentSettings",
"usesTaskDependencies",
"onAllTasksComplete",
"onTaskFailure",
"taskFactory",
"metadata"
];
async function writeApplicationTemplateSchema() : Promise<void> {
const schema = await createApplicationTemplateSchema();
const schemaText = JSON.stringify(schema, null, 2);
const schemaFilePath = path.join(__dirname, `../../schema/applicationtemplate.schema.json`);
fs.writeFileSync(schemaFilePath, schemaText);
}
async function createApplicationTemplateSchema() : Promise<any> {
const appTemplateSchemaTemplatePath = path.join(__dirname, "../../tools/applicationtemplate.schematemplate.json");
let appTemplateSchema : any = JSON.parse(fs.readFileSync(appTemplateSchemaTemplatePath, 'utf8'));
fixAllDefinitionsSoTitlesShowInJsonValidation(appTemplateSchema);
const jobSchema = await createResourceSchema('job');
addParameterSupport(jobSchema.definitions);
for (const d in jobSchema.definitions) {
appTemplateSchema.definitions[d] = jobSchema.definitions[d];
}
const jobResourceSchema = jobSchema.definitions['JobAddParameter'];
for (const p in jobResourceSchema.properties) {
if (applicationTemplateableProperties.indexOf(p) >= 0) {
appTemplateSchema.definitions['BatchApplicationTemplate'].properties[p] = jobResourceSchema.properties[p];
}
}
return appTemplateSchema;
}
async function createResourceSchema(resourceType : batch.BatchResourceType) : Promise<any> {
let schemaDefinitions : any = {};
const swagger = await fetchSwagger();
extendSchemaForBatchExtensions(swagger.definitions);
const addResourceOperation = swagger.paths[resourcePath(resourceType)].post;
const addResourceBodySchemaRef : string = addResourceOperation.parameters.find((p: any) => p.in === 'body').schema['$ref'];
const bodySchema = chaseRef(swagger, addResourceBodySchemaRef);
schemaDefinitions[bodySchema.name] = bodySchema.schema;
fixSchemaSoTitlesShowInJsonValidation(schemaDefinitions[bodySchema.name]);
recursivelyAddDefns(swagger, bodySchema.schema, schemaDefinitions);
enrichSchema(schemaDefinitions); // do this here to save us having to deal with oneOf etc. in the recursive addition process
const schema : any = {
'$schema': 'http://json-schema.org/draft-04/schema#',
title: resourceType,
description: `An Azure Batch ${resourceType}`,
type: 'object',
'$ref': `#/definitions/${bodySchema.name}`,
definitions: schemaDefinitions
};
return schema;
}
// NOTE: VS Code JSON validation has a bug where it shows description rather than title
// in intellisense. We could write the template schema template to return descriptions,
// but in order to keep it 'correct' we return titles and fix them up in the same way
// as we fix up the definitions that we source from Swagger.
function templateSchemaTemplate(resourceType: batch.BatchResourceType) : any {
const pascalCased = resourceType[0].toUpperCase() + resourceType.substring(1);
return {
'$schema': 'http://json-schema.org/draft-04/schema#',
title: `${resourceType}template`,
description: `An Azure Batch ${resourceType} template`,
type: "object",
'$ref': `#/definitions/${pascalCased}Template`,
definitions: {
[`${pascalCased}Template`]: {
properties: {
parameters: {
type: "object",
additionalProperties: {
type: "object",
"$ref": "#/definitions/BatchTemplateParameter"
},
title: "The parameters whose values may be supplied each time the template is used."
},
[resourceType]: {
type: "object",
"$ref": `#/definitions/${pascalCased}Template${pascalCased}`,
title: `The resource to be created from the template.`
}
},
required: [resourceType],
title: `An Azure Batch ${resourceType} template.`
},
BatchTemplateParameter: {
properties: {
type: {
type: "string",
enum: [ "int", "string", "bool" ],
title: "The data type of the parameter."
},
defaultValue: {
title: "The default value of the parameter."
},
allowedValues: {
type: "array",
title: "The allowed values of the parameter."
},
minValue: {
type: "integer",
title: "The minimum value of the parameter."
},
maxValue: {
type: "integer",
title: "The maximum value of the parameter."
},
minLength: {
type: "integer",
title: "The minimum length of the parameter value."
},
maxLength: {
type: "integer",
title: "The maximum length of the parameter value."
},
metadata: {
type: "object",
"$ref": "#/definitions/BatchTemplateParameterMetadata",
title: "Additional data about the parameter."
}
},
required: ["type"]
},
BatchTemplateParameterMetadata: {
properties: {
description: {
type: "string",
title: "A description of the parameter, suitable for display in a user interface."
}
},
title: "Additional data about an Azure Batch template parameter."
},
[`${pascalCased}Template${pascalCased}`]: {
properties: {
type: {
type: "string",
title: `The type of Azure Batch resource to create. Must be '${templateResourceType(resourceType)}'.`,
enum: [templateResourceType(resourceType)] // const not yet supported in VS Code
},
apiVersion: {
type: "string",
title: "The Azure Batch API version against which the template is written. Must be '2017-05-01.5.0'.",
enum: ["2017-05-01.5.0"] // const not yet supported in VS Code
},
properties: {
type: "object",
"$ref": `#/definitions/${pascalCased}AddParameter`, // except any property can also be a string because substitution - handled by the addParameterSupport transformation
title: `The ${resourceType} to be created from the template.`
}
},
required: [ "type", "apiVersion", "properties" ],
title: "The resource to be created from an Azure Batch template."
}
}
};
}
async function createTemplateSchema(resourceType: batch.BatchResourceType) : Promise<any> {
const resourceSchema = await createResourceSchema(resourceType);
addParameterSupport(resourceSchema.definitions);
let templateSchema : any = templateSchemaTemplate(resourceType);
fixAllDefinitionsSoTitlesShowInJsonValidation(templateSchema); // Rather than compromise our template schema to deal with the VS Code title bug, we fix it up here
Object.assign(templateSchema.definitions, resourceSchema.definitions);
return templateSchema;
}
function addParameterSupport(definitions : any) : void {
// so the idea is we go through all the properties
// and change them all from type: X to anyOf: [ { type: X }, { type: string, pattern: param_regex } ]
for (let d in definitions) {
for (let pn in definitions[d].properties) {
let p = definitions[d].properties[pn];
const type = p.type;
if (type === "integer" || type === "boolean") {
p.anyOf = [
{ type: type },
{ type: "string", pattern: "\\[parameters\\('\\w+'\\)\\]" }
];
delete p.type;
}
}
}
}
function extendSchemaForBatchExtensions(definitions: any) : void {
const extensionsText = fs.readFileSync(path.join(__dirname, `../../tools/extensions.schema.json`), 'utf8');
const extensions : any = JSON.parse(extensionsText);
mergeExtensions(extensions, definitions);
}
function mergeExtensions(extensions: any, base: any) {
for (const p in extensions) {
if (base[p]) {
base[p].properties = Object.assign(base[p].properties, extensions[p].properties);
} else {
base[p] = extensions[p];
}
}
fillInImplicitExtensionTypes(base);
}
function fillInImplicitExtensionTypes(definitions: any) {
for (const extensionType of implicitExtensionTypes) {
let basedOn = definitions[extensionType.basedOn];
let definition : any = { properties: { } }; // can't use Object.assign({}, definitions[extensionType.basedOn]); because of shallow copies
for (const property in basedOn.properties) {
if (extensionType.removing.indexOf(property) < 0) {
definition.properties[property] = basedOn.properties[property];
}
}
definition.title = basedOn.title;
definition.description = basedOn.description;
definition.required = basedOn.required.filter((p : string) => extensionType.removing.indexOf(p) < 0);
definitions[extensionType.name] = definition;
}
}
function enrichSchema(definitions: any) {
for (const e in enrichments) {
let declaringType = definitions[e];
if (declaringType) { // we run this after filtering to the job or pool subset, so some enrichments may not relate to the definitions at hand
declaringType = Object.assign(declaringType, enrichments[e]);
}
}
}
function chaseRef(swagger: any, ref: string) : { name: string, schema: any } {
const refPath = ref.split('/');
refPath.shift();
let r = swagger;
for (const p of refPath) {
r = r[p];
}
const schema : any = r;
const name = refPath.reverse()[0];
return { name: name, schema: schema };
}
function recursivelyAddDefns(swagger: any, source: any, destination: any) : void {
if (source.properties) {
for (const p in source.properties) {
if (source.properties[p]['$ref']) {
const ref : string = source.properties[p]['$ref'];
recursivelyAddDefnsForRef(swagger, ref, destination);
} else if (source.properties[p].items && source.properties[p].items['$ref']) {
const ref : string = source.properties[p].items['$ref'];
recursivelyAddDefnsForRef(swagger, ref, destination);
}
}
}
}
function recursivelyAddDefnsForRef(swagger: any, ref: string, destination: any) {
const refSchema = chaseRef(swagger, ref);
if (!destination[refSchema.name]) {
destination[refSchema.name] = refSchema.schema;
fixSchemaSoTitlesShowInJsonValidation(destination[refSchema.name]);
recursivelyAddDefns(swagger, refSchema.schema, destination);
}
}
function fixAllDefinitionsSoTitlesShowInJsonValidation(schema: any) : void {
for (const p in schema.definitions) { // Rather than compromise our template schema to deal with the VS Code title bug, we fix it up here
fixSchemaSoTitlesShowInJsonValidation(schema.definitions[p]);
}
}
function fixSchemaSoTitlesShowInJsonValidation(schema: any) : any {
// Workaround for https://github.com/Microsoft/vscode/issues/28978
if (schema.properties) {
for (const p in schema.properties) {
schema.properties[p].description = schema.properties[p].title;
}
}
}
function resourcePath(resourceType : batch.BatchResourceType) : string {
switch (resourceType) {
case 'job':
return '/jobs';
case 'pool':
return '/pools';
default:
throw 'Unknown resource type ' + resourceType;
}
}
// We don't want to take a runtime dependency on batch.ts as it indirectly
// imports the vscode module. So we copy these two functions from there.
// (We are allowed to take compile time dependencies on type definitions.)
function templateResourceType(resourceType : batch.BatchResourceType) : string {
return "Microsoft.Batch/batchAccounts/" + plural(resourceType);
}
function plural(resourceType : batch.BatchResourceType) : string {
switch (resourceType) {
case 'job': return 'jobs';
case 'pool': return 'pools';
default: throw `unknown resource type ${resourceType}`;
}
}
// End of copy from the batch.ts module
export async function fetchSwagger() : Promise<any> {
const swaggerUrl = `https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/batch/2017-05-01.5.0/swagger/BatchService.json`;
const response = await httpsGet(swaggerUrl);
if (response.statusCode === 200) {
const swaggerText = await readText(response);
const swagger : any = JSON.parse(swaggerText);
return swagger;
}
response.resume();
throw `Failed to download Swagger: ${response.statusCode} ${response.statusMessage}`;
}
function readText(response : http.IncomingMessage) : Promise<string> {
return new Promise<string>((resolve, reject) => {
if (response.statusCode === 200) {
response.setEncoding('utf8');
let text = '';
response.on('data', (chunk) => { text += chunk; });
response.on('end', () => {
resolve(text);
return;
});
} else {
response.resume();
reject("Failed to download Swagger");
}
});
}
function httpsGet(url : string) : Promise<http.IncomingMessage> {
return new Promise<any>((resolve, reject) => {
https.get(url, (result: http.IncomingMessage) => {
resolve(result);
});
});
}