hetzner-robot-perl
hetzner-robot-perl copied to clipboard
Perl module and command line tool for control over the Hetzner robot
Hetzner::Robot / hetzner-robot.pl by Stefan Tomanek [email protected]
http://github.com/wertarbyte/hetzner-robot-perl
Control the Hetzner robot from your Perl scripts or console.
The script hetzner-robot.pl can be used as a standalone program as well as an object oriented Perl module in your own scripts. It uses the JSON-Webservice deployed by Hetzner (http://wiki.hetzner.de/index.php/Robot_Webservice) and encapsulates it into a class/object structure. Many default operations are provided through a command line interface.
== Examples for standalone operation ==
retrieve reverse DNS entry for IP address 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD"
--mode rdns --get --addr 1.2.3.4
set reverse DNS entry for address 1.2.3.4 to "foobar.example.org"
hetzner-robot.pl --user "USERNAME" --password "PASSWORD"
--mode rdns --set --addr 1.2.3.4 --hostname foobar.example.org
instruct the hetzner robot to trigger a hardware reset at server 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD"
--mode reset --address 1.2.3.4 --method hw
enable the rescue system for server 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD"
--mode rescue --address 1.2.3.4 --system linux --arch 64
send Wake-On-LAN signal to system 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD"
--mode wol --address 1.2.3.4
switch failover address to server 1.2.3.4
hetzner-robot.pl --user "USERNAME" --password "PASSWORD"
--mode failover --address 5.6.7.8 --target 1.2.3.4
retrieve status of a failover address
hetzner-robot.pl --user "USERNAME" --password "PASSWORD"
--mode failover --address 5.6.7.8 --status
to hide the password from the command line, it can be read from stdin:
echo "passphrase" | hetzner-robot.pl --user "USERNAME" --readpw ...
== Examples for use in scripts ==
#!/usr/bin/perl
load module
use Hetzner::Robot;
my $robot = new Hetzner::Robot("username", "password"); my $serverA = $robot->server("1.2.3.4");
enumerate subnets assigned to server
for my $n ($serverA->subnets) { print $n->address."/".$n->netmask, "\n"; }
send WOL signal to all servers
for my $sys ($robot->servers) { print "Waking up ".$sys->address."\n"; $sys->wol->execute; # $sys->reset->execute("sw"); # we could trigger a soft reboot as well ;-) }
The examples directory also contains a simple CGI script to grant customers limited access to the reverse DNS capabilities of the robot; each customer can access the RDNS records of the addresses associated with their username.