diff --git a/client/src/main/python/slipstream/Client.py b/client/src/main/python/slipstream/Client.py index 6e1057c3..9e45db2d 100644 --- a/client/src/main/python/slipstream/Client.py +++ b/client/src/main/python/slipstream/Client.py @@ -21,7 +21,6 @@ import subprocess from multiprocessing.dummy import Pool as ThreadPool - from SlipStreamHttpClient import SlipStreamHttpClient from exceptions.Exceptions import NotYetSetException @@ -90,6 +89,41 @@ def getRuntimeParameter(self, key): return value + def kb_extract_param_name_node_name(self, key): + node_name = None + param_name = key + if NodeDecorator.NODE_PROPERTY_SEPARATOR in key: + if not key.startswith(NodeDecorator.globalNamespacePrefix): + param_split = key.split(NodeDecorator.NODE_PROPERTY_SEPARATOR) + node_name = param_split[0] + param_name = param_split[1] + else: + node_name = self._getNodeName() + return node_name, param_name + + def kb_getRuntimeParameter(self, key): + node_name, param_name = self.kb_extract_param_name_node_name(key) + if self.no_block: + value = self.httpClient.kb_get_deployment_parameter(param_name, node_name) + else: + timer = 0 + while True: + value = self.httpClient.kb_get_deployment_parameter(key, node_name) + + if value is not None: + break + if self.timeout != 0 and timer >= self.timeout: + raise TimeoutException( + "Exceeded timeout limit of %s waiting for key '%s' " + "to be set" % (self.timeout, key)) + print >> sys.stderr, "Waiting for %s" % key + sys.stdout.flush() + sleepTime = 5 + time.sleep(sleepTime) + timer += sleepTime + + return value + def launchDeployment(self, params): """ @return: Run location @@ -139,10 +173,10 @@ def _qualifyKey(self, key): # multiplicity parameter should NOT be qualified make an exception if len(parts) == 1 and propertyPart not in node_level_properties: _key = nodename + \ - NodeDecorator.NODE_MULTIPLICITY_SEPARATOR + \ - NodeDecorator.nodeMultiplicityStartIndex + \ - NodeDecorator.NODE_PROPERTY_SEPARATOR + \ - propertyPart + NodeDecorator.NODE_MULTIPLICITY_SEPARATOR + \ + NodeDecorator.nodeMultiplicityStartIndex + \ + NodeDecorator.NODE_PROPERTY_SEPARATOR + \ + propertyPart return _key if _key not in node_level_properties: @@ -176,13 +210,18 @@ def setRuntimeParameter(self, key, value): raise ClientError("value exceeds maximum length of %d characters" % self.VALUE_LENGTH_LIMIT) self.httpClient.setRuntimeParameter(_key, stripped_value) + def kb_setRuntimeParameter(self, key, value): + node_name, param_name = self.kb_extract_param_name_node_name(key) + self.httpClient.kb_set_deployment_parameter(param_name, util.removeASCIIEscape(value), node_name) + def cancel_abort(self): # Global abort - self.httpClient.unset_runtime_parameter(NodeDecorator.globalNamespacePrefix + NodeDecorator.ABORT_KEY, - ignore_abort=True) + self.httpClient.kb_unset_deployment_parameter(NodeDecorator.globalNamespacePrefix + NodeDecorator.ABORT_KEY) + + self.httpClient.kb_unset_deployment_parameter(NodeDecorator.ABORT_KEY, self._getNodeName()) - _key = self._qualifyKey(NodeDecorator.ABORT_KEY) - self.httpClient.unset_runtime_parameter(_key, ignore_abort=True) + self.httpClient.kb_set_deployment_parameter(NodeDecorator.globalNamespacePrefix + NodeDecorator.STATE_KEY, + "Ready") def executScript(self, script): return self._systemCall(script, retry=False) @@ -265,7 +304,7 @@ def get_rtp_all(self, compname, key): nparams = len(params) pool_size = min(POOL_MAX, nparams) self._printDetail("Get %s RTP instances with pool size: %s" % - (nparams, pool_size)) + (nparams, pool_size)) pool = ThreadPool(pool_size) results = pool.map(self._get_rtp, params) results = [v or '' for v in results] @@ -277,4 +316,4 @@ def get_session(self): return self.httpClient.get_session() def get_api(self): - return self.httpClient.get_api() \ No newline at end of file + return self.httpClient.get_api() diff --git a/client/src/main/python/slipstream/SlipStreamHttpClient.py b/client/src/main/python/slipstream/SlipStreamHttpClient.py index 909390ba..f554f48b 100644 --- a/client/src/main/python/slipstream/SlipStreamHttpClient.py +++ b/client/src/main/python/slipstream/SlipStreamHttpClient.py @@ -18,6 +18,7 @@ from __future__ import print_function import os +import uuid import json from collections import defaultdict @@ -38,6 +39,7 @@ class SlipStreamHttpClient(object): def __init__(self, configHolder): self.category = None self.run_dom = None + self.kb_deployment = None self.ignoreAbort = False self.username = '' self.password = '' @@ -137,7 +139,7 @@ def get_nodes_instances(self, cloud_service_name=None): ''' nodes_instances = {} - self._retrieveAndSetRun() + self._kb_retrieveAndSetRun() nodes_instances_runtime_parameters = \ DomExtractor.extract_nodes_instances_runtime_parameters(self.run_dom, cloud_service_name) @@ -168,6 +170,15 @@ def get_nodes_instances(self, cloud_service_name=None): return nodes_instances + def kb_get_node_instance(self, node_name): + type = self.kb_get_run_type() + if type in ('COMPONENT', 'IMAGE'): + return self.kb_deployment['module'] + elif type == 'APPLICATION': # FIXME more than the module returned + nodes = self.kb_deployment['module']['content']['nodes'] + return filter(lambda d: d['node'] == node_name, nodes)[0] + + def _get_nodename(self): 'Node name derived from the node instance name.' return self.node_instance_name.split( @@ -194,6 +205,17 @@ def _retrieveAndSetRun(self): _, run = self._retrieve(url) self.run_dom = etree.fromstring(run.encode('utf-8')) + def kb_get_run_type(self): + return self._kb_retrieveAndSetRun()['module']['type'] + + def kb_get_userparam_ssh_pubkeys(self): + return self._kb_retrieveAndSetRun().get('sshPublicKeys') + + def _kb_retrieveAndSetRun(self): + if self.kb_deployment is None: + self.kb_deployment = self.api.cimi_get(self.diid).json + return self.kb_deployment + def _retrieve(self, url): return self._httpGet(url, 'application/xml') @@ -207,6 +229,9 @@ def complete_state(self, node_instance_name): url += SlipStreamHttpClient.URL_IGNORE_ABORT_ATTRIBUTE_QUERY return self._httpPost(url, 'reset', 'text/plain') + def kb_complete_state(self, state, node_instance_name): + return self.kb_set_deployment_parameter(NodeDecorator.COMPLETE_KEY, state, node_instance_name) + def terminate_run(self): return self._httpDelete(self.run_url) @@ -268,6 +293,29 @@ def getRuntimeParameter(self, key, ignoreAbort=False): return content.strip().strip('"').strip("'") + @staticmethod + def kb_from_data_uuid(text): + class NullNameSpace: + bytes = b'' + + return str(uuid.uuid3(NullNameSpace, text)) + + def __contruct_deployment_param_href(self, node_id, param_name): + param_id = ':'.join(item or '' for item in [self.diid, node_id, param_name]) + return 'deployment-parameter/' + self.kb_from_data_uuid(param_id) + + def kb_get_deployment_parameter(self, param_name, node_id=None): + deployment_parameter_href = self.__contruct_deployment_param_href(node_id, param_name) + return self.api.cimi_get(deployment_parameter_href).json.get('value') + + def kb_set_deployment_parameter(self, param_name, value, node_id=None): + deployment_parameter_href = self.__contruct_deployment_param_href(node_id, param_name) + return self.api.cimi_edit(deployment_parameter_href, {'value': value}) + + def kb_unset_deployment_parameter(self, param_name, node_id=None): + deployment_parameter_href = self.__contruct_deployment_param_href(node_id, param_name) + return self.api.cimi_edit(deployment_parameter_href, {}, select='value') + def setRuntimeParameter(self, key, value, ignoreAbort=False): url = self.run_url + '/' + key if self.ignoreAbort or ignoreAbort: diff --git a/client/src/main/python/slipstream/__version__.py b/client/src/main/python/slipstream/__version__.py index ad459cc7..3fd5850f 100644 --- a/client/src/main/python/slipstream/__version__.py +++ b/client/src/main/python/slipstream/__version__.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # coding=latin-1 """ SlipStream Client diff --git a/client/src/main/python/slipstream/cloudconnectors/BaseCloudConnector.py b/client/src/main/python/slipstream/cloudconnectors/BaseCloudConnector.py index 4da1b84d..2e294ce7 100644 --- a/client/src/main/python/slipstream/cloudconnectors/BaseCloudConnector.py +++ b/client/src/main/python/slipstream/cloudconnectors/BaseCloudConnector.py @@ -468,11 +468,17 @@ def __start_node_instance_and_client(self, user_info, node_instance): self._print_detail("Starting instance: %s" % node_instance_name) - self.cimi_deployment_prototype = bool(node_instance.get_deployment_context()) + node_context = node_instance.get_deployment_context() + self.cimi_deployment_prototype = bool(node_context) + + if self.cimi_deployment_prototype: + vm_name = node_instance_name + '--' + node_context.get('SLIPSTREAM_DIID', '').replace('deployment/', '') + else: + vm_name = self._generate_vm_name(node_instance_name) vm = self._start_image(user_info, node_instance, - self._generate_vm_name(node_instance_name)) + vm_name) self.__add_vm(vm, node_instance) @@ -533,6 +539,12 @@ def _publish_vm_info(self, vm, node_instance): already_published.add('ssh') if vm_ports_mapping and 'vm_ports_mapping' not in already_published: node_instance.set_cloud_node_ports_mapping(vm_ports_mapping) + ssh_found = re.search('tcp:(\d+):22', str(vm_ports_mapping)) + if ssh_found: + ssh_username, ssh_password = self.__get_vm_username_password(node_instance) + node_instance.set_cloud_node_ssh_url('ssh://{}@{}:{}'.format(ssh_username.strip(), + vm_ip.strip(), + ssh_found.group(1))) already_published.add('vm_ports_mapping') else: if vm_id and 'id' not in already_published: diff --git a/client/src/main/python/slipstream/command/RunInstancesCommand.py b/client/src/main/python/slipstream/command/RunInstancesCommand.py index d8d5b4c9..3e388a3f 100755 --- a/client/src/main/python/slipstream/command/RunInstancesCommand.py +++ b/client/src/main/python/slipstream/command/RunInstancesCommand.py @@ -153,7 +153,7 @@ def _run_instance(self, node_instance): verbose_level = self.get_option('verbose') and 3 or 0 ch = ConfigHolder(options={'verboseLevel': verbose_level, 'retry': False, - KEY_RUN_CATEGORY: RUN_CATEGORY_DEPLOYMENT}, + KEY_RUN_CATEGORY: RUN_CATEGORY_DEPLOYMENT}, context={'foo': 'bar'}, config={'foo': 'bar'}) diff --git a/client/src/main/python/slipstream/command/VMCommandBase.py b/client/src/main/python/slipstream/command/VMCommandBase.py index 8f70004d..d257ea01 100755 --- a/client/src/main/python/slipstream/command/VMCommandBase.py +++ b/client/src/main/python/slipstream/command/VMCommandBase.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/slipstream/command/VerticalScaleCommandBase.py b/client/src/main/python/slipstream/command/VerticalScaleCommandBase.py index a8c2a8ce..d9841c95 100755 --- a/client/src/main/python/slipstream/command/VerticalScaleCommandBase.py +++ b/client/src/main/python/slipstream/command/VerticalScaleCommandBase.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/slipstream/executors/MachineExecutor.py b/client/src/main/python/slipstream/executors/MachineExecutor.py index d5378ea7..a2e6730d 100644 --- a/client/src/main/python/slipstream/executors/MachineExecutor.py +++ b/client/src/main/python/slipstream/executors/MachineExecutor.py @@ -75,7 +75,7 @@ def _execute(self): state = self._get_state() while True: self._execute_state(state) - self._complete_state(state) + self._kb_complete_state(state) state = self._wait_for_next_state(state) def _get_state(self): @@ -131,6 +131,10 @@ def _complete_state(self, state): if self._need_to_complete(state): self.wrapper.complete_state() + def _kb_complete_state(self, state): + if self._need_to_complete(state): + self.wrapper.kb_complete_state(state) + @staticmethod def _failure_msg_from_exception(exception): """ @@ -177,7 +181,7 @@ def _get_sleep_time(self, state): return self.WAIT_NEXT_STATE_SHORT def _retrieve_my_node_instance(self): - node_instance = self.wrapper.get_my_node_instance() + node_instance = self.wrapper.kb_get_my_node_instance() if node_instance is None: raise ExecutionException("Couldn't get the node instance for the current VM.") return node_instance @@ -189,7 +193,7 @@ def _is_recovery_mode(self): return self.recovery_mode == True def _is_mutable(self): - return self.wrapper.is_mutable() + return False # self.wrapper.is_mutable() def _need_to_complete(self, state): return state not in ['Finalizing', 'Done', 'Cancelled', 'Aborted'] @@ -201,6 +205,10 @@ def _execute_execute_target(self): self._execute_target('execute', abort_on_err=True) self._set_need_to_send_reports() + def _kb_execute_execute_target(self): + self._kb_execute_target('deployment', abort_on_err=True) + self._set_need_to_send_reports() + def _execute_target(self, target_name, exports=None, abort_on_err=False, ssdisplay=True, ignore_abort=False): target = self.node_instance.get_image_target(target_name) @@ -237,6 +245,24 @@ def _execute_target(self, target_name, exports=None, abort_on_err=False, ssdispl else: util.printAndFlush('Nothing to do for script: %s' % full_target_name) + def _kb_get_target(self, target_name): + return self.node_instance['content'].get('targets', {}).get(target_name) + + def _kb_execute_target(self, target_name, exports=None, abort_on_err=False, ssdisplay=True, ignore_abort=False): + target = self._kb_get_target(target_name) + + if not target: + util.printAndFlush('Nothing to do for script: %s' % target_name) + return + + full_target_name = '%s:%s' % (self.node_instance['name'], target_name) + message = "Executing script '%s'" % full_target_name + util.printStep(message) + + fail_msg = "Failed running '%s' script on '%s'" % (target_name, self._get_node_instance_name()) + for i, sub_t in enumerate(target): + self._launch_script(sub_t, exports, abort_on_err, ignore_abort, fail_msg, '{}[{}]'.format(target_name, i)) + def _need_to_execute_build_step(self, target, subtarget): return MachineExecutor.need_to_execute_build_step(self._get_node_instance(), target, subtarget) @@ -340,10 +366,12 @@ def _run_target_script(self, target_script, exports=None, ignore_abort=False, na util.printDetail("End of the script '%s'" % (_name,)) stderr_last_line = '' - try: - stderr_last_line = result.get(timeout=60) - except Empty: - pass + + if process.returncode != self.SCRIPT_EXIT_SUCCESS: + try: + stderr_last_line = result.get(timeout=60) + except Empty: + pass return process.returncode, stderr_last_line def _write_target_script_to_file(self, target_script, name=None): @@ -446,21 +474,15 @@ def onSendingReports(self): def onReady(self): util.printAction('Ready') - def onFinalizing(self): - util.printAction('Finalizing') - - if self.wrapper.isAbort(): - util.printError("Failed") - else: - util.printAction('Done!') - def onDone(self): + util.printAction('Done!') self._abort_running_in_final_state() def onCancelled(self): self._abort_running_in_final_state() def onAborted(self): + util.printError("Failed") self._abort_running_in_final_state() def _abort_running_in_final_state(self): diff --git a/client/src/main/python/slipstream/executors/node/NodeDeploymentExecutor.py b/client/src/main/python/slipstream/executors/node/NodeDeploymentExecutor.py index 43ae66d1..b5197879 100644 --- a/client/src/main/python/slipstream/executors/node/NodeDeploymentExecutor.py +++ b/client/src/main/python/slipstream/executors/node/NodeDeploymentExecutor.py @@ -43,58 +43,67 @@ def __init__(self, wrapper, config_holder=ConfigHolder()): @override def onProvisioning(self): - super(NodeDeploymentExecutor, self).onProvisioning() - - if self.wrapper.is_scale_state_creating(): - self._add_ssh_pubkey(self.node_instance.get_username()) - self.wrapper.set_scale_state_created() - elif self._is_vertical_scaling(): - if not self._is_pre_scale_done(): - self._execute_pre_scale_action_target() - self.wrapper.set_pre_scale_done() - - # Orchestrator applies IaaS action on the node instance. - - self.wrapper.wait_scale_iaas_done() - self.wrapper.unset_pre_scale_done() - self._execute_post_scale_action_target() - self.wrapper.set_scale_action_done() - self._skip_execute_due_to_vertical_scaling = True - elif self._is_horizontal_scale_down(): - self._execute_pre_scale_action_target() - self._execute_report_target_and_send_reports() - self.wrapper.set_pre_scale_done() - # We are ready to be terminated. + util.printAction('Provisioning') + self._add_ssh_pubkey(self.wrapper.get_user_login()) + # super(NodeDeploymentExecutor, self).onProvisioning() + # + # if self.wrapper.is_scale_state_creating(): + # self._add_ssh_pubkey(self.node_instance.get_username()) + # self.wrapper.set_scale_state_created() + # elif self._is_vertical_scaling(): + # if not self._is_pre_scale_done(): + # self._execute_pre_scale_action_target() + # self.wrapper.set_pre_scale_done() + # + # # Orchestrator applies IaaS action on the node instance. + # + # self.wrapper.wait_scale_iaas_done() + # self.wrapper.unset_pre_scale_done() + # self._execute_post_scale_action_target() + # self.wrapper.set_scale_action_done() + # self._skip_execute_due_to_vertical_scaling = True + # elif self._is_horizontal_scale_down(): + # self._execute_pre_scale_action_target() + # self._execute_report_target_and_send_reports() + # self.wrapper.set_pre_scale_done() + # # We are ready to be terminated. @override def onExecuting(self): util.printAction('Executing') - self._get_recovery_mode() - if self._is_recovery_mode(): - util.printDetail("Recovery mode enabled, recipes will not be executed.", - verboseThreshold=util.VERBOSE_LEVEL_QUIET) - return + #self._get_recovery_mode() + #if self._is_recovery_mode(): + # util.printDetail("Recovery mode enabled, recipes will not be executed.", + # verboseThreshold=util.VERBOSE_LEVEL_QUIET) + # return - if self._skip_execute_due_to_vertical_scaling: - util.printDetail("Vertical scaling: skipping execution of execute targets.", - verboseThreshold=util.VERBOSE_LEVEL_QUIET) - self._skip_execute_due_to_vertical_scaling = False - return + #if self._skip_execute_due_to_vertical_scaling: + # util.printDetail("Vertical scaling: skipping execution of execute targets.", + # verboseThreshold=util.VERBOSE_LEVEL_QUIET) + # self._skip_execute_due_to_vertical_scaling = False + # return - if not self.wrapper.is_scale_state_operational(): - self._execute_build_recipes() - self._execute_execute_target() - else: - self._execute_scale_action_target() + #if not self.wrapper.is_scale_state_operational(): + self._kb_execute_build_recipes() + self._kb_execute_execute_target() + #else: + # self._execute_scale_action_target() def _execute_build_recipes(self): util.printDetail('Executing build recipes') - self._execute_target(NodeDecorator.NODE_PRERECIPE, abort_on_err=True) + self._execute_target('preinstall', abort_on_err=True) self._install_user_packages() self._execute_target(NodeDecorator.NODE_RECIPE, abort_on_err=True) + def _kb_execute_build_recipes(self): + util.printDetail('Executing build recipes') + + self._kb_execute_target('preinstall', abort_on_err=True) + self._kb_install_user_packages() + self._kb_execute_target('postinstall', abort_on_err=True) + def _install_user_packages(self): util.printAndFlush('Installing packages') @@ -113,17 +122,35 @@ def _install_user_packages(self): else: util.printAndFlush('No packages to install') + def _kb_install_user_packages(self): + util.printAndFlush('Installing packages') + + # if self.is_image_built(): + # util.printAndFlush('Component already built. No packages to install') + # return + + packages = self._kb_get_target('packages') + if packages: + message = 'Installing packages: %s' % ', '.join(packages) + fail_msg = "Failed installing packages on '%s'" % self._get_node_instance_name() + util.printStep(message) + #self.wrapper.set_statecustom(message) + cmd = util.get_packages_install_command('ubuntu', packages) + self._launch_script('#!/bin/sh -xe\n%s' % cmd, fail_msg=fail_msg, name='Install packages') + else: + util.printAndFlush('No packages to install') + @override def onSendingReports(self): util.printAction('Sending report') if self._need_to_send_reports(): - self._execute_report_target_and_send_reports() + self._kb_execute_report_target_and_send_reports() self._unset_need_to_send_reports() else: util.printDetail('INFO: Conditionally skipped sending reports.', verboseThreshold=util.VERBOSE_LEVEL_QUIET) - self.wrapper.set_scale_state_operational() + # self.wrapper.set_scale_state_operational() def _execute_report_target_and_send_reports(self): exports = {'SLIPSTREAM_REPORT_DIR': util.get_platform_reports_dir()} @@ -137,6 +164,18 @@ def _execute_report_target_and_send_reports(self): finally: super(NodeDeploymentExecutor, self).onSendingReports() + def _kb_execute_report_target_and_send_reports(self): + exports = {'SLIPSTREAM_REPORT_DIR': util.get_platform_reports_dir()} + try: + self._kb_execute_target('reporting', exports=exports, ssdisplay=False, ignore_abort=True) + except ExecutionException as ex: + util.printDetail("Failed executing 'report' with: \n%s" % str(ex), + verboseLevel=self.verboseLevel, + verboseThreshold=util.VERBOSE_LEVEL_NORMAL) + raise + finally: + super(NodeDeploymentExecutor, self).onSendingReports() + @override def onReady(self): super(NodeDeploymentExecutor, self).onReady() @@ -189,7 +228,7 @@ def _unset_need_to_send_reports(self): self._send_reports = False def _need_to_send_reports(self): - return self._send_reports or not self.wrapper.is_scale_state_operational() + return self._send_reports # or not self.wrapper.is_scale_state_operational() def _get_scale_action(self): return self.wrapper.get_scale_action() diff --git a/client/src/main/python/slipstream/executors/node/NodeExecutorFactory.py b/client/src/main/python/slipstream/executors/node/NodeExecutorFactory.py index 5acb8415..3badc2a3 100644 --- a/client/src/main/python/slipstream/executors/node/NodeExecutorFactory.py +++ b/client/src/main/python/slipstream/executors/node/NodeExecutorFactory.py @@ -38,7 +38,7 @@ class NodeExecutorFactory: @staticmethod def createExecutor(configHolder): wrapper = BaseWrapper(configHolder) - runType = wrapper.get_run_type() + runType = 'Run' # wrapper.get_run_type() return loadModule(get_executor_module_name(runType)). \ getExecutor(wrapper, configHolder) diff --git a/client/src/main/python/slipstream/util.py b/client/src/main/python/slipstream/util.py index a4deafea..d384d76b 100644 --- a/client/src/main/python/slipstream/util.py +++ b/client/src/main/python/slipstream/util.py @@ -717,7 +717,8 @@ def append_ssh_pubkey_to_authorized_keys(pubkey, user=''): except: pass - file_content = '\n# Keys added by SlipStream\n%s\n# End of keys added by SlipStream\n' % pubkey + # pubkey is a collection of keys in cimi deployment + file_content = '\n# Keys added by SlipStream\n%s\n# End of keys added by SlipStream\n' % '\r\n\r\n'.join(pubkey) authorized_keys_path = dot_ssh_path + '/authorized_keys' fileAppendContent(authorized_keys_path, file_content) diff --git a/client/src/main/python/slipstream/wrappers/BaseWrapper.py b/client/src/main/python/slipstream/wrappers/BaseWrapper.py index 127b2ebb..64ab3fda 100644 --- a/client/src/main/python/slipstream/wrappers/BaseWrapper.py +++ b/client/src/main/python/slipstream/wrappers/BaseWrapper.py @@ -159,9 +159,13 @@ def complete_state(self, node_instance_name=None): node_instance_name = self.get_my_node_instance_name() self._ss_client.complete_state(node_instance_name) + def kb_complete_state(self, state, node_instance_name=None): + if not node_instance_name: + node_instance_name = self.get_my_node_instance_name() + self._ss_client.kb_complete_state(state, node_instance_name) + def fail(self, message): - key = self._qualifyKey(NodeDecorator.ABORT_KEY) - self._fail(key, message) + self._ss_client.kb_set_deployment_parameter(NodeDecorator.ABORT_KEY, message, self.get_my_node_instance_name()) def fail_global(self, message): key = NodeDecorator.globalNamespacePrefix + NodeDecorator.ABORT_KEY @@ -171,23 +175,20 @@ def _fail(self, key, message): util.printError('Failing... %s' % message) traceback.print_exc() value = util.truncate_middle(Client.VALUE_LENGTH_LIMIT, message, '\n(truncated)\n') - self._ss_client.setRuntimeParameter(key, value) + self._ss_client.kb_set_deployment_parameter(key, value) def getState(self): - key = NodeDecorator.globalNamespacePrefix + NodeDecorator.STATE_KEY - return self._get_runtime_parameter(key) + return self._ss_client.kb_get_deployment_parameter( + NodeDecorator.globalNamespacePrefix + NodeDecorator.STATE_KEY) def get_recovery_mode(self): key = NodeDecorator.globalNamespacePrefix + NodeDecorator.RECOVERY_MODE_KEY return util.str2bool(self._get_runtime_parameter(key)) def isAbort(self): - key = NodeDecorator.globalNamespacePrefix + NodeDecorator.ABORT_KEY - try: - value = self._get_runtime_parameter(key, True) - except Exceptions.NotYetSetException: - value = '' - return (value and True) or False + value = self._ss_client.kb_get_deployment_parameter( + NodeDecorator.globalNamespacePrefix + NodeDecorator.ABORT_KEY) + return value is not None def get_max_iaas_workers(self): """Available only on orchestrator. @@ -236,8 +237,10 @@ def get_cloud_instance_id(self): return self._get_runtime_parameter(key) def get_user_ssh_pubkey(self): - userInfo = self._get_user_info('') - return userInfo.get_public_keys() + return self._ss_client.kb_get_userparam_ssh_pubkeys() + + def get_user_login(self): + return self.kb_get_my_node_instance().get('content', {}).get('loginUser') def get_pre_scale_done(self, node_instance_or_name=None): """Get pre.scale.done RTP for the current node instance or for the requested one @@ -548,10 +551,10 @@ def wait_scale_iaas_done(self): timeout_at = 0 # no timeout self._log('Waiting for Orchestrator to finish scaling this node instance (no timeout).') - node_instances = [self.get_my_node_instance()] - - self._wait_rtp_equals(node_instances, NodeDecorator.SCALE_IAAS_DONE_SUCCESS, - self.get_scale_iaas_done, timeout_at) + # node_instances = [self.get_my_node_instance()] + # + # self._wait_rtp_equals(node_instances, NodeDecorator.SCALE_IAAS_DONE_SUCCESS, + # self.get_scale_iaas_done, timeout_at) self._log('All node instances finished pre-scaling.') @@ -591,6 +594,10 @@ def get_my_node_instance(self): node_name = self.get_my_node_instance_name() return self._get_nodes_instances_with_orchestrators().get(node_name) + def kb_get_my_node_instance(self): + node_name = self.get_my_node_instance_name() + return self._ss_client.kb_get_node_instance(node_name) + def discard_run_locally(self): self._ss_client.discard_run() diff --git a/client/src/main/python/ss-abort.py b/client/src/main/python/ss-abort.py index bc03ba3f..810361c6 100755 --- a/client/src/main/python/ss-abort.py +++ b/client/src/main/python/ss-abort.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== @@ -69,7 +69,8 @@ def doWork(self): else: value = truncate_middle(Client.VALUE_LENGTH_LIMIT, self.reason, '\n(truncated)\n') - client.setRuntimeParameter(NodeDecorator.ABORT_KEY, value) + client.kb_setRuntimeParameter(NodeDecorator.ABORT_KEY, value) + if __name__ == "__main__": try: diff --git a/client/src/main/python/ss-cancel-abort.py b/client/src/main/python/ss-cancel-abort.py index 76817e6a..27147002 100755 --- a/client/src/main/python/ss-cancel-abort.py +++ b/client/src/main/python/ss-cancel-abort.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-config-dump.py b/client/src/main/python/ss-config-dump.py index 91f62b03..48f26673 100755 --- a/client/src/main/python/ss-config-dump.py +++ b/client/src/main/python/ss-config-dump.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-display.py b/client/src/main/python/ss-display.py index dac73ab2..7d42cf64 100755 --- a/client/src/main/python/ss-display.py +++ b/client/src/main/python/ss-display.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== @@ -57,7 +57,8 @@ def parse(self): def doWork(self): ch = ConfigHolder(self.options) client = Client(ch) - client.setRuntimeParameter('statecustom', self.value) + client.kb_setRuntimeParameter('statecustom', self.value) + if __name__ == "__main__": try: diff --git a/client/src/main/python/ss-execute.py b/client/src/main/python/ss-execute.py index 557be279..cc52ad0e 100755 --- a/client/src/main/python/ss-execute.py +++ b/client/src/main/python/ss-execute.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-get-all.py b/client/src/main/python/ss-get-all.py index ec09f26f..57777e9b 100755 --- a/client/src/main/python/ss-get-all.py +++ b/client/src/main/python/ss-get-all.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-get.py b/client/src/main/python/ss-get.py index fc32033a..56bd754c 100755 --- a/client/src/main/python/ss-get.py +++ b/client/src/main/python/ss-get.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== @@ -68,9 +68,10 @@ def _checkArgs(self): def doWork(self): ch = ConfigHolder(self.options) client = Client(ch) - value = client.getRuntimeParameter(self.key) + value = client.kb_getRuntimeParameter(self.key) print(value if value is not None else '') + if __name__ == "__main__": try: MainProgram() diff --git a/client/src/main/python/ss-login.py b/client/src/main/python/ss-login.py index 3487fb81..31ef549d 100755 --- a/client/src/main/python/ss-login.py +++ b/client/src/main/python/ss-login.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-logout.py b/client/src/main/python/ss-logout.py index 3dd1c425..6a433915 100755 --- a/client/src/main/python/ss-logout.py +++ b/client/src/main/python/ss-logout.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-module-delete.py b/client/src/main/python/ss-module-delete.py index 57a731d3..6e413cde 100755 --- a/client/src/main/python/ss-module-delete.py +++ b/client/src/main/python/ss-module-delete.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-module-download.py b/client/src/main/python/ss-module-download.py index db612edc..7a2eccac 100755 --- a/client/src/main/python/ss-module-download.py +++ b/client/src/main/python/ss-module-download.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-module-get.py b/client/src/main/python/ss-module-get.py index 04d26a7b..00645a1a 100755 --- a/client/src/main/python/ss-module-get.py +++ b/client/src/main/python/ss-module-get.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-module-put.py b/client/src/main/python/ss-module-put.py index a86e3930..f792f51c 100755 --- a/client/src/main/python/ss-module-put.py +++ b/client/src/main/python/ss-module-put.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-module-upload.py b/client/src/main/python/ss-module-upload.py index 558eba43..271c8154 100755 --- a/client/src/main/python/ss-module-upload.py +++ b/client/src/main/python/ss-module-upload.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-node-add.py b/client/src/main/python/ss-node-add.py index 47358887..408e724d 100755 --- a/client/src/main/python/ss-node-add.py +++ b/client/src/main/python/ss-node-add.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-node-remove.py b/client/src/main/python/ss-node-remove.py index c5c37da6..f052327f 100755 --- a/client/src/main/python/ss-node-remove.py +++ b/client/src/main/python/ss-node-remove.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-random.py b/client/src/main/python/ss-random.py index 802d49cf..4071aefe 100755 --- a/client/src/main/python/ss-random.py +++ b/client/src/main/python/ss-random.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-reports-get.py b/client/src/main/python/ss-reports-get.py index 712af07c..00371967 100755 --- a/client/src/main/python/ss-reports-get.py +++ b/client/src/main/python/ss-reports-get.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-run-get.py b/client/src/main/python/ss-run-get.py index 6a1975ae..3fd9c425 100755 --- a/client/src/main/python/ss-run-get.py +++ b/client/src/main/python/ss-run-get.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-scale-disk.py b/client/src/main/python/ss-scale-disk.py index 0aa289b7..3e8dfbdf 100755 --- a/client/src/main/python/ss-scale-disk.py +++ b/client/src/main/python/ss-scale-disk.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-scale-resize.py b/client/src/main/python/ss-scale-resize.py index f3b98268..0d217f03 100755 --- a/client/src/main/python/ss-scale-resize.py +++ b/client/src/main/python/ss-scale-resize.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-set.py b/client/src/main/python/ss-set.py index 97259dde..fedd2e40 100755 --- a/client/src/main/python/ss-set.py +++ b/client/src/main/python/ss-set.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== @@ -60,7 +60,8 @@ def parse(self): def doWork(self): ch = ConfigHolder(self.options) client = Client(ch) - client.setRuntimeParameter(self.key, self.value) + client.kb_setRuntimeParameter(self.key, self.value) + if __name__ == "__main__": try: diff --git a/client/src/main/python/ss-terminate.py b/client/src/main/python/ss-terminate.py index da067f7e..a0af2311 100755 --- a/client/src/main/python/ss-terminate.py +++ b/client/src/main/python/ss-terminate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-user-get.py b/client/src/main/python/ss-user-get.py index 2dd487fa..ed0ffdee 100755 --- a/client/src/main/python/ss-user-get.py +++ b/client/src/main/python/ss-user-get.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/python/ss-user-put.py b/client/src/main/python/ss-user-put.py index 10934b80..0417913f 100755 --- a/client/src/main/python/ss-user-put.py +++ b/client/src/main/python/ss-user-put.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/scripts/slipstream-node b/client/src/main/scripts/slipstream-node index f082eee3..f452be2f 100755 --- a/client/src/main/scripts/slipstream-node +++ b/client/src/main/scripts/slipstream-node @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/scripts/slipstream-orchestrator b/client/src/main/scripts/slipstream-orchestrator index da00eabe..d64042ef 100755 --- a/client/src/main/scripts/slipstream-orchestrator +++ b/client/src/main/scripts/slipstream-orchestrator @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/scripts/slipstream-prepare-bootstrap.py b/client/src/main/scripts/slipstream-prepare-bootstrap.py index 4cd1a7e9..01b1166e 100644 --- a/client/src/main/scripts/slipstream-prepare-bootstrap.py +++ b/client/src/main/scripts/slipstream-prepare-bootstrap.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ SlipStream Client ===== diff --git a/client/src/main/scripts/slipstream.bootstrap.py b/client/src/main/scripts/slipstream.bootstrap.py index fb21348b..d213bf1c 100755 --- a/client/src/main/scripts/slipstream.bootstrap.py +++ b/client/src/main/scripts/slipstream.bootstrap.py @@ -846,9 +846,6 @@ def _is_linux(): def _get_machine_executor_direct_startup_command(executor_name): - custom_python_bin = os.path.join(os.sep, 'opt', 'python', 'bin') - info('Prepending %s to PATH.' % custom_python_bin) - os.putenv('PATH', '%s:%s' % (custom_python_bin, os.environ['PATH'])) cmd = os.path.join(SLIPSTREAM_CLIENT_HOME, 'sbin', 'slipstream-%s' % executor_name) os.chdir(cmd.rsplit(os.sep, 1)[0]) if sys.platform == 'win32': @@ -1063,7 +1060,7 @@ def _process_response(self, response): error(response.status, response.reason) error(response.read()) else: - print('Published abort message to %s' % uri) + print('Published abort message to %s' % url) if __name__ == "__main__": diff --git a/client/src/main/scripts/slipstream_bootstrap.py b/client/src/main/scripts/slipstream_bootstrap.py deleted file mode 120000 index 6785d710..00000000 --- a/client/src/main/scripts/slipstream_bootstrap.py +++ /dev/null @@ -1 +0,0 @@ -slipstream.bootstrap.py \ No newline at end of file