IcingaServiceForm: adjust overrides for host-...
...generated services
This commit is contained in:
parent
b8fb0d4267
commit
f8ed937ffa
|
@ -132,16 +132,21 @@ class HostController extends ObjectController
|
||||||
$parent = IcingaService::create(array(
|
$parent = IcingaService::create(array(
|
||||||
'object_type' => 'template',
|
'object_type' => 'template',
|
||||||
'object_name' => $this->translate('Host'),
|
'object_name' => $this->translate('Host'),
|
||||||
'vars' => $props->vars->getValue(),
|
|
||||||
), $db);
|
), $db);
|
||||||
|
|
||||||
|
if (isset($props->vars)) {
|
||||||
|
$parent->vars = $props->vars->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
$service = IcingaService::create(array(
|
$service = IcingaService::create(array(
|
||||||
'object_type' => 'apply',
|
'object_type' => 'apply',
|
||||||
'object_name' => $serviceName,
|
'object_name' => $serviceName,
|
||||||
'host_id' => $host->id,
|
'host_id' => $host->id,
|
||||||
|
'vars' => $host->getOverriddenServiceVars($serviceName),
|
||||||
), $db);
|
), $db);
|
||||||
|
|
||||||
if ($templates = $props->templates->getValue()) {
|
|
||||||
|
if (isset($props->templates) && $templates = $props->templates->getValue()) {
|
||||||
$imports = $templates;
|
$imports = $templates;
|
||||||
} else {
|
} else {
|
||||||
$imports = $serviceName;
|
$imports = $serviceName;
|
||||||
|
@ -152,7 +157,7 @@ class HostController extends ObjectController
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Validation for $imports? They might not exist!
|
// TODO: Validation for $imports? They might not exist!
|
||||||
array_unshift($imports, $parent);
|
array_push($imports, $parent);
|
||||||
$service->imports = $imports;
|
$service->imports = $imports;
|
||||||
|
|
||||||
$this->view->title = sprintf(
|
$this->view->title = sprintf(
|
||||||
|
|
|
@ -83,29 +83,27 @@ class IcingaServiceForm extends DirectorObjectForm
|
||||||
|
|
||||||
protected function setupHostGenerated()
|
protected function setupHostGenerated()
|
||||||
{
|
{
|
||||||
$this->addNameElement()
|
$msg = $this->translate(
|
||||||
->addImportsElement()
|
'This service has been generated from host properties.'
|
||||||
->addDisabledElement();
|
);
|
||||||
|
|
||||||
|
$this->addHtmlHint($msg);
|
||||||
|
|
||||||
$this->setSubmitLabel(
|
$this->setSubmitLabel(
|
||||||
$this->translate('Override vars')
|
$this->translate('Override vars')
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach (array('object_name', 'imports') as $name) {
|
|
||||||
$this->getElement($name)->setAttrib('disabled', 'disabled');
|
|
||||||
$this->getElement($name)->setRequired(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setupInherited()
|
protected function setupInherited()
|
||||||
{
|
{
|
||||||
$msg = $this->translate(
|
$view = $this->getView();
|
||||||
|
$msg = $view->escape($this->translate(
|
||||||
'This service has been inherited from %s. Still, you might want'
|
'This service has been inherited from %s. Still, you might want'
|
||||||
. ' to change the following properties for this host only.'
|
. ' to change the following properties for this host only.'
|
||||||
);
|
));
|
||||||
|
|
||||||
$name = $this->inheritedFrom;
|
$name = $this->inheritedFrom;
|
||||||
$link = $this->getView()->qlink(
|
$link = $view->qlink(
|
||||||
$name,
|
$name,
|
||||||
'director/service',
|
'director/service',
|
||||||
array(
|
array(
|
||||||
|
|
Loading…
Reference in New Issue