Skip to content

Commit

Permalink
try to resolve linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandido committed Jul 31, 2024
1 parent a0e4588 commit 4582dc5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/vm-repair/azext_vm_repair/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def validate_create(cmd, namespace):
if namespace.encrypt_recovery_key:
if not namespace.unlock_encrypted_vm:
raise CLIError('Recovery password is provided in the argument, but unlock_encypted_vm is not passed. Rerun command adding --unlock_encypted_vm.')

if namespace.enable_nested:
if is_linux:
raise CLIError('Nested VM is not supported for Linux VM')
Expand Down Expand Up @@ -433,4 +433,4 @@ def validate_repair_and_restore(cmd, namespace):

# Validate repair run command
source_vm = _validate_and_get_vm(cmd, namespace.resource_group_name, namespace.vm_name)
is_linux = _is_linux_os(source_vm)
is_linux = _is_linux_os(source_vm)
6 changes: 3 additions & 3 deletions src/vm-repair/azext_vm_repair/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ def reset_nic(cmd, vm_name, resource_group_name, yes=False):
vnet_resource_group = subnet_id_tokens[-7]
ipconfig_name = ip_config_object['name']
orig_ip_address = ip_config_object['privateIPAddress']
application_names= ""
applicationSecurityGroups= 'applicationSecurityGroups'
application_names = ""
applicationSecurityGroups = 'applicationSecurityGroups'
if applicationSecurityGroups in ip_config_object:
for item in ip_config_object[applicationSecurityGroups]:
application_id_tokens = item['id'].split('/')
Expand Down Expand Up @@ -663,7 +663,7 @@ def reset_nic(cmd, vm_name, resource_group_name, yes=False):
update_ip_command = 'az network nic ip-config update -g {g} --nic-name {nic} -n {config} --private-ip-address {ip}' \
.format(g=resource_group_name, nic=primary_nic_name, config=ipconfig_name, ip=swap_ip_address)
_call_az_command(update_ip_command)

# Wait for IP updated
wait_ip_update_command = 'az network nic ip-config wait --updated -g {g} --nic-name {nic}' \
.format(g=resource_group_name, nic=primary_nic_name)
Expand Down
12 changes: 6 additions & 6 deletions src/vm-repair/azext_vm_repair/repair_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def _fetch_compatible_windows_os_urn_v2(source_vm):
sku = source_vm.storage_profile.image_reference.sku
offer = source_vm.storage_profile.image_reference.offer
publisher = source_vm.storage_profile.image_reference.publisher
fetch_urn_command = 'az vm image list -s {sku} -f {offer} -p {publisher} -l {loc} --verbose --all --query "[?sku==\'{sku}\'].urn | reverse(sort(@))" -o json'.format(loc = location, sku = sku, offer = offer, publisher = publisher)
fetch_urn_command = 'az vm image list -s {sku} -f {offer} -p {publisher} -l {loc} --verbose --all --query "[?sku==\'{sku}\'].urn | reverse(sort(@))" -o json'.format(loc=location, sku=sku, offer=offer, publisher=publisher)
logger.info('Fetching compatible Windows OS images from gallery...')
urns = loads(_call_az_command(fetch_urn_command))

Expand Down Expand Up @@ -783,22 +783,22 @@ def _fetch_vm_security_profile_parameters(source_vm):
non_standard_security_type = _fetch_non_standard_security_type(source_vm)
if non_standard_security_type is None:
return create_repair_vm_command
create_repair_vm_command += ' --security-type {securityType}'.format(securityType = non_standard_security_type)
create_repair_vm_command += ' --security-type {securityType}'.format(securityType=non_standard_security_type)
if source_vm.security_profile.uefi_settings is not None:
if source_vm.security_profile.uefi_settings.secure_boot_enabled is not None:
create_repair_vm_command += ' --enable-secure-boot {enableSecureBoot}'.format(enableSecureBoot = source_vm.security_profile.uefi_settings.secure_boot_enabled)
create_repair_vm_command += ' --enable-secure-boot {enableSecureBoot}'.format(enableSecureBoot=source_vm.security_profile.uefi_settings.secure_boot_enabled)

if source_vm.security_profile.uefi_settings.v_tpm_enabled is not None:
create_repair_vm_command += ' --enable-vtpm {enableVTpm}'.format(enableVTpm = source_vm.security_profile.uefi_settings.v_tpm_enabled)
create_repair_vm_command += ' --enable-vtpm {enableVTpm}'.format(enableVTpm=source_vm.security_profile.uefi_settings.v_tpm_enabled)
return create_repair_vm_command


def _fetch_osdisk_security_profile_parameters(source_vm):
create_repair_vm_command = ''
if source_vm.storage_profile.os_disk.managed_disk is not None and source_vm.storage_profile.os_disk.managed_disk.security_profile is not None:
create_repair_vm_command += ' --os-disk-security-encryption-type {val}'.format(val = source_vm.storage_profile.os_disk.managed_disk.security_profile.security_encryption_type)
create_repair_vm_command += ' --os-disk-security-encryption-type {val}'.format(val=source_vm.storage_profile.os_disk.managed_disk.security_profile.security_encryption_type)

if source_vm.storage_profile.os_disk.managed_disk.security_profile.disk_encryption_set is not None:
create_repair_vm_command += ' --os-disk-secure-vm-disk-encryption-set {val}'.format(val = source_vm.storage_profile.os_disk.managed_disk.security_profile.disk_encryption_set.id)
create_repair_vm_command += ' --os-disk-secure-vm-disk-encryption-set {val}'.format(val=source_vm.storage_profile.os_disk.managed_disk.security_profile.disk_encryption_set.id)

return create_repair_vm_command

0 comments on commit 4582dc5

Please sign in to comment.