-
Notifications
You must be signed in to change notification settings - Fork 109
Support attaching multiple network interfaces to the same network card #2855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,8 @@ set -e | |
|
|
||
| if | ||
| [ -z "${DEVICE_NAME}" ] || # name of the device | ||
| [ -z "${DEVICE_NUMBER}" ] || # number of the device | ||
| [ -z "${DEVICE_NUMBER}" ] || # index of the device | ||
| [ -z "${NETWORK_CARD_INDEX}" ] || # index of the network card | ||
| [ -z "${GW_IP_ADDRESS}" ] || # gateway ip address | ||
| [ -z "${DEVICE_IP_ADDRESS}" ] || # ip address to assign to the interface | ||
| [ -z "${CIDR_PREFIX_LENGTH}" ] || # the prefix length of the device IP cidr block | ||
|
|
@@ -20,9 +21,11 @@ then | |
| exit 1 | ||
| fi | ||
|
|
||
| ROUTE_TABLE="100${DEVICE_NUMBER}" | ||
| SUFFIX=$(printf "%03d" $NETWORK_CARD_INDEX)$(printf "%03d" $DEVICE_NUMBER) | ||
|
|
||
| echo "Configuring ${DEVICE_NAME} with IP:${DEVICE_IP_ADDRESS} CIDR_PREFIX:${CIDR_PREFIX_LENGTH} NETMASK:${NETMASK} GW:${GW_IP_ADDRESS} ROUTING_TABLE:${ROUTE_TABLE}" | ||
| ROUTE_TABLE="1${SUFFIX}" | ||
|
|
||
| echo "Configuring device name: ${DEVICE_NAME} with IP:${DEVICE_IP_ADDRESS} CIDR_PREFIX:${CIDR_PREFIX_LENGTH} NETMASK:${NETMASK} GW:${GW_IP_ADDRESS} ROUTING_TABLE:${ROUTE_TABLE}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about adding network card index too? ${NETWORK_CARD_INDEX} |
||
|
|
||
| # config file | ||
| FILE="/etc/sysconfig/network-scripts/ifcfg-${DEVICE_NAME}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,8 @@ set -e | |
|
|
||
| if | ||
| [ -z "${DEVICE_NAME}" ] || # name of the device | ||
| [ -z "${DEVICE_NUMBER}" ] || # number of the device | ||
| [ -z "${DEVICE_NUMBER}" ] || # index of the device | ||
| [ -z "${NETWORK_CARD_INDEX}" ] || # index of the network card | ||
| [ -z "${GW_IP_ADDRESS}" ] || # gateway ip address | ||
| [ -z "${DEVICE_IP_ADDRESS}" ] || # ip address to assign to the interface | ||
| [ -z "${CIDR_PREFIX_LENGTH}" ] # the prefix length of the device IP cidr block | ||
|
|
@@ -23,9 +24,10 @@ then | |
| fi | ||
|
|
||
| con_name="System ${DEVICE_NAME}" | ||
| route_table="100${DEVICE_NUMBER}" | ||
| priority="100${DEVICE_NUMBER}" | ||
| metric="100${DEVICE_NUMBER}" | ||
| SUFFIX=$(printf "%03d" $NETWORK_CARD_INDEX)$(printf "%03d" $DEVICE_NUMBER) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be consistent with existing code we should use lowercase variable names for internal variables, so we should have |
||
| route_table="1${SUFFIX}" | ||
| priority="1${SUFFIX}" | ||
| metric="1${SUFFIX}" | ||
|
|
||
| # Rename connection | ||
| original_con_name=`nmcli -t -f GENERAL.CONNECTION device show ${DEVICE_NAME} | cut -f2 -d':'` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,8 @@ set -e | |
|
|
||
| if | ||
| [ -z "${DEVICE_NAME}" ] || # name of the device | ||
| [ -z "${DEVICE_NUMBER}" ] || # number of the device | ||
| [ -z "${DEVICE_NUMBER}" ] || # index of the device | ||
| [ -z "${NETWORK_CARD_INDEX}" ] || # index of the network card | ||
| [ -z "${GW_IP_ADDRESS}" ] || # gateway ip address | ||
| [ -z "${DEVICE_IP_ADDRESS}" ] || # ip address to assign to the interface | ||
| [ -z "${CIDR_PREFIX_LENGTH}" ] || # the prefix length of the device IP cidr block | ||
|
|
@@ -40,7 +41,8 @@ if [ "${STATIC_IP_CONFIG}" = "" ] | |
| fi | ||
|
|
||
| FILE="/etc/netplan/${DEVICE_NAME}.yaml" | ||
| ROUTE_TABLE="100${DEVICE_NUMBER}" | ||
| SUFFIX=$(printf "%03d" $NETWORK_CARD_INDEX)$(printf "%03d" $DEVICE_NUMBER) | ||
| ROUTE_TABLE="1${SUFFIX}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have expected kitchen tests to fail in the https://github.com/aws/aws-parallelcluster-cookbook/blob/develop/cookbooks/aws-parallelcluster-environment/test/controls/network_interfaces_spec.rb after this changes. Could you please run them and double check if we can improve existing coverage? |
||
|
|
||
| echo "Configuring ${DEVICE_NAME} with IP:${DEVICE_IP_ADDRESS} CIDR_PREFIX:${CIDR_PREFIX_LENGTH} NETMASK:${NETMASK} GW:${GW_IP_ADDRESS} ROUTING_TABLE:${ROUTE_TABLE}" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,13 @@ | |
| return if on_docker? | ||
|
|
||
| def network_card_index(mac, token) | ||
| # This IMDS call is not available on single NIC instance, therefore fallback to 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to link in a comment the public documentation where this behavior is described. |
||
| uri = URI("http://169.254.169.254/latest/meta-data/network/interfaces/macs/#{mac}/network-card") | ||
| get_metadata_with_token(token, uri) || 0 | ||
| end | ||
|
|
||
| def device_number(mac, token) | ||
| uri = URI("http://169.254.169.254/latest/meta-data/network/interfaces/macs/#{mac}/device-number") | ||
| get_metadata_with_token(token, uri) | ||
| end | ||
|
|
||
|
|
@@ -69,6 +75,7 @@ def cidr_to_netmask(cidr) | |
| # Configure nw interfaces | ||
| macs.each do |mac| | ||
| device_name = device_name(mac) | ||
| device_number = device_number(mac, token) | ||
| network_card_index = network_card_index(mac, token) | ||
| gw_ip_address = gateway_address | ||
| device_ip_address = device_ip(mac, token) | ||
|
|
@@ -84,7 +91,8 @@ def cidr_to_netmask(cidr) | |
| environment( | ||
| # TODO: The variables are a superset of what's required by individual scripts. Consider simplification. | ||
| 'DEVICE_NAME' => device_name, | ||
| 'DEVICE_NUMBER' => "#{network_card_index}", # in configure_nw_interface DEVICE_NUMBER actually means network card index | ||
| 'DEVICE_NUMBER' => "#{device_number}", | ||
| 'NETWORK_CARD_INDEX' => "#{network_card_index}", | ||
| 'GW_IP_ADDRESS' => gw_ip_address, | ||
| 'DEVICE_IP_ADDRESS' => device_ip_address, | ||
| 'CIDR_PREFIX_LENGTH' => cidr_prefix_length, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be good to add an example of the expected output in a comment