コード例 #1
0
 def Http(**kwargs):
     # TODO(user) This check is required due to tests that use interactive
     # mode. Remove this check when all tests are converted to use cli mode.
     if hasattr(args, 'trace_token'):
         return core_cli.Http(cmd_path=command_path_string,
                              trace_token=args.trace_token,
                              **kwargs)
     else:
         return core_cli.Http(cmd_path=command_path_string,
                              **kwargs)
コード例 #2
0
ファイル: __init__.py プロジェクト: harshilasu/GraphicMelon
    def Filter(self, context, args):
        """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """

        api_server = properties.VALUES.core.api_host.Get()
        api_version = args.api_version
        if api_version is None:
            api_version = 'v1beta1'

        timeout = None
        if args.http_timeout is not None:
            timeout = float(args.http_timeout)
        http = cli.Http(timeout=timeout)
        if args.log_http is not None:
            httplib2.debuglevel = 4

        dns = self.LoadApi(http, api_server, api_version, args)
        context['dns'] = dns

        return context
コード例 #3
0
    def Filter(self, context, args):
        http = cli.Http()
        core_values = properties.VALUES.core
        compute_values = properties.VALUES.compute
        context['http'] = http
        context['project'] = core_values.project.Get(required=True)

        for api, param, prop in (('compute', 'project', core_values.project),
                                 ('resourceviews', 'projectName',
                                  core_values.project), ('compute', 'zone',
                                                         compute_values.zone),
                                 ('resourceviews', 'zone',
                                  compute_values.zone),
                                 ('compute', 'region', compute_values.region),
                                 ('resourceviews', 'region',
                                  compute_values.region)):
            resources.SetParamDefault(api=api,
                                      collection=None,
                                      param=param,
                                      resolver=resolvers.FromProperty(prop))

        api_host = properties.VALUES.core.api_host.Get()
        v1_version_component = 'compute/v1/'

        compute_url = urlparse.urljoin(api_host, v1_version_component)
        context['batch-url'] = urlparse.urljoin(api_host, 'batch')

        v1_compute = compute_v1_client.ComputeV1(url=compute_url,
                                                 get_credentials=False,
                                                 http=http)
        context['compute'] = v1_compute
        context['resources'] = resources.REGISTRY.CloneAndSwitchAPIs(
            v1_compute)
コード例 #4
0
ファイル: backend.py プロジェクト: bopopescu/brydzenie
    def Http(**kwargs):
      # Possibly override timeout, making sure to leave kwargs[timeout]
      # undefined (as opposed to None) if args.http_timout is not set.
      if args.http_timeout:
        kwargs['timeout'] = args.http_timeout

      return core_cli.Http(cmd_path=self.dotted_name,
                           trace_token=args.trace_token,
                           log_http=properties.VALUES.core.log_http.GetBool(),
                           **kwargs)
コード例 #5
0
ファイル: __init__.py プロジェクト: bopopescu/packmybot
    def Filter(self, context, args):
        """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """
        if args.zone is None:
            raise exceptions.ToolException('argument --zone is required')

        context['updater_api'] = updater_v1beta1.ReplicapoolupdaterV1beta1(
            get_credentials=False, http=cli.Http())
        context['updater_messages'] = replicapoolupdater_v1beta1_messages
        resources.SetParamDefault(api='compute',
                                  collection='instanceTemplates',
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapool',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapool',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        resources.SetParamDefault(api='resourceviews',
                                  collection=None,
                                  param='projectName',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='resourceviews',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        resources.SetParamDefault(api='replicapoolupdater',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapoolupdater',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        context['updater_resources'] = resources
        return context
コード例 #6
0
    def Filter(self, context, args):
        http = cli.Http()
        core_values = properties.VALUES.core
        compute_values = properties.VALUES.compute
        context['http'] = http
        context['project'] = core_values.project.Get(required=True)

        for api, param, prop in (('compute', 'project', core_values.project),
                                 ('resourceviews', 'projectName',
                                  core_values.project), ('compute', 'zone',
                                                         compute_values.zone),
                                 ('resourceviews', 'zone',
                                  compute_values.zone),
                                 ('compute', 'region', compute_values.region),
                                 ('resourceviews', 'region',
                                  compute_values.region)):
            resources.SetParamDefault(api=api,
                                      collection=None,
                                      param=param,
                                      resolver=resolvers.FromProperty(prop))

        utils.UpdateContextEndpointEntries(context, )
コード例 #7
0
    def Filter(self, context, args):
        """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """
        properties.VALUES.compute.zone.Get(required=True)
        context['updater_api'] = updater_v1beta1.ReplicapoolupdaterV1beta1(
            get_credentials=False, http=cli.Http())
        context['updater_messages'] = replicapoolupdater_v1beta1_messages
        resources.SetParamDefault(api='compute',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='compute',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        resources.SetParamDefault(api='replicapoolupdater',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapoolupdater',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        context['updater_resources'] = resources
        return context
コード例 #8
0
 def Http(**kwargs):
   return core_cli.Http(cmd_path=self.dotted_name,
                        trace_token=args.trace_token,
                        log_http=args.log_http,
                        timeout=args.http_timeout,
                        **kwargs)
コード例 #9
0
 def __init__(self, http=None):
     if not http:
         http = cli.Http(timeout=HTTP_TIMEOUT)
     self.client = storage_v1_client.StorageV1(http=http,
                                               get_credentials=False)