def edit(req): prefix = 'edit-' cluster_id = req.POST['cluster_id'] tech_account_id = req.POST['id'] name = req.POST[prefix + 'name'] is_active = req.POST.get(prefix + 'is_active') is_active = True if is_active else False cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() try: zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster_id zato_message.data.tech_account_id = tech_account_id zato_message.data.name = name zato_message.data.is_active = is_active _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:security.tech-account.edit', zato_message) except Exception, e: msg = "Could not update the technical account, e=[{e}]".format(e=format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)
def index(req): zato_clusters = req.odb.query(Cluster).order_by('name').all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get('cluster') items = [] create_form = CreateForm() edit_form = EditForm(prefix='edit') if cluster_id and req.method == 'GET': cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() def_ids = _get_def_ids(cluster) create_form.set_def_id(def_ids) edit_form.set_def_id(def_ids) zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:outgoing.amqp.get-list', zato_message) if zato_path('data.item_list.item').get_from(zato_message) is not None: for msg_item in zato_message.data.item_list.item: id = msg_item.id.text name = msg_item.name.text is_active = is_boolean(msg_item.is_active.text) delivery_mode = int(msg_item.delivery_mode.text) priority = msg_item.priority.text content_type = msg_item.content_type.text content_encoding = msg_item.content_encoding.text expiration = msg_item.expiration.text user_id = msg_item.user_id.text app_id = msg_item.app_id.text delivery_mode_text = delivery_friendly_name[delivery_mode] def_name = msg_item.def_name.text def_id = msg_item.def_id.text item = OutgoingAMQP(id, name, is_active, delivery_mode, priority, content_type, content_encoding, expiration, user_id, app_id, def_id, delivery_mode_text, def_name) items.append(item) return_data = {'zato_clusters':zato_clusters, 'cluster_id':cluster_id, 'choose_cluster_form':choose_cluster_form, 'items':items, 'create_form':create_form, 'edit_form':edit_form, } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data)) return render_to_response('zato/outgoing/amqp.html', return_data, context_instance=RequestContext(req))
def _get_security_list(cluster): zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster.id _, zato_message, _ = invoke_admin_service(cluster, 'zato:security.get-list', zato_message) return zato_message
def index(req): zato_clusters = req.odb.query(Cluster).order_by('name').all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get('cluster') items = [] create_form = CreateForm() edit_form = EditForm(prefix='edit') if cluster_id and req.method == 'GET': cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:definition.jms_wmq.get-list', zato_message) if zato_path('data.definition_list.definition').get_from(zato_message) is not None: for definition_elem in zato_message.data.definition_list.definition: id = definition_elem.id.text name = definition_elem.name.text host = definition_elem.host.text port = definition_elem.port.text queue_manager = definition_elem.queue_manager.text channel = definition_elem.channel.text cache_open_send_queues = is_boolean(definition_elem.cache_open_send_queues.text) cache_open_receive_queues = is_boolean(definition_elem.cache_open_receive_queues.text) use_shared_connections = is_boolean(definition_elem.use_shared_connections.text) ssl = is_boolean(definition_elem.ssl.text) ssl_cipher_spec = definition_elem.ssl_cipher_spec.text ssl_key_repository = definition_elem.ssl_key_repository.text needs_mcd = is_boolean(definition_elem.needs_mcd.text) max_chars_printed = definition_elem.max_chars_printed.text def_jms_wmq = ConnDefWMQ(id, name, host, port, queue_manager, channel, cache_open_send_queues, cache_open_receive_queues, use_shared_connections, ssl, ssl_cipher_spec, ssl_key_repository, needs_mcd, max_chars_printed) items.append(def_jms_wmq) return_data = {'zato_clusters':zato_clusters, 'cluster_id':cluster_id, 'choose_cluster_form':choose_cluster_form, 'items':items, 'create_form':create_form, 'edit_form':edit_form, } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data)) return render_to_response('zato/definition/jms_wmq.html', return_data, context_instance=RequestContext(req))
def _get_edit_create_message(params, prefix=''): """ Creates a base document which can be used by both 'edit' and 'create' actions for channels and outgoing connections. """ zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.is_internal = False zato_message.data.connection = params['connection'] zato_message.data.transport = params['transport'] zato_message.data.id = params.get('id') zato_message.data.cluster_id = params['cluster_id'] zato_message.data.name = params[prefix + 'name'] zato_message.data.is_active = bool(params.get(prefix + 'is_active')) zato_message.data.url_path = params[prefix + 'url_path'] zato_message.data.method = params[prefix + 'method'] zato_message.data.soap_action = params.get(prefix + 'soap_action', '') zato_message.data.soap_version = params.get(prefix + 'soap_version', '') zato_message.data.service = params[prefix + 'service'] security = params[prefix + 'security'] if security != ZATO_NONE: _, sec_def_id = security.split('/') else: _, sec_def_id = ZATO_NONE, ZATO_NONE zato_message.data.sec_def_id = sec_def_id return zato_message
def index(req): zato_clusters = req.odb.query(Cluster).order_by('name').all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get('cluster') items = [] create_form = CreateForm() edit_form = EditForm(prefix='edit') change_password_form = ChangePasswordForm() if cluster_id and req.method == 'GET': cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster_id _ignored, zato_message, soap_response = invoke_admin_service(cluster, 'zato:security.wss.get-list', zato_message) if zato_path('data.definition_list.definition').get_from(zato_message) is not None: for definition_elem in zato_message.data.definition_list.definition: id = definition_elem.id.text name = definition_elem.name.text is_active = is_boolean(definition_elem.is_active.text) username = definition_elem.username.text password_type = ZATO_WSS_PASSWORD_TYPES[definition_elem.password_type.text] password_type_raw = definition_elem.password_type.text reject_empty_nonce_ts = definition_elem.reject_empty_nonce_ts reject_stale_username = definition_elem.reject_stale_username expiry_limit = definition_elem.expiry_limit nonce_freshness = definition_elem.nonce_freshness wss = WSSDefinition(id, name, is_active, username, None, password_type, reject_empty_nonce_ts, reject_stale_username, expiry_limit, nonce_freshness, password_type_raw=password_type_raw) items.append(wss) return_data = {'zato_clusters':zato_clusters, 'cluster_id':cluster_id, 'choose_cluster_form':choose_cluster_form, 'items':items, 'create_form': create_form, 'edit_form': edit_form, 'change_password_form': change_password_form } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, 'Returning render_to_response [%s]' % return_data) return render_to_response('zato/security/wss.html', return_data, context_instance=RequestContext(req))
def _get_edit_create_message(params, prefix=''): """ Creates a base document which can be used by both 'edit' and 'create' actions. """ zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = params.get('id') zato_message.data.cluster_id = params['cluster_id'] zato_message.data.name = params[prefix + 'name'] zato_message.data.is_active = bool(params.get(prefix + 'is_active')) return zato_message
def index(req): zato_clusters = req.odb.query(Cluster).order_by('name').all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get('cluster') items = [] create_form = CreateForm() edit_form = EditForm(prefix='edit') change_password_form = ChangePasswordForm() if cluster_id and req.method == 'GET': cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:definition.amqp.get-list', zato_message) if zato_path('data.definition_list.definition').get_from(zato_message) is not None: for definition_elem in zato_message.data.definition_list.definition: id = definition_elem.id.text name = definition_elem.name.text host = definition_elem.host.text port = definition_elem.port.text vhost = definition_elem.vhost.text username = definition_elem.username.text frame_max = definition_elem.frame_max.text heartbeat = definition_elem.heartbeat.text def_amqp = ConnDefAMQP(id, name, 'amqp', host, port, vhost, username, None, frame_max, heartbeat) items.append(def_amqp) return_data = {'zato_clusters':zato_clusters, 'cluster_id':cluster_id, 'choose_cluster_form':choose_cluster_form, 'items':items, 'create_form':create_form, 'edit_form':edit_form, 'change_password_form':change_password_form } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data)) return render_to_response('zato/definition/amqp.html', return_data, context_instance=RequestContext(req))
def index(req): zato_clusters = req.odb.query(Cluster).order_by("name").all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get("cluster") items = [] create_form = CreateForm() edit_form = EditForm(prefix="edit") if cluster_id and req.method == "GET": cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() def_ids = _get_def_ids(cluster) create_form.set_def_id(def_ids) edit_form.set_def_id(def_ids) zato_message = Element("{%s}zato_message" % zato_namespace) zato_message.data = Element("data") zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, "zato:channel.amqp.get-list", zato_message) if zato_path("data.item_list.item").get_from(zato_message) is not None: for msg_item in zato_message.data.item_list.item: id = msg_item.id.text name = msg_item.name.text is_active = is_boolean(msg_item.is_active.text) queue = msg_item.queue.text consumer_tag_prefix = msg_item.consumer_tag_prefix.text def_name = msg_item.def_name.text def_id = msg_item.def_id.text service_name = msg_item.service_name.text item = ChannelAMQP(id, name, is_active, queue, consumer_tag_prefix, def_id, def_name, service_name) items.append(item) return_data = { "zato_clusters": zato_clusters, "cluster_id": cluster_id, "choose_cluster_form": choose_cluster_form, "items": items, "create_form": create_form, "edit_form": edit_form, } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, "Returning render_to_response [{0}]".format(return_data)) return render_to_response("zato/channel/amqp.html", return_data, context_instance=RequestContext(req))
def index(req): zato_clusters = req.odb.query(Cluster).order_by("name").all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get("cluster") items = [] create_form = CreateForm() edit_form = EditForm(prefix="edit") change_password_form = ChangePasswordForm() if cluster_id and req.method == "GET": cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() zato_message = Element("{%s}zato_message" % zato_namespace) zato_message.data = Element("data") zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, "zato:outgoing.ftp.get-list", zato_message) if zato_path("data.item_list.item").get_from(zato_message) is not None: for msg_item in zato_message.data.item_list.item: id = msg_item.id.text name = msg_item.name.text is_active = is_boolean(msg_item.is_active.text) host = msg_item.host.text if msg_item.host else "" user = msg_item.user.text if msg_item.user else "" acct = msg_item.acct.text if msg_item.acct else "" timeout = msg_item.timeout.text if msg_item.timeout else "" port = msg_item.port.text if msg_item.port else "" dircache = is_boolean(msg_item.dircache.text) item = OutgoingFTP(id, name, is_active, host, user, None, acct, timeout, port, dircache) items.append(item) return_data = { "zato_clusters": zato_clusters, "cluster_id": cluster_id, "choose_cluster_form": choose_cluster_form, "items": items, "create_form": create_form, "edit_form": edit_form, "change_password_form": change_password_form, } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, "Returning render_to_response [{0}]".format(return_data)) return render_to_response("zato/outgoing/ftp.html", return_data, context_instance=RequestContext(req))
def index(req): zato_clusters = req.odb.query(Cluster).order_by('name').all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get('cluster') items = [] create_form = CreateForm() edit_form = EditForm(prefix='edit') if cluster_id and req.method == 'GET': cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() def_ids = _get_def_ids(cluster) create_form.set_def_id(def_ids) edit_form.set_def_id(def_ids) zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:channel.jms_wmq.get-list', zato_message) if zato_path('data.item_list.item').get_from(zato_message) is not None: for msg_item in zato_message.data.item_list.item: id = msg_item.id.text name = msg_item.name.text is_active = is_boolean(msg_item.is_active.text) queue = msg_item.queue.text def_name = msg_item.def_name.text def_id = msg_item.def_id.text service_name = msg_item.service_name.text item = ChannelWMQ(id, name, is_active, queue, def_id, def_name, service_name) items.append(item) return_data = {'zato_clusters':zato_clusters, 'cluster_id':cluster_id, 'choose_cluster_form':choose_cluster_form, 'items':items, 'create_form':create_form, 'edit_form':edit_form, } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data)) return render_to_response('zato/channel/jms_wmq.html', return_data, context_instance=RequestContext(req))
def _edit_create_response(cluster, verb, id, name, def_id): zato_message = Element("{%s}zato_message" % zato_namespace) zato_message.data = Element("data") zato_message.data.id = def_id _, zato_message, soap_response = invoke_admin_service(cluster, "zato:definition.amqp.get-by-id", zato_message) return_data = { "id": id, "message": "Successfully {0} the AMQP channel [{1}]".format(verb, name), "def_name": zato_message.data.definition.name.text, } return HttpResponse(dumps(return_data), mimetype="application/javascript")
def _get_edit_create_message(params, prefix=""): """ Creates a base document which can be used by both 'edit' and 'create' actions. """ zato_message = Element("{%s}zato_message" % zato_namespace) zato_message.data = Element("data") zato_message.data.id = params.get("id") zato_message.data.cluster_id = params["cluster_id"] zato_message.data.name = params[prefix + "name"] zato_message.data.is_active = bool(params.get(prefix + "is_active")) zato_message.data.def_id = params[prefix + "def_id"] zato_message.data.queue = params[prefix + "queue"] zato_message.data.consumer_tag_prefix = params[prefix + "consumer_tag_prefix"] zato_message.data.service = params[prefix + "service"] return zato_message
def _edit_create_response(cluster, verb, id, name, cluster_id, def_id): zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = def_id zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:definition.jms_wmq.get-by-id', zato_message) return_data = {'id': id, 'message': 'Successfully {0} the JMS WebSphere MQ channel [{1}]'.format(verb, name), 'def_name': zato_message.data.definition.name.text } return HttpResponse(dumps(return_data), mimetype='application/javascript')
def _get_def_ids(cluster): out = {} zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster.id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:definition.amqp.get-list', zato_message) if zato_path('data.definition_list.definition').get_from(zato_message) is not None: for definition_elem in zato_message.data.definition_list.definition: id = definition_elem.id.text name = definition_elem.name.text out[id] = name return out
def _get_create_edit_message(cluster, params, form_prefix=""): """ Creates a base document which can be used by both 'edit' and 'create' actions, regardless of the job's type. """ zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.name = params[form_prefix + 'name'] zato_message.data.cluster_id = cluster.id zato_message.data.id = params.get(form_prefix + 'id', '') zato_message.data.is_active = bool(params.get(form_prefix + 'is_active')) zato_message.data.service = params.get(form_prefix + 'service', '') zato_message.data.extra = params.get(form_prefix + 'extra', '') zato_message.data.start_date = params.get(form_prefix + 'start_date', '') return zato_message
def _edit_create_response(cluster, verb, id, name, delivery_mode_text, def_id): zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = def_id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:definition.amqp.get-by-id', zato_message) return_data = {'id': id, 'message': 'Successfully {0} the outgoing AMQP connection [{1}]'.format(verb, name), 'delivery_mode_text': delivery_mode_text, 'def_name': zato_message.data.definition.name.text } return HttpResponse(dumps(return_data), mimetype='application/javascript')
def index(req): zato_clusters = req.odb.query(Cluster).order_by('name').all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get('cluster') items = [] create_form = CreateForm() edit_form = EditForm(prefix='edit') change_password_form = ChangePasswordForm() if cluster_id and req.method == 'GET': cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:security.tech-account.get-list', zato_message) if zato_path('data.definition_list.definition').get_from(zato_message) is not None: for definition_elem in zato_message.data.definition_list.definition: id = definition_elem.id.text name = definition_elem.name.text is_active = is_boolean(definition_elem.is_active.text) account = TechnicalAccount(id, name, is_active=is_active) items.append(account) return_data = {'zato_clusters':zato_clusters, 'cluster_id':cluster_id, 'choose_cluster_form':choose_cluster_form, 'items':items, 'create_form':create_form, 'edit_form':edit_form, 'change_password_form':change_password_form } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data)) return render_to_response('zato/security/tech-account.html', return_data, context_instance=RequestContext(req))
def delete(req, id, cluster_id): cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() try: zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:security.basic-auth.delete', zato_message) except Exception, e: msg = "Could not delete the HTTP Basic Auth definition, e=[{e}]".format(e=format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)
def get_by_id(req, tech_account_id, cluster_id): try: zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.tech_account_id = tech_account_id cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:security.tech-account.get-by-id', zato_message) except Exception, e: msg = "Could not fetch the technical account, e=[{e}]".format(e=format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)
def execute(req, job_id, cluster_id): """ Executes a scheduler's job. """ try: cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = job_id invoke_admin_service(cluster, 'zato:scheduler.job.execute', zato_message) except Exception, e: msg = 'Could not execute the job. job_id=[{0}], cluster_id=[{1}], e=[{2}]'.format( job_id, cluster_id, format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)
def _get_edit_create_message(params, prefix=''): """ Creates a base document which can be used by both 'edit' and 'create' actions. """ zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = params.get('id') zato_message.data.cluster_id = params['cluster_id'] zato_message.data.name = params[prefix + 'name'] zato_message.data.host = params[prefix + 'host'] zato_message.data.port = params[prefix + 'port'] zato_message.data.vhost = params[prefix + 'vhost'] zato_message.data.username = params[prefix + 'username'] zato_message.data.frame_max = params[prefix + 'frame_max'] zato_message.data.heartbeat = int(params.get(prefix + 'heartbeat')) return zato_message
def _get_edit_create_message(params, prefix=''): """ Creates a base document which can be used by both 'edit' and 'create' actions. """ zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = params.get('id') zato_message.data.cluster_id = params['cluster_id'] zato_message.data.name = params[prefix + 'name'] zato_message.data.is_active = bool(params.get(prefix + 'is_active')) zato_message.data.username = params[prefix + 'username'] zato_message.data.password_type = params[prefix + 'password_type'] zato_message.data.reject_empty_nonce_ts = bool(params.get(prefix + 'reject_empty_nonce_ts')) zato_message.data.reject_stale_username = bool(params.get(prefix + 'reject_stale_username')) zato_message.data.expiry_limit = params[prefix + 'expiry_limit'] zato_message.data.nonce_freshness = params[prefix + 'nonce_freshness'] return zato_message
def _get_edit_create_message(params, prefix=""): """ Creates a base document which can be used by both 'edit' and 'create' actions. """ zato_message = Element("{%s}zato_message" % zato_namespace) zato_message.data = Element("data") zato_message.data.id = params.get("id") zato_message.data.cluster_id = params["cluster_id"] zato_message.data.name = params[prefix + "name"] zato_message.data.is_active = bool(params.get(prefix + "is_active")) zato_message.data.host = params[prefix + "host"] zato_message.data.user = params.get(prefix + "user") zato_message.data.timeout = params.get(prefix + "timeout") zato_message.data.acct = params.get(prefix + "acct") zato_message.data.port = params[prefix + "port"] zato_message.data.dircache = bool(params.get(prefix + "dircache")) return zato_message
def delete(req, id, cluster_id): cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() try: zato_message = Element("{%s}zato_message" % zato_namespace) zato_message.data = Element("data") zato_message.data.id = id _, zato_message, soap_response = invoke_admin_service(cluster, "zato:outgoing.ftp.delete", zato_message) return HttpResponse() except Exception, e: msg = "Could not delete the outgoing FTP connection, e=[{e}]".format(e=format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)
def delete(req, tech_account_id, cluster_id): cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() try: zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.tech_account_id = tech_account_id zato_message.data.zato_admin_tech_account_name = TECH_ACCOUNT_NAME _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:security.tech-account.delete', zato_message) except Exception, e: msg = "Could not delete the account, e=[{e}]".format(e=format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)
def delete(req, id, cluster_id): cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() try: zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:http_soap.delete', zato_message) return HttpResponse() except Exception, e: msg = 'Could not delete the object, e=[{e}]'.format(e=format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)
def details(req, service_id): zato_clusters = req.odb.query(Cluster).order_by('name').all() choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET) cluster_id = req.GET.get('cluster') service = None create_form = CreateForm() edit_form = EditForm(prefix='edit') if cluster_id and req.method == 'GET': cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = service_id zato_message.data.cluster_id = cluster_id _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:service.get-by-id', zato_message) if zato_path('data.item').get_from(zato_message) is not None: msg_item = zato_message.data.item id = msg_item.id.text name = msg_item.name.text is_active = is_boolean(msg_item.is_active.text) impl_name = msg_item.impl_name.text is_internal = is_boolean(msg_item.is_internal.text) usage_count = msg_item.usage_count.text service = Service(id, name, is_active, impl_name, is_internal, None, usage_count) return_data = {'zato_clusters':zato_clusters, 'service': service, 'cluster_id':cluster_id, 'choose_cluster_form':choose_cluster_form, 'create_form':create_form, 'edit_form':edit_form, } # TODO: Should really be done by a decorator. if logger.isEnabledFor(TRACE1): logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data)) return render_to_response('zato/service/details.html', return_data, context_instance=RequestContext(req))
def _get_edit_create_message(params, prefix=''): """ Creates a base document which can be used by both 'edit' and 'create' actions. """ zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.id = params.get('id') zato_message.data.cluster_id = params['cluster_id'] zato_message.data.name = params[prefix + 'name'] zato_message.data.is_active = bool(params.get(prefix + 'is_active')) zato_message.data.def_id = params[prefix + 'def_id'] zato_message.data.delivery_mode = params[prefix + 'delivery_mode'] zato_message.data.priority = params[prefix + 'priority'] zato_message.data.content_type = params.get(prefix + 'content_type') zato_message.data.content_encoding = params.get(prefix + 'content_encoding') zato_message.data.expiration = params.get(prefix + 'expiration') zato_message.data.user_id = params.get(prefix + 'user_id') zato_message.data.app_id = params.get(prefix + 'app_id') return zato_message
def create(req): cluster_id = req.POST.get('cluster_id') name = req.POST.get('name') is_active = req.POST.get('is_active', False) cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first() zato_message = Element('{%s}zato_message' % zato_namespace) zato_message.data = Element('data') zato_message.data.cluster_id = cluster_id zato_message.data.name = name zato_message.data.is_active = is_active try: _, zato_message, soap_response = invoke_admin_service(cluster, 'zato:security.tech-account.create', zato_message) except Exception, e: msg = "Could not create a technical account, e=[{e}]".format(e=format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)