[Openstack] Using Nova APIs from Javascript: possible?

Nick Lothian nick.lothian at gmail.com
Mon Apr 23 05:19:35 UTC 2012


Hi,

I've been playing with the Nova APIs from Javascript, and I've run into a
problem.

The very first thing one needs to do to use the APIs is to get a token.

That requires a POST to the API endpoint. Using curl & trystack that looks
like this:

$ curl -k -X 'POST' -v https://nova-api.trystack.org:5443/v2.0/tokens -d
'{"auth":{"passwordCredentials":{"username": "<username>",
"password":"<password>"}}}' -H 'Content-type: application/json'


The Javascript equivalent (using JQuery) is:

    $.ajax({
        url: "https://nova-api.trystack.org:5443/v2.0/tokens",
        type: 'POST',
        headers: {"Content-Type": "application/json"},
        data:  {"auth":{"passwordCredentials":{"username":"<username>",
"password":"<password>"}}},
        success: function(data) { alert(data); }
    });

That fails because the call is cross-domain, and Nova doesn't support CORS (
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing). <script> based
cross-domain requests only supports GET requests, so that doesn't work
either.

I have raised a bug: https://bugs.launchpad.net/nova/+bug/987044, but I'm
really hoping someone can point out something obvious I'm missing here.

Regards
  Nick Lothian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20120423/acc11ac8/attachment.html>


More information about the Openstack mailing list