summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@no.no.james.local>2019-05-10 22:48:36 +0100
committerroot <root@no.no.james.local>2019-05-10 22:52:42 +0100
commitef393874b4df287089d07f8d49d91972e0c5ca18 (patch)
tree3e8d5d13ee8f32c8b27fb15ef79f79ca7cb0722c
parentd3a4ea5a9e34197a9950af285fc9e186a5228493 (diff)
downloadinf-ef393874b4df287089d07f8d49d91972e0c5ca18.tar.gz
inf-ef393874b4df287089d07f8d49d91972e0c5ca18.tar.bz2
inf-ef393874b4df287089d07f8d49d91972e0c5ca18.zip
supermicro support
-rw-r--r--INF.pm3
-rw-r--r--INF/SuperMicro.pm344
-rw-r--r--Makefile12
-rw-r--r--supermicro/SharedLibrary32.dllbin0 -> 176128 bytes
-rw-r--r--supermicro/SharedLibrary64.dllbin0 -> 205824 bytes
-rw-r--r--supermicro/iKVM32.dllbin0 -> 294400 bytes
-rw-r--r--supermicro/iKVM64.dllbin0 -> 252928 bytes
-rw-r--r--supermicro/iKVM__V1.69.25.0x0.jarbin0 -> 3124210 bytes
-rw-r--r--supermicro/libSharedLibrary32.sobin0 -> 243584 bytes
-rw-r--r--supermicro/libSharedLibrary64.sobin0 -> 261688 bytes
-rw-r--r--supermicro/libiKVM32.sobin0 -> 184768 bytes
-rw-r--r--supermicro/libiKVM64.sobin0 -> 203144 bytes
-rw-r--r--supermicro/orig/iKVM__V1.69.25.0x0.jar.pack.gzbin0 -> 2952700 bytes
-rw-r--r--supermicro/orig/liblinux_x86_64__V1.0.8.jar.pack.gzbin0 -> 169304 bytes
-rw-r--r--supermicro/orig/liblinux_x86__V1.0.8.jar.pack.gzbin0 -> 159339 bytes
-rw-r--r--supermicro/orig/libwin_x86_64__V1.0.8.jar.pack.gzbin0 -> 221079 bytes
-rw-r--r--supermicro/orig/libwin_x86__V1.0.8.jar.pack.gzbin0 -> 216921 bytes
17 files changed, 359 insertions, 0 deletions
diff --git a/INF.pm b/INF.pm
index 962b15a..556a546 100644
--- a/INF.pm
+++ b/INF.pm
@@ -3,6 +3,7 @@ use INF::APC;
use INF::DSRx020;
use INF::ILO;
use INF::ILO2;
+use INF::SuperMicro;
#$infs = [
@@ -31,6 +32,8 @@ sub new ($;$) {
}
elsif ( $inf->{inf_type} eq 'apc' ) {
return INF::APC->new($inf);
+ } elsif ( $inf->{inf_type} eq 'supermicro' ) {
+ return INF::SuperMicro->new($inf);
} elsif ( $inf->{inf_type} eq 'ilo' ) {
return INF::ILO->new($inf);
} elsif ( $inf->{inf_type} eq 'ilo2' ) {
diff --git a/INF/SuperMicro.pm b/INF/SuperMicro.pm
new file mode 100644
index 0000000..68927c7
--- /dev/null
+++ b/INF/SuperMicro.pm
@@ -0,0 +1,344 @@
+#!/usr/bin/env perl
+
+IO::Socket::SSL::set_ctx_defaults( SSL_verify_mode => SSL_VERIFY_NONE );
+
+package INF::SuperMicro;
+
+use HTTP::Status;
+use HTTP::Cookies;
+
+use IO::Socket::SSL qw();
+use HTML::TreeBuilder;
+use HTTP::Request::Common;
+use LWP::UserAgent;
+use URI::Escape;
+use File::Temp qw/ tempfile tempdir /;
+use XML::Simple;
+use Data::Dumper;
+use JSON::PP;
+
+my $prefix = "/usr/local/share/inf/supermicro/";
+
+my $jars = [ $prefix . "iKVM__V1.69.25.0x0.jar" ];
+
+sub login($) {
+ my $self = shift;
+
+ my $post = POST( $self->{bmc_url} . '/cgi/login.cgi' );
+ my $form_content =
+ 'name=' . $self->{user} . '&' . 'pwd=' . $self->{password};
+
+ $post->header( 'Content-Type' => 'application/x-www-form-urlencoded' );
+ $post->header( 'Content-Length' => length($form_content) );
+ $post->content($form_content);
+
+ my $res = $self->{ua}->request($post);
+
+ unless ( $res->is_success ) {
+ print STDERR "Login failed - did not get 200\n";
+
+ print Dumper($res);
+
+ $self->{logged_in} = undef;
+ return -1;
+ }
+
+ $self->{logged_in} = 1;
+
+ #my $json = decode_json( $res->content );
+
+ #$self->{skey} = $json->{session_key};
+
+ #print "Session key ".$self->{skey}."\n";
+
+ return 0;
+}
+
+sub view($) {
+ my $self = shift;
+
+ $self->login() unless defined $self->{logged_in};
+
+ my $get = GET( $self->{bmc_url}
+ . '/cgi/url_redirect.cgi?url_name=ikvm&url_type=jwsk' );
+
+ my $res = $self->{ua}->request($get);
+
+ unless ( $res->is_success ) {
+ print STDERR "JWSK frequest failed - did not get 200\n";
+ return -1;
+ }
+
+ my $xml = new XML::Simple;
+
+ my $c = $res->content;
+
+ $c =~ s/^[\s\n\r]+//s;
+
+ my $data = $xml->XMLin($c);
+
+ return undef unless defined $data->{'application-desc'};
+
+ my $args = $data->{'application-desc'}->{'argument'};
+
+ return undef unless defined $args;
+
+ mkdir $ENV{HOME} . "/.supermicro_kvm";
+ chdir $ENV{HOME} . "/.supermicro_kvm";
+
+ my $cp = join( ':', @$jars );
+
+ if ( $self->{proxy_host} ) {
+ system(
+ "echo",
+ "java",
+ "-Djava.net.preferIPv4Stack=true",
+ "-Djava.net.useSystemProxies=false",
+ "-DsocksProxyVersion=4",
+ "-DsocksProxySet=true",
+ "-DsocksProxyHost=" . $self->{proxy_host},
+ "-DsocksProxyPort=" . $self->{proxy_port},
+ "-cp",
+ $cp,
+ "-Djava.library.path=" . $prefix,
+ "tw.com.aten.ikvm.KVMMain",
+ @$args
+ );
+ system(
+ "java",
+ "-Djava.net.preferIPv4Stack=true",
+ "-Djava.net.useSystemProxies=false",
+ "-DsocksProxyVersion=4",
+ "-DsocksProxySet=true",
+ "-DsocksProxyHost=" . $self->{proxy_host},
+ "-DsocksProxyPort=" . $self->{proxy_port},
+ "-cp",
+ $cp,
+ "-Djava.library.path=" . $prefix,
+ "tw.com.aten.ikvm.KVMMain",
+ @$args
+ );
+
+ }
+ else {
+ system( "java", "-cp", $cp, "-Djava.library.path=" . $prefix,
+ "tw.com.aten.ikvm.KVMMain", @$args );
+ }
+
+}
+
+#
+# unless ( $content =~ /Netscape'\) {(.*)}[\s\n]*else if/s ) {
+# print STDERR "returned html doesn't look right\n";
+# return -1;
+# }
+#
+# $content = $1;
+#
+# #$content=~ s/document.writeln\("(.*)"\);$/\1/m;
+# $content =~ s/^\s*document.writeln\("(.*)"\);\s*$/\1/mg;
+# $content =~ s/\\//g;
+#
+# $content =~ s/RCINFO1=.*$/RCINFO1="$self->{skey}"/m;
+# $content =~ s/RCINFO6=.*$/RCINFO6="17990"/m;
+# $content =~ s/RCINFOLANG=.*$/RCINFOLANG="en"/m;
+# $content =~ s%(archive=)(/.*)$%\1$self->{proxy_url}\2%m;
+#
+# $content = "<html><head></head><body>" . $content . "</body></html>";
+#
+# $self->{java_html} = $content;
+#
+# my $webserver_pid = fork();
+#
+# if ( $webserver_pid == 0 ) {
+# $SIG{INT} = sub { kill 'KILL', ( @{ $self->{to_kill} } ); die; };
+# $SIG{TERM} = sub { kill 'KILL', ( @{ $self->{to_kill} } ); die; };
+#
+# $self->{server}->start;
+# print STDERR "failed to web server";
+# sleep(100000);
+# }
+#
+# push @{ $self->{to_kill} }, $webserver_pid;
+#
+# $SIG{INT} = sub { kill 'INT', ( @{ $self->{to_kill} } ); die; };
+# $SIG{TERM} = sub { kill 'TERM', ( @{ $self->{to_kill} } ); die; };
+#
+# system(
+# "appletviewer",
+# "-J-Djava.security.manager",
+# "-J-Djava.security.policy=/usr/local/share/inf/ilo/mypolicy",
+# "-J-Djavax.net.ssl.trustStore=/usr/local/share/inf/ilo/server.jks",
+# $self->{proxy_url} . "/html/java_irc.html"
+# );
+#
+# kill 'TERM', ( @{ $self->{to_kill} } );
+#}
+#
+sub get_host_power($) {
+ my ($self) = @_;
+
+ $self->login() unless defined $self->{logged_in};
+
+ my $post = POST( $self->{bmc_url} . '/cgi/ipmi.cgi' );
+ my $form_content = 'op=POWER_INFO.XML&r=(0%2C0)';
+
+ $post->header( 'Content-Type' => 'application/x-www-form-urlencoded' );
+ $post->header( 'Content-Length' => length($form_content) );
+ $post->content($form_content);
+
+ my $res = $self->{ua}->request($post);
+
+ unless ( $res->is_success ) {
+ print STDERR " get host power - did not get 200\n";
+ return undef;
+ }
+
+ my $xml = new XML::Simple;
+
+ my $c = $res->content;
+
+ $c =~ s/^[\s\n\r]+//s;
+
+ my $data = $xml->XMLin($c);
+
+ return undef unless defined $data->{'POWER_INFO'};
+ return undef unless defined $data->{'POWER_INFO'}->{'POWER'};
+ return undef unless defined $data->{'POWER_INFO'}->{'POWER'}->{'STATUS'};
+
+ return $data->{'POWER_INFO'}->{'POWER'}->{'STATUS'};
+}
+
+sub set_host_power($$) {
+ my ( $self, $what ) = @_;
+
+ $self->login() unless defined $self->{logged_in};
+
+ my $post = POST( $self->{bmc_url} . '/cgi/ipmi.cgi' );
+ my $form_content = 'op=POWER_INFO.XML&r=(1%2C' . $what . ')';
+
+ $post->header( 'Content-Type' => 'application/x-www-form-urlencoded' );
+ $post->header( 'Content-Length' => length($form_content) );
+ $post->content($form_content);
+
+ my $res = $self->{ua}->request($post);
+
+ unless ( $res->is_success ) {
+ print STDERR " get host power - did not get 200\n";
+ return 0;
+ }
+
+ my $xml = new XML::Simple;
+
+ my $c = $res->content;
+
+ $c =~ s/^[\s\n\r]+//s;
+
+ my $data = $xml->XMLin($c);
+
+ return 0 unless defined $data->{'POWER_INFO'};
+ return 0 unless defined $data->{'POWER_INFO'}->{'POWER'};
+ return 0 unless defined $data->{'POWER_INFO'}->{'POWER'}->{'STATUS'};
+
+ return 1;
+}
+
+sub reset($) {
+ my $self = shift;
+ return $self->set_host_power('0');
+}
+
+sub port_off($) {
+ my $self = shift;
+ return $self->set_host_power('1');
+}
+
+sub orderly_shutdown($) {
+ my $self = shift;
+ return $self->set_host_power('2');
+}
+
+sub port_on($) {
+ my $self = shift;
+ return $self->set_host_power('3');
+}
+
+sub port_cycle($) {
+ my $self = shift;
+ return $self->set_host_power('5');
+}
+
+sub port_state_get($$) {
+ my $self = shift;
+ return $self->get_host_power();
+}
+
+sub port_name_get($$) {
+ my $self = shift;
+ return $self->{name};
+}
+
+sub name_get($) {
+ my $self = shift;
+ return $self->{name};
+}
+
+sub pdu_load_get($) {
+ return "N/A";
+}
+
+sub psu_status($) {
+ return "N/A";
+}
+
+sub port_count($) {
+ return 1;
+}
+
+sub port_id_get_by_number($$) {
+ return "K0";
+}
+
+sub logout($) {
+ my $self = shift;
+}
+
+sub new ($;$) {
+ my ( $class, $parm ) = @_;
+ my $self;
+
+ $self->{ua} = my $ua = LWP::UserAgent->new;
+ $self->{cookie_jar} = HTTP::Cookies->new();
+ $self->{ua}->cookie_jar( $self->{cookie_jar} );
+
+ $self->{host} = $parm->{host} || "127.0.0.1";
+
+ $self->{user} = $parm->{user} || "ADMIN";
+ $self->{password} = $parm->{password} || "ADMIN";
+
+ $self->{name} = $parm->{name} || $self->{host};
+
+ $self->{bmc_url} = $parm->{bmc_url}
+ || 'https://' . $self->{host};
+
+ $self->{ua}->ssl_opts(
+ SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,
+ verify_hostname => 0,
+ );
+
+ if ( defined $parm->{proxy_host} ) {
+ $self->{ua}->proxy( [qw(http https)] => "socks://"
+ . $parm->{proxy_host} . ":"
+ . $parm->{proxy_port} );
+ $self->{proxy_host} = $parm->{proxy_host};
+ $self->{proxy_port} = $parm->{proxy_port};
+ }
+
+ $self->{logged_in} = undef;
+
+ return bless $self, $class;
+
+}
+
+1;
+
diff --git a/Makefile b/Makefile
index 307448d..3da1407 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ install:
mkdir -p /usr/local/share/inf/HTTP/Server
mkdir -p /usr/local/share/inf/avocent
mkdir -p /usr/local/share/inf/ilo
+ mkdir -p /usr/local/share/inf/supermicro
install -m 755 inf.pl /usr/local/bin/inf
install -m 644 HTTP/Server/Brick.pm /usr/local/share/inf/HTTP/Server/
install -m 644 INF.pm /usr/local/share/inf/
@@ -12,6 +13,7 @@ install:
install -m 644 INF/DSRx020.pm /usr/local/share/inf/INF
install -m 644 INF/ILO.pm /usr/local/share/inf/INF
install -m 644 INF/ILO2.pm /usr/local/share/inf/INF
+ install -m 644 INF/SuperMicro.pm /usr/local/share/inf/INF
install -m 644 mibs/PowerNet-MIB.mib /usr/local/share/inf/mibs/
install -m 644 mibs/RFC1155-SMI.mib /usr/local/share/inf/mibs/
install -m 644 mibs/RFC-1212.mib /usr/local/share/inf/mibs/
@@ -39,3 +41,13 @@ install:
install -m 644 ilo/server.crt /usr/local/share/inf/ilo/
install -m 644 ilo/server.jks /usr/local/share/inf/ilo/
install -m 644 ilo/server.key /usr/local/share/inf/ilo/
+ install -m 644 supermicro/iKVM32.dll /usr/local/share/inf/supermicro/
+ install -m 644 supermicro/iKVM64.dll /usr/local/share/inf/supermicro/
+ install -m 644 supermicro/iKVM__V1.69.25.0x0.jar /usr/local/share/inf/supermicro/
+ install -m 644 supermicro/libiKVM32.so /usr/local/share/inf/supermicro/
+ install -m 644 supermicro/libiKVM64.so /usr/local/share/inf/supermicro/
+ install -m 644 supermicro/libSharedLibrary32.so /usr/local/share/inf/supermicro/
+ install -m 644 supermicro/libSharedLibrary64.so /usr/local/share/inf/supermicro/
+ install -m 644 supermicro/SharedLibrary32.dll /usr/local/share/inf/supermicro/
+ install -m 644 supermicro/SharedLibrary64.dll /usr/local/share/inf/supermicro/
+
diff --git a/supermicro/SharedLibrary32.dll b/supermicro/SharedLibrary32.dll
new file mode 100644
index 0000000..a2a5f56
--- /dev/null
+++ b/supermicro/SharedLibrary32.dll
Binary files differ
diff --git a/supermicro/SharedLibrary64.dll b/supermicro/SharedLibrary64.dll
new file mode 100644
index 0000000..2c0eab3
--- /dev/null
+++ b/supermicro/SharedLibrary64.dll
Binary files differ
diff --git a/supermicro/iKVM32.dll b/supermicro/iKVM32.dll
new file mode 100644
index 0000000..288c226
--- /dev/null
+++ b/supermicro/iKVM32.dll
Binary files differ
diff --git a/supermicro/iKVM64.dll b/supermicro/iKVM64.dll
new file mode 100644
index 0000000..10f7f37
--- /dev/null
+++ b/supermicro/iKVM64.dll
Binary files differ
diff --git a/supermicro/iKVM__V1.69.25.0x0.jar b/supermicro/iKVM__V1.69.25.0x0.jar
new file mode 100644
index 0000000..3b3e326
--- /dev/null
+++ b/supermicro/iKVM__V1.69.25.0x0.jar
Binary files differ
diff --git a/supermicro/libSharedLibrary32.so b/supermicro/libSharedLibrary32.so
new file mode 100644
index 0000000..9c517f8
--- /dev/null
+++ b/supermicro/libSharedLibrary32.so
Binary files differ
diff --git a/supermicro/libSharedLibrary64.so b/supermicro/libSharedLibrary64.so
new file mode 100644
index 0000000..4ded62e
--- /dev/null
+++ b/supermicro/libSharedLibrary64.so
Binary files differ
diff --git a/supermicro/libiKVM32.so b/supermicro/libiKVM32.so
new file mode 100644
index 0000000..96b90d7
--- /dev/null
+++ b/supermicro/libiKVM32.so
Binary files differ
diff --git a/supermicro/libiKVM64.so b/supermicro/libiKVM64.so
new file mode 100644
index 0000000..caf5c54
--- /dev/null
+++ b/supermicro/libiKVM64.so
Binary files differ
diff --git a/supermicro/orig/iKVM__V1.69.25.0x0.jar.pack.gz b/supermicro/orig/iKVM__V1.69.25.0x0.jar.pack.gz
new file mode 100644
index 0000000..a375e2e
--- /dev/null
+++ b/supermicro/orig/iKVM__V1.69.25.0x0.jar.pack.gz
Binary files differ
diff --git a/supermicro/orig/liblinux_x86_64__V1.0.8.jar.pack.gz b/supermicro/orig/liblinux_x86_64__V1.0.8.jar.pack.gz
new file mode 100644
index 0000000..6255470
--- /dev/null
+++ b/supermicro/orig/liblinux_x86_64__V1.0.8.jar.pack.gz
Binary files differ
diff --git a/supermicro/orig/liblinux_x86__V1.0.8.jar.pack.gz b/supermicro/orig/liblinux_x86__V1.0.8.jar.pack.gz
new file mode 100644
index 0000000..13586e5
--- /dev/null
+++ b/supermicro/orig/liblinux_x86__V1.0.8.jar.pack.gz
Binary files differ
diff --git a/supermicro/orig/libwin_x86_64__V1.0.8.jar.pack.gz b/supermicro/orig/libwin_x86_64__V1.0.8.jar.pack.gz
new file mode 100644
index 0000000..a5c1c10
--- /dev/null
+++ b/supermicro/orig/libwin_x86_64__V1.0.8.jar.pack.gz
Binary files differ
diff --git a/supermicro/orig/libwin_x86__V1.0.8.jar.pack.gz b/supermicro/orig/libwin_x86__V1.0.8.jar.pack.gz
new file mode 100644
index 0000000..6a6ed40
--- /dev/null
+++ b/supermicro/orig/libwin_x86__V1.0.8.jar.pack.gz
Binary files differ