[racktables-users] Re: DB structure

  • From: Ian Bettinger <ibettinger@xxxxxxxxx>
  • To: racktables-users@xxxxxxxxxxxxx
  • Date: Wed, 6 Feb 2013 11:41:16 -0800

Just use the add object method:
    https://
<<YOURHOST>>/api.php?method=add_object&object_name=my-new-server&object_type_id=4

You don't need to know the allocation to add an object -- it'll just show
up as "Unmounted." The API has a method, "update_object_allocation," which
can be used to mount the object when you're ready.

Once the host is added, yes, you need to be able to track the hostname <->
racktables object id mapping. My scripts etc that use Racktables typically
use either "get_depot" to get the full depot mapping, or "search" to try to
find a single server or whatever.
    https://<<YOURHOST>>/api.php?method=search&term=<<HOSTNAME OR WHATEVER>>

--Ian


On Wed, Feb 6, 2013 at 11:15 AM, Les Mikesell <lesmikesell@xxxxxxxxx> wrote:

> On Wed, Feb 6, 2013 at 12:51 PM, Ian Bettinger <ibettinger@xxxxxxxxx>
> wrote:
> > Hi Yuri,
> >
> > Yes, the API is intended to allow remote access. Basically it's a single
> > page (api.php):
> >     https://github.com/ibettinger/racktables/blob/master/wwwroot/api.php
> >
> > The documentation for it is similarly lacking, but if you add it to your
> > Racktables installation you can try a few sample queries like:
> >
> > gets all values in chapter 11:
> > https://<<YOURHOST>>/api.php?method=get_chapter&chapter_no=11&style=o
> >
> > gets basic info on object ID 1827:
> > https://<<YOURHOST>>/api.php?method=get_object&object_id=1827
> >
> > gets object ID 1827, including attribute data:
> > https://
> <<YOURHOST>>/api.php?method=get_object&object_id=1827&include_attrs=1
> >
> > gets object ID 1827, including attribute data for all attributes,
> including
> > unset ones:
> > https://
> <<YOURHOST>>/api.php?method=get_object&object_id=1827&include_attrs=1&include_unset_attrs=1
> >
> > gets all objects in the depot with object type 4 (servers)
> > https://<<YOURHOST>>/api.php?method=get_depot&andor=and&cft[4]
> >
> > Most exceptions are printed out as JSON responses.
> >
> > Hope this helps. I'm working on a more robust integrated version (for
> > example this API basically circumvents the Racktables permissions model)
> but
> > it will probably be a couple months before that becomes a reality.
>
> Thanks but my data isn't in racktables yet and probably won't be until
> there is a way to automate the input and track object keys that can
> let other programs make changes or stay in sync.   Is there a way to
> import things?   And if there is/will be, what happens if you don't
> initially know the positions within the racks for the items?
>
> --
>    Les Mikesell
>      lesmikesell@xxxxxxxxx
>
>

Other related posts: