2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-21 19:22:05 +00:00

Support ZTP process for Cumulus Switch (#3085)

* Support ZTP process for Cumulus Switch

* change name of onieztp to cumulusztp and add server ip
This commit is contained in:
cxhong 2017-05-22 22:45:18 -04:00 committed by yangsong
parent e2f2d67ba8
commit bd60341cb6
2 changed files with 39 additions and 0 deletions

View File

@ -2271,6 +2271,7 @@ sub addnet6
push @netent, " option domain-search $domainstring;\n";
}
}
my $nameservers = $netcfgs{$net}->{nameservers};
if ($nameservers and $nameservers =~ /:/) {
@ -2574,6 +2575,7 @@ sub addnet
push @netent, " option interface-mtu $mtu;\n";
}
# add domain-search if not sles10 or rh5
my $osv = xCAT::Utils->osver();
unless (($osv =~ /^sle[sc]10/) || ($osv =~ /^rh.*5$/)) {
@ -2591,6 +2593,8 @@ sub addnet
push @netent, " option domain-search $domainstring;\n";
}
}
#for cumulus ZTP process
push @netent, " option cumulus-provision-url \"http://$tftp/install/postscripts/cumulusztp\";\n";
my $ddnserver = $nameservers;
$ddnserver =~ s/,.*//;
@ -2928,6 +2932,7 @@ sub newconfig
}
push @dhcpconf, "option gpxe.no-pxedhcp 1;\n";
push @dhcpconf, "option www-server code 114 = string;\n";
push @dhcpconf, "option cumulus-provision-url code 239 = text;\n";
push @dhcpconf, "\n";
push @dhcpconf, "omapi-port 7911;\n"; #Enable omapi...
push @dhcpconf, "key xcat_key {\n";

34
xCAT/postscripts/cumulusztp Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
function error() {
echo -e "\e[0;33mERROR: The Zero Touch Provisioning script failed while running the command $BASH_COMMAND at line $BASH_LINENO.\e[0m" >&2
exit 1
}
# Log all output from this script
exec >/var/log/autoprovision 2>&1
trap error ERR
#Add Debian Repositories
echo "deb http://http.us.debian.org/debian jessie main" >> /etc/apt/sources.list
echo "deb http://security.debian.org/ jessie/updates main" >> /etc/apt/sources.list
#get ip address for server node
server_ip=`grep cumulus-provision-url /var/lib/dhcp/dhclient.eth0.leases | tail -1 | awk -F/ '{print $3}'`
#push root ssh keys, config passwordless
echo "CumulusLinux!" | sudo -S mkdir -p /root/.ssh
echo "CumulusLinux!" | sudo -S /usr/bin/wget -O /root/.ssh/authorized_keys http://$server_ip/install/postscripts/_ssh/authorized_keys
#enable and config snmpd
echo "CumulusLinux!" | sudo -S /usr/bin/wget -O /home/cumulus/enablesnmp http://$server_ip/install/postscripts/enablesnmp
sudo chmod +x /home/cumulus/enablesnmp
sudo /home/cumulus/enablesnmp
#config base interface
echo "CumulusLinux!" | sudo -S /usr/bin/wget -O /home/cumulus/configinterface http://$server_ip/install/postscripts/configinterface
sudo chmod +x /home/cumulus/configinterface
sudo /home/cumulus/configinterface
# CUMULUS-AUTOPROVISIONING
exit 0