|
|
@ -179,14 +179,16 @@ class AzureRMImage(AzureRMModuleBase):
|
|
|
|
if vm:
|
|
|
|
if vm:
|
|
|
|
if self.data_disk_sources:
|
|
|
|
if self.data_disk_sources:
|
|
|
|
self.fail('data_disk_sources is not allowed when capturing image from vm')
|
|
|
|
self.fail('data_disk_sources is not allowed when capturing image from vm')
|
|
|
|
image_instance = self.compute_models.Image(self.location, source_virtual_machine=self.compute_models.SubResource(vm.id), tags=self.tags)
|
|
|
|
image_instance = self.compute_models.Image(location=self.location,
|
|
|
|
|
|
|
|
source_virtual_machine=self.compute_models.SubResource(id=vm.id),
|
|
|
|
|
|
|
|
tags=self.tags)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if not self.os_type:
|
|
|
|
if not self.os_type:
|
|
|
|
self.fail('os_type is required to create the image')
|
|
|
|
self.fail('os_type is required to create the image')
|
|
|
|
os_disk = self.create_os_disk()
|
|
|
|
os_disk = self.create_os_disk()
|
|
|
|
data_disks = self.create_data_disks()
|
|
|
|
data_disks = self.create_data_disks()
|
|
|
|
storage_profile = self.compute_models.ImageStorageProfile(os_disk=os_disk, data_disks=data_disks)
|
|
|
|
storage_profile = self.compute_models.ImageStorageProfile(os_disk=os_disk, data_disks=data_disks)
|
|
|
|
image_instance = self.compute_models.Image(self.location, storage_profile=storage_profile, tags=self.tags)
|
|
|
|
image_instance = self.compute_models.Image(location=self.location, storage_profile=storage_profile, tags=self.tags)
|
|
|
|
|
|
|
|
|
|
|
|
# finally make the change if not check mode
|
|
|
|
# finally make the change if not check mode
|
|
|
|
if not self.check_mode and image_instance:
|
|
|
|
if not self.check_mode and image_instance:
|
|
|
@ -236,8 +238,8 @@ class AzureRMImage(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
|
def create_os_disk(self):
|
|
|
|
def create_os_disk(self):
|
|
|
|
blob_uri, disk, snapshot = self.resolve_storage_source(self.source)
|
|
|
|
blob_uri, disk, snapshot = self.resolve_storage_source(self.source)
|
|
|
|
snapshot_resource = self.compute_models.SubResource(snapshot) if snapshot else None
|
|
|
|
snapshot_resource = self.compute_models.SubResource(id=snapshot) if snapshot else None
|
|
|
|
managed_disk = self.compute_models.SubResource(disk) if disk else None
|
|
|
|
managed_disk = self.compute_models.SubResource(id=disk) if disk else None
|
|
|
|
return self.compute_models.ImageOSDisk(os_type=self.os_type,
|
|
|
|
return self.compute_models.ImageOSDisk(os_type=self.os_type,
|
|
|
|
os_state=self.compute_models.OperatingSystemStateTypes.generalized,
|
|
|
|
os_state=self.compute_models.OperatingSystemStateTypes.generalized,
|
|
|
|
snapshot=snapshot_resource,
|
|
|
|
snapshot=snapshot_resource,
|
|
|
@ -247,8 +249,8 @@ class AzureRMImage(AzureRMModuleBase):
|
|
|
|
def create_data_disk(self, lun, source):
|
|
|
|
def create_data_disk(self, lun, source):
|
|
|
|
blob_uri, disk, snapshot = self.resolve_storage_source(source)
|
|
|
|
blob_uri, disk, snapshot = self.resolve_storage_source(source)
|
|
|
|
if blob_uri or disk or snapshot:
|
|
|
|
if blob_uri or disk or snapshot:
|
|
|
|
snapshot_resource = self.compute_models.SubResource(snapshot) if snapshot else None
|
|
|
|
snapshot_resource = self.compute_models.SubResource(id=snapshot) if snapshot else None
|
|
|
|
managed_disk = self.compute_models.SubResource(disk) if disk else None
|
|
|
|
managed_disk = self.compute_models.SubResource(id=disk) if disk else None
|
|
|
|
return self.compute_models.ImageDataDisk(lun,
|
|
|
|
return self.compute_models.ImageDataDisk(lun,
|
|
|
|
blob_uri=blob_uri,
|
|
|
|
blob_uri=blob_uri,
|
|
|
|
snapshot=snapshot_resource,
|
|
|
|
snapshot=snapshot_resource,
|
|
|
|