mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 09:14:09 +02:00
IcingaCloneObjectForm: Fix cloning of hosts in director branches (#2898)
The cloned host must also have services and service sets that are under the original host.
This commit is contained in:
commit
030740942e
@ -148,7 +148,8 @@ class IcingaCloneObjectForm extends DirectorForm
|
|||||||
$object->getObjectName()
|
$object->getObjectName()
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($object->isTemplate() && $this->branch && $this->branch->isBranch()) {
|
$isBranch = $this->branch && $this->branch->isBranch();
|
||||||
|
if ($object->isTemplate() && $isBranch) {
|
||||||
throw new IcingaException('Cloning templates is not available for Branches');
|
throw new IcingaException('Cloning templates is not available for Branches');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +212,11 @@ class IcingaCloneObjectForm extends DirectorForm
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($new instanceof IcingaHost) {
|
if ($new instanceof IcingaHost) {
|
||||||
$clone->set('host_id', $newId);
|
if ($isBranch) {
|
||||||
|
$clone->set('host', $newName);
|
||||||
|
} else {
|
||||||
|
$clone->set('host_id', $newId);
|
||||||
|
}
|
||||||
} elseif ($new instanceof IcingaServiceSet) {
|
} elseif ($new instanceof IcingaServiceSet) {
|
||||||
$clone->set('service_set_id', $newId);
|
$clone->set('service_set_id', $newId);
|
||||||
}
|
}
|
||||||
@ -222,7 +227,14 @@ class IcingaCloneObjectForm extends DirectorForm
|
|||||||
$newSet = IcingaServiceSet::fromPlainObject(
|
$newSet = IcingaServiceSet::fromPlainObject(
|
||||||
$set->toPlainObject(),
|
$set->toPlainObject(),
|
||||||
$connection
|
$connection
|
||||||
)->set('host_id', $newId);
|
);
|
||||||
|
|
||||||
|
if ($isBranch) {
|
||||||
|
$newSet->set('host', $newName);
|
||||||
|
} else {
|
||||||
|
$newSet->set('host_id', $newId);
|
||||||
|
}
|
||||||
|
|
||||||
$store->store($newSet);
|
$store->store($newSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user