Commit 4de5b678 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(systemImport): Avoid dependency toward dns and dhcp for import

This avoids a crash when trying to import OPSI hosts while DHCP plugin
 is not installed.

issue #5766
Showing with 7 additions and 3 deletions
+7 -3
...@@ -41,7 +41,11 @@ class systemImport extends simplePlugin ...@@ -41,7 +41,11 @@ class systemImport extends simplePlugin
$messages = array(); $messages = array();
$dhcps = array(); $dhcps = array();
$dns = objects::ls('dnsZone'); try {
$dns = objects::ls('dnsZone');
} catch (NonExistingObjectTypeException $e) {
$dns = array();
}
if (!empty($template_dn)) { if (!empty($template_dn)) {
$template = new template($type, $template_dn); $template = new template($type, $template_dn);
} }
...@@ -95,7 +99,7 @@ class systemImport extends simplePlugin ...@@ -95,7 +99,7 @@ class systemImport extends simplePlugin
$tabObject = $template->apply(); $tabObject = $template->apply();
} }
if (!$tabObject->by_object['dhcpSystem']->is_account) { if (class_available('dhcpSystem') && !$tabObject->by_object['dhcpSystem']->is_account) {
/* Get existing DHCP servers */ /* Get existing DHCP servers */
if (empty($dhcps)) { if (empty($dhcps)) {
list(, $dhcpParentNodes) = dhcpSystem::getDhcpParentNodes(); list(, $dhcpParentNodes) = dhcpSystem::getDhcpParentNodes();
...@@ -125,7 +129,7 @@ class systemImport extends simplePlugin ...@@ -125,7 +129,7 @@ class systemImport extends simplePlugin
} }
} }
if (!$tabObject->by_object['dnsHost']->is_account) { if (class_available('dnsHost') && !$tabObject->by_object['dnsHost']->is_account) {
/* Activate DNS if we find a matching server */ /* Activate DNS if we find a matching server */
foreach ($dns as $dn => $value) { foreach ($dns as $dn => $value) {
if (preg_match('/^'.$zone.'\.?$/', $value)) { if (preg_match('/^'.$zone.'\.?$/', $value)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment