Merge "Handle upper and lower case system uuids"

This commit is contained in:
Zuul 2019-02-21 18:36:12 +00:00 committed by Gerrit Code Review
commit 8521da402f
2 changed files with 15 additions and 2 deletions

View File

@ -105,9 +105,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
"

View File

@ -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:]')
# needed to handle where python lives
function get_python() {
@ -47,6 +51,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