|
18 | 18 | # pylint: disable=redefined-builtin |
19 | 19 |
|
20 | 20 |
|
| 21 | +def disk_encryption_target_format(value): |
| 22 | + """Space seperated target disks to be encrypted. Values can either be OsDisk or TemporaryDisk""" |
| 23 | + from azext.batch.models import DiskEncryptionTarget |
| 24 | + if value == 'OsDisk': |
| 25 | + return DiskEncryptionTarget.os_disk |
| 26 | + if value == 'TemporaryDisk': |
| 27 | + return DiskEncryptionTarget.temporary_disk |
| 28 | + message = 'Argument {} is not a valid disk_encryption_target' |
| 29 | + raise ValueError(message.format(value)) |
| 30 | + |
| 31 | + |
21 | 32 | def create_pool(client, template=None, parameters=None, json_file=None, id=None, vm_size=None, # pylint:disable=too-many-arguments, too-many-locals |
22 | 33 | target_dedicated_nodes=None, target_low_priority_nodes=None, auto_scale_formula=None, # pylint: disable=redefined-builtin |
23 | | - enable_inter_node_communication=False, os_family=None, image=None, |
| 34 | + enable_inter_node_communication=False, os_family=None, image=None, disk_encryption_targets=None, |
24 | 35 | node_agent_sku_id=None, resize_timeout=None, start_task_command_line=None, |
25 | 36 | start_task_resource_files=None, start_task_wait_for_success=False, application_licenses=None, |
26 | 37 | certificate_references=None, application_package_references=None, metadata=None): |
27 | 38 | # pylint: disable=too-many-branches, too-many-statements |
28 | 39 | from azext.batch.errors import MissingParameterValue |
29 | 40 | from azext.batch.models import ( |
30 | 41 | PoolAddOptions, StartTask, ImageReference, |
31 | | - CloudServiceConfiguration, VirtualMachineConfiguration) |
| 42 | + CloudServiceConfiguration, VirtualMachineConfiguration, |
| 43 | + DiskEncryptionConfiguration) |
32 | 44 | if template or json_file: |
33 | 45 | if template: |
34 | 46 | json_obj = None |
@@ -81,6 +93,13 @@ def create_pool(client, template=None, parameters=None, json_file=None, id=None, |
81 | 93 | pool.virtual_machine_configuration = VirtualMachineConfiguration( |
82 | 94 | image_reference=ImageReference(publisher=publisher, offer=offer, sku=sku, version=version), |
83 | 95 | node_agent_sku_id=node_agent_sku_id) |
| 96 | + if disk_encryption_targets: |
| 97 | + targets = disk_encryption_targets.split(' ') |
| 98 | + parsed_targets = [] |
| 99 | + for target in targets: |
| 100 | + parsed_targets.append( |
| 101 | + disk_encryption_target_format(target)) |
| 102 | + pool.virtual_machine_configuration.disk_configuration = DiskEncryptionConfiguration(targets=parsed_targets) |
84 | 103 | except ValueError: |
85 | 104 | if '/' not in image: |
86 | 105 | message = ("Incorrect format for VM image. Should be in the format: \n" |
|
0 commit comments