Skip to content

Commit 6c629e4

Browse files
committed
cleanup
1 parent 831276b commit 6c629e4

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/vm-repair/azext_vm_repair/_validators.py

+2
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ def _prompt_public_ip(namespace):
235235
except NoTTYException:
236236
raise ValidationError('Please specify the associate-public-ip parameter in non-interactive mode.')
237237

238+
238239
def _return_public_ip_name(namespace):
239240
return namespace.repair_vm_name + "PublicIP"
240241

242+
241243
def _classic_vm_exists(cmd, resource_group_name, vm_name):
242244
classic_vm_provider = 'Microsoft.ClassicCompute'
243245
vm_resource_type = 'virtualMachines'

src/vm-repair/azext_vm_repair/custom.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern
162162
# Adding the size to the command.
163163
create_repair_vm_command += ' --size {sku}'.format(sku=sku)
164164

165-
166165
# Setting the availability zone for the repair VM.
167-
# If the source VM has availability zones, the first one is chosen for the repair VM.
166+
# If the source VM has availability zones, the first one is chosen for the repair VM.
168167
if source_vm.zones:
169168
zone = source_vm.zones[0]
170169
create_repair_vm_command += ' --zone {zone}'.format(zone=zone)
@@ -271,7 +270,6 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern
271270
# Execute the command to attach the disk.
272271
_call_az_command(attach_disk_command)
273272

274-
275273
# Check if the source VM uses unmanaged disks.
276274
# If it does, the repair VM will also be created with unmanaged disks.
277275
else:
@@ -334,7 +332,6 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern
334332
.format(g=repair_group_name, disk_name=copy_disk_name, vm_name=repair_vm_name, uri=copy_disk_id)
335333
_call_az_command(attach_disk_command)
336334

337-
338335
# Check if the Nested Hyper-V needs to be enabled.
339336
# If it does, run the script to install Hyper-V and create the nested VM.
340337
if enable_nested:
@@ -436,6 +433,10 @@ def create(cmd, vm_name, resource_group_name, repair_password=None, repair_usern
436433
# This method is responsible for restoring the VM after repair
437434
def restore(cmd, vm_name, resource_group_name, disk_name=None, repair_vm_id=None, yes=False):
438435

436+
# Initialize repair VM variables to avoid "used before assignment" errors
437+
repair_vm_name = None
438+
repair_resource_group = None
439+
439440
# Create an instance of the command helper object to facilitate logging and status tracking.
440441
command = command_helper(logger, cmd, 'vm repair restore')
441442

@@ -605,8 +606,7 @@ def run(cmd, vm_name, resource_group_name, run_id=None, repair_vm_id=None, custo
605606

606607
logger.info('Running script on %s: %s', vm_string, repair_vm_name) # Log the VM on which the script is being run
607608

608-
609-
# Start the timer to measure the run-time of the script
609+
# Start the timer to measure the run-time of the script
610610
script_start_time = timeit.default_timer()
611611

612612
# Invoke the run command on the VM and capture the standard output and error
@@ -654,7 +654,6 @@ def run(cmd, vm_name, resource_group_name, run_id=None, repair_vm_id=None, custo
654654
# Set the overall command status to success
655655
command.set_status_success()
656656

657-
658657
except KeyboardInterrupt:
659658
command.error_stack_trace = traceback.format_exc()
660659
command.error_message = "Command interrupted by user input."

src/vm-repair/azext_vm_repair/repair_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def _get_function_param_dict(frame):
729729
return values
730730

731731

732-
def _unlock_encrypted_vm_run(repair_vm_name, repair_group_name, is_linux, encrypt_recovery_key = ""):
732+
def _unlock_encrypted_vm_run(repair_vm_name, repair_group_name, is_linux, encrypt_recovery_key=""):
733733
stdout, stderr = _unlock_singlepass_encrypted_disk(repair_vm_name, repair_group_name, is_linux, encrypt_recovery_key)
734734
logger.debug('Unlock script STDOUT:\n%s', stdout)
735735
if stderr:

0 commit comments

Comments
 (0)