e-smith-hosts/root/etc/e-smith/db/hosts/migrate/10reformat

39 lines
1.1 KiB
Plaintext
Raw Normal View History

{
foreach my $host ($DB->get_all)
{
next if defined $host->prop('HostType');
my %properties;
$properties{'InternalIP'} = $host->prop('InternalIP') || '';
$properties{'ExternalIP'} = $host->prop('ExternalIP') || '';
$properties{'MACAddress'} = $host->prop('MACAddress') || '';
# If defined as host 'self', change to new format
if (($properties{'InternalIP'} eq 'self') &&
($properties{'ExternalIP'} eq 'self'))
{
$properties{'HostType'} = 'Self';
$properties{'InternalIP'} = '';
$properties{'ExternalIP'} = '';
$properties{'MACAddress'} = '';
}
# defined as 'local' entry in new format
elsif( $properties{InternalIP} ne 'self' )
{
$properties{'HostType'} = 'Local';
$properties{ExternalIP} = '';
}
elsif( $properties{ExternalIP} ne 'self' )
{
$properties{'HostType'} = 'Remote';
$properties{InternalIP} = '';
}
else {
warn "$host has no InternalIP or ExternalIP!\n";
}
$host->delete_prop('Visibility');
$host->merge_props(%properties);
}
}