No longer hard coding to a specifc network interface name.
Instead of using a specific network interface name, thi fix fetch all ethernet mac addresses. Then uses this list of mac addresses to do a check if any entries in the list match any of the values in NetConfigDataLookup for a node. If there is a match, the /etc/os-net-config/mapping.yaml file for the node will be written. This fix removes the hard coded interface name 'eth0' used to get a mac address as identifyer for the specific node before. Using a hard coded interface name such as 'eth0' would have failed on most hardware because of "consistent network device names". Fix Bug: #1642551 Change-Id: I6c1d1b4d70b916bc5d9049469df8221f8ab2eb95
This commit is contained in:
parent
e171ef1b68
commit
06d4d088ad
@ -38,7 +38,7 @@ resources:
|
|||||||
str_replace:
|
str_replace:
|
||||||
template: |
|
template: |
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
eth_addr=$(/sbin/ifconfig eth0 | grep ether | awk '{print $2}')
|
eth_addr=$(cat /sys/class/net/*/address | tr '\n' ',')
|
||||||
mkdir -p /etc/os-net-config
|
mkdir -p /etc/os-net-config
|
||||||
|
|
||||||
# Create an os-net-config mapping file, note this defaults to
|
# Create an os-net-config mapping file, note this defaults to
|
||||||
@ -51,7 +51,7 @@ resources:
|
|||||||
input = sys.stdin.readline() or '{}'
|
input = sys.stdin.readline() or '{}'
|
||||||
data = json.loads(input)
|
data = json.loads(input)
|
||||||
for node in data:
|
for node in data:
|
||||||
if '${eth_addr}' in data[node].values():
|
if any(x in '$eth_addr'.split(',') for x in data[node].values()):
|
||||||
interface_mapping = {'interface_mapping': data[node]}
|
interface_mapping = {'interface_mapping': data[node]}
|
||||||
with open('/etc/os-net-config/mapping.yaml', 'w') as f:
|
with open('/etc/os-net-config/mapping.yaml', 'w') as f:
|
||||||
yaml.safe_dump(interface_mapping, f, default_flow_style=False)
|
yaml.safe_dump(interface_mapping, f, default_flow_style=False)
|
||||||
|
Loading…
Reference in New Issue
Block a user