PS... Ignore my comment about "conn.list_sizes()" in the below code not generating a HTTP call. I looked at the base.py source and see that my usage (of the returned class) below is slightly off. :)
My original auth problem below still remains. I continue to investigate it. Thanks again, -- nmv >________________________________ > From: Noel Milton Vega <[email protected]> >To: "[email protected]" <[email protected]> >Sent: Friday, May 11, 2012 2:25 PM >Subject: Re: Terremark authentication example using libcloud ... > >Hello Sengork: > >Thank you for the reply. I'll formulate this reply in "PARTS" for >clarity. > >============= > >PART1: >============= > >Thanks for the gentle reminder to include the libcloud >version, which I should have originally stated is >version "0.9.1" for python3. Obtained via: >>> libcloud.__version__ > > >============= > >PART2: >============= > >Per your example below, I tried running it again, this time by >inserting the following prior to the get_driver() call: > > > libcloud.security.VERIFY_SSL_CERT = False > >Sadly, it did not resolve the issue. Here again, for referential >convenience, is the cleaned up code (including my >in-line comments where the exception is being raised): > >> ############################################### >> #! /usr/bin/env python3 >> >> import libcloud.compute.types >> import libcloud.compute.providers >> import libcloud.security >> # >> TERREMARK_USERNAME = "[email protected]" >> TERREMARK_PASSWORD = "some-password" >> # >> libcloud.security.VERIFY_SSL_CERT = False >> # Including this or not doesn't change the exception outcome. > >> Driver = >> libcloud.compute.providers.get_driver(libcloud.compute.types.Provider.TERREMARK) >> conn = Driver(TERREMARK_USERNAME, TERREMARK_PASSWORD) >> > >> for aSize in conn.list_sizes(): print(aSize) # No HTTP request generated >> here. Why? Hmmm. > >> # Oddly, this call to list_sizes() doesn't seem to generate a HTTP >>request (i.e. no curl(1) >> # output for this). However it does return a Python list with seemingly >>fake/dummy VM >> # sizes generated internally by libcloud. > >> >> for anImage in conn.list_images(): print(anImage) # HTTP request is >> generated here, but so is the exception. >> # On the other hand, this call to list_images() does generate a HTTP >>request (and curl(1) output), >> # and causes the exception above to be raised. See below (in this >>email) for a cut/paste of >> # curl(1) output as well as related python exception. > >> >> [ ... snip ... ] >> ######################################### >The exception, with or without the VERIFY_SSL_CERT flag, is the same and >appears as follows: > >------------------- >IN CURL(1) LOG: > >------------------- > > # -------- begin 27800016 request ---------- > curl -i -X POST -H 'Content-Length: 0' -H 'X-LC-Request-ID: 27800016' > -H 'Authorization: Basic b'"'"'a-60-character-scring'"'"'' > --compress https://services.vcloudexpress.terremark.com:443/api/v0.8/login > # -------- begin 27800016:27800208 response ---------- > HTTP/1.1 401 Unauthorized > Content-Type: text/html > Server: Microsoft-IIS/7.0 > Www-Authenticate: Basic Realm="vCloud Api" > X-Powered-By: ASP.NET > Date: Fri, 11 May 2012 17:31:52 GMT > Content-Length: 1293 > [ ... snip ... ] > > >-------------------- > >IN Python3 IDE: >-------------------- > > xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, >column 1 > File >"/home/nmvega/Dropbox/CodeDEV.d/PYTHON.d/Libcloud-Client-Development.d/terremark.py", > line 28, in <module> > for anImage in conn.list_images(): print(anImage) > File "/usr/lib/python3.2/site-packages/libcloud/compute/drivers/vcloud.py", >line 474, in list_images > for vdc in self.vdcs: > File "/usr/lib/python3.2/site-packages/libcloud/compute/drivers/vcloud.py", >line 281, in vdcs > self.connection.check_org() # make sure the org is set. > File "/usr/lib/python3.2/site-packages/libcloud/compute/drivers/vcloud.py", >line 226, in check_org > self._get_auth_token() > File "/usr/lib/python3.2/site-packages/libcloud/compute/drivers/vcloud.py", >line 246, in _get_auth_token > body = ET.XML(resp.read()) > File "/usr/lib64/python3.2/xml/etree/ElementTree.py", line 1329, in XML > parser.feed(text) > File "/usr/lib64/python3.2/xml/etree/ElementTree.py", line 1662, in feed > > > > >================= > >PART3: >================= >Finally, just a note that in v0.9.1 of libcloud, the source file >/usr/lib/python3.2/site-packages/libcloud/compute/providers.py >doesn't have a dict() entry for Providers.VCLOUD, so I couldn't try >your included example (... Just for grins -- it would not have worked >for TERREMARK anyay, since they use a modified version of the >vCloud API). Just a side note that Providers.VCLOUD was not there. > > >Thank you in advance again Sengork, et. al. > > >-- nmv > > > > >>________________________________ >> From: Sengor <[email protected]> >>To: [email protected]; Noel Milton Vega >><[email protected]> >>Sent: Thursday, May 10, 2012 11:37 PM >>Subject: Re: Terremark authentication example using libcloud ... >> >>Hi, >> >>I've not used the Terremark variant of vCloud driver, but this is what >>should work: >>conn = Driver(TERREMARK_USERNAME, TERREMARK_PASSWORD) >> >>The driver will perform base64 encoding and joining "user:name" on your >>behalf. >> >>As an example this is what's done for vCloud v1.5: >> >>from libcloud.compute.types import Provider >>from libcloud.compute.providers import get_driver >># Do this only if API has self signed SSL certificate >>import libcloud.security >>libcloud.security.VERIFY_SSL_CERT = False >>Driver = get_driver(Provider.VCLOUD) >>conn = Driver("user@organisation", "password", host="hostname.com", >>api_version="1.5") >>conn.list_images() >> >>You should not need api_version and host for v0.8. >> >>I suggest that you enable libcloud debugging and observe the raw API >>request/responses for any hints as to the cause of the issue. >> >>$ export LIBCLOUD_DEBUG=/tmp/raw >>$ tail -f /tmp/raw >>$ python >>..... >> >>Please also let us know which version of libcloud are you using? >> >> >> >> >>On 11 May 2012 06:00, Noel Milton Vega <[email protected]>wrote: >> >>> Hello friends: >>> >>> I was wondering if anyone had a Terremark libcloud authentication >>> example, similar to the ones indicated here for Amazon EC2 and Rackspace: >>> >>> http://libcloud.apache.org/getting-started.html >>> >>> I've tried a few variations of the examples provided in the above link for >>> the Terremark case (a vCloud API implementation), but received an "Invalid >>> Credentials with the provider" Exception in each case. >>> >>> So far I've tried passing Authentication using the three (3) variations >>> shown below (commented out) for "conn = Driver()". >>> >>> Thank you in advance! >>> >>> ############################################### >>> #! /usr/bin/env python3 >>> >>> import libcloud.compute.types >>> import libcloud.compute.providers >>> import base64 >>> # >>> TERREMARK_USERNAME = "[email protected]" >>> TERREMARK_PASSWORD = "some-password" >>> TERREMARK_B64AUTH = base64.b64encode(bytes(TERREMARK_USERNAME + ":" + >>> TERREMARK_PASSWORD, encoding='utf-8')) >>> # >>> Driver = >>> libcloud.compute.providers.get_driver(libcloud.compute.types.Provider.TERREMARK) >>> >>> #conn = Driver(TERREMARK_USERNAME, TERREMARK_PASSWORD) >>> #conn = Driver(TERREMARK_B64AUTH) >>> #conn = Driver(TERREMARK_USERNAME + ":" + TERREMARK_PASSWORD) >>> >>> [ ... snip ... ] >>> ######################################### >>> >> >> >> >>-- >>sengork >> >> >> > >
