Using generic installer
o The installer has been removed and setup as its own project o some path names have been chenged to allow this to happen o move openstack specific methodes into modules/ospluginutils.py
This commit is contained in:
parent
1c87b73a6e
commit
41d88ed710
59
modules/ospluginutils.py
Normal file
59
modules/ospluginutils.py
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
import os
|
||||
|
||||
import basedefs
|
||||
from setup_controller import Controller
|
||||
|
||||
controller = Controller()
|
||||
|
||||
PUPPET_DIR = os.path.join(basedefs.DIR_PROJECT_DIR, "puppet")
|
||||
PUPPET_MANIFEST_DIR = os.path.join(PUPPET_DIR, "manifests")
|
||||
PUPPET_TEMPLATE_DIR = os.path.join(PUPPET_DIR, "templates")
|
||||
|
||||
class NovaConfig(object):
|
||||
"""
|
||||
Helper class to create puppet manifest entries for nova_config
|
||||
"""
|
||||
options = {}
|
||||
def addOption(self, n, v):
|
||||
self.options[n] = v
|
||||
|
||||
def getManifestEntry(self):
|
||||
entry = ""
|
||||
if not self.options:
|
||||
return entry
|
||||
|
||||
entry += "nova_config{\n"
|
||||
for k,v in self.options.items():
|
||||
entry += ' "%s": value => "%s";\n'%(k,v)
|
||||
entry += "}"
|
||||
return entry
|
||||
|
||||
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):
|
||||
manifestfile = os.path.join(PUPPET_MANIFEST_DIR, manifest_name)
|
||||
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(data)
|
||||
|
||||
def gethostlist(CONF):
|
||||
hosts = []
|
||||
for key,value in CONF.items():
|
||||
if key.endswith("_HOST"):
|
||||
value = value.split('/')[0]
|
||||
if value not in hosts:
|
||||
hosts.append(value)
|
||||
if key.endswith("_HOSTS"):
|
||||
for host in value.split(","):
|
||||
host = host.strip()
|
||||
host = host.split('/')[0]
|
||||
if host not in hosts:
|
||||
hosts.append(host)
|
||||
return hosts
|
||||
|
||||
|
@ -21,8 +21,8 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
|
||||
|
||||
logging.debug("plugin %s loaded", __name__)
|
||||
|
||||
PUPPET_MANIFEST_DIR = 'puppet/manifests'
|
||||
PUPPET_MANIFEST_TEMPLATE = 'puppet/templates/glance.pp'
|
||||
PUPPET_MANIFEST_TEMPLATE = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/templates/glance.pp')
|
||||
PUPPET_MANIFEST_DIR = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/manifests')
|
||||
|
||||
def initConfig(controllerObject):
|
||||
global controller
|
||||
|
@ -20,8 +20,9 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
|
||||
|
||||
logging.debug("plugin %s loaded", __name__)
|
||||
|
||||
PUPPET_MANIFEST_DIR = 'puppet/manifests'
|
||||
PUPPET_MANIFEST_TEMPLATE = 'puppet/templates/keystone.pp'
|
||||
PUPPET_MANIFEST_DIR = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/manifests')
|
||||
PUPPET_MANIFEST_TEMPLATE = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/templates/keystone.pp')
|
||||
|
||||
|
||||
def initConfig(controllerObject):
|
||||
global controller
|
||||
|
@ -18,8 +18,8 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
|
||||
|
||||
logging.debug("plugin %s loaded", __name__)
|
||||
|
||||
PUPPET_MANIFEST_TEMPLATE = 'puppet/templates/mysql.pp'
|
||||
PUPPET_MANIFEST_DIR = 'puppet/manifests'
|
||||
PUPPET_MANIFEST_DIR = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/manifests')
|
||||
PUPPET_MANIFEST_TEMPLATE = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/templates/mysql.pp')
|
||||
|
||||
def initConfig(controllerObject):
|
||||
global controller
|
||||
|
@ -20,8 +20,9 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
|
||||
|
||||
logging.debug("plugin %s loaded", __name__)
|
||||
|
||||
PUPPET_MANIFEST_DIR = 'puppet/manifests'
|
||||
PUPPET_MANIFEST_TEMPLATE = 'puppet/templates/openstack_client.pp'
|
||||
PUPPET_MANIFEST_DIR = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/manifests')
|
||||
PUPPET_MANIFEST_TEMPLATE = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/templates/openstack_client.pp')
|
||||
|
||||
|
||||
def initConfig(controllerObject):
|
||||
global controller
|
||||
|
@ -9,6 +9,9 @@ import engine_validators as validate
|
||||
import basedefs
|
||||
import common_utils as utils
|
||||
|
||||
from ospluginutils import gethostlist
|
||||
|
||||
|
||||
# Controller object will be initialized from main flow
|
||||
controller = None
|
||||
|
||||
@ -18,7 +21,7 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
|
||||
|
||||
logging.debug("plugin %s loaded", __name__)
|
||||
|
||||
PUPPETDIR = "puppet"
|
||||
PUPPETDIR = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet')
|
||||
MODULEDIR = os.path.join(PUPPETDIR, "modules")
|
||||
MANIFESTDIR = os.path.join(PUPPETDIR, "manifests")
|
||||
PUPPET_MODULES = [
|
||||
@ -106,7 +109,7 @@ def getPuppetModules():
|
||||
localserver.execute()
|
||||
|
||||
def installpuppet():
|
||||
for hostname in utils.gethostlist(controller.CONF):
|
||||
for hostname in gethostlist(controller.CONF):
|
||||
server = utils.ScriptRunner(hostname)
|
||||
server.append("rpm -q puppet || yum install -y puppet")
|
||||
server.append("sed -i -e 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo ")
|
||||
@ -114,14 +117,15 @@ def installpuppet():
|
||||
|
||||
def copyPuppetModules():
|
||||
server = utils.ScriptRunner()
|
||||
for hostname in utils.gethostlist(controller.CONF):
|
||||
for hostname in gethostlist(controller.CONF):
|
||||
server.append("cd %s"%basedefs.DIR_PROJECT_DIR,)
|
||||
server.append("tar -czf - puppet/manifests puppet/modules | ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@%s tar -C /etc -xzf -"%(hostname))
|
||||
server.execute()
|
||||
|
||||
def applyPuppetManifest():
|
||||
print
|
||||
for manifest in controller.CONF['CONFIG_MANIFESTFILES']:
|
||||
for hostname in utils.gethostlist(controller.CONF):
|
||||
for hostname in gethostlist(controller.CONF):
|
||||
if "/%s_"%hostname not in manifest: continue
|
||||
|
||||
print "Applying "+ manifest
|
||||
|
@ -20,8 +20,8 @@ PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE)
|
||||
|
||||
logging.debug("plugin %s loaded", __name__)
|
||||
|
||||
PUPPET_MANIFEST_DIR = 'puppet/manifests'
|
||||
PUPPET_MANIFEST_TEMPLATE = 'puppet/templates/qpid.pp'
|
||||
PUPPET_MANIFEST_DIR = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/manifests')
|
||||
PUPPET_MANIFEST_TEMPLATE = os.path.join(basedefs.DIR_PROJECT_DIR, 'puppet/templates/qpid.pp')
|
||||
|
||||
def initConfig(controllerObject):
|
||||
global controller
|
||||
|
@ -10,6 +10,8 @@ import engine_validators as validate
|
||||
import basedefs
|
||||
import common_utils as utils
|
||||
|
||||
from ospluginutils import gethostlist
|
||||
|
||||
# Controller object will be initialized from main flow
|
||||
controller = None
|
||||
|
||||
@ -50,7 +52,7 @@ def initSequences(controller):
|
||||
|
||||
|
||||
def installepel():
|
||||
for hostname in utils.gethostlist(controller.CONF):
|
||||
for hostname in gethostlist(controller.CONF):
|
||||
if '/' in hostname:
|
||||
hostname = hostname.split('/')[0]
|
||||
server = utils.ScriptRunner(hostname)
|
||||
|
@ -10,6 +10,8 @@ import engine_validators as validate
|
||||
import basedefs
|
||||
import common_utils as utils
|
||||
|
||||
from ospluginutils import gethostlist
|
||||
|
||||
# Controller object will be initialized from main flow
|
||||
controller = None
|
||||
|
||||
@ -60,7 +62,7 @@ def installKeys():
|
||||
with open(controller.CONF["CONFIG_SSH_KEY"]) as fp:
|
||||
sshkeydata = fp.read().strip()
|
||||
|
||||
for hostname in utils.gethostlist(controller.CONF):
|
||||
for hostname in gethostlist(controller.CONF):
|
||||
if '/' in hostname:
|
||||
hostname = hostname.split('/')[0]
|
||||
server = utils.ScriptRunner(hostname)
|
||||
|
Loading…
x
Reference in New Issue
Block a user