initial commit of file from CVS for e-smith-hosts on Wed 12 Jul 08:56:08 BST 2023
This commit is contained in:
38
root/etc/e-smith/db/hosts/migrate/10reformat
Normal file
38
root/etc/e-smith/db/hosts/migrate/10reformat
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user