def create(cloudify_agent, installer, **_): # When not in "remote" mode, this operation is called only to set the # agent_config dict in the runtime properties create_agent_record(cloudify_agent) if cloudify_agent.has_installer: with script.install_script_path(cloudify_agent) as script_path: ctx.logger.info('Creating Agent {0}'.format( cloudify_agent['name'])) try: installer.runner.run_script(script_path) except (CommandExecutionError, CommandExecutionException): ctx.logger.error("Failed creating agent; marking agent as " "failed") update_agent_record(cloudify_agent, AgentState.FAILED) raise ctx.logger.info( 'Agent created, configured and started successfully' ) update_agent_record(cloudify_agent, AgentState.STARTED) elif cloudify_agent.is_proxied: ctx.logger.info('Working in "proxied" mode') elif cloudify_agent.is_provided: ctx.logger.info('Working in "provided" mode') _, install_script_download_link = script.install_script_download_link( cloudify_agent ) ctx.logger.info( 'Agent config created. To configure/start the agent, download the ' 'following script: {0}'.format(install_script_download_link) ) cloudify_agent['install_script_download_link'] = \ install_script_download_link update_agent_runtime_properties(cloudify_agent) update_agent_record(cloudify_agent, AgentState.CREATED)
def create(cloudify_agent, installer, **_): # When not in "remote" mode, this operation is called only to set the # agent_config dict in the runtime properties create_agent_record(cloudify_agent) if cloudify_agent.has_installer: with script.install_script_path(cloudify_agent) as script_path: ctx.logger.info('Creating Agent {0}'.format( cloudify_agent['name'])) try: installer.runner.run_script(script_path) except (CommandExecutionError, CommandExecutionException): ctx.logger.error("Failed creating agent; marking agent as " "failed") update_agent_record(cloudify_agent, AgentState.FAILED) raise ctx.logger.info( 'Agent created, configured and started successfully') update_agent_record(cloudify_agent, AgentState.STARTED) elif cloudify_agent.is_proxied: ctx.logger.info('Working in "proxied" mode') elif cloudify_agent.is_provided: ctx.logger.info('Working in "provided" mode') _, install_script_download_link = script.install_script_download_link( cloudify_agent) ctx.logger.info( 'Agent config created. To configure/start the agent, download the ' 'following script: {0}'.format(install_script_download_link)) cloudify_agent['install_script_download_link'] = \ install_script_download_link update_agent_runtime_properties(cloudify_agent) update_agent_record(cloudify_agent, AgentState.CREATED)
def install_script_download_link(self, agent_config=None, clean=True): self._validate_agent_env() from cloudify_agent.installer import script try: script_path, script_url = script.install_script_download_link( cloudify_agent=agent_config) self.script_path = script_path yield script_url finally: if clean: self.clean_script()
def install_script_download_link(self, agent_config=None, clean=True): self._validate_agent_env() from cloudify_agent.installer import script try: script_path, script_url = script.install_script_download_link( cloudify_agent=agent_config ) self.script_path = script_path yield script_url finally: if clean: self.clean_script()
ctx.logger.info('Creating Agent {0}'.format( cloudify_agent['name'])) try: response = installer.runner.run_script(script_path) output = response.std_out if output: for line in output.splitlines(): ctx.logger.info(line) except CommandExecutionError, e: ctx.logger.error(str(e)) raise ctx.logger.info( 'Agent created, configured and started successfully') elif cloudify_agent.is_provided: ctx.logger.info('Working in "provided" mode') _, install_script_download_link = script.install_script_download_link( cloudify_agent) ctx.logger.info( 'Agent config created. To configure/start the agent, download the ' 'following script: {0}'.format(install_script_download_link)) cloudify_agent['install_script_download_link'] = \ install_script_download_link update_agent_runtime_properties(cloudify_agent) @operation @create_agent_config_and_installer def configure(cloudify_agent, installer, **_): ctx.logger.info('Configuring Agent {0}'.format(cloudify_agent['name'])) installer.configure_agent()