These are chat archives for allegro/ralph

20th
Sep 2016
Pete
@kasim1r
Sep 20 2016 07:27
hey marcin, already in?
✪ vi4m Marcin Kliks
@vi4m
Sep 20 2016 07:28
yeah, back to you
Pete
@kasim1r
Sep 20 2016 07:28
cool.
still waiting for those examples "how to connect ipaddresses to ethernets to virtualservers"
✪ vi4m Marcin Kliks
@vi4m
Sep 20 2016 07:28
@szok will show you example request
Pete
@kasim1r
Sep 20 2016 07:28
very nice, thx
Piotr Jarolewski
@szok
Sep 20 2016 07:31
@kasim1r Ok, you have add virtual server?
Pete
@kasim1r
Sep 20 2016 07:31
yup
Piotr Jarolewski
@szok
Sep 20 2016 07:32
Please go to Network Tab.
and add new ethernet.
Next, go to Network->IP Address from top menu.
Pete
@kasim1r
Sep 20 2016 07:33
em, I was asking to do that via API
I created a new virtualserver
Piotr Jarolewski
@szok
Sep 20 2016 07:33
Add new, write new IP address, and select ethernet which you added in Network Tab
aa
ok
sek
Pete
@kasim1r
Sep 20 2016 07:34
now I will probably need to create an ethernet, an IP address, and connect those to the virtualserver
OK, jsut found out that "base object" is the attribute that connects the ethernet to the virtualserver
ok, and "ethernet" seems to be the attribute that connects the ipaddress to the ethernet
Pete
@kasim1r
Sep 20 2016 07:41
so, the process of inventoring VMs for me looks like
  1. create virtualserver, save the ID from the server response
  1. create ethernet with the id from 1. as "base object", again save the ID
  1. create ipaddress with the from 2. as "ethernet"
(thanks gitter for renumbering)
does that make sense?
Piotr Jarolewski
@szok
Sep 20 2016 07:48
solution:

New VirtualServer

curl -H "Content-Type: application/json" -H "Authorization: Token 9af03a5ed0eabdc665f00c7043c3913f88d0943b" -XPOST http://ralph-demo.allegro.tech/api/virtual-servers/ -d '{"hypervisor": 810, "type": 4}' -vvv

Result:
{"id":870,"hypervisor":810,"tags":[],"created":"2016-09-20T09:35:40.193310","modified":"2016-09-20T09:35:40.193370","remarks":"","status":"new","hostname":null,"sn":null,"content_type":78,"service_env":null,"configuration_path":null,"type":4,"cluster":null}

Add new ethernet (in base_object field set VirtualServer ID)

curl -H "Content-Type: application/json" -H "Authorization: Token 9af03a5ed0eabdc665f00c7043c3913f88d0943b" -XPOST http://ralph-demo.allegro.tech/api/ethernets/ -d '{"base_object": 870}' -vvv

Result:
{"id":313,"created":"2016-09-20T09:37:08.370714","modified":"2016-09-20T09:37:08.370776","model_name":null,"label":null,"mac":null,"speed":"unknown speed","firmware_version":null,"base_object":870,"model":null}

And add new IP Address with ethernet. (in ethernet field set Ethernet ID)

curl -H "Content-Type: application/json" -H "Authorization: Token 9af03a5ed0eabdc665f00c7043c3913f88d0943b" -XPOST http://ralph-demo.allegro.tech/api/ipaddresses/ -d '{"address": "10.10.10.10", "ethernet": 313}' -vvv

Result:
{"id":290,"created":"2016-09-20T09:40:03.841679","modified":"2016-09-20T09:40:03.841736","last_seen":"2016-09-20T09:40:03.841768","address":"10.10.10.10","hostname":null,"number":"168430090","is_management":false,"is_public":false,"is_gateway":false,"status":"used (fixed address in DHCP)","dhcp_expose":false,"ethernet":313,"network":null}

curl -H "Content-Type: application/json" -H "Authorization: Token 9af03a5ed0eabdc665f00c7043c3913f88d0943b" -XGET http://ralph-demo.allegro.tech/api/virtual-servers/870/ -vvv

