-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for root filesystem image transfer via uftp, and md5sum c…
…heck
- Loading branch information
Richard Ray
committed
Jul 28, 2017
1 parent
fe04623
commit b2c09d5
Showing
10 changed files
with
306 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Implementing UFTP in xCAT | ||
|
||
When a node boots via xCAT in stateless mode, it first receives a kernel and | ||
an initial ramdisk from the management server. Inside the initial ramdisk is | ||
a script named xcatroot which is responsible for copying the node's root | ||
filesystem image from the management server with wget, uncompressing it into | ||
RAM, and switching to it. The URL of the root filesystem image is passed to | ||
xcatroot via a kernel boot parameter. | ||
|
||
In order to support uftp, xcatroot needs to start uftpd, and then signal the | ||
management server that it is ready to receive the image file. The management | ||
server also needs to wait for some amount of time before starting the transfer, | ||
since there could be some variability in the hardware boot process, and the | ||
slowest node might not have started uftpd yet. In order to make sure the image | ||
transferred correctly, the md5 checksum is checked. If the md5 check fails, or | ||
the transfer times out, xcatroot falls back to wget. | ||
|
||
To implement this, three kernel boot parameters were added, which are: | ||
|
||
uftp | ||
uftpdelay | ||
md5sum | ||
|
||
To use UFTP, set uftp=true. The uftpdelay parameter is for specifying the | ||
number of seconds to wait before the transfer starts, and defaults to 30 if | ||
not specified. The md5sum parameter should be set to the md5 checksum of the | ||
root filesystem image. These need to be set in the addkcmdline field in the | ||
osimage table in xCAT, so that nodeset will pick them up. The packimage | ||
command has been extended with some options to facilitate this: | ||
|
||
packimage [-s| --sum] set md5sum=<md5 checksum of image> | ||
packimage [-u| --uftp] set uftp=true | ||
packimage [-d| --delay=<uftp delay in seconds> set uftpdelay=<uftp delay in seconds> | ||
|
||
Note that if -s is omitted, and an md5sum exists in addkcmdline, the existing | ||
entry is removed because it would no longer be valid. Similarly, if -u is | ||
omitted and uftp=true exists in addkcmdline, it is removed. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/bash | ||
set -E | ||
LOGDIR=/var/log/xcat/ | ||
LOGFILE=uftp_listener.log | ||
mkdir -p $LOGDIR | ||
|
||
usage() { | ||
echo "usage: uftp-listener [ -i interface ] [ -s sleep time ]" | ||
exit 1 | ||
} | ||
|
||
debug() { | ||
[ "$DEBUG" ] && echo "$@" | ||
echo "$@" >> $LOGDIR/$LOGFILE | ||
} | ||
|
||
while getopts ":i:s:hd" options | ||
do | ||
case ${options} in | ||
i ) INTERFACE=${OPTARG};; | ||
s ) SLEEP=${OPTARG};; | ||
d ) DEBUG=true;; | ||
h ) usage | ||
exit 1;; | ||
* ) usage | ||
exit 1;; | ||
esac | ||
done | ||
|
||
# if INTERFACE is null, try to detect | ||
if [ -z "$INTERFACE" ]; then | ||
MAN_NET=$(/opt/xcat/bin/lsdef -t network management | grep net | sed 's/.*=//') | ||
INTERFACE=$(netstat -nr | grep $MAN_NET | awk '{print $8}') | ||
fi | ||
|
||
if [ -z "$INTERFACE" ]; then | ||
debug "ERROR: detection of interface failed and none supplied with -i, aborting..." | ||
exit 1 | ||
fi | ||
|
||
ip link show $INTERFACE > /dev/null 2>&1 | ||
RC=$? | ||
|
||
if [ "$RC" != 0 ]; then | ||
debug "ERROR: invalid interface $INTERFACE" | ||
exit 1 | ||
fi | ||
|
||
# if no sleep time supplied, use the default of 30 seconds | ||
if [ -z "$SLEEP" ]; then | ||
SLEEP=30 | ||
fi | ||
|
||
UFTP=$(which uftp) | ||
if [ ! -x $UFTP ]; then | ||
debug "ERROR: uftp binary not found, exiting!" | ||
exit 1 | ||
fi | ||
|
||
# make sure 1045/tcp is not already in use | ||
nc -i 500ms -l -p 1045 2>&1 | grep "Address already in use" > /dev/null | ||
RC=$? | ||
if [ "$RC" = 0 ]; then | ||
debug "ERROR: 1045/tcp is already in use, sleeping 10 seconds and exiting" | ||
sleep 10 | ||
exit 1 | ||
fi | ||
|
||
debug "listening for transfer request on 1045/tcp" | ||
while true | ||
do | ||
LINE=$(nc -l -p 1045 | grep -E "/install/.*/rootimg(\.sfs|\.cpio\.gz|\.cpio\.xz|\.tar.gz|\.tar\.xz|-statelite\.gz)") | ||
DATE=$(date --rfc-3339=ns) | ||
debug $DATE $LINE | ||
ROOTIMG=$(echo $LINE | sed 's/.*GET //' | sed 's+HTTP/1.1.*++') | ||
if [ ! -f $ROOTIMG ] | ||
then | ||
debug "$ROOTIMG: file not found" | ||
else | ||
debug "sleeping $SLEEP seconds" | ||
sleep $SLEEP # wait for additional nodes that might also want this image | ||
debug "copying $ROOTIMG" | ||
$UFTP -I $INTERFACE -R 500000 -B 104857600 -b 8800 -D /rootimg.cpio.gz $ROOTIMG | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=UFTP listener | ||
Wants=basic.target | ||
After=basic.target network.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/bin/bash /opt/xcat/bin/uftp-listener | ||
KillMode=control-group | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Name: uftp | ||
Version: 4.9.3 | ||
Release: 1 | ||
Summary: UFTP - Encrypted UDP based FTP with multicast | ||
|
||
Group: FTP Server | ||
License: GPL | ||
URL: http://uftp-multicast.sourceforge.net | ||
Source0: http://sourceforge.net/projects/uftp-multicast/files/source-tar/uftp-4.9.3.tar.gz | ||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | ||
|
||
BuildRequires: openssl-devel | ||
|
||
%description | ||
UFTP is an encrypted multicast file transfer program, designed to securely, reliably, and efficiently transfer files to multiple receivers simultaneously. This is useful for distributing large files to a large number of receivers, and is especially useful for data distribution over a satellite link (with two way communication), where the inherent delay makes any TCP based communication highly inefficient. The multicast encryption scheme is based on TLS with extensions to allow multiple receivers to share a common key. UFTP also has the capability to communicate over disjoint networks separated by one or more firewalls (NAT traversal) and without full end-to-end multicast capability (multicast tunneling) through the use of a UFTP proxy server. These proxies also provide scalability by aggregating responses from a group of receivers. | ||
|
||
%prep | ||
%setup -q | ||
|
||
%build | ||
make %{?_smp_mflags} | ||
|
||
%install | ||
rm -rf $RPM_BUILD_ROOT | ||
make install DESTDIR=$RPM_BUILD_ROOT | ||
|
||
%clean | ||
rm -rf $RPM_BUILD_ROOT | ||
|
||
%files | ||
%defattr(-,root,root,-) | ||
/usr/bin/uftp | ||
/usr/sbin/uftpd | ||
/usr/sbin/uftpproxyd | ||
/usr/bin/uftp_keymgt | ||
/usr/share/man/man1/uftp.1.gz | ||
/usr/share/man/man1/uftp_keymgt.1.gz | ||
/usr/share/man/man1/uftpd.1.gz | ||
/usr/share/man/man1/uftpproxyd.1.gz | ||
|
||
%changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.