Exemplo n.º 1
0
 /**
  * Display the configuration snapshot of a host
  * with template inheritance
  *
  * @method get
  * @route /hosttemplate/snapshotslide/[i:id]
  */
 public function snapshotslideAction()
 {
     $params = $this->getParams();
     $data = HostTemplateRepository::getInheritanceValues($params['id'], true);
     $host = HostTemplate::get($params['id'], 'host_name');
     $data['host_name'] = $host['host_name'];
     $data['icon'] = HostRepository::getIconImage($data['host_name']);
     $hostConfiguration = HostRepository::formatDataForSlider($data);
     /*
     $aDataRealTime = HostRealtime::get($params['id']);
     $hostReal = HostRepository::formatDataForSlider($aDataRealTime);
     
     $servicesStatus = ServiceRealTimeRepository::countAllStatusForHost($params['id']);
     */
     $edit_url = $this->router->getPathFor("/centreon-configuration/hosttemplate/" . $params['id']);
     $this->router->response()->json(array('hostConfig' => $hostConfiguration, 'edit_url' => $edit_url, 'success' => true));
 }
Exemplo n.º 2
0
 /**
  * Get the value from template
  *
  * @param int $hostId The host template Id
  * @return array
  */
 public static function getInheritanceValues($hostId, $withHostValues = false, $columns = array())
 {
     $values = array();
     $templates = static::getTemplateChain($hostId, array(), -1);
     if ($withHostValues) {
         array_unshift($templates, array('id' => $hostId));
     }
     foreach ($templates as $template) {
         if (count($columns) > 0) {
             $inheritanceValues = HostTemplateRepository::getInheritanceValues($template['id'], false, $columns);
             $tmplValues = Host::getParameters($template['id'], $columns);
         } else {
             $inheritanceValues = HostTemplateRepository::getInheritanceValues($template['id']);
             $tmplValues = Host::getParameters($template['id'], self::$inheritanceColumns);
         }
         $tmplValues = array_filter($tmplValues, function ($value) {
             return !is_null($value);
         });
         $tmplValues = array_merge($inheritanceValues, $tmplValues);
         $values = array_merge($tmplValues, $values);
     }
     return $values;
 }