Ipmitool

 view release on metacpan or  search on metacpan

lib/Ipmitool.pm  view on Meta::CPAN

	while(<F1>)
	{
		if ( $. == $start )
		{
			$rec_name = $_;
			remove_spaces(\$rec_name);	
			#print "rec_name : $rec_name\n";
		}
		if ( ($. > $start ) && ( $. < $end ) )
		{
			#print "inside if block\n";
			my @a1 = split(":");
			remove_spaces(\$a1[0]);
			remove_spaces(\$a1[1]);
			#print "$fruname : $rec_name : $a1[0] : $a1[1]\n";
			$FRU{$fruname}{$rec_name}{$a1[0]} = $a1[1];
		}
	}
	close(F1);
}	

sub print
{
	my $self= shift;
	foreach (keys (%{$self}))
	{
		print "$_: $self->{$_}\n"
	}
	#print "IP Address : $self->{ipaddress}\n" if (defined($self->{ipaddress}));
	#print "Username : $self->{username}\n" if (defined($self->{username}));
	#print "Password : $self->{password}\n" if (defined($self->{password}));
	return 0;
}

sub bmc
{
	my $self = shift;
	my $cmd = shift;
	my @op = `ipmitool -H $self->{ipaddress} -U $self->{username} -f file bmc $cmd`;
	#print @op;
	foreach(@op)
	{
		print "$_";
	}
}

sub _init
{

my ($self,@args)=@_;
while (@args)
{
	my ($x);
	($x)=shift(@args);
	if ($x eq "-ipaddress")
	{
		$self->{"ipaddress"}=shift(@args);
		my $p = Net::Ping->new();
		if (!$p->ping($self->{"ipaddress"}))
		{
			#print " Machine is alive\n";
			die "$self->{ipaddress} : invalid ip address or machine is unreachable\n";
		}
		$p->close();
	} elsif ($x eq "-username")
	{
		$self->{"username"}=shift(@args);
	} elsif ($x eq "-password")
	{
		$self->{"password"}=shift(@args);
		open PASSFILE, ">file" or die "Unable to create password file\n";
        	print PASSFILE "$self->{password}";
	        close(PASSFILE);
	} else
	{
		die "Invalid argument : $x\n";
	} 
}

return(0);

}


# Preloaded methods go here.

1;
__END__
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

Ipmitool - Perl interface to the ipmitool.

=head1 SYNOPSIS

  use Ipmitool;
  use Data::Dumper;
  $i = Ipmitool->new(-ipaddress => "10.8.151.179", -username => "root", -password => "changeme");
  $i->print();
  %FRU = $i->fru();
  print Dumper($i);
  $i->bmc("info");

=head1 DESCRIPTION

Ipmitool module lets you manage Intelligent Platform Management Interface (IPMI) functions of either the local system, via a kernel device driver, or a remote system, using IPMI V1.5 and IPMI v2.0. These functions include printing FRU information, LA...

=head1 METHODS

=head2 new()

This function will create object of ipmitool class, takes ipaddress, username, password as a input paramter

=head2 fru()

This function will access perticular machine's fru information and returns the FRU HASH.

=head2 bmc()

This function prints the bmc information of the machine.



( run in 1.648 second using v1.01-cache-2.11-cpan-39bf76dae61 )