def got_session(session): version = session.query(paasmaker.model.ApplicationVersion).get( context['application_version_id']) # Build our environment for later. environment = ApplicationEnvironment.get_environment( self.configuration, version) # And signal success so the prepare jobs can start. session.close() self.success({'environment': environment}, "All services created and updated.")
def start_job(self, context): self.instance_id = self.parameters['instance_id'] self.instance_path = self.configuration.get_instance_path( self.instance_id) self.instance_data = self.configuration.instances.get_instance( self.instance_id) if not os.path.exists(self.instance_path): # Oops. Something is out of sync. self.logger.error("Instance path no longer exists.") self.failed("Instance path no longer exists.") return self.startup_commands = list( self.instance_data['instance_type']['startup']) # Reverse them - we don't execute in reverse order, # but we do pop() them off, so this allows them to work in # the intended manifest supplied order. self.startup_commands.reverse() # Merge in the local environment at this stage. self.instance_data[ 'environment'] = ApplicationEnvironment.merge_local_environment( self.configuration, self.instance_data['environment']) if self.instance_data['instance'].has_key('port'): self.instance_data['environment']['PM_PORT'] = str( self.instance_data['instance']['port']) # If supplied with a runtime, get that runtime to set up the environment # before we continue. It can be None, so check for that too. runtime_name = self.instance_data['instance_type']['runtime_name'] if not self.configuration.plugins.exists( runtime_name, paasmaker.util.plugin.MODE.RUNTIME_ENVIRONMENT): error_message = "No such runtime plugin %s" % runtime_name self.logger.error(error_message) self.failed(error_message) else: # Fetch the plugin. plugin = self.configuration.plugins.instantiate( runtime_name, paasmaker.util.plugin.MODE.RUNTIME_ENVIRONMENT, {}, self.logger) self.logger.debug( "Getting runtime plugin %s to set up environment.", runtime_name) # Get it to set up the environment, and call our continue # function when ready. plugin.environment( self.instance_data['instance_type']['runtime_version'], self.instance_data['environment'], self._environment_ready, self._plugin_failure)
def start_job(self, context): self.instance_id = self.parameters['instance_id'] self.instance_path = self.configuration.get_instance_path(self.instance_id) self.instance_data = self.configuration.instances.get_instance(self.instance_id) if not os.path.exists(self.instance_path): # Oops. Something is out of sync. self.logger.error("Instance path no longer exists.") self.failed("Instance path no longer exists.") return self.startup_commands = list(self.instance_data['instance_type']['startup']) # Reverse them - we don't execute in reverse order, # but we do pop() them off, so this allows them to work in # the intended manifest supplied order. self.startup_commands.reverse() # Merge in the local environment at this stage. self.instance_data['environment'] = ApplicationEnvironment.merge_local_environment( self.configuration, self.instance_data['environment'] ) if self.instance_data['instance'].has_key('port'): self.instance_data['environment']['PM_PORT'] = str(self.instance_data['instance']['port']) # If supplied with a runtime, get that runtime to set up the environment # before we continue. It can be None, so check for that too. runtime_name = self.instance_data['instance_type']['runtime_name'] if not self.configuration.plugins.exists(runtime_name, paasmaker.util.plugin.MODE.RUNTIME_ENVIRONMENT): error_message = "No such runtime plugin %s" % runtime_name self.logger.error(error_message) self.failed(error_message) else: # Fetch the plugin. plugin = self.configuration.plugins.instantiate( runtime_name, paasmaker.util.plugin.MODE.RUNTIME_ENVIRONMENT, {}, self.logger ) self.logger.debug("Getting runtime plugin %s to set up environment.", runtime_name) # Get it to set up the environment, and call our continue # function when ready. plugin.environment( self.instance_data['instance_type']['runtime_version'], self.instance_data['environment'], self._environment_ready, self._plugin_failure )
def got_session(session): version = session.query( paasmaker.model.ApplicationVersion ).get( context['application_version_id'] ) # Build our environment for later. environment = ApplicationEnvironment.get_environment(self.configuration, version) # And signal success so the prepare jobs can start. session.close() self.success({'environment': environment}, "All services created and updated.")