示例#1
0
    def Modify(self, args, existing):
        replacement = super(UpdateAlpha, self).Modify(args, existing)

        if args.connection_draining_timeout is not None:
            replacement.connectionDraining = self.messages.ConnectionDraining(
                drainingTimeoutSec=args.connection_draining_timeout)

        if args.iap:
            replacement.iap = backend_services_utils.GetIAP(
                args,
                self.messages,
                existing_iap_settings=getattr(existing, 'iap', None))
            if (replacement.iap.enabled and replacement.protocol is not self.
                    messages.BackendService.ProtocolValueValuesEnum.HTTPS):
                log.warning(
                    'IAP has been enabled for a backend service that does '
                    'not use HTTPS. Data sent from the Load Balancer to your '
                    'VM will not be encrypted.')

        cache_key_policy = self.messages.CacheKeyPolicy()
        if (replacement.cdnPolicy is not None
                and replacement.cdnPolicy.cacheKeyPolicy is not None):
            cache_key_policy = replacement.cdnPolicy.cacheKeyPolicy
        backend_services_utils.ValidateCacheKeyPolicyArgs(args)
        backend_services_utils.UpdateCacheKeyPolicy(args, cache_key_policy)
        if (args.cache_key_include_protocol is not None
                or args.cache_key_include_host is not None
                or args.cache_key_include_query_string is not None
                or args.cache_key_query_string_whitelist is not None
                or args.cache_key_query_string_blacklist is not None):
            replacement.cdnPolicy = self.messages.BackendServiceCdnPolicy(
                cacheKeyPolicy=cache_key_policy)

        return replacement
示例#2
0
 def _ApplyCustomCacheKeysArgs(self, args, backend_service):
     cache_key_policy = self.messages.CacheKeyPolicy()
     backend_services_utils.ValidateCacheKeyPolicyArgs(args)
     backend_services_utils.UpdateCacheKeyPolicy(args, cache_key_policy)
     if (not args.cache_key_include_host
             or not args.cache_key_include_protocol
             or not args.cache_key_include_query_string
             or args.cache_key_query_string_blacklist is not None
             or args.cache_key_query_string_whitelist is not None):
         backend_service.cdnPolicy = self.messages.BackendServiceCdnPolicy(
             cacheKeyPolicy=cache_key_policy)
示例#3
0
 def _ApplyCustomCacheKeysArgs(self, args, existing, replacement):
     cache_key_policy = self.messages.CacheKeyPolicy()
     if (replacement.cdnPolicy is not None
             and replacement.cdnPolicy.cacheKeyPolicy is not None):
         cache_key_policy = replacement.cdnPolicy.cacheKeyPolicy
     backend_services_utils.ValidateCacheKeyPolicyArgs(args)
     backend_services_utils.UpdateCacheKeyPolicy(args, cache_key_policy)
     if (args.cache_key_include_protocol is not None
             or args.cache_key_include_host is not None
             or args.cache_key_include_query_string is not None
             or args.cache_key_query_string_whitelist is not None
             or args.cache_key_query_string_blacklist is not None):
         replacement.cdnPolicy = self.messages.BackendServiceCdnPolicy(
             cacheKeyPolicy=cache_key_policy)
