示例#1
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.
    """
        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
示例#2
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