|
|
|
@ -1205,12 +1205,32 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|
|
|
|
# pass if the availability set is not set
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
vm_resource = self.compute_models.VirtualMachine(
|
|
|
|
|
location=vm_dict['location'],
|
|
|
|
|
os_profile=self.compute_models.OSProfile(
|
|
|
|
|
if 'imageReference' in vm_dict['properties']['storageProfile'].keys():
|
|
|
|
|
if 'id' in vm_dict['properties']['storageProfile']['imageReference'].keys():
|
|
|
|
|
image_reference = self.compute_models.ImageReference(
|
|
|
|
|
id=vm_dict['properties']['storageProfile']['imageReference']['id']
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
image_reference = self.compute_models.ImageReference(
|
|
|
|
|
publisher=vm_dict['properties']['storageProfile']['imageReference'].get('publisher'),
|
|
|
|
|
offer=vm_dict['properties']['storageProfile']['imageReference'].get('offer'),
|
|
|
|
|
sku=vm_dict['properties']['storageProfile']['imageReference'].get('sku'),
|
|
|
|
|
version=vm_dict['properties']['storageProfile']['imageReference'].get('version')
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
image_reference = None
|
|
|
|
|
|
|
|
|
|
if 'osProfile' in vm_dict['properties']:
|
|
|
|
|
os_profile = self.compute_models.OSProfile(
|
|
|
|
|
admin_username=vm_dict['properties'].get('osProfile', {}).get('adminUsername'),
|
|
|
|
|
computer_name=vm_dict['properties'].get('osProfile', {}).get('computerName')
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
os_profile = None
|
|
|
|
|
|
|
|
|
|
vm_resource = self.compute_models.VirtualMachine(
|
|
|
|
|
location=vm_dict['location'],
|
|
|
|
|
os_profile=os_profile,
|
|
|
|
|
hardware_profile=self.compute_models.HardwareProfile(
|
|
|
|
|
vm_size=vm_dict['properties']['hardwareProfile'].get('vmSize')
|
|
|
|
|
),
|
|
|
|
@ -1224,14 +1244,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|
|
|
|
caching=vm_dict['properties']['storageProfile']['osDisk'].get('caching'),
|
|
|
|
|
disk_size_gb=vm_dict['properties']['storageProfile']['osDisk'].get('diskSizeGB')
|
|
|
|
|
),
|
|
|
|
|
image_reference=self.compute_models.ImageReference(
|
|
|
|
|
id=vm_dict['properties']['storageProfile']['imageReference']['id'],
|
|
|
|
|
) if 'id' in vm_dict['properties']['storageProfile']['imageReference'].keys() else self.compute_models.ImageReference(
|
|
|
|
|
publisher=vm_dict['properties']['storageProfile']['imageReference'].get('publisher'),
|
|
|
|
|
offer=vm_dict['properties']['storageProfile']['imageReference'].get('offer'),
|
|
|
|
|
sku=vm_dict['properties']['storageProfile']['imageReference'].get('sku'),
|
|
|
|
|
version=vm_dict['properties']['storageProfile']['imageReference'].get('version')
|
|
|
|
|
),
|
|
|
|
|
image_reference=image_reference
|
|
|
|
|
),
|
|
|
|
|
availability_set=availability_set_resource,
|
|
|
|
|
network_profile=self.compute_models.NetworkProfile(
|
|
|
|
@ -1243,17 +1256,17 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
|
|
|
|
vm_resource.tags = vm_dict['tags']
|
|
|
|
|
|
|
|
|
|
# Add custom_data, if provided
|
|
|
|
|
if vm_dict['properties']['osProfile'].get('customData'):
|
|
|
|
|
if vm_dict['properties'].get('osProfile', {}).get('customData'):
|
|
|
|
|
custom_data = vm_dict['properties']['osProfile']['customData']
|
|
|
|
|
# Azure SDK (erroneously?) wants native string type for this
|
|
|
|
|
vm_resource.os_profile.custom_data = to_native(base64.b64encode(to_bytes(custom_data)))
|
|
|
|
|
|
|
|
|
|
# Add admin password, if one provided
|
|
|
|
|
if vm_dict['properties']['osProfile'].get('adminPassword'):
|
|
|
|
|
if vm_dict['properties'].get('osProfile', {}).get('adminPassword'):
|
|
|
|
|
vm_resource.os_profile.admin_password = vm_dict['properties']['osProfile']['adminPassword']
|
|
|
|
|
|
|
|
|
|
# Add linux configuration, if applicable
|
|
|
|
|
linux_config = vm_dict['properties']['osProfile'].get('linuxConfiguration')
|
|
|
|
|
linux_config = vm_dict['properties'].get('osProfile', {}).get('linuxConfiguration')
|
|
|
|
|
if linux_config:
|
|
|
|
|
ssh_config = linux_config.get('ssh', None)
|
|
|
|
|
vm_resource.os_profile.linux_configuration = self.compute_models.LinuxConfiguration(
|
|
|
|
|