summaryrefslogtreecommitdiffstats
path: root/common/IFCFG.pm
diff options
context:
space:
mode:
Diffstat (limited to 'common/IFCFG.pm')
-rw-r--r--common/IFCFG.pm20
1 files changed, 8 insertions, 12 deletions
diff --git a/common/IFCFG.pm b/common/IFCFG.pm
index 24441494..f6d793e6 100644
--- a/common/IFCFG.pm
+++ b/common/IFCFG.pm
@@ -34,15 +34,14 @@ sub new {
my $ifconfig = `LC_ALL=C /sbin/ifconfig -a`;
my $device = 'NONE';
- my @interfaces;
foreach (split('\n', $ifconfig)) {
- my ($temp) = /(^eth[0-9]*:?[0-9]*).*/;
+ my ($temp) = /(^eth[0-9]*:?[0-9]*)/;
$device = $temp if defined $temp;
- my ($ip, $bcast, $netmask) = /\s*inet addr:([0-9\.]*)\s*Bcast:([0-9\.]*)\s*Mask:([0-9\.]*).*/;
+ my ($ip, $bcast, $netmask) = /\s*inet addr:([0-9\.]*)\s*Bcast:([0-9\.]*)\s*Mask:([0-9\.]*)/;
if (defined $ip && defined $bcast && defined $netmask) {
- $self->{itf}{$device} = {IPADDR => $ip, BROADCAST => $bcast, NETMASK => $netmask};
+ $self->{itf}{$device} = { IPADDR => $ip, BROADCAST => $bcast, NETMASK => $netmask };
my %conf = getVarsFromSh("/etc/sysconfig/network-scripts/ifcfg-$device");
- $self->{itf}{$device}{$_} = $conf{$_} foreach ('BOOTPROTO');
+ $self->{itf}{$device}{$_} = $conf{$_} foreach 'BOOTPROTO';
}
}
%{$self->{network}} = getVarsFromSh("/etc/sysconfig/network");
@@ -57,8 +56,7 @@ sub new {
}
sub is_dhcp {
- my $self = shift;
- my ($itf) = @_;
+ my ($self, $itf) = @_;
$itf ||= default_itf();
$self->{itf}{$itf}{BOOTPROTO} eq 'dhcp';
@@ -70,17 +68,15 @@ sub default_itf {
}
sub itf_get {
- my $self = shift;
- my ($key, $itf) = @_;
+ my ($self, $key, $itf) = @_;
- $itf ||= default_itf;
+ $itf ||= default_itf();
exists $self->{itf}{$itf}{$key} or print "ERROR: no $key field in $itf hash\n";
$self->{itf}{$itf}{$key}
}
sub network_get {
- my $self = shift;
- my ($key) = @_;
+ my ($self, $key) = @_;
exists $self->{network}{$key} or print "ERROR: no $key field in network hash\n";
$self->{network}{$key}