In RabbitMQ management console, for import and export purpose, I saw this link Import / export definitions at the bottom of the Overview page. But with this I am able to export the entire set of queues, exchanges etc.
I am having an MQ server which contains the MQ setup of multiple applications. I would like to do a selective export of queues, exchanges etc of my application. Is it possible?
I don't think it's built in the tools provided. However, since the output is pure JSON, you can easily remove what is unnecessary.
Example:
#!/usr/bin/python2.7
import json
dump = json.load(open("export.json"))
for k, v in dump.iteritems():
if k == "queues":
for i in reversed(range(len(v))):
if v[i]["name"] not in ["QUEUE#0", "QUEUE#1"]:
v.pop(i)
break
open("export-updated.json", "w").write(json.dumps(dump))
Related
I'm using latest vue2 and latest vue2-storage.
I'd like to have a local storage and session storage at the same time.
The goal is: store app config into local storage, store tmp user data in session storage.
As far as I get, the plugin will initialize only one storage for the whole app and - beside enforcing options each time you need it - there's no way to use a second storage on demand.
I've checked the source code and done some manual test but it seems impossible to import the constructor class to initialize a second storage.
Disclaimer 1: bare local/sessionStorage is not enough.
Disclaimer 2: I'm pretty new to vue2.
Hi)) I have updated the package to version 6.0.0, which implements the ability to separately import the class and plugin. issues/49
Is it easier if you just use plain javascript ?
you can easily use localStorage.setItem("test", "value") and localStorage.getItem("test") , sessionStorage.setItem("test", "value") and sessionStorage.getItem("test")
I'm working on a Web Application which uses Vue.js as the frontend framework. Currently we are handling static text directly where it is used i.e. inputting it directly at source in components data.
<script>
export default {
name: "ExampleComponent",
data: function () {
return {
title: 'Business Title',
modalBodyText: 'Some business text that devs don't care about'
}
}
}
</script>
However the Web App requires a lot of input from the business team on how things are phrased and how text is worded. Due to compliance some of the text in the application changes frequently and I am wondering whether there is a better way of handling static text in frontend frameworks such as Vue.js?
I feel we should be abstracting out the static text from the code and importing a file globally but I'm unsure if this is common practice or how best to do it. Any input on this would be much appreciated.
Easiest thing you can do is to create some json file (or multiple files ...depending how big and structured your app is) with all the texts and simple import it into your components
import content from './content.json'
Webpack will make content of such file available as JS object so you can easily reference keys in your code (not directly from template tho)
Slightly more sophisticated way would by to use of I18n libraries like vue-i18n - still keeping your text in separate json files with some utilities on top for accessing it directly from templates - but with an option of changing text storage mechanisms later and using many open source tools available for managing and changing the content by non-developer users...
I am working on a project to automate junos firewall policy creation workflow. I found pyEZ as the most viable option for my case.
Although I am able to retrieve the complete configuration from the device in xml format by using rpc.get_config() method. Unfortunately I don't see the default junos applications inside the retrieved xml file. But I can see them when running the commands manually on the device
show configuration groups junos-defaults applications | display set
set groups junos-defaults applications application junos-ftp application-protocol ftp
...
Please find the snippet below that am using currently to get the config
from jnpr.junos import Device
from lxml import etree
dev = Device(host='xxxx', user='demo', password='demo123', gather_facts=False)
dev.open()
cnf = dev.rpc.get_config()
print etree.tostring(cnf)
dev.close()
Please let me know if there is any such method available to get the default application group details.
Many thanks,
Prabir
check if this helps
dev.rpc.get_config(filter_xml='<groups><name>junos-defaults</name></groups>')
I have a Tornado web server that exposes some endpoints in its API.
I want to be able to document my handlers (endpoints) in-code, including description, parameters, example, response structure, etc., and afterwards generate an interactive documentation that enables one to "play" with my API, easily make requests and experience the response on a sandbox environment.
I know Swagger, and particularly their SwaggerUI solution is one of the best tools for that, but I get confused how it works. I understand that I need to feed the SwaggerUI engine some .yaml that defines my API, but how do I generate it from my code?
Many github libraries I found aren't good enough or only support Flask...
Thanks
To my understanding, SwaggerUI is dependent on swagger specification.
So, it boils down to generating the Swagger Specification in a clean and elegant manner.
Did you get a chance to look at apispec?
I am finding this to be an active project with a plugin for tornado.
Here's how we are doing it in our project. We made our own module and we are still actively developing this. For more info: https://pypi.org/project/tornado-swirl/
import tornado.web
import tornado_swirl as swirl
#swirl.restapi('/item/(?P<itemid>\d+)')
class ItemHandler(tornado.web.RequestHandler):
def get(self, itemid):
"""Get Item data.
Gets Item data from database.
Path Parameter:
itemid (int) -- The item id
"""
pass
#swirl.schema
class User(object):
"""This is the user class
Your usual long description.
Properties:
name (string) -- required. Name of user
age (int) -- Age of user
"""
pass
def make_app():
return swirl.Application(swirl.api_routes())
if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
We are creating a online platform and exposing an Julia API via a embedded code-editor. The user can access the API and run some analysis on our web-app. I have a question related to controlling access to the API and objects.
The API right now contains a database handle and other objects that are exposed to the user and can be used to hack the internal system.
Below is the current architecture:
UserProgram.jl
function doanalysis()
data = getdata()
# some analysis on data
end
InternalProgram.jl
const client = MongoClient()
const collection = MongoCollection(client,"dbname","collectionName")
function getdata()
data = #some function to get data from collection
return data
end
#after parsing the user program
doanalysis()
To run the user analysis, we pass user program as a command-line argument (using ArgParse module) and run the internal program as follows
$ julia InternalProgram.jl --file Userprogram.jl
With this architecture, user potentially gets access to "client" and "collection" and can modify internal databases.
Is there a better way to solve this problem without exposing the objects?
I hope someone has an answer to this.
You will be exposing yourself to multiple types of vulnerabilities - as the general rule, executing user inputed code is a VERY BAD IDEA.
1/ like you said, you'll potentially allow users to execute random code against your database.
2/ your users will have access to all the power of Julia to do things on your server (download files they can later execute for example, access other servers and services on the server [MySQL, email, etc]). Depending on the level of access of the Julia process, think unauthorized access to your file system, installing key loggers, running spam servers, etc.
3/ will be able to use Julia packages and get you into a lot of trouble - like for example add/use the Requests.jl package and execute DoS attacks on other servers.
If you really want to go this way, I recommend that:
A/ set proper (minimal) permissions for the MongoDB user configured to be used in the app (ex: http://blog.mlab.com/2016/07/mongodb-tips-tricks-collection-level-access-control/)
B/ execute each user's code into a separate sandbox / container that only exposes the minimum necessary software
C/ have your containers running on a managed platform where tooling exists (firewalls) to monitor incoming and outgoing traffic (for example to block spam or DoS attacks)
In order to achieve B/ and C/ my recommendation is to use JuliaBox. I haven't used it myself, but seems to be exactly what you need: https://github.com/JuliaCloud/JuliaBox
Once you get that running, you can also use https://github.com/JuliaWeb/JuliaWebAPI.jl