Ip-to-Hex <ip> (Generate hex for specific Ip )
 

#!/usr/bin/perl
# Author:  Digimer; digimer@alteeve.ca
# Date:    Jun. 21, 2010
# License: GPLv2

# Be clean
use strict;
use warnings;

# Read the IP address
my $ip=$ARGV[0];
 
# Sanity-check it.
usage() if not $ip;
my ($a, $b, $c, $d)=($ip=~/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/);
usage() if ((not defined $a) || (not defined $b) || (not defined $c) || (not defined $d));
 
# Convert and print
#print $ip." = ".convert($a).convert($b).convert($c).convert($d), "\n";
print convert($a).convert($b).convert($c).convert($d);
 
 
exit (0);
 
sub convert {
        my ($dec)=@_;
 
        # Convert the decimal to hexadecimal and pad the result with a leading
        # zero if needed.
        my $hex = sprintf("%x", $dec);
        $hex=length($hex) == 1 ? "0".$hex : $hex;
 
        # Return the upercase result.
        return (uc($hex));
}
 
# Useful death.
sub usage {
        print "\nPlease pass in the IP address as the only argument.\n";
        print "Do not pass the netmask. Example:\n";
        print "\n\t./ip-to-hex 192.168.1.100\n\n";
        exit(1);
}

 


 

Node-Pxe-ln
 

#!/bin/bash

echo "link $1($2) to $3"
sudo ln -sf $3 $1
sudo ln -sf $1 `ip-to-hex $2`

 

node-pxe-ln <name> <ip> <pxe-default>
node-pxe-ln node00-61 192.168.1.61 default.finnix

 

會産生兩個link

  • C0A8013D → node00-61 (C0A8013D為 IP:192.168.1.61 的HEX)
  • node00-61 → default.finnix

 

Node-Pxe-Boot <node-ip> 執行node pxe重啟

node-pxe-boot
#!/bin/bash
cxmanage power off $1
sleep 2
ipmitool -I lanplus -U admin -P admin -H $1 chassis bootdev pxe
sleep 2
cxmanage power on $1

 

Node-Disk-Boot <node-ip> 執行node disk重啟

node-disk-boot
#!/bin/bash

cxmanage power off $1
sleep 2
ipmitool -I lanplus -U admin -P admin -H $1 chassis bootdev disk
sleep 2
cxmanage power on $1

 

 

 

 

 

 

文章標籤
全站熱搜
創作者介紹
創作者 Lexra 的頭像
Lexra

Lexra Pixnet

Lexra 發表在 痞客邦 留言(0) 人氣(90)