Add lun for azure_rm_manageddisk (#66153)
* add lun for azure_rm_manageddisk * add whitespace * Change condition
This commit is contained in:
parent
a589b10b26
commit
eb3d081c11
1 changed files with 16 additions and 3 deletions
|
@ -115,6 +115,12 @@ options:
|
||||||
- 3
|
- 3
|
||||||
- ''
|
- ''
|
||||||
version_added: "2.8"
|
version_added: "2.8"
|
||||||
|
lun:
|
||||||
|
description:
|
||||||
|
- The logical unit number for data disk.
|
||||||
|
- This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM.
|
||||||
|
type: int
|
||||||
|
version_added: '2.10'
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- azure
|
- azure
|
||||||
|
@ -263,6 +269,9 @@ class AzureRMManagedDisk(AzureRMModuleBase):
|
||||||
attach_caching=dict(
|
attach_caching=dict(
|
||||||
type='str',
|
type='str',
|
||||||
choices=['', 'read_only', 'read_write']
|
choices=['', 'read_only', 'read_write']
|
||||||
|
),
|
||||||
|
lun=dict(
|
||||||
|
type='int'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
required_if = [
|
required_if = [
|
||||||
|
@ -286,6 +295,7 @@ class AzureRMManagedDisk(AzureRMModuleBase):
|
||||||
self.zone = None
|
self.zone = None
|
||||||
self.managed_by = None
|
self.managed_by = None
|
||||||
self.attach_caching = None
|
self.attach_caching = None
|
||||||
|
self.lun = None
|
||||||
super(AzureRMManagedDisk, self).__init__(
|
super(AzureRMManagedDisk, self).__init__(
|
||||||
derived_arg_spec=self.module_arg_spec,
|
derived_arg_spec=self.module_arg_spec,
|
||||||
required_if=required_if,
|
required_if=required_if,
|
||||||
|
@ -343,6 +353,9 @@ class AzureRMManagedDisk(AzureRMModuleBase):
|
||||||
def attach(self, vm_name, disk):
|
def attach(self, vm_name, disk):
|
||||||
vm = self._get_vm(vm_name)
|
vm = self._get_vm(vm_name)
|
||||||
# find the lun
|
# find the lun
|
||||||
|
if self.lun:
|
||||||
|
lun = self.lun
|
||||||
|
else:
|
||||||
luns = ([d.lun for d in vm.storage_profile.data_disks]
|
luns = ([d.lun for d in vm.storage_profile.data_disks]
|
||||||
if vm.storage_profile.data_disks else [])
|
if vm.storage_profile.data_disks else [])
|
||||||
lun = max(luns) + 1 if luns else 0
|
lun = max(luns) + 1 if luns else 0
|
||||||
|
|
Loading…
Reference in a new issue