def Run(self, args): """List the account for known credentials.""" accounts = c_store.AvailableAccounts() active_account = properties.VALUES.core.account.Get() if args.account: # TODO(user) Remove error after Sept. 13, 2015. raise exceptions.Error( 'The behavior of ``gcloud auth list --account has changed. ' 'Please use ``--filter-account'' to filter the output of ' '``auth list''. Elsewhere in gcloud ``--account'' sets the ' 'currently active account and this behavior will become available ' 'to ``auth list'' in a future gcloud release.') if args.filter_account: if args.filter_account in accounts: accounts = [args.filter_account] else: accounts = [] auth_info = collections.namedtuple( 'auth_info', ['active_account', 'accounts']) return auth_info(active_account, accounts)
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ adapter = self.context["api_adapter"] describe_info = collections.namedtuple("describe_info", ["cluster", "text"]) text = None vv = VersionVerifier() c = adapter.GetCluster(adapter.ParseCluster(args.name)) ver_status = vv.Compare(c.currentMasterVersion, c.currentNodeVersion) if ver_status == VersionVerifier.UPGRADE_AVAILABLE: text = UpgradeHelpText.UPGRADE_AVAILABLE elif ver_status == VersionVerifier.SUPPORT_ENDING: text = UpgradeHelpText.SUPPORT_ENDING elif ver_status == VersionVerifier.UNSUPPORTED: text = UpgradeHelpText.UNSUPPORTED if ver_status != VersionVerifier.UP_TO_DATE: text += UpgradeHelpText.UPGRADE_COMMAND.format(name=c.name) return describe_info(c, text)
def Run(self, args): """This is what gets called when the user runs this command. Args: args: an argparse namespace. All the arguments that were provided to this command invocation. Returns: Some value that we want to have printed later. """ adapter = self.context['api_adapter'] project = properties.VALUES.core.project.Get(required=True) zone = None if args.zone: zone = adapter.registry.Parse(args.zone, collection='compute.zones').zone try: clusters = adapter.ListClusters(project, zone) upgrade_available = False support_ending = False unsupported = False text = '' list_info = collections.namedtuple('list_info', ['clusters', 'text']) vv = VersionVerifier() for c in clusters.clusters: ver_status = vv.Compare(c.currentMasterVersion, c.currentNodeVersion) if ver_status == VersionVerifier.UPGRADE_AVAILABLE: c.currentNodeVersion += ' *' upgrade_available = True elif ver_status == VersionVerifier.SUPPORT_ENDING: c.currentNodeVersion += ' **' support_ending = True elif ver_status == VersionVerifier.UNSUPPORTED: c.currentNodeVersion += ' ***' unsupported = True if upgrade_available: text += UpgradeHelpText.UPGRADE_AVAILABLE if support_ending: text += UpgradeHelpText.SUPPORT_ENDING if unsupported: text += UpgradeHelpText.UNSUPPORTED if text: text += UpgradeHelpText.UPGRADE_COMMAND.format(name='NAME') return list_info(clusters, text) except apitools_exceptions.HttpError as error: raise exceptions.HttpException(util.GetError(error))
class ComponentState(object): """An enum for the available update states.""" _COMPONENT_STATE_TUPLE = collections.namedtuple('ComponentStateTuple', ['name']) UP_TO_DATE = _COMPONENT_STATE_TUPLE('Installed') UPDATE_AVAILABLE = _COMPONENT_STATE_TUPLE('Update Available') REMOVED = _COMPONENT_STATE_TUPLE('Deprecated') NEW = _COMPONENT_STATE_TUPLE('Not Installed') @staticmethod def All(): """Gets all the different states. Returns: list(ComponentStateTuple), All the states. """ return [ ComponentState.UPDATE_AVAILABLE, ComponentState.REMOVED, ComponentState.NEW, ComponentState.UP_TO_DATE ]
# Copyright 2014 Google Inc. All Rights Reserved. """Implements the command for copying files from and to virtual machines.""" import getpass import logging from googlecloudsdk.api_lib.compute import constants from googlecloudsdk.api_lib.compute import ssh_utils from googlecloudsdk.calliope import actions from googlecloudsdk.calliope import base from googlecloudsdk.calliope import exceptions from googlecloudsdk.core import properties from googlecloudsdk.third_party.py27 import py27_collections as collections RemoteFile = collections.namedtuple( 'RemoteFile', ['user', 'instance_name', 'file_path']) LocalFile = collections.namedtuple( 'LocalFile', ['file_path']) @base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA) class Scp(ssh_utils.BaseSSHCLICommand): """Copy files to and from Google Compute Engine virtual machines.""" @staticmethod def Args(parser): ssh_utils.BaseSSHCLICommand.Args(parser) parser.add_argument( '--port', help='The port to connect to.')
STANDARD_DISK_PERFORMANCE_WARNING_GB = 200 SSD_DISK_PERFORMANCE_WARNING_GB = 10 # The maximum number of results that can be returned in a single list # response. MAX_RESULTS_PER_PAGE = 500 # Defaults for instance creation. DEFAULT_ACCESS_CONFIG_NAME = 'external-nat' DEFAULT_MACHINE_TYPE = 'n1-standard-1' DEFAULT_NETWORK = 'default' DEFAULT_IMAGE = 'debian-8' ImageAlias = collections.namedtuple('ImageAlias', ['project', 'name_prefix']) IMAGE_ALIASES = { 'centos-6': ImageAlias(project='centos-cloud', name_prefix='centos-6'), 'centos-7': ImageAlias(project='centos-cloud', name_prefix='centos-7'), 'container-vm': ImageAlias(project='google-containers', name_prefix='container-vm'), 'coreos': ImageAlias(project='coreos-cloud', name_prefix='coreos-stable'), 'debian-7': ImageAlias(project='debian-cloud', name_prefix='debian-7-wheezy'), 'debian-7-backports': ImageAlias(project='debian-cloud', name_prefix='backports-debian-7-wheezy'),
# See the License for the specific language governing permissions and # limitations under the License. """Implements the command for copying files from and to virtual machines.""" import logging from googlecloudsdk.api_lib.compute import ssh_utils from googlecloudsdk.calliope import actions from googlecloudsdk.calliope import base from googlecloudsdk.calliope import exceptions from googlecloudsdk.command_lib.compute import flags from googlecloudsdk.core import properties from googlecloudsdk.third_party.py27 import py27_collections as collections RemoteFile = collections.namedtuple( 'RemoteFile', ['user', 'instance_name', 'file_path']) LocalFile = collections.namedtuple( 'LocalFile', ['file_path']) @base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA) class Scp(ssh_utils.BaseSSHCLICommand): """Copy files to and from Google Compute Engine virtual machines.""" @staticmethod def Args(parser): ssh_utils.BaseSSHCLICommand.Args(parser) parser.add_argument( '--port', help='The port to connect to.')
STANDARD_DISK_PERFORMANCE_WARNING_GB = 200 SSD_DISK_PERFORMANCE_WARNING_GB = 10 # The maximum number of results that can be returned in a single list # response. MAX_RESULTS_PER_PAGE = 500 # Defaults for instance creation. DEFAULT_ACCESS_CONFIG_NAME = 'external-nat' DEFAULT_MACHINE_TYPE = 'n1-standard-1' DEFAULT_NETWORK = 'default' DEFAULT_IMAGE = 'debian-8' ImageAlias = collections.namedtuple( 'ImageAlias', ['project', 'name_prefix']) IMAGE_ALIASES = { 'centos-6': ImageAlias(project='centos-cloud', name_prefix='centos-6'), 'centos-7': ImageAlias(project='centos-cloud', name_prefix='centos-7'), 'container-vm': ImageAlias( project='google-containers', name_prefix='container-vm'), 'coreos': ImageAlias(project='coreos-cloud', name_prefix='coreos-stable'), 'debian-7': ImageAlias(project='debian-cloud', name_prefix='debian-7-wheezy'), 'debian-7-backports': ImageAlias( project='debian-cloud', name_prefix='backports-debian-7-wheezy'), 'debian-8': ImageAlias(project='debian-cloud', name_prefix='debian-8-jessie'), 'opensuse-13': ImageAlias( project='opensuse-cloud', name_prefix='opensuse-13'),
for field in sorted(message_class.all_fields(), key=lambda field: field.name): if isinstance(field, messages.MessageField): for remainder in _ProtobufDefinitionToFields(field.type): if field.repeated: yield field.name + '[].' + remainder else: yield field.name + '.' + remainder else: if field.repeated: yield field.name + '[]' else: yield field.name _InternalSpec = collections.namedtuple( 'Spec', ['message_class_name', 'table_cols', 'transformations', 'editables']) _SPECS_V1 = { 'addresses': _InternalSpec( message_class_name='Address', table_cols=[ ('NAME', 'name'), ('REGION', 'region'), ('ADDRESS', 'address'), ('STATUS', 'status'), ], transformations=[ ('region', path_simplifier.Name), ('users[]', path_simplifier.ScopedSuffix), ],
key=lambda field: field.name): if isinstance(field, messages.MessageField): for remainder in _ProtobufDefinitionToFields(field.type): if field.repeated: yield field.name + '[].' + remainder else: yield field.name + '.' + remainder else: if field.repeated: yield field.name + '[]' else: yield field.name _InternalSpec = collections.namedtuple( 'Spec', ['message_class_name', 'table_cols', 'transformations', 'editables']) _SPECS_V1 = { 'addresses': _InternalSpec( message_class_name='Address', table_cols=[ ('NAME', 'name'), ('REGION', 'region'), ('ADDRESS', 'address'), ('STATUS', 'status'), ], transformations=[ ('region', path_simplifier.Name), ('users[]', path_simplifier.ScopedSuffix),
class ToolResultsIds( collections.namedtuple('ToolResultsIds', ['history_id', 'execution_id'])): """A tuple to hold the history & execution IDs returned from Tool Results.
""" for field in sorted(message_class.all_fields(), key=lambda field: field.name): if isinstance(field, messages.MessageField): for remainder in _ProtobufDefinitionToFields(field.type): if field.repeated: yield field.name + "[]." + remainder else: yield field.name + "." + remainder else: if field.repeated: yield field.name + "[]" else: yield field.name _InternalSpec = collections.namedtuple("Spec", ["message_class_name", "table_cols", "transformations", "editables"]) _SPECS_V1 = { "addresses": _InternalSpec( message_class_name="Address", table_cols=[("NAME", "name"), ("REGION", "region"), ("ADDRESS", "address"), ("STATUS", "status")], transformations=[("region", path_simplifier.Name), ("users[]", path_simplifier.ScopedSuffix)], editables=None, ), "autoscalers": _InternalSpec( message_class_name="Autoscaler", table_cols=[("NAME", "name"), ("TARGET", "target"), ("POLICY", "autoscalingPolicy")], transformations=[("zone", path_simplifier.Name), ("target", path_simplifier.Name)], editables=None, ), "backendServices": _InternalSpec(
class TestOutcome( collections.namedtuple('TestOutcome', ['outcome', 'axis_value', 'test_details'])): """A tuple to hold the outcome for a single test axis value.