예제 #1
0
    def compute(self) -> compute_module.GoogleCloudCompute:
        """Get a GoogleCloudCompute object for the project.

    Returns:
      GoogleCloudCompute: Object that represents Google Cloud Compute Engine.
    """

        if self._compute:
            return self._compute
        self._compute = compute_module.GoogleCloudCompute(  # type: ignore
            self.project_id, self.default_zone)
        return self._compute  # type: ignore
예제 #2
0
def DeleteInstance(args: 'argparse.Namespace') -> None:
  """Deletes a GCE instance.

  Args:
    args (argparse.Namespace): Arguments from ArgumentParser.
  """

  compute_client = gcp_compute.GoogleCloudCompute(args.project)
  instance = compute_client.GetInstance(instance_name=args.instance_name)
  instance.Delete(delete_disks=args.delete_disks)

  print('Instance deleted.')