From 00bb4eb77613321cf6bef591193023b21b41038c Mon Sep 17 00:00:00 2001 From: Halley de Souza Date: Mon, 18 Sep 2023 17:39:21 +0200 Subject: [PATCH] patch for issues/22. --- gce_rescue/gce.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gce_rescue/gce.py b/gce_rescue/gce.py index 0884a1a..aac89d2 100644 --- a/gce_rescue/gce.py +++ b/gce_rescue/gce.py @@ -13,8 +13,10 @@ # limitations under the License. """ Initilization Instance() with VM information. """ +import sys from googleapiclient.discovery import Resource +from googleapiclient.errors import HttpError from dataclasses import dataclass, field from typing import Dict, List, Union @@ -42,7 +44,6 @@ def get_instance_info( **project_data, instance = name).execute() - def guess_guest(data: Dict) -> str: """Determined which Guest OS Family is being used and select a different OS for recovery disk. @@ -113,12 +114,16 @@ def __post_init__(self): test_mode=self.test_mode, **self.project_data ) - self.compute = check.compute - self.project = check.adc_project - self.data = get_instance_info( + try: + self.compute = check.compute + self.project = check.adc_project + self.data = get_instance_info( compute=self.compute, name=self.name, project_data=self.project_data) + except HttpError as e: + print(e.reason) + sys.exit(1) self._rescue_mode_status = validate_instance_mode(self.data) self.ts = self._rescue_mode_status['ts']