Skip to content

Commit

Permalink
Patch files for rescuing Windows VMs
Browse files Browse the repository at this point in the history
  • Loading branch information
halleysouza committed Jul 19, 2024
1 parent 4d32bd2 commit 83ab7d6
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
65 changes: 65 additions & 0 deletions 07192024-windows.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/gce_rescue/config.py b/gce_rescue/config.py
index 3f25983..c1319ad 100644
--- a/gce_rescue/config.py
+++ b/gce_rescue/config.py
@@ -26,14 +26,16 @@ config = {
'debug': False,
'skip-snapshot': False,
'startup-script-file': os.path.join(dirname, 'startup-script.txt'),
+
+ # Temporary workaround for rescue Windows machine
'source_guests': {
'x86_64':[
- 'projects/debian-cloud/global/images/family/debian-11',
- 'projects/rocky-linux-cloud/global/images/family/rocky-linux-9'
+ 'projects/windows-cloud/global/images/family/windows-2016',
+ 'projects/windows-cloud/global/images/family/windows-2016'
],
'arm64':[
- 'projects/debian-cloud/global/images/family/debian-11-arm64',
- 'projects/rocky-linux-cloud/global/images/family/rocky-linux-9-arm64'
+ 'projects/windows-cloud/global/images/family/windows-2016',
+ 'projects/windows-cloud/global/images/family/windows-2016'
]
}
}
diff --git a/gce_rescue/tasks/actions.py b/gce_rescue/tasks/actions.py
index 7d3c453..dfd9f36 100644
--- a/gce_rescue/tasks/actions.py
+++ b/gce_rescue/tasks/actions.py
@@ -122,6 +122,7 @@ def call_tasks(vm: Instance, action: str) -> None:
""" Loop tasks dict and execute """
tasks = _list_tasks(vm = vm, action = action)
async_backup_thread = None
+
if action == 'set_rescue_mode':
if get_config('skip-snapshot'):
_logger.info(f'Skipping snapshot backup.')
@@ -135,6 +136,11 @@ def call_tasks(vm: Instance, action: str) -> None:

for task in tasks:
execute = task['name']
+
+ # Temporary workaround for Windows rescue boot disk
+ if execute == 'restore_metadata_items' or execute == "set_metadata":
+ continue
+
args = task['args'][0]

execute(**args)
diff --git a/gce_rescue/tasks/metadata.py b/gce_rescue/tasks/metadata.py
index 8ac1821..f7a639f 100644
--- a/gce_rescue/tasks/metadata.py
+++ b/gce_rescue/tasks/metadata.py
@@ -70,8 +70,9 @@ def restore_metadata_items(vm, remove_rescue_mode: bool = False) -> Dict:
_logger.info('Restoring original metadata...')

# gce-rescue/issues/21 - continue after wait period timed out
- if not remove_rescue_mode:
- wait_for_os_boot(vm)
+ # Commented as temporary patch for rescuing Windows images
+ #if not remove_rescue_mode:
+ # wait_for_os_boot(vm)

operation = vm.compute.instances().setMetadata(
**vm.project_data,
10 changes: 6 additions & 4 deletions gce_rescue/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
'debug': False,
'skip-snapshot': False,
'startup-script-file': os.path.join(dirname, 'startup-script.txt'),

# Temporary workaround for rescue Windows machine
'source_guests': {
'x86_64':[
'projects/debian-cloud/global/images/family/debian-11',
'projects/rocky-linux-cloud/global/images/family/rocky-linux-9'
'projects/windows-cloud/global/images/family/windows-2016',
'projects/windows-cloud/global/images/family/windows-2016'
],
'arm64':[
'projects/debian-cloud/global/images/family/debian-11-arm64',
'projects/rocky-linux-cloud/global/images/family/rocky-linux-9-arm64'
'projects/windows-cloud/global/images/family/windows-2016',
'projects/windows-cloud/global/images/family/windows-2016'
]
}
}
Expand Down
6 changes: 6 additions & 0 deletions gce_rescue/tasks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def call_tasks(vm: Instance, action: str) -> None:
""" Loop tasks dict and execute """
tasks = _list_tasks(vm = vm, action = action)
async_backup_thread = None

if action == 'set_rescue_mode':
if get_config('skip-snapshot'):
_logger.info(f'Skipping snapshot backup.')
Expand All @@ -135,6 +136,11 @@ def call_tasks(vm: Instance, action: str) -> None:

for task in tasks:
execute = task['name']

# Temporary workaround for Windows rescue boot disk
if execute == 'restore_metadata_items' or execute == "set_metadata":
continue

args = task['args'][0]

execute(**args)
Expand Down
5 changes: 3 additions & 2 deletions gce_rescue/tasks/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ def restore_metadata_items(vm, remove_rescue_mode: bool = False) -> Dict:
_logger.info('Restoring original metadata...')

# gce-rescue/issues/21 - continue after wait period timed out
if not remove_rescue_mode:
wait_for_os_boot(vm)
# Commented as temporary patch for rescuing Windows images
#if not remove_rescue_mode:
# wait_for_os_boot(vm)

operation = vm.compute.instances().setMetadata(
**vm.project_data,
Expand Down

0 comments on commit 83ab7d6

Please sign in to comment.