File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
libcloudforensics/providers/gcp/internal Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1794,6 +1794,26 @@ def GetPowerState(self) -> str:
17941794 """
17951795 return str (self .GetOperation ()['status' ])
17961796
1797+ def Suspend (self ) -> None :
1798+ """
1799+ Suspends the instance.
1800+
1801+ Raises:
1802+ errors.InstanceStateChangeError: If the Suspend operation is unsuccessful
1803+ """
1804+
1805+ logger .info ('Suspending instance "{0:s}"' .format (self .name ))
1806+ try :
1807+ gce_instance_client = self .GceApi ().instances () # pylint: disable=no-member
1808+ request = gce_instance_client .suspend (
1809+ project = self .project_id , instance = self .name , zone = self .zone )
1810+ response = request .execute ()
1811+ self .BlockOperation (response , zone = self .zone )
1812+ except HttpError as exception :
1813+ raise errors .InstanceStateChangeError (
1814+ 'Could not suspend instance: {0:s}' .format (str (exception )), __name__ )
1815+
1816+
17971817 def Stop (self ) -> None :
17981818 """
17991819 Stops the instance.
You can’t perform that action at this time.
0 commit comments