示例#4
0
    def CreateGlobalRequests(self, args):
        if args.load_balancing_scheme == 'INTERNAL':
            raise exceptions.ToolException(
                'Must specify --region for internal load balancer.')
        backend_service = self._CreateBackendService(args)
        if args.connection_draining_timeout is not None:
            backend_service.connectionDraining = self.messages.ConnectionDraining(
                drainingTimeoutSec=args.connection_draining_timeout)

        if args.enable_cdn:
            backend_service.enableCDN = args.enable_cdn

        cache_key_policy = self.messages.CacheKeyPolicy()
        backend_services_utils.ValidateCacheKeyPolicyArgs(args)
        backend_services_utils.UpdateCacheKeyPolicy(args, cache_key_policy)
        if (not args.cache_key_include_host
                or not args.cache_key_include_protocol
                or not args.cache_key_include_query_string
                or args.cache_key_query_string_blacklist is not None
                or args.cache_key_query_string_whitelist is not None):
            backend_service.cdnPolicy = self.messages.BackendServiceCdnPolicy(
                cacheKeyPolicy=cache_key_policy)

        if args.session_affinity is not None:
            backend_service.sessionAffinity = (
                self.messages.BackendService.SessionAffinityValueValuesEnum(
                    args.session_affinity))
        if args.affinity_cookie_ttl is not None:
            backend_service.affinityCookieTtlSec = args.affinity_cookie_ttl

        if args.iap:
            backend_service.iap = backend_services_utils.GetIAP(
                args, self.messages)
            if (backend_service.iap.enabled
                    and backend_service.protocol is not self.messages.
                    BackendService.ProtocolValueValuesEnum.HTTPS):
                log.warning(
                    'IAP has been enabled for a backend service that does '
                    'not use HTTPS. Data sent from the Load Balancer to your '
                    'VM will not be encrypted.')

        request = self.messages.ComputeBackendServicesInsertRequest(
            backendService=backend_service, project=self.project)

        return [request]
    def CreateGlobalRequests(self, args, backend_services_ref):
        if args.load_balancing_scheme == 'INTERNAL':
            raise exceptions.ToolException(
                'Must specify --region for internal load balancer.')
        backend_service = self._CreateBackendService(args,
                                                     backend_services_ref)
        if args.connection_draining_timeout is not None:
            backend_service.connectionDraining = self.messages.ConnectionDraining(
                drainingTimeoutSec=args.connection_draining_timeout)

        if args.enable_cdn:
            backend_service.enableCDN = args.enable_cdn

        cache_key_policy = self.messages.CacheKeyPolicy()
        backend_services_utils.ValidateCacheKeyPolicyArgs(args)
        backend_services_utils.UpdateCacheKeyPolicy(args, cache_key_policy)
        if (not args.cache_key_include_host
                or not args.cache_key_include_protocol
                or not args.cache_key_include_query_string
                or args.cache_key_query_string_blacklist is not None
                or args.cache_key_query_string_whitelist is not None):
            backend_service.cdnPolicy = self.messages.BackendServiceCdnPolicy(
                cacheKeyPolicy=cache_key_policy)

        if args.session_affinity is not None:
            backend_service.sessionAffinity = (
                self.messages.BackendService.SessionAffinityValueValuesEnum(
                    args.session_affinity))
        if args.affinity_cookie_ttl is not None:
            backend_service.affinityCookieTtlSec = args.affinity_cookie_ttl

        self._ApplyIapArgs(args.iap, backend_service)

        request = self.messages.ComputeBackendServicesInsertRequest(
            backendService=backend_service, project=self.project)

        return [request]
  def Modify(self, args, existing):
    replacement = super(UpdateAlpha, self).Modify(args, existing)

    if args.connection_draining_timeout is not None:
      replacement.connectionDraining = self.messages.ConnectionDraining(
          drainingTimeoutSec=args.connection_draining_timeout)

    self._ApplyIapArgs(args.iap, existing, replacement)

    cache_key_policy = self.messages.CacheKeyPolicy()
    if (replacement.cdnPolicy is not None and
        replacement.cdnPolicy.cacheKeyPolicy is not None):
      cache_key_policy = replacement.cdnPolicy.cacheKeyPolicy
    backend_services_utils.ValidateCacheKeyPolicyArgs(args)
    backend_services_utils.UpdateCacheKeyPolicy(args, cache_key_policy)
    if (args.cache_key_include_protocol is not None or
        args.cache_key_include_host is not None or
        args.cache_key_include_query_string is not None or
        args.cache_key_query_string_whitelist is not None or
        args.cache_key_query_string_blacklist is not None):
      replacement.cdnPolicy = self.messages.BackendServiceCdnPolicy(
          cacheKeyPolicy=cache_key_policy)

    return replacement