Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions libcloudforensics/providers/gcp/internal/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,26 @@ def GetPowerState(self) -> str:
"""
return str(self.GetOperation()['status'])

def Suspend(self) -> None:
"""
Suspends the instance.

Raises:
errors.InstanceStateChangeError: If the Suspend operation is unsuccessful
"""

logger.info('Suspending instance "{0:s}"'.format(self.name))
try:
gce_instance_client = self.GceApi().instances() # pylint: disable=no-member
request = gce_instance_client.suspend(
project=self.project_id, instance=self.name, zone=self.zone)
response = request.execute()
self.BlockOperation(response, zone=self.zone)
except HttpError as exception:
raise errors.InstanceStateChangeError(
'Could not suspend instance: {0:s}'.format(str(exception)), __name__)


def Stop(self) -> None:
"""
Stops the instance.
Expand Down
Loading