genau.
ich lass meine user ein virtual server objekt befuellen.. mehrere kategorien..
am schluss setzt der user den status auf 'to_deploy', und nur auf dieses event reagiere ich in einem eventhook, und stosse dann den deploy-eine-vm prozess an...
die logik um das event zu filtern ist relativ kompliziert geworden.. weil 10mal nachbessern..
function check_event($event)
{
// at idoit overview category savebutton click -> we get two events, global and overview
// at idoit global category savebutton click -> we get only one event
if ($event->categoryConst=='C__CATG__OVERVIEW')
{
die (getmypid().": not reacting on events of overview category. quitting\n");
}
//print_r ($event);
$proceed=false;
if ($event->categoryConst=='C__CATG__GLOBAL')
{
if (count ($event->changes)==0)
die (getmypid().": no changes. quitting\n");
if (isset ($event->changes->C__OBJ__CMDB_STATUS->to))
{
if ($event->changes->C__OBJ__CMDB_STATUS->to !=STRING_DEPLOY)
die (getmypid().": status didnt change to '".STRING_DEPLOY."'. quitting\n");
else
$proceed=true;
}
if (isset ($event->changes->{'isys_cmdb_dao_category_g_global::cmdb_status'}->to) )
{
if ($event->changes->{'isys_cmdb_dao_category_g_global::cmdb_status'}->to!=STRING_DEPLOY)
die (getmypid().": status didnt change to '".STRING_DEPLOY."'. quitting\n");
else
$proceed=true;
}
}
if ($proceed)
debug( "checking server...\n");
else
die (getmypid().": event didnt match categories global or cmdb_status, quitting\n");
}
function get_event()
{
$deploy="";
while($l = fgets(STDIN)){
$deploy.=$l;
}
$event=json_decode(base64_decode($deploy));
if (json_last_error())
die (getmypid().": error json decode, quitting\n");
return $event;
}