Connecting to Scalr via API V2 and Python

90 views
Skip to first unread message

Ron Rabakukk

unread,
Nov 28, 2016, 12:14:36 PM11/28/16
to scalr-discuss

I have been successfully using the earlier version of the API and want to upgrade to the new version. I am trying this example (https://github.com/scalr-tutorials/apiv2-examples/tree/master/python) and also trying to connect via the API Explorer like on this page (https://api-explorer.scalr.com/user/images/get.html). I have verified that I set it up right in the /etc/scalr-server/scalr-server.rb file:

app[:configuration] = { 
  :scalr => {

    # Enable the system API 
    :system => { 
        :api => { 
            :enabled => true, 
            :allowed_origins => '*' 
        }, 
    },

and I have my credentials set properly. But when I try to run a query to get a list of images (like on the API explorer page I listed above) I get the following response:


  "meta": { 
    "requestId": "549b445c-7a76-449f-98ce-b3daff2d884f", 
    "stringToSign": "GET\n2016-11-28T16:53:58.239Z\n/api/v1beta0/user/1/images/\n\n" 
  }, 
  "errors": [ 
    { 
      "code": "InternalServerError", 
      "message": "Server Error" 
    } 
  ] 
}

I get the same thing when I try to run the example in Git, I get an "InternalServerError".

Any ideas what this could be?

Thanks!

Igor Savchenko

unread,
Nov 28, 2016, 12:15:35 PM11/28/16
to scalr-...@googlegroups.com
What version of Scalr you have?

Thanks,
Igor
> --
> You received this message because you are subscribed to the Google Groups
> "scalr-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scalr-discus...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ron Rabakukk

unread,
Nov 28, 2016, 12:17:22 PM11/28/16
to scalr-...@googlegroups.com
Version 5.11.22


> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "scalr-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scalr-discuss/V23_FdpKmLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scalr-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Igor Savchenko

unread,
Nov 28, 2016, 12:20:19 PM11/28/16
to scalr-...@googlegroups.com
Images management was added in 7.X version which is available only as
Enterprise Edition. You need to wait for the next OS release.

Regards,
Igor
>> > email to scalr-discus...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "scalr-discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/scalr-discuss/V23_FdpKmLo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> scalr-discus...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Ron Rabakukk
> ron.ra...@gmail.com
> r...@rabakukk.com
> (512) 986-0358
>
> --
> You received this message because you are subscribed to the Google Groups
> "scalr-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scalr-discus...@googlegroups.com.

Ron Rabakukk

unread,
Nov 28, 2016, 12:23:33 PM11/28/16
to scalr-...@googlegroups.com
I only picked to query images as a test. What is available in the version we are using? Thanks.


>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "scalr-discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/scalr-discuss/V23_FdpKmLo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to

>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Ron Rabakukk
> ron.ra...@gmail.com
> r...@rabakukk.com
> (512) 986-0358
>
> --
> You received this message because you are subscribed to the Google Groups
> "scalr-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "scalr-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scalr-discuss/V23_FdpKmLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scalr-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ron Rabakukk

unread,
Nov 28, 2016, 1:53:08 PM11/28/16
to scalr-...@googlegroups.com
Is there any documentation anywhere on what is available for the API v2 with the version that we have? Thanks.


>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "scalr-discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/scalr-discuss/V23_FdpKmLo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to

>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Ron Rabakukk
> ron.ra...@gmail.com
> r...@rabakukk.com
> (512) 986-0358
>
> --
> You received this message because you are subscribed to the Google Groups
> "scalr-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "scalr-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scalr-discuss/V23_FdpKmLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scalr-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Marc O'Brien

unread,
Nov 28, 2016, 2:05:11 PM11/28/16
to scalr-discuss
Hi Ron,

Although this list is not specific to API, you can find all changes and additions for each version of Scalr in our Release Notes page.

Many thanks,
Wm. Marc O'Brien
Scalr Technical Support


On Monday, November 28, 2016 at 11:53:08 AM UTC-7, Ron Rabakukk wrote:
Is there any documentation anywhere on what is available for the API v2 with the version that we have? Thanks.
On Mon, Nov 28, 2016 at 11:20 AM, Igor Savchenko <> wrote:
Images management was added in 7.X version which is available only as
Enterprise Edition. You need to wait for the next OS release.

Regards,
Igor

>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "scalr-discuss" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/scalr-discuss/V23_FdpKmLo/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>>
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Ron Rabakukk

>
> --
> You received this message because you are subscribed to the Google Groups
> "scalr-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "scalr-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scalr-discuss/V23_FdpKmLo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
For more options, visit https://groups.google.com/d/optout.

Ron Rabakukk

unread,
Nov 28, 2016, 4:00:41 PM11/28/16
to scalr-...@googlegroups.com
Thanks.

So anytime I get the response:

"errors": [ { "code": "InternalServerError", "message": "Server Error" } ]

that means it isn't supported in our version? It seems that is the error I get on everything I'd like to use out of the APIv2 Explorer.

To unsubscribe from this group and all its topics, send an email to scalr-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Marc O'Brien

unread,
Nov 28, 2016, 4:37:23 PM11/28/16
to scalr-discuss
Hi Ron,

This may actually mean that there is an error preventing proper API communication on your Scalr server.  Did you run the reconfigure command after enabling and setting allowed origin in your scalr-server.rb?  If so, can you archive and attach your Scalr server logs from /opt/scalr-server/var/logs ?  We may find errors related to this in your php logs.


Many thanks,
Wm. Marc O'Brien
Scalr Technical Support

On Monday, November 28, 2016 at 2:00:41 PM UTC-7, Ron Rabakukk wrote:
Thanks.

So anytime I get the response:

"errors": [ { "code": "InternalServerError", "message": "Server Error" } ]

that means it isn't supported in our version? It seems that is the error I get on everything I'd like to use out of the APIv2 Explorer.

Ron Rabakukk

unread,
Nov 28, 2016, 6:05:16 PM11/28/16
to scalr-...@googlegroups.com
Yes, I did run the reconfigure command. I even reset enabled to false, ran the reconfigure and verified that the error I got was that the API was not enabled, then set it back to true and ran reconfigure. Attached is a tar of the logs. Thanks for looking.



To unsubscribe from this group and all its topics, send an email to scalr-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
ScalrOptLogs.tar

Marc O'Brien

unread,
Nov 28, 2016, 6:22:24 PM11/28/16
to scalr-discuss
Hi Ron,

I am seeing the following repeated in your web.app.error.log:

[Mon Nov 28 20:25:38.390632 2016] [:error] [pid 30236] [client 127.0.0.1:40676] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Both LDAP user and password must be provided in the config for the scalr.connections.ldap parameter's bag.' in /opt/scalr-server/embedded/scalr/app/src/Scalr/Api/Rest/ApiApplication.php:670\nStack trace:\n #0 [internal function]: Scalr\\Api\\Rest\\ApiApplication->authenticationMiddleware(Object(Scalr\\Api\\Rest\\Routing\\Route))\n  #1 /opt/scalr-server/embedded/scalr/app/src/Scalr/Api/Rest/Routing/Route.php(457): call_user_func_array(Array, Array)\n  #2 /opt/scalr-server/embedded/scalr/app/src/Scalr/Api/Rest/Application.php(348): Scalr\\Api\\Rest\\Routing\\Route->dispatch()\n  #3 /opt/scalr-server/embedded/scalr/app/src/Scalr/Api/Rest/Application.php(275): Scalr\\Api\\Rest\\Application->call()\n  #4 /opt/scalr-server/embedded/scalr/app/www/restapi.php(39): Scalr\\Api\\Rest\\Application->run()\n  #5 {main}, referer: https://api-explorer.scalr.com/user/roles/get_roleId.html

Can you verify your scalr-server.rb has these values configured correctly?  This is addressed in our LDAP config documentation under the header for "API Key Authentication when using LDAP."


Many thanks,
Wm. Marc O'Brien
Scalr Technical Support

Ron Rabakukk

unread,
Nov 29, 2016, 12:06:26 PM11/29/16
to scalr-...@googlegroups.com
Thanks for that. I do not have a scalr.connections.ldap.user, or a scalr.connections.ldap.pass defined there though LDAP has been working fine for us to log into the client, etc. The documentation says that these are needed "if you intend to use APIv1 with LDAP auth."  I am adding them in, running the reconfigure, and trying again. Thanks.

To unsubscribe from this group and all its topics, send an email to scalr-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ron Rabakukk

unread,
Nov 29, 2016, 12:09:35 PM11/29/16
to scalr-...@googlegroups.com
It looks like that worked. I was able to run the example and am able to get data back from the API Explorer. Thanks for your help!

To unsubscribe from this group and all its topics, send an email to scalr-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Marc O'Brien

unread,
Nov 30, 2016, 1:58:33 PM11/30/16
to scalr-discuss
Hi Ron,

Very glad that did the trick.

By the way, welcome to the Scalr Open Source community! We're excited to have you join us.  Please feel free to post any issues or questions you have moving forward and we will do our best to lend a hand.

Cheers,

Wm. Marc O'Brien
Scalr Technical Support

On Tuesday, November 29, 2016 at 10:09:35 AM UTC-7, Ron Rabakukk wrote:
It looks like that worked. I was able to run the example and am able to get data back from the API Explorer. Thanks for your help!

Ron Rabakukk

unread,
Nov 30, 2016, 1:59:34 PM11/30/16
to scalr-...@googlegroups.com
Thanks! I truly appreciate all the help you provided.

To unsubscribe from this group and all its topics, send an email to scalr-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages