X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cloudify%2Fscripts%2Fconfigure_node.py;fp=cloudify%2Fscripts%2Fconfigure_node.py;h=9cfa206b54350a481d021625f34b13b7b36c0a4a;hb=5e1853a28f9ca1d13280db06fdb9edaf33fd7354;hp=0000000000000000000000000000000000000000;hpb=097208524f1954a08e3c6d82d15bb4090678b2ed;p=oom.git diff --git a/cloudify/scripts/configure_node.py b/cloudify/scripts/configure_node.py new file mode 100644 index 0000000000..9cfa206b54 --- /dev/null +++ b/cloudify/scripts/configure_node.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +import subprocess +from cloudify import ctx +from cloudify.state import ctx_parameters as inputs + + +def execute_command(_command): + + ctx.logger.debug('_command {0}.'.format(_command)) + + subprocess_args = { + 'args': _command.split(), + 'stdout': subprocess.PIPE, + 'stderr': subprocess.PIPE + } + + ctx.logger.debug('subprocess_args {0}.'.format(subprocess_args)) + + process = subprocess.Popen(**subprocess_args) + output, error = process.communicate() + + ctx.logger.debug('command: {0} '.format(_command)) + ctx.logger.debug('output: {0} '.format(output)) + ctx.logger.debug('error: {0} '.format(error)) + ctx.logger.debug('process.returncode: {0} '.format(process.returncode)) + + if process.returncode: + ctx.logger.error('Running `{0}` returns error.'.format(_command)) + return False + + return output + + +if __name__ == '__main__': + + join_command = inputs['join_command'] + join_command = 'sudo {0} --skip-preflight-checks'.format(join_command) + execute_command(join_command) + + # Install weave-related utils + execute_command('sudo curl -L git.io/weave -o /usr/local/bin/weave') + execute_command('sudo chmod a+x /usr/local/bin/weave') + execute_command('sudo curl -L git.io/scope -o /usr/local/bin/scope') + execute_command('sudo chmod a+x /usr/local/bin/scope') + execute_command('/usr/local/bin/scope launch') + + hostname = execute_command('hostname') + ctx.instance.runtime_properties['hostname'] = hostname.rstrip('\n')