[racktables-users] Re: API related questions

  • From: Denis Ovsienko <pilot@xxxxxxxxxx>
  • To: racktables-users@xxxxxxxxxxxxx
  • Date: Mon, 31 Aug 2009 22:50:55 +0400

On Mon, 31 Aug 2009 13:02:48 +0000 Killsystem wrote:

> Hi,
> 
> I'm playing around with the API and try to figure out how it works.
> I hope someone can help me out with these questions:
> 
> 1. I try to get an object by its name.
> First I tried to get the object with something like
> scanRealmByText('object','{$objname_servername}'), but this won't work.
> Sure I can do the same task with
> $server = scanRealmByText('object','{$typeid_4}');
> foreach ($server as $object) {
> if ($object['name'] == "servername" ) {
> print_r ($object);
> }
> }
> But that's a bit messy because I have to check every object to find one.

It should be {$cn_somename} (oops, I see it's broken now), but that's
indeed not the best way to lookup items. You can find
getSearchResultByField() to be useful (which is likely to remain in the
code for 0.17/0.18).

> 2. If I have found the object I want, can I change a value?
> I need to toggle the [has_problems] value. It this possible? (will it be
> recorded in the history?)

There's a function, which updates all fields at once, you can figure it
out quite easy. However, it's not a part of any kind of public (declared
and supported) API. Perhaps, it's worth having own function for this
specific column?

> 3. How can I get additional information like ip adresses from the object
> when I have the ID?

// this is always one SELECT per id
$a = spotEntity ('object', $id);
// this is often more, than one SELECT (and per each call)
amplifyCell
($a);
dump ($a);

-- 

Other related posts: