forked from aws/aws-parallelcluster-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hanwen <[email protected]>
- Loading branch information
1 parent
673f874
commit d3b60ea
Showing
4 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...arallelcluster-environment/files/amazon-2023/network_interfaces/configure_nw_interface.sh
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,62 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
if | ||
[ -z "${DEVICE_NAME}" ] || # name of the device | ||
[ -z "${DEVICE_NUMBER}" ] || # number of the device | ||
[ -z "${DEVICE_IP_ADDRESS}" ] || # ip of the device | ||
[ -z "${MAC}" ] || # mac address of the device | ||
[ -z "${CIDR_BLOCK}" ] # CIDR block of the subnet | ||
then | ||
echo 'One or more environment variables missing' | ||
exit 1 | ||
fi | ||
echo "Device name: ${DEVICE_NAME}, Device number: ${DEVICE_NUMBER}" | ||
|
||
configuration_directory="/etc/systemd/network" | ||
file_name="70-${DEVICE_NAME}.network" | ||
sub_directory="${configuration_directory}/${file_name}.d" | ||
if [ ! -d "$sub_directory" ]; then | ||
mkdir -p "$sub_directory"; | ||
fi | ||
|
||
cd "$configuration_directory" | ||
|
||
ROUTE_TABLE=200${DEVICE_NUMBER} | ||
|
||
ln -s /usr/lib/systemd/network/80-ec2.network ${file_name} | ||
|
||
if ! grep "RoutingPolicyRule" $files_list; then | ||
/bin/cat <<EOF > ${sub_directory}/eni.conf | ||
# Configuration for ${DEVICE_NUMBER} generated by ParallelCluster | ||
[Match] | ||
MACAddress=${MAC} | ||
[Network] | ||
DHCP=yes | ||
[DHCPv4] | ||
RouteMetric=$ROUTE_TABLE | ||
UseRoutes=true | ||
UseGateway=true | ||
[IPv6AcceptRA] | ||
RouteMetric=$ROUTE_TABLE | ||
UseGateway=true | ||
[Route] | ||
Table=$ROUTE_TABLE | ||
Gateway=_ipv6ra | ||
[Route] | ||
Gateway=_dhcp4 | ||
Table=$ROUTE_TABLE | ||
[Route] | ||
Table=$ROUTE_TABLE | ||
Destination=$CIDR_BLOCK | ||
[RoutingPolicyRule] | ||
From=${DEVICE_IP_ADDRESS} | ||
Priority=$ROUTE_TABLE | ||
Table=$ROUTE_TABLE | ||
EOF | ||
fi |
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
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