Merge pull request #39941 from moio/minionswarm-set-uuid

minionswarm.py: allow random UUID
This commit is contained in:
Mike Place 2017-03-10 09:16:57 -07:00 committed by GitHub
commit bdbff1ed73

View File

@ -19,6 +19,7 @@ import tempfile
import shutil import shutil
import sys import sys
import hashlib import hashlib
import uuid
# Import salt libs # Import salt libs
import salt import salt
@ -96,6 +97,12 @@ def parse():
default=False, default=False,
action='store_true', action='store_true',
help='Each Minion claims a different machine id grain') help='Each Minion claims a different machine id grain')
parser.add_option(
'--rand-uuid',
dest='rand_uuid',
default=False,
action='store_true',
help='Each Minion claims a different UUID grain')
parser.add_option( parser.add_option(
'-k', '-k',
'--keep-modules', '--keep-modules',
@ -347,6 +354,8 @@ class MinionSwarm(Swarm):
data['grains']['saltversion'] = random.choice(VERS) data['grains']['saltversion'] = random.choice(VERS)
if self.opts['rand_machine_id']: if self.opts['rand_machine_id']:
data['grains']['machine_id'] = hashlib.md5(minion_id).hexdigest() data['grains']['machine_id'] = hashlib.md5(minion_id).hexdigest()
if self.opts['rand_uuid']:
data['grains']['uuid'] = str(uuid.uuid4())
with open(path, 'w+') as fp_: with open(path, 'w+') as fp_:
yaml.dump(data, fp_) yaml.dump(data, fp_)