used wrong models
This commit is contained in:
parent
addc714e7c
commit
f2037bb629
1 changed files with 37 additions and 37 deletions
|
@ -756,7 +756,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
self.image['version'] = marketplace_image.name
|
self.image['version'] = marketplace_image.name
|
||||||
self.log("Using image version {0}".format(self.image['version']))
|
self.log("Using image version {0}".format(self.image['version']))
|
||||||
|
|
||||||
image_reference = self.network_models.ImageReference(
|
image_reference = self.compute_models.ImageReference(
|
||||||
publisher=self.image['publisher'],
|
publisher=self.image['publisher'],
|
||||||
offer=self.image['offer'],
|
offer=self.image['offer'],
|
||||||
sku=self.image['sku'],
|
sku=self.image['sku'],
|
||||||
|
@ -898,7 +898,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
parsed_availability_set = parse_resource_id(self.availability_set)
|
parsed_availability_set = parse_resource_id(self.availability_set)
|
||||||
availability_set = self.get_availability_set(parsed_availability_set.get('resource_group', self.resource_group),
|
availability_set = self.get_availability_set(parsed_availability_set.get('resource_group', self.resource_group),
|
||||||
parsed_availability_set.get('name'))
|
parsed_availability_set.get('name'))
|
||||||
availability_set_resource = self.network_models.SubResource(availability_set.id)
|
availability_set_resource = self.compute_models.SubResource(availability_set.id)
|
||||||
|
|
||||||
# Get defaults
|
# Get defaults
|
||||||
if not self.network_interface_names:
|
if not self.network_interface_names:
|
||||||
|
@ -922,46 +922,46 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
if not self.short_hostname:
|
if not self.short_hostname:
|
||||||
self.short_hostname = self.name
|
self.short_hostname = self.name
|
||||||
|
|
||||||
nics = [self.network_models.NetworkInterfaceReference(id=id) for id in network_interfaces]
|
nics = [self.compute_models.NetworkInterfaceReference(id=id) for id in network_interfaces]
|
||||||
|
|
||||||
# os disk
|
# os disk
|
||||||
if self.managed_disk_type:
|
if self.managed_disk_type:
|
||||||
vhd = None
|
vhd = None
|
||||||
managed_disk = self.network_models.ManagedDiskParameters(storage_account_type=self.managed_disk_type)
|
managed_disk = self.compute_models.ManagedDiskParameters(storage_account_type=self.managed_disk_type)
|
||||||
elif custom_image:
|
elif custom_image:
|
||||||
vhd = None
|
vhd = None
|
||||||
managed_disk = None
|
managed_disk = None
|
||||||
else:
|
else:
|
||||||
vhd = self.network_models.VirtualHardDisk(uri=requested_vhd_uri)
|
vhd = self.compute_models.VirtualHardDisk(uri=requested_vhd_uri)
|
||||||
managed_disk = None
|
managed_disk = None
|
||||||
|
|
||||||
plan = None
|
plan = None
|
||||||
if self.plan:
|
if self.plan:
|
||||||
plan = self.network_models.Plan(name=self.plan.get('name'), product=self.plan.get('product'),
|
plan = self.compute_models.Plan(name=self.plan.get('name'), product=self.plan.get('product'),
|
||||||
publisher=self.plan.get('publisher'),
|
publisher=self.plan.get('publisher'),
|
||||||
promotion_code=self.plan.get('promotion_code'))
|
promotion_code=self.plan.get('promotion_code'))
|
||||||
|
|
||||||
vm_resource = self.network_models.VirtualMachine(
|
vm_resource = self.compute_models.VirtualMachine(
|
||||||
self.location,
|
self.location,
|
||||||
tags=self.tags,
|
tags=self.tags,
|
||||||
os_profile=self.network_models.OSProfile(
|
os_profile=self.compute_models.OSProfile(
|
||||||
admin_username=self.admin_username,
|
admin_username=self.admin_username,
|
||||||
computer_name=self.short_hostname,
|
computer_name=self.short_hostname,
|
||||||
),
|
),
|
||||||
hardware_profile=self.network_models.HardwareProfile(
|
hardware_profile=self.compute_models.HardwareProfile(
|
||||||
vm_size=self.vm_size
|
vm_size=self.vm_size
|
||||||
),
|
),
|
||||||
storage_profile=self.network_models.StorageProfile(
|
storage_profile=self.compute_models.StorageProfile(
|
||||||
os_disk=self.network_models.OSDisk(
|
os_disk=self.compute_models.OSDisk(
|
||||||
name=self.storage_blob_name,
|
name=self.storage_blob_name,
|
||||||
vhd=vhd,
|
vhd=vhd,
|
||||||
managed_disk=managed_disk,
|
managed_disk=managed_disk,
|
||||||
create_option=self.network_models.DiskCreateOptionTypes.from_image,
|
create_option=self.compute_models.DiskCreateOptionTypes.from_image,
|
||||||
caching=self.os_disk_caching,
|
caching=self.os_disk_caching,
|
||||||
),
|
),
|
||||||
image_reference=image_reference,
|
image_reference=image_reference,
|
||||||
),
|
),
|
||||||
network_profile=self.network_models.NetworkProfile(
|
network_profile=self.compute_models.NetworkProfile(
|
||||||
network_interfaces=nics
|
network_interfaces=nics
|
||||||
),
|
),
|
||||||
availability_set=availability_set_resource,
|
availability_set=availability_set_resource,
|
||||||
|
@ -972,13 +972,13 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
vm_resource.os_profile.admin_password = self.admin_password
|
vm_resource.os_profile.admin_password = self.admin_password
|
||||||
|
|
||||||
if self.os_type == 'Linux':
|
if self.os_type == 'Linux':
|
||||||
vm_resource.os_profile.linux_configuration = self.network_models.LinuxConfiguration(
|
vm_resource.os_profile.linux_configuration = self.compute_models.LinuxConfiguration(
|
||||||
disable_password_authentication=disable_ssh_password
|
disable_password_authentication=disable_ssh_password
|
||||||
)
|
)
|
||||||
if self.ssh_public_keys:
|
if self.ssh_public_keys:
|
||||||
ssh_config = self.network_models.SshConfiguration()
|
ssh_config = self.compute_models.SshConfiguration()
|
||||||
ssh_config.public_keys = \
|
ssh_config.public_keys = \
|
||||||
[self.network_models.SshPublicKey(path=key['path'], key_data=key['key_data']) for key in self.ssh_public_keys]
|
[self.compute_models.SshPublicKey(path=key['path'], key_data=key['key_data']) for key in self.ssh_public_keys]
|
||||||
vm_resource.os_profile.linux_configuration.ssh = ssh_config
|
vm_resource.os_profile.linux_configuration.ssh = ssh_config
|
||||||
|
|
||||||
# data disk
|
# data disk
|
||||||
|
@ -1016,10 +1016,10 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
if not data_disk.get('managed_disk_type'):
|
if not data_disk.get('managed_disk_type'):
|
||||||
data_disk_managed_disk = None
|
data_disk_managed_disk = None
|
||||||
disk_name = data_disk['storage_blob_name']
|
disk_name = data_disk['storage_blob_name']
|
||||||
data_disk_vhd = self.network_models.VirtualHardDisk(uri=data_disk_requested_vhd_uri)
|
data_disk_vhd = self.compute_models.VirtualHardDisk(uri=data_disk_requested_vhd_uri)
|
||||||
else:
|
else:
|
||||||
data_disk_vhd = None
|
data_disk_vhd = None
|
||||||
data_disk_managed_disk = self.network_models.ManagedDiskParameters(storage_account_type=data_disk['managed_disk_type'])
|
data_disk_managed_disk = self.compute_models.ManagedDiskParameters(storage_account_type=data_disk['managed_disk_type'])
|
||||||
disk_name = self.name + "-datadisk-" + str(count)
|
disk_name = self.name + "-datadisk-" + str(count)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
@ -1027,12 +1027,12 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
'caching', 'ReadOnly'
|
'caching', 'ReadOnly'
|
||||||
)
|
)
|
||||||
|
|
||||||
data_disks.append(self.network_models.DataDisk(
|
data_disks.append(self.compute_models.DataDisk(
|
||||||
lun=data_disk['lun'],
|
lun=data_disk['lun'],
|
||||||
name=disk_name,
|
name=disk_name,
|
||||||
vhd=data_disk_vhd,
|
vhd=data_disk_vhd,
|
||||||
caching=data_disk['caching'],
|
caching=data_disk['caching'],
|
||||||
create_option=self.network_models.DiskCreateOptionTypes.empty,
|
create_option=self.compute_models.DiskCreateOptionTypes.empty,
|
||||||
disk_size_gb=data_disk['disk_size_gb'],
|
disk_size_gb=data_disk['disk_size_gb'],
|
||||||
managed_disk=data_disk_managed_disk,
|
managed_disk=data_disk_managed_disk,
|
||||||
))
|
))
|
||||||
|
@ -1048,37 +1048,37 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
self.log("Update virtual machine {0}".format(self.name))
|
self.log("Update virtual machine {0}".format(self.name))
|
||||||
self.results['actions'].append('Updated VM {0}'.format(self.name))
|
self.results['actions'].append('Updated VM {0}'.format(self.name))
|
||||||
|
|
||||||
nics = [self.network_models.NetworkInterfaceReference(id=interface['id'])
|
nics = [self.compute_models.NetworkInterfaceReference(id=interface['id'])
|
||||||
for interface in vm_dict['properties']['networkProfile']['networkInterfaces']]
|
for interface in vm_dict['properties']['networkProfile']['networkInterfaces']]
|
||||||
|
|
||||||
# os disk
|
# os disk
|
||||||
if not vm_dict['properties']['storageProfile']['osDisk'].get('managedDisk'):
|
if not vm_dict['properties']['storageProfile']['osDisk'].get('managedDisk'):
|
||||||
managed_disk = None
|
managed_disk = None
|
||||||
vhd = self.network_models.VirtualHardDisk(uri=vm_dict['properties']['storageProfile']['osDisk']['vhd']['uri'])
|
vhd = self.compute_models.VirtualHardDisk(uri=vm_dict['properties']['storageProfile']['osDisk']['vhd']['uri'])
|
||||||
else:
|
else:
|
||||||
vhd = None
|
vhd = None
|
||||||
managed_disk = self.network_models.ManagedDiskParameters(
|
managed_disk = self.compute_models.ManagedDiskParameters(
|
||||||
storage_account_type=vm_dict['properties']['storageProfile']['osDisk']['managedDisk']['storageAccountType']
|
storage_account_type=vm_dict['properties']['storageProfile']['osDisk']['managedDisk']['storageAccountType']
|
||||||
)
|
)
|
||||||
|
|
||||||
availability_set_resource = None
|
availability_set_resource = None
|
||||||
try:
|
try:
|
||||||
availability_set_resource = self.network_models.SubResource(vm_dict['properties']['availabilitySet']['id'])
|
availability_set_resource = self.compute_models.SubResource(vm_dict['properties']['availabilitySet']['id'])
|
||||||
except Exception:
|
except Exception:
|
||||||
# pass if the availability set is not set
|
# pass if the availability set is not set
|
||||||
pass
|
pass
|
||||||
|
|
||||||
vm_resource = self.network_models.VirtualMachine(
|
vm_resource = self.compute_models.VirtualMachine(
|
||||||
vm_dict['location'],
|
vm_dict['location'],
|
||||||
os_profile=self.network_models.OSProfile(
|
os_profile=self.compute_models.OSProfile(
|
||||||
admin_username=vm_dict['properties']['osProfile']['adminUsername'],
|
admin_username=vm_dict['properties']['osProfile']['adminUsername'],
|
||||||
computer_name=vm_dict['properties']['osProfile']['computerName']
|
computer_name=vm_dict['properties']['osProfile']['computerName']
|
||||||
),
|
),
|
||||||
hardware_profile=self.network_models.HardwareProfile(
|
hardware_profile=self.compute_models.HardwareProfile(
|
||||||
vm_size=vm_dict['properties']['hardwareProfile']['vmSize']
|
vm_size=vm_dict['properties']['hardwareProfile']['vmSize']
|
||||||
),
|
),
|
||||||
storage_profile=self.network_models.StorageProfile(
|
storage_profile=self.compute_models.StorageProfile(
|
||||||
os_disk=self.network_models.OSDisk(
|
os_disk=self.compute_models.OSDisk(
|
||||||
name=vm_dict['properties']['storageProfile']['osDisk']['name'],
|
name=vm_dict['properties']['storageProfile']['osDisk']['name'],
|
||||||
vhd=vhd,
|
vhd=vhd,
|
||||||
managed_disk=managed_disk,
|
managed_disk=managed_disk,
|
||||||
|
@ -1086,7 +1086,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
os_type=vm_dict['properties']['storageProfile']['osDisk']['osType'],
|
os_type=vm_dict['properties']['storageProfile']['osDisk']['osType'],
|
||||||
caching=vm_dict['properties']['storageProfile']['osDisk']['caching'],
|
caching=vm_dict['properties']['storageProfile']['osDisk']['caching'],
|
||||||
),
|
),
|
||||||
image_reference=self.network_models.ImageReference(
|
image_reference=self.compute_models.ImageReference(
|
||||||
publisher=vm_dict['properties']['storageProfile']['imageReference']['publisher'],
|
publisher=vm_dict['properties']['storageProfile']['imageReference']['publisher'],
|
||||||
offer=vm_dict['properties']['storageProfile']['imageReference']['offer'],
|
offer=vm_dict['properties']['storageProfile']['imageReference']['offer'],
|
||||||
sku=vm_dict['properties']['storageProfile']['imageReference']['sku'],
|
sku=vm_dict['properties']['storageProfile']['imageReference']['sku'],
|
||||||
|
@ -1094,7 +1094,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
availability_set=availability_set_resource,
|
availability_set=availability_set_resource,
|
||||||
network_profile=self.network_models.NetworkProfile(
|
network_profile=self.compute_models.NetworkProfile(
|
||||||
network_interfaces=nics
|
network_interfaces=nics
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1110,16 +1110,16 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
linux_config = vm_dict['properties']['osProfile'].get('linuxConfiguration')
|
linux_config = vm_dict['properties']['osProfile'].get('linuxConfiguration')
|
||||||
if linux_config:
|
if linux_config:
|
||||||
ssh_config = linux_config.get('ssh', None)
|
ssh_config = linux_config.get('ssh', None)
|
||||||
vm_resource.os_profile.linux_configuration = self.network_models.LinuxConfiguration(
|
vm_resource.os_profile.linux_configuration = self.compute_models.LinuxConfiguration(
|
||||||
disable_password_authentication=linux_config.get('disablePasswordAuthentication', False)
|
disable_password_authentication=linux_config.get('disablePasswordAuthentication', False)
|
||||||
)
|
)
|
||||||
if ssh_config:
|
if ssh_config:
|
||||||
public_keys = ssh_config.get('publicKeys')
|
public_keys = ssh_config.get('publicKeys')
|
||||||
if public_keys:
|
if public_keys:
|
||||||
vm_resource.os_profile.linux_configuration.ssh = self.network_models.SshConfiguration(public_keys=[])
|
vm_resource.os_profile.linux_configuration.ssh = self.compute_models.SshConfiguration(public_keys=[])
|
||||||
for key in public_keys:
|
for key in public_keys:
|
||||||
vm_resource.os_profile.linux_configuration.ssh.public_keys.append(
|
vm_resource.os_profile.linux_configuration.ssh.public_keys.append(
|
||||||
self.network_models.SshPublicKey(path=key['path'], key_data=key['keyData'])
|
self.compute_models.SshPublicKey(path=key['path'], key_data=key['keyData'])
|
||||||
)
|
)
|
||||||
|
|
||||||
# data disk
|
# data disk
|
||||||
|
@ -1129,13 +1129,13 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
for data_disk in vm_dict['properties']['storageProfile']['dataDisks']:
|
for data_disk in vm_dict['properties']['storageProfile']['dataDisks']:
|
||||||
if data_disk.get('managedDisk'):
|
if data_disk.get('managedDisk'):
|
||||||
managed_disk_type = data_disk['managedDisk']['storageAccountType']
|
managed_disk_type = data_disk['managedDisk']['storageAccountType']
|
||||||
data_disk_managed_disk = self.network_models.ManagedDiskParameters(storage_account_type=managed_disk_type)
|
data_disk_managed_disk = self.compute_models.ManagedDiskParameters(storage_account_type=managed_disk_type)
|
||||||
data_disk_vhd = None
|
data_disk_vhd = None
|
||||||
else:
|
else:
|
||||||
data_disk_vhd = data_disk['vhd']['uri']
|
data_disk_vhd = data_disk['vhd']['uri']
|
||||||
data_disk_managed_disk = None
|
data_disk_managed_disk = None
|
||||||
|
|
||||||
data_disks.append(self.network_models.DataDisk(
|
data_disks.append(self.compute_models.DataDisk(
|
||||||
lun=int(data_disk['lun']),
|
lun=int(data_disk['lun']),
|
||||||
name=data_disk.get('name'),
|
name=data_disk.get('name'),
|
||||||
vhd=data_disk_vhd,
|
vhd=data_disk_vhd,
|
||||||
|
@ -1448,7 +1448,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
for vm_image in vm_images:
|
for vm_image in vm_images:
|
||||||
if vm_image.name == name:
|
if vm_image.name == name:
|
||||||
self.log("Using custom image id {0}".format(vm_image.id))
|
self.log("Using custom image id {0}".format(vm_image.id))
|
||||||
return self.network_models.ImageReference(id=vm_image.id)
|
return self.compute_models.ImageReference(id=vm_image.id)
|
||||||
|
|
||||||
self.fail("Error could not find image with name {0}".format(name))
|
self.fail("Error could not find image with name {0}".format(name))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue