Esempio n. 1
0
    def Run(self, args):
        """Run 'instance-groups list-services'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      the API response.

    Raises:
      HttpException: A http error response was received while executing api
          request.
      ToolException: An error other than http error occured while executing
          the command.
    """
        log.warn('Please use instead [gcloud compute instance-groups '
                 'unmanaged get-named-ports].')
        client = self.context['instanceGroupsClient']
        project = properties.VALUES.core.project.Get(required=True)
        get_request = client.getService(project=project,
                                        zone=args.zone,
                                        resourceView=args.name)

        try:
            response = get_request.execute()
            util.PrettyPrint(response)
            return response
        except errors.HttpError as error:
            raise exceptions.HttpException(util.GetError(error))
        except errors.Error as error:
            raise exceptions.ToolException(error)
Esempio n. 2
0
    def Run(self, args):
        """Run 'managed-instance-groups describe'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Raises:
      HttpException: A http error response was received while executing api
          request.
      ToolException: An error other than http error occured while executing
          the command.

    Returns:
      response: the response returned by the service, expected to be a
          zonal operation resource
    """
        log.warn('Please use instead [gcloud compute instance-groups '
                 'managed describe].')
        client = self.context['managedInstanceGroupsClient']
        project = properties.VALUES.core.project.Get(required=True)

        request = client.instanceGroupManagers().get(
            project=project, zone=args.zone, instanceGroupManager=args.group)

        try:
            response = request.execute()
            util.PrettyPrint(response, args.format or 'yaml')
            return response
        except errors.HttpError as error:
            raise exceptions.HttpException(util.GetError(error))
        except errors.Error as error:
            raise exceptions.ToolException(error)
Esempio n. 3
0
  def Run(self, args):
    """Run 'instance group get'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      The object representing the instance group.

    Raises:
      HttpException: A http error response was received while executing api
          request.
      ToolException: An error other than http error occured while executing
          the command.
    """
    log.warn('Please use instead [gcloud compute instance-groups '
             'unmanaged describe].')
    client = self.context['instanceGroupsClient']
    project = properties.VALUES.core.project.Get(required=True)

    request = client.get(
        project=project, zone=args.zone, resourceView=args.name)

    try:
      response = request.execute()
      if not args.format:
        util.PrettyPrint(response, 'yaml')
      return response
    except errors.HttpError as error:
      raise exceptions.HttpException(util.GetError(error))
    except errors.Error as error:
      raise exceptions.ToolException(error)
Esempio n. 4
0
    def Run(self, args):
        """Run 'replicapool get'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Raises:
      HttpException: A http error response was received while executing api
          request.
      ToolException: An error other than http error occured while executing
          the command.

    Returns:
      The get API's response
    """
        client = self.context['replicapool']
        project = properties.VALUES.core.project.Get(required=True)

        request = client.pools().get(projectName=project,
                                     zone=args.zone,
                                     poolName=args.pool)

        try:
            response = request.execute()
            util.PrettyPrint(response, args.format or 'yaml')
            return response
        except errors.HttpError as error:
            raise exceptions.HttpException(util.GetError(error))
        except errors.Error as error:
            raise exceptions.ToolException(error)
Esempio n. 5
0
    def Run(self, args):
        """Run 'resourceviews get'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      The object representing the resource views.

    Raises:
      HttpException: A http error response was received while executing api
          request.
      ToolException: An error other than http error occured while executing
          the command.
    """
        zone_views_client = self.context['zoneViewsClient']
        region_views_client = self.context['regionViewsClient']

        project = properties.VALUES.core.project.Get(required=True)

        if 'v1beta1' in args.api_version:
            if args.region:
                request = region_views_client.get(projectName=project,
                                                  region=args.region,
                                                  resourceViewName=args.name)
            else:
                request = zone_views_client.get(projectName=project,
                                                zone=args.zone,
                                                resourceViewName=args.name)
        else:
            request = zone_views_client.get(project=project,
                                            zone=args.zone,
                                            resourceView=args.name)

        try:
            response = request.execute()
            if not args.format:
                util.PrettyPrint(response, 'yaml')
            return response
        except errors.HttpError as error:
            raise exceptions.HttpException(util.GetError(error))
        except errors.Error as error:
            raise exceptions.ToolException(error)