Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IcingaCloneObjectForm: Fix cloning of hosts in director branches #2898

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions application/forms/IcingaCloneObjectForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public function onSuccess()
$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');
}

Expand Down Expand Up @@ -211,7 +212,11 @@ public function onSuccess()
);

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) {
$clone->set('service_set_id', $newId);
}
Expand All @@ -222,7 +227,14 @@ public function onSuccess()
$newSet = IcingaServiceSet::fromPlainObject(
$set->toPlainObject(),
$connection
)->set('host_id', $newId);
);

if ($isBranch) {
$newSet->set('host', $newName);
} else {
$newSet->set('host_id', $newId);
}

$store->store($newSet);
}

Expand Down