def main(args): sm = storage_manager_instance() manager_venv = args[1] operation = args[2] max_attempts = args[3] with open('auth_config.yaml', 'r') as auth_stream: custom_auth = yaml.load(auth_stream) or {} actions = _prepare_auth_updates(custom_auth, sm) if os.path.isfile('deployment_id'): with open('deployment_id', 'r') as deployment_file: deployment_id = deployment_file.read() deployments = [sm.get_deployment(deployment_id)] else: deployments = sm.deployments_list() errors = [] for deployment in deployments: node_instances = sm.get_node_instances(deployment.id) if agents_utils.is_deployment_installed(node_instances): try: _perform_deployment_updates( deployment.id, actions, 'update', sm ) cmd = '/bin/bash modify_agents.sh {} {} {} {} {}'.format( deployment.blueprint_id, deployment.id, manager_venv, operation, max_attempts ) ret = os.system(cmd) finally: _perform_deployment_updates( deployment.id, actions, 'revert', sm ) if ret: errors.append(deployment.id) else: print 'Deployment {0} is not installed, skipping'.format( deployment.id ) for dep in errors: print 'Deployment {0}: operation {1} failed.'.format(dep, operation)
def main(args): execution_id = str(uuid.uuid4()) blueprint_id = args[1] deployment_id = args[2] op_name = args[3] if len(args) > 4: attempt_limit = int(args[4]) else: attempt_limit = _DEFAULT_ATTEMPT_LIMIT sm = storage_manager_instance() _start_workflow(blueprint_id, deployment_id, execution_id, op_name, sm) return _wait_for_execution_finish(execution_id, attempt_limit, sm)