all scenarios for availability set and ssh key working

This commit is contained in:
Burt Bielicki 2016-04-21 16:45:22 -07:00
Родитель 44dcf0b600
Коммит a7f9b0b6f1
14 изменённых файлов: 629 добавлений и 33 удалений

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

@ -132,9 +132,11 @@
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_operation.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_operations_list_result.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_operation_properties.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_parameter_virtual_network_ip_address_prefix.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_properties_extended.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_validate_result.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_vm.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\deployment_vnet.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\generic_resource.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\generic_resource_filter.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\parameters_link.py" />
@ -170,6 +172,7 @@
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\models\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\deployments.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\vm_operations.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\vnet_operations.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\operations\__init__.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\resource_management_client.py" />
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\mgmt\lib\version.py" />

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

@ -208,7 +208,35 @@ VM_SPECIFIC_PARAMS = {
'deployment_parameter_ssh_key_path_value': {
'name': '--ssh-key-path',
'metavar': 'SSHPATH',
}
},
'deployment_parameter_add_to_availability_set_value': {
'name': '--add-to-availability-set',
'metavar': 'AVAILSETTYPE',
},
'deployment_parameter_availability_set_id_value': {
'name': '--availability-set-name',
'metavar': 'AVAILSETNAME',
},
'deployment_parameter_new_or_existing_vnet_value': {
'name': '--new-or-existing-vnet',
'metavar': 'VNET',
},
'deployment_parameter_subnet_ip_address_prefix_value': {
'name': '--subnet-ip-prefix',
'metavar': 'SUBNETPREFIX',
},
'deployment_parameter_subnet_name_value': {
'name': '--subnet-name',
'metavar': 'NAME',
},
'deployment_parameter_virtual_network_ip_address_type_value': {
'name': '--vnet-ip-address-type',
'metavar': 'ADDRESSTYPE',
},
'deployment_parameter_virtual_network_name_value': {
'name': '--vnet-name',
'metavar': 'NAME',
},
}
build_operation('vm',

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

@ -142,14 +142,14 @@
"existing"
],
"metadata": {
"description": "An existing availability set to add this VM to."
"description": "Flag to add the VM to an existing availability set."
}
},
"availabilitySetId": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "An existing availability set to add this VM to."
"description": "Existing availability set for the VM."
}
},
"authenticationMethod": {
@ -165,11 +165,17 @@
},
"sshKeyValue": {
"type": "string",
"defaultValue": ""
"defaultValue": "",
"metadata": {
"description": "SSH key file data."
}
},
"sshKeyPath": {
"type": "string",
"defaultValue": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]"
"defaultValue": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]",
"metadata": {
"description": "VM file path for SSH key."
}
},
"_artifactsLocation": {
"type": "string",
@ -218,7 +224,7 @@
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]",
"vhdStorageName": "[concat('vhdstorage', uniqueString(parameters('dnsNameForPublicIP')))]",
"availSetId": "[parameters('availabilitySetId')]",
"availSetId": "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySetId'))]",
"vnetTemplateFilePaths": {
"new": "nested_templates/NewVNet.json",
"existing": "nested_templates/ExistingVNet.json"
@ -327,7 +333,8 @@
"size": { "value": "[variables('vmSize')]" },
"storageType": { "value": "[variables('vhdStorageType')]" },
"sshKeyValue": { "value": "[parameters('sshKeyValue')]" },
"sshKeyPath": { "value": "[parameters('sshKeyPath')]" }
"sshKeyPath": { "value": "[parameters('sshKeyPath')]" },
"availabilitySetId": { "value": "[variables('availSetId')]" }
}
}
}

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

