def Run(self, args): log.warn('This command is deprecated, and will soon be removed. ' 'It is no longer necessary, given recent improvements to ' 'deployment infrastructure.') client = appengine_client.AppengineClient(args.server) for module in args.modules: client.CancelDeployment(module, args.version)
def Run(self, args): client = appengine_client.AppengineClient() services = client.ListModules() log.debug('All services: {0}'.format(services)) if args.service and args.service not in services: raise ServiceNotFoundError('Service [{0}] not found.'.format( args.service)) versions = [] for service, versions_for_service in sorted(services.iteritems()): if not versions_for_service or not isinstance(versions, list): log.warn('Unexpected version list for service [{0}]'.format( service)) continue if args.service and service != args.service: # Not for a service we are interested in. continue # First version is always the default version (from the API). default_version = versions_for_service[0] for version in sorted(versions_for_service): traffic_split_percentage = 100 if (version == default_version) else 0 versions.append({ 'service': service, 'version': version, 'traffic_split': traffic_split_percentage }) if args.hide_no_traffic: versions = [v for v in versions if v['traffic_split']] return versions
def Run(self, args): # TODO(user): This fails with "module/version does not exist" even # when it exists if the scaling mode is set to auto. It would be good # to improve that error message. client = appengine_client.AppengineClient() versions = version_util.GetMatchingVersions(client.ListVersions(), args.versions, args.service, client.project) if versions: printer = console_io.ListPrinter( 'Stopping the following versions:') printer.Print(versions, output_stream=log.status) console_io.PromptContinue(cancel_on_no=True) else: log.warn('No matching versions found.') errors = [] for version in sorted(versions): try: with console_io.ProgressTracker( 'Stopping [{0}]'.format(version)): client.StopModule(module=version.service, version=version.version) except util.RPCError as err: errors.append(str(err)) if errors: raise VersionsStopError('\n\n'.join(errors))
def Run(self, args): # TODO(user): This fails with "module/version does not exist" even # when it exists if the scaling mode is set to auto. It would be good # to improve that error message. client = appengine_client.AppengineClient(args.server) for module in args.modules: client.StopModule(module=module, version=args.version) log.status.Print('Stopped: {0}/{1}/{2}'.format( client.project, module, args.version))
def Run(self, args): client = appengine_client.AppengineClient(args.server) message = ('You are about to set the default serving version to [{version}]' ' for the following modules:\n\t'.format(version=args.version)) message += '\n\t'.join([client.project + '/' + m for m in args.modules]) console_io.PromptContinue(message=message, cancel_on_no=True) client.SetDefaultVersion(args.modules, args.version) log.status.Print('Default serving version set to: ' + args.version)
def Run(self, args): project = properties.VALUES.core.project.Get(required=True) app_config = yaml_parsing.AppConfigSet([args.index_file], project) if yaml_parsing.ConfigYamlInfo.INDEX not in app_config.Configs(): raise exceptions.InvalidArgumentException( 'index_file', 'You must provide the path to a valid index.yaml file.') client = appengine_client.AppengineClient() info = app_config.Configs()[yaml_parsing.ConfigYamlInfo.INDEX] client.CleanupIndexes(info.parsed)
def Run(self, args): if args.output_dir: output_dir = args.output_dir if not os.path.isdir(output_dir): raise exceptions.InvalidArgumentException( 'output-dir', 'The directory does not exist.') else: output_dir = os.getcwd() client = appengine_client.AppengineClient(args.server) for m in args.modules: module_dir = os.path.join(output_dir, m) files.MakeDir(module_dir) log.status.Print('Downloading module [{module}] to [{dir}]'.format( module=m, dir=module_dir)) client.DownloadModule(m, args.version, module_dir)
def Run(self, args): client = appengine_client.AppengineClient(args.server) message = 'You are about to delete the following module versions:\n\t' message += '\n\t'.join([ '{0}/{1}/{2}'.format(client.project, m, args.version) for m in args.modules ]) console_io.PromptContinue(message=message, cancel_on_no=True) # Will run client.DeleteModule on each module with the specified version. # In event of a failure, will still attempt to delete the remaining modules. # Prints out a warning or error as appropriate for each module deletion. delete_results = [] for module in args.modules: delete_results.append(client.DeleteModule(module, args.version)) if not all(delete_results): raise exceptions.ToolException('Not all deletions succeeded.')
def Run(self, args): project = properties.VALUES.core.project.Get(required=True) app_config = yaml_parsing.AppConfigSet([args.index_file], project) if yaml_parsing.ConfigYamlInfo.INDEX not in app_config.Configs(): raise exceptions.InvalidArgumentException( 'index_file', 'You must provide the path to a valid index.yaml file.') info = app_config.Configs()[yaml_parsing.ConfigYamlInfo.INDEX] printer = console_io.ListPrinter( 'You are about to update the following configurations:') printer.Print( ['{0}/{1} From: [{2}]'.format(project, info.config, info.file)], output_stream=log.status) console_io.PromptContinue(default=True, throw_if_unattended=False, cancel_on_no=True) client = appengine_client.AppengineClient() client.UpdateIndexes(info.parsed)
def Run(self, args): client = appengine_client.AppengineClient(args.server) modules = client.ListModules() module_versions = [] for module, versions in sorted(modules.iteritems()): if not versions or not isinstance(versions, list): # No versions for some reason. continue if args.modules and module not in args.modules: # Not for a module we are interested in. continue # First version is always the default version (from the API). default_version = versions[0] for version in sorted(versions): module_versions.append({ 'module': module, 'version': version, 'is_default': version == default_version }) return module_versions
def Run(self, args): client = appengine_client.AppengineClient(args.server) severity = (GetLogs.SEVERITIES.index(args.severity) if args.severity else None) include_vhost = args.details include_all = args.details if args.append: if args.output_file == '-': raise exceptions.InvalidArgumentException( 'OUTPUT_FILE', 'You must specify a file when using append mode') if args.days is not None: raise exceptions.InvalidArgumentException( '--days', 'You cannot use the --days flag when in append mode. ' 'All logs will be fetched back to the last entry found in the ' 'output file.') client.GetLogsAppend(args.module, args.version, severity, args.vhost, include_vhost, include_all, args.end_date, args.output_file) else: client.GetLogs(args.module, args.version, severity, args.vhost, include_vhost, include_all, args.days, args.end_date, args.output_file)
def Run(self, args): client = appengine_client.AppengineClient(args.server) return client.ResourceLimitsInfo(args.version)
def Run(self, args): client = appengine_client.AppengineClient(args.server) func = client.SetManagedBySelf if args.self else client.SetManagedByGoogle for module in args.modules: func(module=module, version=args.version, instance=args.instance)
def Run(self, args): if args.env_vars: log.warn('The env-vars flag is deprecated, and will soon be removed.') # Do this up-front to print applicable warnings early promote = deploy_command_util.GetPromoteFromArgs(args) project = properties.VALUES.core.project.Get(required=True) use_cloud_build = properties.VALUES.app.use_cloud_build.GetBool() app_config = yaml_parsing.AppConfigSet( args.deployables, project, args.version or util.GenerateVersionId()) remote_build = True docker_build_property = properties.VALUES.app.docker_build.Get() if args.docker_build: remote_build = args.docker_build == 'remote' elif docker_build_property: remote_build = docker_build_property == 'remote' # This will either be args.version or a generated version. Either way, if # any yaml file has a version in it, it must match that version. version = app_config.Version() gae_client = appengine_client.AppengineClient(args.server) api_client = appengine_api_client.GetApiClient(self.Http(timeout=None)) log.debug('API endpoint: [{endpoint}], API version: [{version}]'.format( endpoint=api_client.client.url, version=api_client.api_version)) cloudbuild_client = cloudbuild_v1.CloudbuildV1(http=self.Http(), get_credentials=False) deployed_urls = _DisplayProposedDeployment(project, app_config, version, promote) if args.version or promote: # Prompt if there's a chance that you're overwriting something important: # If the version is set manually, you could be deploying over something. # If you're setting the new deployment to be the default version, you're # changing the target of the default URL. # Otherwise, all existing URLs will continue to work, so need to prompt. console_io.PromptContinue(default=True, throw_if_unattended=False, cancel_on_no=True) log.status.Print('Beginning deployment...') code_bucket = None if use_cloud_build: # If using Argo CloudBuild, we'll need to upload source to a GCS bucket. code_bucket = self._GetCodeBucket(api_client, args) modules = app_config.Modules() if args.image_url: if len(modules) != 1: raise exceptions.ToolException( 'No more than one module may be deployed when using the ' 'image-url flag') for registry in constants.ALL_SUPPORTED_REGISTRIES: if args.image_url.startswith(registry): break else: raise exceptions.ToolException( '%s is not in a supported registry. Supported registries are %s' % (args.image_url, constants.ALL_SUPPORTED_REGISTRIES)) module = modules.keys()[0] images = {module: args.image_url} else: images = deploy_command_util.BuildAndPushDockerImages(modules, version, gae_client, cloudbuild_client, code_bucket, self.cli, remote_build) deployment_manifests = {} if app_config.NonHermeticModules() and self.use_admin_api: # TODO(user): Consider doing this in parallel with # BuildAndPushDockerImage. code_bucket = self._GetCodeBucket(api_client, args) metrics.CustomTimedEvent(metric_names.GET_CODE_BUCKET) log.debug('Using bucket [{b}].'.format(b=code_bucket)) if not code_bucket: raise exceptions.ToolException(('Could not retrieve the default Google ' 'Cloud Storage bucket for [{a}]. ' 'Please try again or use the [bucket] ' 'argument.').format(a=project)) deployment_manifests = deploy_app_command_util.CopyFilesToCodeBucket( app_config.NonHermeticModules().items(), code_bucket) metrics.CustomTimedEvent(metric_names.COPY_APP_FILES) # Now do deployment. for (module, info) in app_config.Modules().iteritems(): message = 'Updating module [{module}]'.format(module=module) with console_io.ProgressTracker(message): if args.force: gae_client.CancelDeployment(module=module, version=version) metrics.CustomTimedEvent(metric_names.CANCEL_DEPLOYMENT) if info.is_hermetic or self.use_admin_api: api_client.DeployModule(module, version, info, deployment_manifests.get(module), images.get(module)) metrics.CustomTimedEvent(metric_names.DEPLOY_API) else: gae_client.DeployModule(module, version, info.parsed, info.file) metrics.CustomTimedEvent(metric_names.DEPLOY_ADMIN_CONSOLE) if promote: if info.is_hermetic or self.use_admin_api: api_client.SetDefaultVersion(module, version) metrics.CustomTimedEvent(metric_names.SET_DEFAULT_VERSION_API) else: gae_client.SetDefaultVersion(modules=[module], version=version) metrics.CustomTimedEvent( metric_names.SET_DEFAULT_VERSION_ADMIN_CONSOLE) # Config files. for (c, info) in app_config.Configs().iteritems(): message = 'Updating config [{config}]'.format(config=c) with console_io.ProgressTracker(message): gae_client.UpdateConfig(c, info.parsed) return deployed_urls
def Run(self, args): client = appengine_client.AppengineClient(args.server) for module in args.modules: client.CancelDeployment(module, args.version)