Handle upper and lower case system uuids
We need to be able to handle when system uuids are upper or lower case
because newer versions of dmidecode have normalized to lower case. Users
who were on CentOS/RHEL 7.5 and older may have per-node customizations
with upper case which turn lowercase with an update to 7.6. This affects
hieradata customizations as well as os-net-config mapping files. This
change outputs both an upper and lowercase hieradata uuid file to handle
the both versions of the UUID. Additionally this change normalizes the
id comparison for os-net-config mappings to lower case.
Change-Id: I65f46056f8a908c60c99d1cee3738344a0bce6b7
Closes-Bug: #1816652
(cherry picked from commit e2a8a494c5
)
This commit is contained in:
parent
2ef87fe13b
commit
759b711b94
|
@ -100,9 +100,10 @@ resources:
|
|||
if 'dmiString' in data[node] and 'id' in data[node]:
|
||||
ps = Popen([ 'dmidecode',
|
||||
'--string', data[node].get('dmiString') ],
|
||||
stdout=PIPE)
|
||||
stdout=PIPE, universal_newlines=True)
|
||||
out, err = ps.communicate()
|
||||
if data[node].get('id') == out.rstrip():
|
||||
# See LP#1816652
|
||||
if data[node].get('id').lower() == out.rstrip().lower():
|
||||
write_mapping_file(lc_interface_mapping)
|
||||
break
|
||||
"
|
||||
|
|
|
@ -32,6 +32,10 @@ resources:
|
|||
node_id=$(dmidecode --s system-uuid | awk 'match($0, \
|
||||
/[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}/) \
|
||||
{ print substr($0, RSTART, RLENGTH) }' | tr '[:upper:]' '[:lower:]')
|
||||
# thanks to dmidecode 3.1, we have to handle both the upper case
|
||||
# and lower case versions of the UUID from dmidecode. LP#1816652
|
||||
# upper for dmidecode < 3.1 and lower for dmidecode >= 3.1
|
||||
node_id_upper=$(echo $node_id | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
# Create a /etc/puppet/hieradata/UUID.json file to provide
|
||||
# the data of the NodeDataLookup parameter that matches the
|
||||
|
@ -43,6 +47,14 @@ resources:
|
|||
cnt = json.loads(input)
|
||||
print json.dumps(cnt.get('${node_id}', {}))
|
||||
" > /etc/puppet/hieradata/${node_id}.json
|
||||
# handle upper case node id LP#1816652
|
||||
echo $node_lookup | $(get_python) -c "
|
||||
import json
|
||||
import sys
|
||||
input = sys.stdin.readline() or '{}'
|
||||
cnt = json.loads(input)
|
||||
print json.dumps(cnt.get('${node_id_upper}', {}))
|
||||
" > /etc/puppet/hieradata/${node_id_upper}.json
|
||||
|
||||
NodeSpecificDeployment:
|
||||
type: OS::Heat::SoftwareDeployment
|
||||
|
|
Loading…
Reference in New Issue