@ -8,6 +8,7 @@
from .deployment_vm import DeploymentVM
from .template_link import TemplateLink
from .deployment_parameter_virtual_network_ip_address_prefix import DeploymentParameterVirtualNetworkIpAddressPrefix
from .parameters_link import ParametersLink
from .provider_resource_type import ProviderResourceType
from .provider import Provider
@ -22,6 +23,7 @@ from .resource_management_client_enums import (
__all__ = [
'DeploymentVM',
'TemplateLink',
'DeploymentParameterVirtualNetworkIpAddressPrefix',
'ParametersLink',
'ProviderResourceType',
'Provider',

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

@ -0,0 +1,23 @@
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class DeploymentParameterVirtualNetworkIpAddressPrefix(Model):
"""DeploymentParameterVirtualNetworkIpAddressPrefix
:param str value:
"""
_attribute_map = {
'value': {'key': 'value', 'type': 'str'},
}
def __init__(self, value=None, **kwargs):
self.value = value

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

@ -37,8 +37,6 @@ class DeploymentVM(Model):
prefix.
:param str deployment_parameter_virtual_machine_name_value: The VM name
that is displayed in the portal.
:param str deployment_parameter_subnet_prefix_value: The subnet address
type.
:param str deployment_parameter_os_sku_value: The OS SKU to install.
:param str deployment_parameter_os_offer_value: The OS Offer to install.
:param str deployment_parameter_os_version_value: The OS version to
@ -50,6 +48,20 @@ class DeploymentVM(Model):
an SSH public key.
:param str deployment_parameter_ssh_key_path_value: The VM file path to
save the SSh key to.
:param str deployment_parameter_add_to_availability_set_value: Whether or
not to add the VM to an availability set. Possible values include:
'none', 'existing'
:param str deployment_parameter_availability_set_id_value: ID of the
availability set the VM should be added to.
:param str deployment_parameter_subnet_name_value: The subnet name.
:param str deployment_parameter_virtual_network_name_value: Name of
virtual network to add VM to.
:param str deployment_parameter_new_or_existing_vnet_value: Whether to
use an existing VNet or create a new one.
:param str deployment_parameter_virtual_network_ip_address_type_value:
Dynamic or Static IP address allocation.
:param str deployment_parameter_subnet_ip_address_prefix_value: The
subnet address type.
:param str mode: Gets or sets the deployment mode. Default value:
"Incremental" .
"""
@ -72,17 +84,23 @@ class DeploymentVM(Model):
'deployment_parameter_dns_name_for_public_ip_value': {'key': 'properties.parameters.dnsNameForPublicIP.value', 'type': 'str'},
'deployment_parameter_ip_address_prefix_value': {'key': 'properties.parameters.ipAddressPrefix.value', 'type': 'str'},
'deployment_parameter_virtual_machine_name_value': {'key': 'properties.parameters.virtualMachineName.value', 'type': 'str'},
'deployment_parameter_subnet_prefix_value': {'key': 'properties.parameters.subnetPrefix.value', 'type': 'str'},
'deployment_parameter_os_sku_value': {'key': 'properties.parameters.osSKU.value', 'type': 'str'},
'deployment_parameter_os_offer_value': {'key': 'properties.parameters.osOffer.value', 'type': 'str'},
'deployment_parameter_os_version_value': {'key': 'properties.parameters.osVersion.value', 'type': 'str'},
'deployment_parameter_authentication_method_value': {'key': 'properties.parameters.authenticationMethod.value', 'type': 'str'},
'deployment_parameter_ssh_key_value_value': {'key': 'properties.parameters.sshKeyValue.value', 'type': 'str'},
'deployment_parameter_ssh_key_path_value': {'key': 'properties.parameters.sshKeyPath.value', 'type': 'str'},
'deployment_parameter_add_to_availability_set_value': {'key': 'properties.parameters.addToAvailabilitySet.value', 'type': 'str'},
'deployment_parameter_availability_set_id_value': {'key': 'properties.parameters.availabilitySetId.value', 'type': 'str'},
'deployment_parameter_subnet_name_value': {'key': 'properties.parameters.subnetName.value', 'type': 'str'},
'deployment_parameter_virtual_network_name_value': {'key': 'properties.parameters.virtualNetworkName.value', 'type': 'str'},
'deployment_parameter_new_or_existing_vnet_value': {'key': 'properties.parameters.newOrExistingVNet.value', 'type': 'str'},
'deployment_parameter_virtual_network_ip_address_type_value': {'key': 'properties.parameters.virtualNetworkIpAddressType.value', 'type': 'str'},
'deployment_parameter_subnet_ip_address_prefix_value': {'key': 'properties.parameters.subnetIpAddressPrefix.value', 'type': 'str'},
'mode': {'key': 'properties.mode', 'type': 'str'},
}
def __init__(self, content_version=None, deployment_parameter_os_value=None, deployment_parameter_os_publisher_value=None, deployment_parameter_admin_password_value=None, deployment_parameter_ip_address_type_value=None, deployment_parameter_storage_type_value=None, deployment_parameter_size_value=None, deployment_parameter_admin_username_value=None, deployment_parameter_dns_name_for_public_ip_value=None, deployment_parameter_ip_address_prefix_value=None, deployment_parameter_virtual_machine_name_value=None, deployment_parameter_subnet_prefix_value=None, deployment_parameter_os_sku_value=None, deployment_parameter_os_offer_value=None, deployment_parameter_os_version_value=None, deployment_parameter_authentication_method_value=None, deployment_parameter_ssh_key_value_value=None, deployment_parameter_ssh_key_path_value=None, **kwargs):
def __init__(self, content_version=None, deployment_parameter_os_value=None, deployment_parameter_os_publisher_value=None, deployment_parameter_admin_password_value=None, deployment_parameter_ip_address_type_value=None, deployment_parameter_storage_type_value=None, deployment_parameter_size_value=None, deployment_parameter_admin_username_value=None, deployment_parameter_dns_name_for_public_ip_value=None, deployment_parameter_ip_address_prefix_value=None, deployment_parameter_virtual_machine_name_value=None, deployment_parameter_os_sku_value=None, deployment_parameter_os_offer_value=None, deployment_parameter_os_version_value=None, deployment_parameter_authentication_method_value=None, deployment_parameter_ssh_key_value_value=None, deployment_parameter_ssh_key_path_value=None, deployment_parameter_add_to_availability_set_value=None, deployment_parameter_availability_set_id_value=None, deployment_parameter_subnet_name_value=None, deployment_parameter_virtual_network_name_value=None, deployment_parameter_new_or_existing_vnet_value=None, deployment_parameter_virtual_network_ip_address_type_value=None, deployment_parameter_subnet_ip_address_prefix_value=None, **kwargs):
self.uri = "https://azuretemplatehost.blob.core.windows.net/templatehost/CreateVM/azuredeploy.json"
self.content_version = content_version
self.deployment_parameter_os_value = deployment_parameter_os_value
@ -95,11 +113,17 @@ class DeploymentVM(Model):
self.deployment_parameter_dns_name_for_public_ip_value = deployment_parameter_dns_name_for_public_ip_value
self.deployment_parameter_ip_address_prefix_value = deployment_parameter_ip_address_prefix_value
self.deployment_parameter_virtual_machine_name_value = deployment_parameter_virtual_machine_name_value
self.deployment_parameter_subnet_prefix_value = deployment_parameter_subnet_prefix_value
self.deployment_parameter_os_sku_value = deployment_parameter_os_sku_value
self.deployment_parameter_os_offer_value = deployment_parameter_os_offer_value
self.deployment_parameter_os_version_value = deployment_parameter_os_version_value
self.deployment_parameter_authentication_method_value = deployment_parameter_authentication_method_value
self.deployment_parameter_ssh_key_value_value = deployment_parameter_ssh_key_value_value
self.deployment_parameter_ssh_key_path_value = deployment_parameter_ssh_key_path_value
self.deployment_parameter_add_to_availability_set_value = deployment_parameter_add_to_availability_set_value
self.deployment_parameter_availability_set_id_value = deployment_parameter_availability_set_id_value
self.deployment_parameter_subnet_name_value = deployment_parameter_subnet_name_value
self.deployment_parameter_virtual_network_name_value = deployment_parameter_virtual_network_name_value
self.deployment_parameter_new_or_existing_vnet_value = deployment_parameter_new_or_existing_vnet_value
self.deployment_parameter_virtual_network_ip_address_type_value = deployment_parameter_virtual_network_ip_address_type_value
self.deployment_parameter_subnet_ip_address_prefix_value = deployment_parameter_subnet_ip_address_prefix_value
self.mode = "Incremental"

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

@ -0,0 +1,68 @@
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.serialization import Model
class DeploymentVNet(Model):
"""
Deployment operation parameters.
:param str uri: URI referencing the template. Default value:
"https://azuretemplatedeploy.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
.
:param str content_version: If included it must match the ContentVersion
in the template.
:param str deployment_parameter_virtual_network_prefix_value: IP address
prefix for the virtual network.
:param str deployment_parameter_subnet_prefix_value: IP address prefix
for the subnet.
:param str deployment_parameter_virtual_network_name_value: Name of the
virtual network.
:param str deployment_parameter_subnet_name_value: Name of the subnet.
:param str deployment_parameter_location_value: Location of the virtual
network.
:param str mode: Gets or sets the deployment mode. Default value:
"Incremental" .
"""
_validation = {
'uri': {'required': True},
'deployment_parameter_virtual_network_prefix_value': {'pattern': '^[\d\./]+$'},
'deployment_parameter_subnet_prefix_value': {'pattern': '^[\d\./]+$'},
'deployment_parameter_virtual_network_name_value': {'required': True, 'max_length': 80, 'min_length': 2, 'pattern': '^[-\w\._]+$'},
'deployment_parameter_subnet_name_value': {'max_length': 80, 'min_length': 2, 'pattern': '^[-\w\._]+$'},
'mode': {'required': True},
}
_attribute_map = {
'uri': {'key': 'properties.templateLink.uri', 'type': 'str'},
'content_version': {'key': 'properties.templateLink.contentVersion', 'type': 'str'},
'deployment_parameter_virtual_network_prefix_value': {'key': 'properties.parameters.virtualNetworkPrefix.value', 'type': 'str'},
'deployment_parameter_subnet_prefix_value': {'key': 'properties.parameters.subnetPrefix.value', 'type': 'str'},
'deployment_parameter_virtual_network_name_value': {'key': 'properties.parameters.virtualNetworkName.value', 'type': 'str'},
'deployment_parameter_subnet_name_value': {'key': 'properties.parameters.subnetName.value', 'type': 'str'},
'deployment_parameter_location_value': {'key': 'properties.parameters.location.value', 'type': 'str'},
'mode': {'key': 'properties.mode', 'type': 'str'},
}
def __init__(self, deployment_parameter_virtual_network_name_value, content_version=None, deployment_parameter_virtual_network_prefix_value=None, deployment_parameter_subnet_prefix_value=None, deployment_parameter_subnet_name_value=None, deployment_parameter_location_value=None, **kwargs):
self.uri = "https://azuretemplatedeploy.blob.core.windows.net/templatehost/CreateVNet/azuredeploy.json"
self.content_version = content_version
self.deployment_parameter_virtual_network_prefix_value = deployment_parameter_virtual_network_prefix_value
self.deployment_parameter_subnet_prefix_value = deployment_parameter_subnet_prefix_value
self.deployment_parameter_virtual_network_name_value = deployment_parameter_virtual_network_name_value
self.deployment_parameter_subnet_name_value = deployment_parameter_subnet_name_value
self.deployment_parameter_location_value = deployment_parameter_location_value
self.mode = "Incremental"

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

@ -32,7 +32,7 @@ class VMOperations(object):
self.config = config
def create_or_update(
self, resource_group_name, deployment_name, content_version=None, deployment_parameter_os_value=None, deployment_parameter_os_publisher_value=None, deployment_parameter_admin_password_value=None, deployment_parameter_ip_address_type_value=None, deployment_parameter_storage_type_value=None, deployment_parameter_size_value=None, deployment_parameter_admin_username_value=None, deployment_parameter_dns_name_for_public_ip_value=None, deployment_parameter_ip_address_prefix_value=None, deployment_parameter_virtual_machine_name_value=None, deployment_parameter_subnet_prefix_value=None, deployment_parameter_os_sku_value=None, deployment_parameter_os_offer_value=None, deployment_parameter_os_version_value=None, deployment_parameter_authentication_method_value=None, deployment_parameter_ssh_key_value_value=None, deployment_parameter_ssh_key_path_value=None, custom_headers={}, raw=False, **operation_config):
self, resource_group_name, deployment_name, content_version=None, deployment_parameter_os_value=None, deployment_parameter_os_publisher_value=None, deployment_parameter_admin_password_value=None, deployment_parameter_ip_address_type_value=None, deployment_parameter_storage_type_value=None, deployment_parameter_size_value=None, deployment_parameter_admin_username_value=None, deployment_parameter_dns_name_for_public_ip_value=None, deployment_parameter_ip_address_prefix_value=None, deployment_parameter_virtual_machine_name_value=None, deployment_parameter_os_sku_value=None, deployment_parameter_os_offer_value=None, deployment_parameter_os_version_value=None, deployment_parameter_authentication_method_value=None, deployment_parameter_ssh_key_value_value=None, deployment_parameter_ssh_key_path_value=None, deployment_parameter_add_to_availability_set_value=None, deployment_parameter_availability_set_id_value=None, deployment_parameter_subnet_name_value=None, deployment_parameter_virtual_network_name_value=None, deployment_parameter_new_or_existing_vnet_value=None, deployment_parameter_virtual_network_ip_address_type_value=None, deployment_parameter_subnet_ip_address_prefix_value=None, custom_headers={}, raw=False, **operation_config):
"""
Create a named template deployment using a template.
@ -73,9 +73,6 @@ class VMOperations(object):
:param deployment_parameter_virtual_machine_name_value: The VM name
that is displayed in the portal.
:type deployment_parameter_virtual_machine_name_value: str
:param deployment_parameter_subnet_prefix_value: The subnet address
type.
:type deployment_parameter_subnet_prefix_value: str
:param deployment_parameter_os_sku_value: The OS SKU to install.
:type deployment_parameter_os_sku_value: str
:param deployment_parameter_os_offer_value: The OS Offer to install.
@ -94,13 +91,34 @@ class VMOperations(object):
:param deployment_parameter_ssh_key_path_value: The VM file path to
save the SSh key to.
:type deployment_parameter_ssh_key_path_value: str
:param deployment_parameter_add_to_availability_set_value: Whether or
not to add the VM to an availability set. Possible values include:
'none', 'existing'
:type deployment_parameter_add_to_availability_set_value: str
:param deployment_parameter_availability_set_id_value: ID of the
availability set the VM should be added to.
:type deployment_parameter_availability_set_id_value: str
:param deployment_parameter_subnet_name_value: The subnet name.
:type deployment_parameter_subnet_name_value: str
:param deployment_parameter_virtual_network_name_value: Name of
virtual network to add VM to.
:type deployment_parameter_virtual_network_name_value: str
:param deployment_parameter_new_or_existing_vnet_value: Whether to
use an existing VNet or create a new one.
:type deployment_parameter_new_or_existing_vnet_value: str
:param deployment_parameter_virtual_network_ip_address_type_value:
Dynamic or Static IP address allocation.
:type deployment_parameter_virtual_network_ip_address_type_value: str
:param deployment_parameter_subnet_ip_address_prefix_value: The
subnet address type.
:type deployment_parameter_subnet_ip_address_prefix_value: str
:param dict custom_headers: headers that will be added to the request
:param boolean raw: returns the direct response alongside the
deserialized response
:rtype: DeploymentExtended
:rtype: msrest.pipeline.ClientRawResponse if raw=True
"""
parameters = models.DeploymentVM(content_version=content_version, deployment_parameter_os_value=deployment_parameter_os_value, deployment_parameter_os_publisher_value=deployment_parameter_os_publisher_value, deployment_parameter_admin_password_value=deployment_parameter_admin_password_value, deployment_parameter_ip_address_type_value=deployment_parameter_ip_address_type_value, deployment_parameter_storage_type_value=deployment_parameter_storage_type_value, deployment_parameter_size_value=deployment_parameter_size_value, deployment_parameter_admin_username_value=deployment_parameter_admin_username_value, deployment_parameter_dns_name_for_public_ip_value=deployment_parameter_dns_name_for_public_ip_value, deployment_parameter_ip_address_prefix_value=deployment_parameter_ip_address_prefix_value, deployment_parameter_virtual_machine_name_value=deployment_parameter_virtual_machine_name_value, deployment_parameter_subnet_prefix_value=deployment_parameter_subnet_prefix_value, deployment_parameter_os_sku_value=deployment_parameter_os_sku_value, deployment_parameter_os_offer_value=deployment_parameter_os_offer_value, deployment_parameter_os_version_value=deployment_parameter_os_version_value, deployment_parameter_authentication_method_value=deployment_parameter_authentication_method_value, deployment_parameter_ssh_key_value_value=deployment_parameter_ssh_key_value_value, deployment_parameter_ssh_key_path_value=deployment_parameter_ssh_key_path_value)
parameters = models.DeploymentVM(content_version=content_version, deployment_parameter_os_value=deployment_parameter_os_value, deployment_parameter_os_publisher_value=deployment_parameter_os_publisher_value, deployment_parameter_admin_password_value=deployment_parameter_admin_password_value, deployment_parameter_ip_address_type_value=deployment_parameter_ip_address_type_value, deployment_parameter_storage_type_value=deployment_parameter_storage_type_value, deployment_parameter_size_value=deployment_parameter_size_value, deployment_parameter_admin_username_value=deployment_parameter_admin_username_value, deployment_parameter_dns_name_for_public_ip_value=deployment_parameter_dns_name_for_public_ip_value, deployment_parameter_ip_address_prefix_value=deployment_parameter_ip_address_prefix_value, deployment_parameter_virtual_machine_name_value=deployment_parameter_virtual_machine_name_value, deployment_parameter_os_sku_value=deployment_parameter_os_sku_value, deployment_parameter_os_offer_value=deployment_parameter_os_offer_value, deployment_parameter_os_version_value=deployment_parameter_os_version_value, deployment_parameter_authentication_method_value=deployment_parameter_authentication_method_value, deployment_parameter_ssh_key_value_value=deployment_parameter_ssh_key_value_value, deployment_parameter_ssh_key_path_value=deployment_parameter_ssh_key_path_value, deployment_parameter_add_to_availability_set_value=deployment_parameter_add_to_availability_set_value, deployment_parameter_availability_set_id_value=deployment_parameter_availability_set_id_value, deployment_parameter_subnet_name_value=deployment_parameter_subnet_name_value, deployment_parameter_virtual_network_name_value=deployment_parameter_virtual_network_name_value, deployment_parameter_new_or_existing_vnet_value=deployment_parameter_new_or_existing_vnet_value, deployment_parameter_virtual_network_ip_address_type_value=deployment_parameter_virtual_network_ip_address_type_value, deployment_parameter_subnet_ip_address_prefix_value=deployment_parameter_subnet_ip_address_prefix_value)
# Construct URL
url = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'

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

@ -0,0 +1,140 @@
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
#pylint: skip-file
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator 0.15.0.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrest.pipeline import ClientRawResponse
from msrestazure.azure_exceptions import CloudError
from msrestazure.azure_operation import AzureOperationPoller
import uuid
from .. import models
class VNetOperations(object):
"""VNetOperations operations.
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An objec model deserializer.
"""
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self.config = config
def create(
self, resource_group_name, deployment_name, deployment_parameter_virtual_network_name_value, content_version=None, deployment_parameter_virtual_network_prefix_value=None, deployment_parameter_subnet_prefix_value=None, deployment_parameter_subnet_name_value=None, deployment_parameter_location_value=None, custom_headers={}, raw=False, **operation_config):
"""
Create a named template deployment using a template.
:param resource_group_name: The name of the resource group. The name
is case insensitive.
:type resource_group_name: str
:param deployment_name: The name of the deployment.
:type deployment_name: str
:param deployment_parameter_virtual_network_name_value: Name of the
virtual network.
:type deployment_parameter_virtual_network_name_value: str
:param content_version: If included it must match the ContentVersion
in the template.
:type content_version: str
:param deployment_parameter_virtual_network_prefix_value: IP address
prefix for the virtual network.
:type deployment_parameter_virtual_network_prefix_value: str
:param deployment_parameter_subnet_prefix_value: IP address prefix
for the subnet.
:type deployment_parameter_subnet_prefix_value: str
:param deployment_parameter_subnet_name_value: Name of the subnet.
:type deployment_parameter_subnet_name_value: str
:param deployment_parameter_location_value: Location of the virtual
network.
:type deployment_parameter_location_value: str
:param dict custom_headers: headers that will be added to the request
:param boolean raw: returns the direct response alongside the
deserialized response
:rtype: DeploymentExtended
:rtype: msrest.pipeline.ClientRawResponse if raw=True
"""
parameters = models.DeploymentVNet(content_version=content_version, deployment_parameter_virtual_network_prefix_value=deployment_parameter_virtual_network_prefix_value, deployment_parameter_subnet_prefix_value=deployment_parameter_subnet_prefix_value, deployment_parameter_virtual_network_name_value=deployment_parameter_virtual_network_name_value, deployment_parameter_subnet_name_value=deployment_parameter_subnet_name_value, deployment_parameter_location_value=deployment_parameter_location_value)
# Construct URL
url = '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}'
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=64, min_length=1, pattern='^[-\w\._]+$'),
'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1, pattern='^[-\w\._]+$'),
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
# Construct body
body_content = self._serialize.body(parameters, 'DeploymentVNet')
# Construct and send request
def long_running_send():
request = self._client.put(url, query_parameters)
return self._client.send(
request, header_parameters, body_content, **operation_config)
def get_long_running_status(status_link, headers={}):
request = self._client.get(status_link)
request.headers.update(headers)
return self._client.send(
request, header_parameters, **operation_config)
def get_long_running_output(response):
if response.status_code not in [200, 201]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize('DeploymentExtended', response)
if response.status_code == 201:
deserialized = self._deserialize('DeploymentExtended', response)
if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response
return deserialized
long_running_operation_timeout = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
return AzureOperationPoller(
long_running_send, get_long_running_output,
get_long_running_status, long_running_operation_timeout)

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

@ -2,26 +2,116 @@
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"adminUsername": {
"type": "string"
},
"vnetIpAddressType": {
"adminPassword": {
"type": "securestring"
},
"dnsNameForPublicIP": {
"type": "string"
},
"vnetIpAddressPrefix": {
"virtualMachineName": {
"type": "string"
},
"subnetIpAddressPrefix": {
"osPublisher": {
"type": "string"
},
"subnetName": {
"osOffer": {
"type": "string"
},
"osSKU": {
"type": "string"
},
"osVersion": {
"type": "string"
},
"size": {
"type": "string"
},
"storageType": {
"type": "string"
},
"sshKeyValue": {
"type": "string",
"defaultValue": ""
},
"sshKeyPath": {
"type": "string",
"defaultValue": ""
},
"availabilitySetId": {
"type": "string"
}
},
"variables": {
"imagePublisher": "[parameters('osPublisher')]",
"imageOffer": "[parameters('osOffer')]",
"imageSku": "[parameters('osSKU')]",
"imageVersion": "[parameters('osVersion')]",
"OSDiskName": "osdiskimage",
"vmName": "[parameters('virtualMachineName')]",
"vmSize": "[parameters('size')]",
"vhdStorageName": "[concat('vhdstorage', uniqueString(parameters('dnsNameForPublicIP')))]",
"vhdStorageType": "[parameters('storageType')]",
"vhdStorageContainerName": "vhds",
"nicName": "[concat('MyVMNic', uniqueString(parameters('dnsNameForPublicIP')))]"
},
"resources": [
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "VirtualMachine"
},
"dependsOn": [ ],
"properties": {
"availabilitySet": {
"id": "[parameters('availabilitySetId')]"
},
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[variables('imageSku')]",
"version": "[variables('imageVersion')]"
},
"osDisk": {
"name": "[concat('osdisk', uniqueString(parameters('dnsNameForPublicIP')))]",
"vhd": {
"uri": "[concat('http://', variables('vhdStorageName'), '.blob.core.windows.net/', variables('vhdStorageContainerName'), '/', variables('OSDiskName'), '.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
}
},
"resources": [
]
}
],
"outputs": {
"NewVM": {
"type": "object",
"value": "[reference(variables('vmName'))]"
}
}
}

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

@ -2,25 +2,120 @@
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vnetName": {
"adminUsername": {
"type": "string"
},
"vnetIpAddressType": {
"adminPassword": {
"type": "securestring"
},
"dnsNameForPublicIP": {
"type": "string"
},
"vnetIpAddressPrefix": {
"virtualMachineName": {
"type": "string"
},
"subnetIpAddressPrefix": {
"osPublisher": {
"type": "string"
},
"subnetName": {
"osOffer": {
"type": "string"
},
"osSKU": {
"type": "string"
},
"osVersion": {
"type": "string"
},
"size": {
"type": "string"
},
"storageType": {
"type": "string"
},
"sshKeyValue": {
"type": "string"
},
"sshKeyPath": {
"type": "string"
},
"availabilitySetId": {
"type": "string"
}
},
"variables": {
"imagePublisher": "[parameters('osPublisher')]",
"imageOffer": "[parameters('osOffer')]",
"imageSku": "[parameters('osSKU')]",
"imageVersion": "[parameters('osVersion')]",
"OSDiskName": "osdiskimage",
"vmName": "[parameters('virtualMachineName')]",
"vmSize": "[parameters('size')]",
"vhdStorageName": "[concat('vhdstorage', uniqueString(parameters('dnsNameForPublicIP')))]",
"vhdStorageType": "[parameters('storageType')]",
"vhdStorageContainerName": "vhds",
"nicName": "[concat('MyVMNic', uniqueString(parameters('dnsNameForPublicIP')))]",
},
"resources": [
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "VirtualMachine"
},
"dependsOn": [ ],
"properties": {
"availabilitySet": {
"id": "[parameters('availabilitySetId')]"
},
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"keyData": "[parameters('sshKeyValue')]",
"path": "[parameters('sshKeyPath')]"
}
]
}
}
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[variables('imageSku')]",
"version": "[variables('imageVersion')]"
},
"osDisk": {
"name": "[concat('osdisk', uniqueString(parameters('dnsNameForPublicIP')))]",
"vhd": {
"uri": "[concat('http://', variables('vhdStorageName'), '.blob.core.windows.net/', variables('vhdStorageContainerName'), '/', variables('OSDiskName'), '.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
}
},
"resources": [
]
}
],
"outputs": {
}

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

@ -39,6 +39,10 @@
"sshKeyPath": {
"type": "string",
"defaultValue": ""
},
"availabilitySetId": {
"type": "string",
"defaultValue": ""
}
},
"variables": {

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

@ -37,6 +37,10 @@
},
"sshKeyPath": {
"type": "string"
},
"availabilitySetId": {
"type": "string",
"defaultValue": ""
}
},
"variables": {

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

@ -211,11 +211,6 @@
"$ref": "#/definitions/DeploymentParameter_virtualMachineName",
"x-ms-client-flatten": true
},
"subnetPrefix": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_subnetPrefix",
"x-ms-client-flatten": true
},
"osSKU": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_osSKU",
@ -245,6 +240,41 @@
"type": "object",
"$ref": "#/definitions/DeploymentParameter_sshKeyPath",
"x-ms-client-flatten": true
},
"addToAvailabilitySet": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_addToAvailabilitySet",
"x-ms-client-flatten": true
},
"availabilitySetId": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_availabilitySetId",
"x-ms-client-flatten": true
},
"subnetName": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_subnetName",
"x-ms-client-flatten": true
},
"virtualNetworkName": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_virtualNetworkName",
"x-ms-client-flatten": true
},
"newOrExistingVNet": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_newOrExistingVNet",
"x-ms-client-flatten": true
},
"virtualNetworkIpAddressType": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_virtualNetworkIpAddressType",
"x-ms-client-flatten": true
},
"subnetIpAddressPrefix": {
"type": "object",
"$ref": "#/definitions/DeploymentParameter_subnetIpAddressPrefix",
"x-ms-client-flatten": true
}
},
"required": [
@ -339,7 +369,39 @@
}
}
},
"DeploymentParameter_subnetPrefix": {
"DeploymentParameter_subnetName": {
"properties": {
"value": {
"type": "string",
"description": "The subnet name."
}
}
},
"DeploymentParameter_virtualNetworkName": {
"properties": {
"value": {
"type": "string",
"description": "Name of virtual network to add VM to."
}
}
},
"DeploymentParameter_newOrExistingVNet": {
"properties": {
"value": {
"type": "string",
"description": "Whether to use an existing VNet or create a new one."
}
}
},
"DeploymentParameter_virtualNetworkIpAddressType": {
"properties": {
"value": {
"type": "string",
"description": "Dynamic or Static IP address allocation."
}
}
},
"DeploymentParameter_subnetIpAddressPrefix": {
"properties": {
"value": {
"type": "string",
@ -347,6 +409,14 @@
}
}
},
"DeploymentParameter_virtualNetworkIpAddressPrefix": {
"properties": {
"value": {
"type": "string",
"description": "IP address prefixe for the virtual network."
}
}
},
"DeploymentParameter_dnsNameForPublicIP": {
"properties": {
"value": {
@ -399,6 +469,26 @@
}
}
},
"DeploymentParameter_addToAvailabilitySet": {
"properties": {
"value": {
"type": "string",
"description": "Whether or not to add the VM to an availability set.",
"enum": [
"none",
"existing"
]
}
}
},
"DeploymentParameter_availabilitySetId": {
"properties": {
"value": {
"type": "string",
"description": "ID of the availability set the VM should be added to."
}
}
},
"ParametersLink": {
"properties": {
"uri": {