diff options
author | Matteo Pasotti <matteo.pasotti@gmail.com> | 2014-01-25 00:29:08 +0100 |
---|---|---|
committer | Matteo Pasotti <matteo.pasotti@gmail.com> | 2014-01-25 00:29:08 +0100 |
commit | 98da7d8102939b47709cf85c484786e37068538c (patch) | |
tree | 085f5d8be23fcee2e7c7eeb75b47c321c523b3f2 | |
parent | db7cd49a868a49e46e35190f4ed73a197c8b892a (diff) | |
download | manatools-98da7d8102939b47709cf85c484786e37068538c.tar manatools-98da7d8102939b47709cf85c484786e37068538c.tar.gz manatools-98da7d8102939b47709cf85c484786e37068538c.tar.bz2 manatools-98da7d8102939b47709cf85c484786e37068538c.tar.xz manatools-98da7d8102939b47709cf85c484786e37068538c.zip |
- initializing configHosts attribute using moose builder
- implemented _dropHost method
-rw-r--r-- | AdminPanel/Hosts/hosts.pm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/AdminPanel/Hosts/hosts.pm b/AdminPanel/Hosts/hosts.pm index 97f9a90e..6b2264f9 100644 --- a/AdminPanel/Hosts/hosts.pm +++ b/AdminPanel/Hosts/hosts.pm @@ -13,9 +13,15 @@ my $is_none = 0; has 'configHosts' => ( is => 'rw', - init_arg => undef + init_arg => undef, + builder => '_initialize' ); +sub _initialize { + my $self = shift(); + $self->configHosts(Config::Hosts->new()); +} + =pod =head2 _getHosts @@ -34,7 +40,7 @@ retrieve data from the hosts file (/etc/hosts) using the Config::Hosts module sub _getHosts { my $self = shift(); - $self->configHosts(Config::Hosts->new()); + # $self->configHosts(Config::Hosts->new()); my $hosts = $self->configHosts->read_hosts(); my @result = (); while( my ($key, $value) = each($hosts)){ @@ -57,6 +63,12 @@ sub _insertHost { return $self->configHosts->insert_host(ip => $ip, hosts => @host_definitions); } +sub _dropHost { + my $self = shift(); + my $host_ip = shift(); + return $self->configHosts->delete_host($host_ip); +} + sub _writeHosts { my $self = shift(); return $self->configHosts->write_hosts(); |