How to use show_region method in tempest

Best Python code snippet using tempest_python

list.py

Source:list.py Github

copy

Full Screen

1# -*- coding: utf-8 -*- #2# Copyright 2017 Google LLC. All Rights Reserved.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15"""Command for listing available services."""16from __future__ import absolute_import17from __future__ import division18from __future__ import unicode_literals19from googlecloudsdk.api_lib.run import global_methods20from googlecloudsdk.calliope import base21from googlecloudsdk.command_lib.run import commands22from googlecloudsdk.command_lib.run import connection_context23from googlecloudsdk.command_lib.run import flags24from googlecloudsdk.command_lib.run import pretty_print25from googlecloudsdk.command_lib.run import resource_args26from googlecloudsdk.command_lib.run import serverless_operations27from googlecloudsdk.command_lib.util.concepts import concept_parsers28from googlecloudsdk.command_lib.util.concepts import presentation_specs29from googlecloudsdk.core import log30@base.ReleaseTracks(base.ReleaseTrack.BETA, base.ReleaseTrack.GA)31class List(commands.List):32 """List available services."""33 detailed_help = {34 'DESCRIPTION': """\35 {description}36 """,37 'EXAMPLES': """\38 To list available services:39 $ {command}40 """,41 }42 @classmethod43 def CommonArgs(cls, parser):44 # Flags specific to connecting to a cluster45 cluster_group = flags.GetClusterArgGroup(parser)46 namespace_presentation = presentation_specs.ResourcePresentationSpec(47 '--namespace',48 resource_args.GetNamespaceResourceSpec(),49 'Namespace to list services in.',50 required=True,51 prefixes=False)52 concept_parsers.ConceptParser(53 [namespace_presentation]).AddToParser(cluster_group)54 parser.display_info.AddUriFunc(cls._GetResourceUri)55 @classmethod56 def Args(cls, parser):57 cls.CommonArgs(parser)58 def _SetFormat(self, args, show_region=False, show_namespace=False):59 """Set display format for output.60 Args:61 args: Namespace, the args namespace62 show_region: bool, True to show region of listed services63 show_namespace: bool, True to show namespace of listed services64 """65 columns = [66 pretty_print.READY_COLUMN,67 'firstof(id,metadata.name):label=SERVICE',68 ]69 if show_region:70 columns.append('region:label=REGION')71 if show_namespace:72 columns.append('namespace:label=NAMESPACE')73 columns.extend([74 'domain:label=URL',75 'last_modifier:label="LAST DEPLOYED BY"',76 'last_transition_time:label="LAST DEPLOYED AT"',77 ])78 args.GetDisplayInfo().AddFormat(79 'table({})'.format(','.join(columns)))80 def Run(self, args):81 """List available services."""82 is_managed = flags.GetPlatform() == flags.PLATFORM_MANAGED83 if is_managed and not args.IsSpecified('region'):84 self._SetFormat(args, show_region=True)85 client = global_methods.GetServerlessClientInstance()86 self.SetPartialApiEndpoint(client.url)87 args.CONCEPTS.namespace.Parse() # Error if no proj.88 # Don't consider region property here, we'll default to all regions89 return commands.SortByName(global_methods.ListServices(client))90 else:91 conn_context = connection_context.GetConnectionContext(92 args, flags.Product.RUN, self.ReleaseTrack())93 self._SetFormat(94 args, show_region=is_managed, show_namespace=(not is_managed))95 namespace_ref = args.CONCEPTS.namespace.Parse()96 with serverless_operations.Connect(conn_context) as client:97 self.SetCompleteApiEndpoint(conn_context.endpoint)98 if not is_managed:99 location_msg = ' in [{}]'.format(conn_context.cluster_location)100 log.status.Print('For cluster [{cluster}]{zone}:'.format(101 cluster=conn_context.cluster_name,102 zone=location_msg if conn_context.cluster_location else ''))103 return commands.SortByName(client.ListServices(namespace_ref))104@base.ReleaseTracks(base.ReleaseTrack.ALPHA)105class AlphaList(List):106 """List available services."""107 @classmethod108 def Args(cls, parser):109 cls.CommonArgs(parser)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful