I am trying to convert my BASH script to Python and am having difficulties in finding the equivalent code for openstack server show or openstack server list --long. I would like to know what host is my server currently located and use this information for a check before migrating it to another host.
Looking through the latest novaclient documentation and its servers module, I have found two potential commands that I was hoping would accomplish the task, but does not do so:
list(detailed=True)
Gets a list servers
detailed=True should return detailed server info (optional).
This returns a regular list of servers with their names.
get(server)
Get a server
This returns only the name of the server.
I have been researching for the past two days, and I could not find the same / similar problem here in stack overflow so I have decided to ask and I am hoping that someone can help me with this.
Either list or get should be fine here.
As an example get would be used like this.
instance = nova_client.servers.get('my-server')
print(instance.name)
print(instance.addresses)
print(instance.status)
Or using list.
for instance in nova_client.servers.list():
print(instance.name)
print(instance.addresses)
print(instance.status)
If you want an easy way of understanding the type of data you can get, you can simply use the Python inbuilt dir.
instance = nova_client.servers.get('my-server')
print(dir(instance))
'my-server' needs to be the id as in instance.id, the name of the server is not valid.
I cant yet comment, so i wrote an answer.
Related
The closest I've gotten is via the rest API call.
https://{HOST}/rest/api/2/project/{Project Key}/statuses
But I need the same call via Python. But I'm unable to find an adequate way.
The closest I've gotten in Python is
jiraInstance.statuses() but this returns all possible statuses for our Jira site.
I need to narrow it down to the workflows for a specific project.
Any help would be appreciated.
Background
This is for a reporting tool where we create a table with all the defects for the specific project in question. In python I can currently retrieve all the statuses/priorities for the Bugs/Bug-task issues but that only returns statuses for the existing bugs. I require a way to retrieve all the statuses from a workflow of the specific project.
This will list all project keys in a given project with their respective status...
issues = jira.search_issues('project=projectname')
for issue in issues:
print (issue.key, 'Status: ',issue.fields.status)
I have a server application written with Django which has a contacts database.
I wish to add a cardav webservice in order to share my contacts on my phone. I have made many search but I am completely lost.
I found some server as Radical, some API which uses files ... but nothing help me.
I need to implement in my server an API which will return to my Android the list of contact from my databases. What output format should I use ?
Thank you.
Your question seems a bit generic nor do you list what resources you looked at and why you are lost.
This presentation is a little old, but shows the fundamentals on how the *DAV protocols work. Building a CardDAV Client is another great starting point.
CardDAV itself is specified in
RFC 6352, and the related RFCs:
WebDAV,
WebDAV ACL,
etc.
What output format should I use ?
CardDAV requests and responses use
WebDAV,
hence XML.
The actual payload is a
vCard v3.
If you are looking for sample code:
The Apple CalendarServer
is a full-fledged CalDAV/CardDAV server written in Python.
Radicale is another one, but you already found that (be more specific why this isn't helping you, Radicale looks like a great starting point to me).
Finally: I don't think Android has CardDAV support builtin. Presumably you are using a sync plugin?
To get connections using the Python facebook package I know to use:
g.get_connections("me", "friends")
But is there a way to get "friends" and "books" in one call?
Didn't see anything in the docs...
Based on the Graph API documentation, you can do a request in the form
GET graph.facebook.com
/{node-id}?
fields={first-level}
Thus, you'd want to execute a GET for /me?fields=friends,books, looking at the facebook-sdk code, the g.get_object seems to be the closest one, thus:
g.get_object('/me', fields='friends,books')
Of course chances are that not all are returned, and you need to page through the results anyway...
Intro
I have a cluster to monitor using Zabbix 2.0, everything works fine and I have all the data I need on Zabbix, but the way zabbix displays the data is not optimal for our use case. At the same time I have a python app running with a web front end I can use to create a more refined way of displaying Zabbix's data. What I want to do is to turn Zabbix's latest data tab into a grid view with a host in every row and the items as columns (like a spreadsheet).
The problem
Apparently Zabbix's API is still a work in progress and the interface sometimes changes, which should not be a problem if some basic functionality is working. What I need to do is to be able to fetch the list of hosts not only IDs but the host's info as well. And for each host I need to be able to fetch some items, again not only the items ID but the entire data too. So far I've tried using two Python libraries to do it: zabbix_api and PyZabbix, no luck so far since both libraries fetch only IDs and not the data I need for hosts and items.
The question
Is there a library/way of doing this that actually works or is this API in a too early stage yet?
Thanks in advance!
I use zabbix_api to do navigate through zabbix catalogs, get hosts, get host, get host's items, etc. Though I didn't try to get the data with python, I don't see why it shouldn't work. I do get data from PHP using PhpZabbixApi. Any specific problems you've run into?
PyZabbix is vital and pretty usable. In fact it is 1:1 mapping of Zabbix API to Python.
I am trying to get up to speed with CouchDB. As a relatively new user on Python, I am trying to set up a view-server so that I can pass on python functions to couchdb.design.ViewDefinitions function. As I understand, ViewDefinitions take javascript code to execute map/reduce function.
Here is what I struggle to understand - I am well aware that this might be a basic question. According to wiki (http://wiki.apache.org/couchdb/View_server):
To register query servers with CouchDB, add a line for each server to local.ini. The basic syntax is:
'[query_servers] python=/usr/bin/couchpy'
How do I access local.ini file? I am an 10.6.8 Mac user. Thanks!
Update: Thank you Kxepal. It seems I was able to create the design/view on Futon in Python. Alternatively, I figured that python viewserver can be created as follows:
curl -X PUT http://[localhost]/_config/query_servers/python '"/path/to/couchpy"'
However, I still cannot execute the python script. Running the view on Couch results in following:
'Error: An error occurred accessing the view no response'
I would appreciate if somebody can point in the right direction. Thanks!
I encountered the same "Error: An error occurred accessing the view no response" problem, and it turned out to be a bug in my python code. Specifically, in the javascript implementation I had something like:
function (doc) {
emit(doc.somefield, doc);
}
I had converted this to:
def map(doc):
yield doc.somefield, doc
However, this gave me the "no response" error you describe.
Changing it to the following fixed the problem.
def map(doc):
yield doc['somefield'], doc
I don't know there OSX keeps CouchDB config files, but you always may setup Python query server through Futon. On sidebar click Configuration, than "Add section" at the bottom of the page and fill the fields with same data as you planned to write into local.ini. As bonus, you don't need restart CouchDB - configuration changes through HTTP API are applied instantly, but be sure that you'd specified correct values.