parent
0e1d036f48
commit
1d384500aa
|
@ -26,6 +26,7 @@ next (will be 1.8.0)
|
|||
* FEATURE: allow to define update-only Sync Rules (#2059)
|
||||
* FEATURE: New Property Modifier: ListToObject (#2062)
|
||||
* FEATURE: Property Modifier: convert binary UUID to HEX presentation (#2138)
|
||||
* FEATURE: Property Modifier: get Host by Address (#2210)
|
||||
* FEATURE: Import Sources now allow to download previewed data as JSON (#2096)
|
||||
* FEATURE: UTF8 validation for failed imports gives better error message (#2143)
|
||||
* FIX: LDAP Import is now able to paginate limited results (#2019)
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Exception\InvalidPropertyException;
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class PropertyModifierGetHostByAddr extends PropertyModifierHook
|
||||
{
|
||||
public static function addSettingsFormFields(QuickForm $form)
|
||||
{
|
||||
$form->addElement('select', 'on_failure', array(
|
||||
'label' => 'On failure',
|
||||
'description' => $form->translate('What should we do if the host (DNS) lookup fails?'),
|
||||
'multiOptions' => $form->optionalEnum(array(
|
||||
'null' => $form->translate('Set no value (null)'),
|
||||
'keep' => $form->translate('Keep the property (hostname) as is'),
|
||||
'fail' => $form->translate('Let the whole import run fail'),
|
||||
)),
|
||||
'required' => true,
|
||||
));
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return mt('director', 'Get host by address (Reverse DNS lookup)');
|
||||
}
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
$host = gethostbyaddr($value);
|
||||
if ($host === false) {
|
||||
switch ($this->getSetting('on_failure')) {
|
||||
case 'null':
|
||||
return null;
|
||||
case 'keep':
|
||||
return $value;
|
||||
case 'fail':
|
||||
default:
|
||||
throw new InvalidPropertyException(
|
||||
'Reverse Host lookup failed for "%s"',
|
||||
$value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $host;
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ use Icinga\Module\Director\PropertyModifier\PropertyModifierDnsRecords;
|
|||
use Icinga\Module\Director\PropertyModifier\PropertyModifierExtractFromDN;
|
||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierFromAdSid;
|
||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierFromLatin1;
|
||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierGetHostByAddr;
|
||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierGetHostByName;
|
||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierGetPropertyFromOtherImportSource;
|
||||
use Icinga\Module\Director\PropertyModifier\PropertyModifierJoin;
|
||||
|
@ -89,6 +90,7 @@ $directorHooks = [
|
|||
PropertyModifierExtractFromDN::class,
|
||||
PropertyModifierFromAdSid::class,
|
||||
PropertyModifierFromLatin1::class,
|
||||
PropertyModifierGetHostByAddr::class,
|
||||
PropertyModifierGetHostByName::class,
|
||||
PropertyModifierGetPropertyFromOtherImportSource::class,
|
||||
PropertyModifierJoin::class,
|
||||
|
|
Loading…
Reference in New Issue