Пример #1
0
    def Run(self, args):
        holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
        client = holder.client

        health_checks_utils.CheckProtocolAgnosticArgs(args)

        args_unset = not (args.port or args.check_interval or args.timeout
                          or args.healthy_threshold or args.unhealthy_threshold
                          or args.proxy_header)
        if (args.description is None and args.request is None
                and args.response is None and args.port_name is None
                and args_unset):
            raise exceptions.ToolException(
                'At least one property must be modified.')

        health_check_ref = self.HEALTH_CHECK_ARG.ResolveAsResource(
            args, holder.resources)
        get_request = self.GetGetRequest(client, health_check_ref)

        objects = client.MakeRequests([get_request])

        new_object = self.Modify(client, args, objects[0])

        # If existing object is equal to the proposed object or if
        # Modify() returns None, then there is no work to be done, so we
        # print the resource and return.
        if objects[0] == new_object:
            log.status.Print(
                'No change requested; skipping update for [{0}].'.format(
                    objects[0].name))
            return objects

        return client.MakeRequests(
            [self.GetSetRequest(client, health_check_ref, new_object)])
Пример #2
0
    def ValidateArgs(self, args):
        health_checks_utils.CheckProtocolAgnosticArgs(args)

        args_unset = not (args.port or args.request_path or args.check_interval
                          or args.timeout or args.healthy_threshold
                          or args.unhealthy_threshold or args.proxy_header)
        if (args.description is None and args.host is None
                and args.port_name is None and args_unset):
            raise exceptions.ToolException(
                'At least one property must be modified.')
Пример #3
0
def _ValidateArgs(args):
  """Validates given args and raises exception if any args are invalid."""
  health_checks_utils.CheckProtocolAgnosticArgs(args)

  args_unset = not (args.port or args.check_interval or args.timeout or
                    args.healthy_threshold or args.unhealthy_threshold or
                    args.proxy_header or args.use_serving_port)
  if (args.description is None and args.request is None and
      args.response is None and args.port_name is None and args_unset):
    raise exceptions.ToolException('At least one property must be modified.')
Пример #4
0
  def Run(self, args):
    """Issues requests necessary to update UDP Health Checks."""
    holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
    client = holder.client

    health_checks_utils.CheckProtocolAgnosticArgs(args)

    args_unset = not (args.port
                      or args.check_interval
                      or args.timeout
                      or args.healthy_threshold
                      or args.unhealthy_threshold
                      or args.request
                      or args.response)
    if args.description is None and args.port_name is None and args_unset:
      raise exceptions.ArgumentError('At least one property must be modified.')

    # Check that request and response are not empty. It is acceptable for it to
    # be None.
    if args.request is not None and not args.request:
      raise exceptions.ArgumentError(
          '"request" field for UDP can not be empty.')
    if args.response is not None and not args.response:
      raise exceptions.ArgumentError(
          '"response" field for UDP can not be empty.')

    health_check_ref = self.HEALTH_CHECK_ARG.ResolveAsResource(
        args, holder.resources)
    if health_checks_utils.IsRegionalHealthCheckRef(health_check_ref):
      get_request = self._GetRegionalGetRequest(client, health_check_ref)
    else:
      get_request = self._GetGetRequest(client, health_check_ref)

    objects = client.MakeRequests([get_request])

    new_object = self.Modify(client, args, objects[0])

    # If existing object is equal to the proposed object or if
    # Modify() returns None, then there is no work to be done, so we
    # print the resource and return.
    if objects[0] == new_object:
      log.status.Print(
          'No change requested; skipping update for [{0}].'.format(
              objects[0].name))
      return objects

    if health_checks_utils.IsRegionalHealthCheckRef(health_check_ref):
      set_request = self._GetRegionalSetRequest(client, health_check_ref,
                                                new_object)
    else:
      set_request = self._GetSetRequest(client, health_check_ref, new_object)

    return client.MakeRequests([set_request])
Пример #5
0
    def Run(self, args):
        health_checks_utils.CheckProtocolAgnosticArgs(args)

        args_unset = not (args.port or args.check_interval or args.timeout or
                          args.healthy_threshold or args.unhealthy_threshold)
        if (args.description is None and args.request is None
                and args.response is None and args.port_name is None
                and args_unset):
            raise exceptions.ToolException(
                'At least one property must be modified.')

        return super(Update, self).Run(args)
Пример #6
0
def _ValidateArgs(args, include_log_config):
  """Validates given args and raises exception if any args are invalid."""
  health_checks_utils.CheckProtocolAgnosticArgs(args)

  args_unset = not (args.port or args.check_interval or args.timeout or
                    args.healthy_threshold or args.unhealthy_threshold or
                    args.use_serving_port)

  if include_log_config:
    args_unset = (args.enable_logging is None and args_unset)

  if (args.description is None and args.grpc_service_name is None and
      args_unset):
    raise exceptions.ArgumentError('At least one property must be modified.')
Пример #7
0
def _Run(args, holder, include_l7_internal_load_balancing):
    """Issues requests necessary to update the HTTP2 Health Checks."""
    client = holder.client

    health_checks_utils.CheckProtocolAgnosticArgs(args)

    args_unset = not (args.port or args.request_path or args.check_interval
                      or args.timeout or args.healthy_threshold
                      or args.unhealthy_threshold or args.proxy_header
                      or args.use_serving_port)
    if (args.description is None and args.host is None
            and args.response is None and args.port_name is None
            and args_unset):
        raise exceptions.ToolException(
            'At least one property must be modified.')

    health_check_arg = flags.HealthCheckArgument(
        'HTTP2',
        include_l7_internal_load_balancing=include_l7_internal_load_balancing)
    health_check_ref = health_check_arg.ResolveAsResource(
        args, holder.resources)
    if health_checks_utils.IsRegionalHealthCheckRef(health_check_ref):
        get_request = _GetRegionalGetRequest(client, health_check_ref)
    else:
        get_request = _GetGetRequest(client, health_check_ref)

    objects = client.MakeRequests([get_request])

    new_object = _Modify(client, args, objects[0])

    # If existing object is equal to the proposed object or if
    # _Modify() returns None, then there is no work to be done, so we
    # print the resource and return.
    if objects[0] == new_object:
        log.status.Print(
            'No change requested; skipping update for [{0}].'.format(
                objects[0].name))
        return objects

    if health_checks_utils.IsRegionalHealthCheckRef(health_check_ref):
        set_request = _GetRegionalSetRequest(client, health_check_ref,
                                             new_object)
    else:
        set_request = _GetSetRequest(client, health_check_ref, new_object)

    return client.MakeRequests([set_request])
Пример #8
0
    def Run(self, args):
        health_checks_utils.CheckProtocolAgnosticArgs(args)

        args_unset = not (args.port or args.check_interval or args.timeout
                          or args.healthy_threshold or args.unhealthy_threshold
                          or args.request or args.response)
        if args.description is None and args.port_name is None and args_unset:
            raise exceptions.ToolException(
                'At least one property must be modified.')

        # Check that request and response are not empty. It is acceptable for it to
        # be None.
        if args.request is not None and not args.request:
            raise exceptions.ToolException(
                '"request" field for UDP can not be empty.')
        if args.response is not None and not args.response:
            raise exceptions.ToolException(
                '"response" field for UDP can not be empty.')

        return super(Update, self).Run(args)
def _ValidateArgs(args,
                  include_log_config,
                  include_weighted_load_balancing=False):
    """Validates given args and raises exception if any args are invalid."""
    health_checks_utils.CheckProtocolAgnosticArgs(args)

    args_unset = not (args.port or args.request_path or args.check_interval
                      or args.timeout or args.healthy_threshold
                      or args.unhealthy_threshold or args.proxy_header
                      or args.use_serving_port)

    if include_log_config:
        args_unset = (args.enable_logging is None and args_unset)

    weight_report_mode_modified = False
    if include_weighted_load_balancing and args.IsSpecified(
            'weight_report_mode'):
        weight_report_mode_modified = True

    if (args.description is None and args.host is None
            and args.response is None and args.port_name is None
            and not weight_report_mode_modified and args_unset):
        raise exceptions.ArgumentError(
            'At least one property must be modified.')