On Aug 9, 2013, at 7:21 PM, Pedro Roque Marques <pedro.r.marq...@gmail.com> 
wrote:

> 
> On Aug 2, 2013, at 2:42 PM, Rohit Yadav wrote:
> 
>> On Thu, Aug 1, 2013 at 10:43 PM, Donal Lafferty
>> <donal.laffe...@citrix.com>wrote:
>> 
>>> I needed a different configuration than DevCloud provided, so I turned to
>>> CloudMonkey to automate setup of my test environment.
>>> 
>>> This led to a blog on automating with CloudMonkey at
>>> http://dlafferty.blogspot.co.uk/2013/07/using-cloudmonkey-to-automate.html
>>> 
>>> 
>> Nice.
>> 
>> 
>>> What I forgot to mention is that automation would be a lot simpler if we
>>> were to do the following:
>>> 
>>> 1.       Update Apache CloudStack logging to provide API calls in a tidy
>>> format that can be fed directly.  E.g. POST parameters are not logged,  GET
>>> parameters are URL encoded.
>>> 
>>> 2.       Update CloudMonkey to allow username / password authentication
>>> 
>> 
>> +1, send patch :)
> 
> I use following:
> cloudauth.py retrieves a key pair...
> cloudclient.py is a simple wrapper around cloudmonkey so that we can use it 
> directly from python scripts and get json replies.
> 
> usage example:
> def createZone(client):
>    try:
>        response = client.request('listZones')
>        if response['listzonesresponse']:
>            return response['listzonesresponse']['zone'][0]['id']
> 
>        response = client.request('createZone',
>                                  {'name': 'default',
>                                   'networktype': 'Advanced',
>                                   'domain': 'ROOT',
>                                   'dns1': PARAMS['external_dns'],
>                                   'internaldns1': PARAMS['internal_dns']})
>        return response['createzoneresponse']['zone']['id']
> 
>    except Exception as e:
>        print 'Error while creating a zone:'
>        print e
>        raise
> 
> 
> 
> <cloudclient.py><cloudauth.py>

Pretty cool,

Maybe in your cloudauth.py you can use the requests module. 
That way there is no need to use popen to call curl

http://docs.python-requests.org/en/latest/

-sebastien


Reply via email to