def submit_task(action_name, target_obj, args, environment, session, token, unit): task = ActionServices.create_action_task( action_name, target_obj, args, environment, session, token) actions_db.update_task(action_name, session, task, unit) rpc.engine().handle_task(task)
def submit_task(action_name, target_obj, args, environment, session, token, unit): task = ActionServices.create_action_task(action_name, target_obj, args, environment, session, token) task_id = actions_db.update_task(action_name, session, task, unit) rpc.engine().handle_task(task) return task_id
def deploy(session, unit, token): """ Prepares environment for deployment and send deployment command to orchestration engine :param session: session that is going to be deployed :param unit: SQLalchemy session :param token: auth token that is going to be used by orchestration """ #Set X-Auth-Token for conductor environment = unit.query(models.Environment).get( session.environment_id) task = { 'action': { 'object_id': environment.id, 'method': 'deploy', 'args': {} }, 'model': session.description, 'token': token, 'tenant_id': environment.tenant_id } task['model']['Objects']['?']['id'] = environment.id task['model']['Objects']['applications'] = \ task['model']['Objects'].get('services', []) if 'services' in task['model']['Objects']: del task['model']['Objects']['services'] session.state = SessionState.deploying deployment = models.Deployment() deployment.environment_id = session.environment_id deployment.description = token_sanitizer.TokenSanitizer().sanitize( dict(session.description.get('Objects'))) status = models.Status() status.text = "Deployment scheduled" status.level = "info" deployment.statuses.append(status) with unit.begin(): unit.add(session) unit.add(deployment) rpc.engine().handle_task(task)
def package_delete(package_id, context): """Delete a package by ID.""" session = db_session.get_session() with session.begin(): package = _package_get(package_id, session) if not context.is_admin and package.owner_id != context.tenant: raise exc.HTTPForbidden( explanation="Package is not owned by the" " tenant '{0}'".format(context.tenant)) task = { 'tenant_id': '-1', 'action': 'delete_package', 'id': package.id, 'fqn': package.fully_qualified_name, 'package_version': package.get('package_version', '0.0.0'), } rpc.engine().broadcast_task(task) session.delete(package)
def delete(environment_id, token): """ Deletes environment and notify orchestration engine about deletion :param environment_id: Environment that is going to be deleted :param token: OpenStack auth token """ unit = db_session.get_session() environment = unit.query(models.Environment).get(environment_id) #preparing data for removal from conductor env = environment.description env['Objects'] = None data = { 'model': env, 'token': token, 'tenant_id': environment.tenant_id } rpc.engine().handle_task(data) with unit.begin(): unit.delete(environment)
def execute(method_name, class_name, pkg_name, class_version, args, credentials): action = { 'method': method_name, 'args': args or {}, 'class_name': class_name, 'pkg_name': pkg_name, 'class_version': class_version } task = { 'action': action, 'token': credentials['token'], 'tenant_id': credentials['tenant_id'], 'id': str(uuid.uuid4()) } return rpc.engine().call_static_action(task)
def get_schema(self, request, class_name, method_names=None): LOG.debug('GetSchema:GetSchema') target = {"class_name": class_name} policy.check("get_schema", request.context, target) class_version = request.GET.get('classVersion') package_name = request.GET.get('packageName') credentials = { 'token': request.context.auth_token, 'project_id': request.context.tenant } try: methods = (list( map(str.strip, method_names.split(','))) if method_names else []) return rpc.engine().generate_schema( credentials, class_name, methods, class_version, package_name) except client.RemoteError as e: if e.exc_type in ('NoClassFound', 'NoPackageForClassFound', 'NoPackageFound'): raise exc.HTTPNotFound(e.value) raise