Removed some duplicate code

Duplicate code in manifest generation
This commit is contained in:
Derek Higgins
2012-11-28 16:19:48 -05:00
parent 82cb714192
commit 6426ac5c76
7 changed files with 21 additions and 70 deletions

View File

@@ -11,6 +11,8 @@ import packstack.installer.engine_validators as validate
from packstack.installer import basedefs
import packstack.installer.common_utils as utils
from packstack.modules.ospluginutils import getManifestTemplate, appendManifestFile
# Controller object will be initialized from main flow
controller = None
@@ -20,9 +22,6 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
logging.debug("plugin %s loaded", __name__)
PUPPET_MANIFEST_TEMPLATE = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/templates/openstack_client.pp')
def initConfig(controllerObject):
global controller
controller = controllerObject
@@ -62,17 +61,6 @@ def initSequences(controller):
controller.addSequence("Installing OpenStack Client", [], [], osclientsteps)
def createmanifest():
with open(PUPPET_MANIFEST_TEMPLATE) as fp:
manifestdata = fp.read()
manifestdata = manifestdata%controller.CONF
if not os.path.exists(basedefs.PUPPET_MANIFEST_DIR):
os.mkdir(basedefs.PUPPET_MANIFEST_DIR)
manifestfile = os.path.join(basedefs.PUPPET_MANIFEST_DIR, "%s_osclient.pp"%controller.CONF['CONFIG_OSCLIENT_HOST'])
if manifestfile not in controller.CONF['CONFIG_MANIFESTFILES']:
controller.CONF['CONFIG_MANIFESTFILES'].append(manifestfile)
with open(manifestfile, 'a') as fp:
fp.write("\n")
fp.write(manifestdata)
manifestfile = "%s_osclient.pp"%controller.CONF['CONFIG_OSCLIENT_HOST']
manifestdata = getManifestTemplate("openstack_client.pp")
appendManifestFile(manifestfile, manifestdata)