[racktables-users] Re: API related questions

  • From: Killsystem <killsystem@xxxxxxxxxxxxxxxx>
  • To: <racktables-users@xxxxxxxxxxxxx>
  • Date: Tue, 01 Sep 2009 09:48:04 +0000

On Mon, 31 Aug 2009 22:50:55 +0400, Denis Ovsienko <pilot@xxxxxxxxxx>
wrote:
> 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).
I created a little function that's far from perfect  but works with regular
expressions.

function scanObjectByRegExp($pattern) {
$result = array ();
$objects = scanRealmByText('object');
foreach ($objects as $object) {
if (preg_match('/'.$pattern.'/i', $object['name'])) {
amplifyCell($object);
$result = array_merge ($result, array($object));
}
}
if (count($result))
return $result;
else
return FALSE;
}

Something like this, but better programmed would be nice for the API.

> 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?

we want to allow a system monitoring solution (nagios) to set a object an
has problems by just calling a webaddress with the name of the server.
Something like http://racktables.org/api.php?name=server01&problem=yes
To archiv it would be better to have one function that only changes this
value, and not all.

> // 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);
Thanks I was somehow to dump to realize how amplifyCell works :(

gretz Killsystem

Other related posts: