Now applying some puppet manifests in parallel

This will speed up the case where we are installing on
multiple machines, this commit makes use of flock to wrap
puppet apply so that packstack can ssh to a machine and apply
puppet in the background moving on to the next manifest. flock
ensures they are not run simultaniously if on the same machine.
This commit is contained in:
Derek Higgins
2012-12-04 09:37:07 -05:00
parent 690a755bdf
commit 2b11b6cc4d
6 changed files with 57 additions and 19 deletions

View File

@@ -28,16 +28,31 @@ class NovaConfig(object):
entry += "}"
return entry
class ManifestFiles(object):
def __init__(self):
self.filelist = []
# continuous manifest file that have the same marker can be
# installed in parallel, if on different servers
def addFile(self, filename, marker):
for f,p in self.filelist:
if f == filename:
return
self.filelist.append((filename, marker,))
def getFiles(self):
return [f for f in self.filelist]
manifestfiles = ManifestFiles()
def getManifestTemplate(template_name):
with open(os.path.join(PUPPET_TEMPLATE_DIR, template_name)) as fp:
return fp.read()%controller.CONF
def appendManifestFile(manifest_name, data):
def appendManifestFile(manifest_name, data, marker=''):
if not os.path.exists(basedefs.PUPPET_MANIFEST_DIR):
os.mkdir(basedefs.PUPPET_MANIFEST_DIR)
manifestfile = os.path.join(basedefs.PUPPET_MANIFEST_DIR, manifest_name)
if manifestfile not in controller.CONF['CONFIG_MANIFESTFILES']:
controller.CONF['CONFIG_MANIFESTFILES'].append(manifestfile)
manifestfiles.addFile(manifestfile, marker)
with open(manifestfile, 'a') as fp:
fp.write("\n")
fp.write(data)
@@ -56,5 +71,3 @@ def gethostlist(CONF):
if host not in hosts:
hosts.append(host)
return hosts