result:
{"id":870,"url":"http://ralph-demo.allegro.tech/api/virtual-servers/870/","business_owners":null,"technical_owners":null,"ethernet":[{"id":313,"mac":null,"ipaddress":{"id":290,"address":"10.10.10.10","hostname":null,"dhcp_expose":false,"is_management":false,

@kasim1r Yes it's ok.
Pete
@kasim1r
Sep 20 2016 07:59
thx for the heads up
Pete
@kasim1r
Sep 20 2016 08:18
documentation says "Accept: application/json; version=v1" is needed
but I cannot mix "accept" and "content-type" headers
right?
your examples above use only content-type
Piotr Jarolewski
@szok
Sep 20 2016 08:46
Yes, by default is version 1
Pete
@kasim1r
Sep 20 2016 09:44
OK, running into a problem here, maybe you can help
Piotr Jarolewski
@szok
Sep 20 2016 09:45
@kasim1r ?
Pete
@kasim1r
Sep 20 2016 09:46
requests to the API seem to run "forever". I can see that in the browser tab, the page never finishes to load, or when doing curl or Powershell API requests, i get back 2944 bytes or so, but the prompt doesn't come back
that's when I do a filter get
like /api/data-center-assets/?hostname=bla
anything I can adapt, a setting that I may have missed?
Pete
@kasim1r
Sep 20 2016 09:51
correcting myself, not only for filter gets, mostly anything, but not always
no nginx or apache, just the "ralph runserver"
Piotr Jarolewski
@szok
Sep 20 2016 10:03
@kasim1r by default we return only 10 records to API. Please add get parameters to url: ?limit=10&offset=0 Please check this.
@kasim1r you run it on Windows?
Pete
@kasim1r
Sep 20 2016 11:16
no, ubuntu 14.04
Piotr Jarolewski
@szok
Sep 20 2016 11:27
if limit and offset work?
Pete
@kasim1r
Sep 20 2016 11:27
hm, then i get "count":0,
Piotr Jarolewski
@szok
Sep 20 2016 11:33
maybe ?hostname=bla ? not found any assets?
Pete
@kasim1r
Sep 20 2016 11:34
:smile: haha, i am searching for an existing server here
Piotr Jarolewski
@szok
Sep 20 2016 11:35
hm. show me curl command
Pete
@kasim1r
Sep 20 2016 11:36
sorry, not curl, but Powershell script full of variables
using the debugger now
should i have the limit and offset after or before the query
I put it at the beginning, still no luck. runs forever, but not always
Pete
@kasim1r
Sep 20 2016 11:42
will restart the server for a try
Piotr Jarolewski
@szok
Sep 20 2016 11:45
You run the script of Powershell ? on windows?
Pete
@kasim1r
Sep 20 2016 11:45
yes, I use Invoke-Webrequest for that.
$objResult = Invoke-WebRequest -Uri $strUrl -Headers $arrHeaders -Method $strMethod -UseBasicParsing -DisableKeepAlive
Piotr Jarolewski
@szok
Sep 20 2016 11:47
Perhaps there is a problem with PowerShell, try to do the same with linux shell?
Pete
@kasim1r
Sep 20 2016 11:53
no, not really :)
last two tries, search string is "srv1", API finds 2 results "srv1" and "srv2"
Piotr Jarolewski
@szok
Sep 20 2016 11:56
/api/data-center-assets/?limit=10&offset=0&hostname=srv1
? replace to &
Pete
@kasim1r
Sep 20 2016 11:56
ah
beginner's error
yup, all good
Piotr Jarolewski
@szok
Sep 20 2016 11:57
:)
Pete
@kasim1r
Sep 20 2016 11:57
after restarting, the "runs forever" effect is gone. let's see for how long
Arkadiusz Adamski
@ar4s
Sep 20 2016 12:14
@kasim1r try with ours demo instance
Invoke-WebRequest -DisableKeepAlive -UseBasicParsing -Uri "http://ralph-demo.allegro.tech/api/virtual-servers/870/" -Method "GET" -Headers @{"Authorization" = "Token 9af03a5ed0eabdc665f00c7043c3913f88d0943b";  "Content-Type" = "application/json"}
Pete
@kasim1r
Sep 20 2016 12:18
yes, that's how it works
great, now you're infected with the Powershell Virus, too :)
Piotr Jarolewski
@szok
Sep 20 2016 12:20
:D