def _UpdateVMSettings(self): """Overwrites vm_settings for App Engine services with VMs. Also sets module_yaml_path which is needed for some runtimes. Raises: AppConfigError: if the function was called for a standard service """ if self.env not in [env.MANAGED_VMS, env.FLEX]: raise AppConfigError( 'This is not an App Engine Flexible service. Please set `env` ' 'field to `flex`.') if not self.parsed.vm_settings: self.parsed.vm_settings = appinfo.VmSettings() self.parsed.vm_settings['module_yaml_path'] = os.path.basename(self.file)
def _UpdateManagedVMConfig(self): """Overwrites vm_settings for Managed VMs services. Sets has_docker_image to be always True. Required for transition period until all images in production are pushed via gcloud (and therefore all builds happen locally in the SDK). Also sets module_yaml_path which is needed for some runtimes. Raises: AppConfigError: if the function was called for the service which is not a Managed VM service. """ if not self.is_vm: raise AppConfigError('This is not a Managed VM module. vm != True') if not self.parsed.vm_settings: self.parsed.vm_settings = appinfo.VmSettings() self.parsed.vm_settings['has_docker_image'] = True self.parsed.vm_settings['module_yaml_path'] = os.path.basename(self.file)
def _UpdateManagedVMConfig(self): """Overwrites vm_settings for App Engine Flexible services. Sets has_docker_image to be always True. Required for transition period until all images in production are pushed via gcloud (and therefore all builds happen locally in the SDK). Also sets module_yaml_path which is needed for some runtimes. Raises: AppConfigError: if the function was called for the service which is not an App Engine Flexible service. """ if self.env is not util.Environment.FLEXIBLE: raise AppConfigError('This is not an App Engine Flexible service. ' 'The `vm` field is not set to `true`.') if not self.parsed.vm_settings: self.parsed.vm_settings = appinfo.VmSettings() self.parsed.vm_settings['has_docker_image'] = True self.parsed.vm_settings['module_yaml_path'] = os.path.basename(self.file)
def _UpdateVMSettings(self): """Overwrites vm_settings for App Engine services with VMs. Sets has_docker_image to be always True. Required for transition period until all images in production are pushed via gcloud (and therefore all builds happen locally in the SDK). Also sets module_yaml_path which is needed for some runtimes. Raises: AppConfigError: if the function was called for a standard service """ if self.env not in [ util.Environment.MANAGED_VMS, util.Environment.FLEX ]: raise AppConfigError( 'This is not an App Engine Flexible service. Please set `env` ' 'field to `flex`.') if not self.parsed.vm_settings: self.parsed.vm_settings = appinfo.VmSettings() self.parsed.vm_settings['has_docker_image'] = True self.parsed.vm_settings['module_yaml_path'] = os.path.basename( self.file)
def __init__(self, rpcserver, project, module, version, module_yaml, module_yaml_path, resource_limits, usage_reporting=False, ignore_endpoints_failures=True): """Creates a new AppVersionUploader. Args: rpcserver: The RPC server to use. Should be an instance of HttpRpcServer or TestRpcServer. project: str, The project being used. module: str, The module to upload. version: str, The version of the module to upload. module_yaml: An AppInfoExternal object that specifies the configuration for this application. module_yaml_path: The full path to the file corresponding to module_yaml resource_limits: Current resource limits. usage_reporting: Whether or not to report usage. ignore_endpoints_failures: True to finish deployment even if there are errors updating the Google Cloud Endpoints configuration (if there is one). False if these errors should cause a failure/rollback. """ self.rpcserver = rpcserver self.module_yaml = module_yaml self.module_yaml_path = module_yaml_path self.app_id = project self.module = module self.version = version self.resource_limits = resource_limits self.params = { 'app_id': self.app_id, 'module': self.module, 'version': self.version } # A map from file name to the sha1 hash of the file contents. This map is # used to track all files that remain to be cloned or uploaded (either as # code files or static blobs). self.files = {} # The set of all file names for the app; not modified after it is populated. self.all_files = set() self.in_transaction = False self.deployed = False self.started = False self.batching = True self.logging_context = util.ClientDeployLoggingContext( rpcserver, self.params, usage_reporting) self.file_batcher = UploadBatcher('file', self.logging_context) self.blob_batcher = UploadBatcher('blob', self.logging_context) self.errorblob_batcher = UploadBatcher('errorblob', self.logging_context) # Init some VM-specific state for this AppVersionUploader. if not self.module_yaml.vm_settings: self.module_yaml.vm_settings = appinfo.VmSettings() self.module_yaml.vm_settings['module_yaml_path'] = ( os.path.basename(module_yaml_path)) # Set auto_id_policy to the default for this sdk version, if unspecified. if not self.module_yaml.auto_id_policy: self.module_yaml.auto_id_policy = appinfo.DATASTORE_ID_POLICY_DEFAULT self.ignore_endpoints_failures = ignore_endpoints_failures