本文整理汇总了Python中common.properties.PropertiesUtil.PropertiesUtility.getOpenstackConfPropertiesFilePath方法的典型用法代码示例。如果您正苦于以下问题:Python PropertiesUtility.getOpenstackConfPropertiesFilePath方法的具体用法?Python PropertiesUtility.getOpenstackConfPropertiesFilePath怎么用?Python PropertiesUtility.getOpenstackConfPropertiesFilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.properties.PropertiesUtil.PropertiesUtility
的用法示例。
在下文中一共展示了PropertiesUtility.getOpenstackConfPropertiesFilePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initNeutron
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def initNeutron():
ha_vip1 = JSONUtility.getValue('ha_vip1')
ha_vip2 = JSONUtility.getValue('ha_vip2')
keystone_admin_password = JSONUtility.getValue('keystone_admin_password')
keystone_vip = ha_vip1
keystone_neutron_password = JSONUtility.getValue('keystone_neutron_password')
neutron_vip = ha_vip1
initNeutronScriptTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'neutron-server', 'initNeutron.sh')
##
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
openstackScriptDirPath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'OPENSTACK_SCRIPT_DIR')
if os.path.exists(openstackScriptDirPath) :
os.system('mkdir -p %s' % openstackScriptDirPath)
pass
ShellCmdExecutor.execCmd('cp -r %s %s' % (initNeutronScriptTemplatePath, openstackScriptDirPath))
initNeutronScriptPath = os.path.join(openstackScriptDirPath, 'initNeutron.sh')
FileUtil.replaceFileContent(initNeutronScriptPath, '<KEYSTONE_ADMIN_PASSWORD>', keystone_admin_password)
FileUtil.replaceFileContent(initNeutronScriptPath, '<KEYSTONE_VIP>', keystone_vip)
FileUtil.replaceFileContent(initNeutronScriptPath, '<KEYSTONE_NEUTRON_PASSWORD>', keystone_neutron_password)
FileUtil.replaceFileContent(initNeutronScriptPath, '<NEUTRON_VIP>', neutron_vip)
ShellCmdExecutor.execCmd('bash %s' % initNeutronScriptPath)
pass
示例2: install
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def install():
if debug == True :
print "DEBUG is True.On local dev env, do test==="
yumCmd = "ls -lt"
ShellCmdExecutor.execCmd(yumCmd)
pass
else :
if not NovaHA.isKeepalivedInstalled() :
keepalivedInstallCmd = "yum install keepalived -y"
ShellCmdExecutor.execCmd(keepalivedInstallCmd)
pass
if not NovaHA.isHAProxyInstalled() :
haproxyInstallCmd = 'yum install haproxy -y'
ShellCmdExecutor.execCmd(haproxyInstallCmd)
#prepare haproxy conf file template
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
haproxyTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'haproxy.cfg')
haproxyConfFilePath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'HAPROXY_CONF_FILE_PATH')
print 'haproxyTemplateFilePath=%s' % haproxyTemplateFilePath
print 'haproxyConfFilePath=%s' % haproxyConfFilePath
if not os.path.exists('/etc/haproxy') :
ShellCmdExecutor.execCmd('sudo mkdir /etc/haproxy')
pass
ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (haproxyTemplateFilePath, '/etc/haproxy'))
pass
pass
pass
示例3: configureKeystoneHAProxy
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configureKeystoneHAProxy():
dashboard_vip = JSONUtility.getValue("dashboard_vip")
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
HAProxyTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'haproxy.cfg')
haproxyConfFilePath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'HAPROXY_CONF_FILE_PATH')
print 'haproxyConfFilePath=%s' % haproxyConfFilePath
if not os.path.exists('/etc/haproxy') :
ShellCmdExecutor.execCmd('sudo mkdir /etc/haproxy')
pass
if not os.path.exists(haproxyConfFilePath) :
ShellCmdExecutor.execCmd('sudo cp -rf %s %s' % (HAProxyTemplateFilePath, haproxyConfFilePath))
pass
ShellCmdExecutor.execCmd('sudo chmod 777 %s' % haproxyConfFilePath)
dashboardBackendStringTemplate = '''
listen dashboard_cluster
bind <DASHBOARD_VIP>:80
balance source
option tcpka
option httpchk
option tcplog
<DASHBOARD_SERVER_LIST>
'''
###############
dashboardBackendString = dashboardBackendStringTemplate.replace('<DASHBOARD_VIP>', dashboard_vip)
################new
dashboard_ips = JSONUtility.getValue("dashboard_ips")
dashboard_ip_list = dashboard_ips.strip().split(',')
serverDashboardBackendTemplate = 'server dashboard-<INDEX> <SERVER_IP>:8080 weight 3 check inter 2000 rise 2 fall 3'
dashboardServerListContent = ''
index = 1
for dashboard_ip in dashboard_ip_list:
print 'dashboard_ip=%s' % dashboard_ip
dashboardServerListContent += serverDashboardBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', dashboard_ip)
dashboardServerListContent += '\n'
dashboardServerListContent += ' '
index += 1
pass
dashboardServerListContent = dashboardServerListContent.strip()
print 'dashboardServerListContent=%s--' % dashboardServerListContent
dashboardBackendString = dashboardBackendString.replace('<DASHBOARD_SERVER_LIST>', dashboardServerListContent)
print 'dashboardBackendString=%s--' % dashboardBackendString
#append
FileUtil.replaceFileContent(haproxyConfFilePath, '<DASHBOARD_LIST>', dashboardBackendString)
ShellCmdExecutor.execCmd('sudo chmod 644 %s' % haproxyConfFilePath)
示例4: configConfFile
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configConfFile():
print "configure keystone conf file======"
mysql_vip = JSONUtility.getValue("mysql_vip")
admin_token = JSONUtility.getValue("admin_token")
#memcache service list
keystone_ips_string = JSONUtility.getValue("keystone_ips")
keystone_ip_list = keystone_ips_string.split(',')
memcached_service_list = []
for ip in keystone_ip_list:
memcached_service_list.append(ip.strip() + ':11211')
pass
memcached_service_string = ','.join(memcached_service_list)
print 'memcached_service_string=%s--' % memcached_service_string
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
keystoneConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'KEYSTONE_CONF_DIR')
keystone_conf_file_path = os.path.join(keystoneConfDir, 'keystone.conf')
if not os.path.exists(keystoneConfDir) :
os.system("sudo mkdir -p %s" % keystoneConfDir)
pass
ShellCmdExecutor.execCmd("cp -r %s %s" % (SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH, keystoneConfDir))
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keystone_conf_file_path)
# #if exist, remove original conf files
# if os.path.exists(keystone_conf_file_path) :
# os.system("sudo rm -rf %s" % keystone_conf_file_path)
# pass
#
# ShellCmdExecutor.execCmd('chmod 777 /etc/keystone')
#
# # os.system("sudo cp -r %s %s" % (SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH, keystoneConfDir))
# ###NEW
# ShellCmdExecutor.execCmd('cat %s > /tmp/keystone.conf' % SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH)
# ShellCmdExecutor.execCmd('mv /tmp/keystone.conf /etc/keystone/')
#
# ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keystone_conf_file_path)
###########LOCAL_IP:retrieve it from one file, the LOCAL_IP file is generated when this project inits.
localIP = Keystone.getLocalIP()
print 'localip=%s--' % localIP
# FileUtil.replaceByRegularExpression(keystone_conf_file_path, '<LOCAL_IP>', localIP)
# FileUtil.replaceByRegularExpression(keystone_conf_file_path, '<MYSQL_VIP>', mysql_vip)
keystoneDbPass = JSONUtility.getValue('keystone_dbpass')
FileUtil.replaceFileContent(keystone_conf_file_path, '<ADMIN_TOKEN>', admin_token)
FileUtil.replaceFileContent(keystone_conf_file_path, '<LOCAL_MANAGEMENT_IP>', localIP)
FileUtil.replaceFileContent(keystone_conf_file_path, '<MYSQL_VIP>', mysql_vip)
FileUtil.replaceFileContent(keystone_conf_file_path, '<KEYSTONE_DBPASS>', keystoneDbPass)
FileUtil.replaceFileContent(keystone_conf_file_path, '<MEMCACHED_LIST>', memcached_service_string)
ShellCmdExecutor.execCmd("chmod 644 %s" % keystone_conf_file_path)
print "configure keystone conf file done####"
pass
示例5: configConfFile
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configConfFile():
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
local_ip_file_path = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'LOCAL_IP_FILE_PATH')
output, exitcode = ShellCmdExecutor.execCmd('cat %s' % local_ip_file_path)
localIP = output.strip()
print 'locaIP=%s' % localIP
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
mongodb_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'mongodb', 'mongodb.conf')
print 'mongodb_conf_template_file_path=%s' % mongodb_conf_template_file_path
mongodb_conf_file_path = '/etc/mongodb.conf'
if os.path.exists(mongodb_conf_file_path) :
ShellCmdExecutor.execCmd("rm -rf %s" % mongodb_conf_file_path)
pass
ShellCmdExecutor.execCmd('cat %s > /tmp/mongodb.conf' % mongodb_conf_template_file_path)
ShellCmdExecutor.execCmd('mv /tmp/mongodb.conf /etc/')
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % mongodb_conf_file_path)
FileUtil.replaceFileContent(mongodb_conf_file_path, '<LOCAL_IP>', localIP)
ShellCmdExecutor.execCmd("sudo chmod 755 %s" % mongodb_conf_file_path)
pass
示例6: getIndex
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def getIndex(): #get host index, the ips has been sorted ascended.
print 'To get this host index of role %s==============' % "glance"
nova_ips = JSONUtility.getValue('nova_ips')
nova_ip_list = nova_ips.split(',')
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
local_ip_file_path = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'LOCAL_IP_FILE_PATH')
output, exitcode = ShellCmdExecutor.execCmd("cat %s" % local_ip_file_path)
localIP = output.strip()
print 'localIP=%s---------------------' % localIP
print 'nova_ip_list=%s--------------' % nova_ip_list
index = nova_ip_list.index(localIP)
print 'index=%s-----------' % index
return index
示例7: configureKeepalived
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configureKeepalived():
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
###################configure keepalived
glanceKeepalivedTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'keepalived.conf')
keepalivedConfFilePath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'KEEPALIVED_CONF_FILE_PATH')
print 'keepalivedConfFilePath=%s' % keepalivedConfFilePath
if not os.path.exists('/etc/keepalived') :
ShellCmdExecutor.execCmd('sudo mkdir /etc/keepalived')
pass
#configure haproxy check script in keepalived
checkHAProxyScriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'check_haproxy.sh')
print 'checkHAProxyScriptPath=%s===========================---' % checkHAProxyScriptPath
ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (checkHAProxyScriptPath, '/etc/keepalived'))
if os.path.exists(keepalivedConfFilePath) :
ShellCmdExecutor.execCmd("sudo rm -rf %s" % keepalivedConfFilePath)
pass
ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (glanceKeepalivedTemplateFilePath, '/etc/keepalived'))
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keepalivedConfFilePath)
##configure
nova_vip = JSONUtility.getValue("nova_vip")
nova_vip_interface = JSONUtility.getValue("nova_vip_interface")
weight_counter = 300
if NovaHA.isMasterNode() :
weight_counter = 300
state = 'MASTER'
pass
else :
index = NovaHA.getIndex() #get this host index which is indexed by the gid in /etc/astutue.yaml responding with this role
weight_counter = 300 - index
state = 'SLAVE' + str(index)
pass
FileUtil.replaceFileContent(keepalivedConfFilePath, '<WEIGHT>', str(weight_counter))
FileUtil.replaceFileContent(keepalivedConfFilePath, '<STATE>', state)
FileUtil.replaceFileContent(keepalivedConfFilePath, '<INTERFACE>', nova_vip_interface)
FileUtil.replaceFileContent(keepalivedConfFilePath, '<VIRTURL_IPADDR>', nova_vip)
##temporary: if current user is not root
ShellCmdExecutor.execCmd("sudo chmod 644 %s" % keepalivedConfFilePath)
#If keepalived need to support more VIP: append here
pass
示例8: configConfFile
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configConfFile():
print "configure keystone conf file======"
mysql_vip = JSONUtility.getValue("mysql_vip")
mysql_password = JSONUtility.getValue("mysql_password")
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
keystoneConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'KEYSTONE_CONF_DIR')
print 'keystoneConfDir=%s' % keystoneConfDir #/etc/keystone
keystone_conf_file_path = os.path.join(keystoneConfDir, 'keystone.conf')
if not os.path.exists(keystoneConfDir) :
os.system("sudo mkdir -p %s" % keystoneConfDir)
pass
#if exist, remove original conf files
if os.path.exists(keystone_conf_file_path) :
os.system("sudo rm -rf %s" % keystone_conf_file_path)
pass
ShellCmdExecutor.execCmd('chmod 777 /etc/keystone')
# os.system("sudo cp -r %s %s" % (SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH, keystoneConfDir))
###NEW
ShellCmdExecutor.execCmd('cat %s > /tmp/keystone.conf' % SOURCE_KEYSTONE_CONF_FILE_TEMPLATE_PATH)
ShellCmdExecutor.execCmd('mv /tmp/keystone.conf /etc/keystone/')
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keystone_conf_file_path)
###########LOCAL_IP:retrieve it from one file, the LOCAL_IP file is generated when this project inits.
localIP = Keystone.getLocalIP()
print 'localip=%s--' % localIP
# FileUtil.replaceByRegularExpression(keystone_conf_file_path, '<LOCAL_IP>', localIP)
# FileUtil.replaceByRegularExpression(keystone_conf_file_path, '<MYSQL_VIP>', mysql_vip)
FileUtil.replaceFileContent(keystone_conf_file_path, '<LOCAL_IP>', localIP)
FileUtil.replaceFileContent(keystone_conf_file_path, '<MYSQL_VIP>', mysql_vip)
FileUtil.replaceFileContent(keystone_conf_file_path, '<MYSQL_PASSWORD>', mysql_password)
ShellCmdExecutor.execCmd("sudo chmod 644 %s" % keystone_conf_file_path)
print "configure keystone conf file done####"
pass
示例9: initNova
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def initNova():
#to replace in template: KEYSTONE_ADMIN_PASSWORD KEYSTONE_VIP KEYSTONE_NOVA_PASSWORD NOVA_VIP
keystone_admin_password = JSONUtility.getValue('keystone_admin_password')
keystone_vip = JSONUtility.getValue('keystone_vip')
keystone_nova_password = JSONUtility.getValue('keystone_nova_password')
nova_vip = JSONUtility.getValue('ha_vip1')
initNovaScriptTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova', 'initNova.sh')
##
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
openstackScriptDirPath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'OPENSTACK_SCRIPT_DIR')
if os.path.exists(openstackScriptDirPath) :
os.system('mkdir -p %s' % openstackScriptDirPath)
pass
ShellCmdExecutor.execCmd('cp -r %s %s' % (initNovaScriptTemplatePath, openstackScriptDirPath))
initNovaScriptPath = os.path.join(openstackScriptDirPath, 'initNova.sh')
FileUtil.replaceFileContent(initNovaScriptPath, '<KEYSTONE_ADMIN_PASSWORD>', keystone_admin_password)
FileUtil.replaceFileContent(initNovaScriptPath, '<KEYSTONE_VIP>', keystone_vip)
FileUtil.replaceFileContent(initNovaScriptPath, '<KEYSTONE_NOVA_PASSWORD>', keystone_nova_password)
FileUtil.replaceFileContent(initNovaScriptPath, '<NOVA_VIP>', nova_vip)
ShellCmdExecutor.execCmd('bash %s' % initNovaScriptPath)
pass
示例10: configureHAProxy
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configureHAProxy():
####################configure haproxy
dashboard_vip = JSONUtility.getValue("dashboard_vip")
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
HAProxyTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'haproxy.cfg')
haproxyConfFilePath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'HAPROXY_CONF_FILE_PATH')
print 'haproxyConfFilePath=%s' % haproxyConfFilePath
if not os.path.exists('/etc/haproxy') :
ShellCmdExecutor.execCmd('sudo mkdir /etc/haproxy')
pass
ShellCmdExecutor.execCmd('sudo chmod 777 /etc/haproxy')
if not os.path.exists(haproxyConfFilePath) :
# ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (HAProxyTemplateFilePath, '/etc/haproxy'))
ShellCmdExecutor.execCmd('cat %s > /tmp/haproxy.cfg' % HAProxyTemplateFilePath)
ShellCmdExecutor.execCmd('mv /tmp/haproxy.cfg /etc/haproxy/')
pass
ShellCmdExecutor.execCmd('sudo chmod 777 %s' % haproxyConfFilePath)
####
##############new
# dashboardBackendStringTemplate = '''
# listen localhost <DASHBOARD_VIP>:80
# mode http
# stats uri /haproxy
# balance roundrobin
# cookie JSESSIONID prefix
# stats hide-version
# option httpclose
# <DASHBOARD_SERVER_LIST>
# '''
dashboardBackendStringTemplate = '''
listen dashboard_cluster
bind <DASHBOARD_VIP>:80
balance source
option tcpka
option httpchk
option tcplog
<DASHBOARD_SERVER_LIST>
'''
###############
dashboardBackendString = dashboardBackendStringTemplate.replace('<DASHBOARD_VIP>', dashboard_vip)
################new
dashboard_ips = JSONUtility.getValue("dashboard_ips")
dashboard_ip_list = dashboard_ips.strip().split(',')
serverDashboardBackendTemplate = 'server dashboard-<INDEX> <SERVER_IP>:8080 weight 3 check inter 2000 rise 2 fall 3'
dashboardServerListContent = ''
index = 1
for dashboard_ip in dashboard_ip_list:
print 'dashboard_ip=%s' % dashboard_ip
dashboardServerListContent += serverDashboardBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', dashboard_ip)
dashboardServerListContent += '\n'
dashboardServerListContent += ' '
index += 1
pass
dashboardServerListContent = dashboardServerListContent.strip()
print 'dashboardServerListContent=%s--' % dashboardServerListContent
dashboardBackendString = dashboardBackendString.replace('<DASHBOARD_SERVER_LIST>', dashboardServerListContent)
print 'dashboardBackendString=%s--' % dashboardBackendString
#append
if os.path.exists(haproxyConfFilePath) :
output, exitcode = ShellCmdExecutor.execCmd('cat %s' % haproxyConfFilePath)
else :
output, exitcode = ShellCmdExecutor.execCmd('cat %s' % HAProxyTemplateFilePath)
pass
haproxyNativeContent = output.strip()
haproxyContent = ''
haproxyContent += haproxyNativeContent
haproxyContent += '\n\n'
haproxyContent += dashboardBackendString
FileUtil.writeContent('/tmp/haproxy.cfg', haproxyContent)
if os.path.exists(haproxyConfFilePath):
ShellCmdExecutor.execCmd("sudo rm -rf %s" % haproxyConfFilePath)
pass
ShellCmdExecutor.execCmd('mv /tmp/haproxy.cfg /etc/haproxy/')
#############
ShellCmdExecutor.execCmd('sudo chmod 644 %s' % haproxyConfFilePath)
pass
示例11: configConfFile
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configConfFile():
#use conf template file to replace
mysql_vip = JSONUtility.getValue("mysql_vip")
mysql_password = JSONUtility.getValue("mysql_password")
# rabbit_host = JSONUtility.getValue("rabbit_host")
# rabbit_vip = JSONUtility.getValue("rabbit_vip")
rabbit_hosts = JSONUtility.getValue("rabbit_hosts")
rabbit_userid = JSONUtility.getValue("rabbit_userid")
rabbit_password = JSONUtility.getValue("rabbit_password")
keystone_vip = JSONUtility.getValue("keystone_vip")
glance_vip = JSONUtility.getValue("glance_vip")
nova_mysql_password = JSONUtility.getValue("nova_mysql_password")
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
local_ip_file_path = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'LOCAL_IP_FILE_PATH')
output, exitcode = ShellCmdExecutor.execCmd('cat %s' % local_ip_file_path)
localIP = output.strip()
print 'ddddddddddddddd========='
print 'mysql_vip=%s' % mysql_vip
print 'mysql_password=%s' % mysql_password
print 'rabbit_hosts=%s' % rabbit_hosts
print 'rabbit_userid=%s' % rabbit_userid
print 'rabbit_password=%s' % rabbit_password
print 'keystone_vip=%s' % keystone_vip
print 'glance_vip=%s' % glance_vip
print 'locaIP=%s' % localIP
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
nova_api_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-api', 'nova.conf')
print 'nova_api_conf_template_file_path=%s' % nova_api_conf_template_file_path
novaConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'NOVA_CONF_DIR')
print 'novaConfDir=%s' % novaConfDir #/etc/nova
nova_conf_file_path = os.path.join(novaConfDir, 'nova.conf')
print 'nova_conf_file_path=%s' % nova_conf_file_path
if not os.path.exists(novaConfDir) :
ShellCmdExecutor.execCmd("sudo mkdir %s" % novaConfDir)
pass
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % novaConfDir)
if os.path.exists(nova_conf_file_path) :
ShellCmdExecutor.execCmd("sudo rm -rf %s" % nova_conf_file_path)
pass
# ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (nova_api_conf_template_file_path, novaConfDir))
ShellCmdExecutor.execCmd("cat %s > /tmp/nova.conf" % nova_api_conf_template_file_path)
ShellCmdExecutor.execCmd("mv /tmp/nova.conf /etc/nova/")
ShellCmdExecutor.execCmd("rm -rf /tmp/nova.conf")
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % nova_conf_file_path)
FileUtil.replaceFileContent(nova_conf_file_path, '<LOCAL_IP>', localIP)
FileUtil.replaceFileContent(nova_conf_file_path, '<MYSQL_VIP>', mysql_vip)
FileUtil.replaceFileContent(nova_conf_file_path, '<MYSQL_PASSWORD>', mysql_password)
FileUtil.replaceFileContent(nova_conf_file_path, '<NOVA_MYSQL_PASSWORD>', nova_mysql_password)
# FileUtil.replaceFileContent(nova_conf_file_path, '<RABBIT_HOST>', rabbit_vip)
FileUtil.replaceFileContent(nova_conf_file_path, '<RABBIT_USERID>', rabbit_userid)
FileUtil.replaceFileContent(nova_conf_file_path, '<RABBIT_PASSWORD>', rabbit_password)
FileUtil.replaceFileContent(nova_conf_file_path, '<RABBIT_HOSTS>', rabbit_hosts)
FileUtil.replaceFileContent(nova_conf_file_path, '<KEYSTONE_VIP>', keystone_vip)
FileUtil.replaceFileContent(nova_conf_file_path, '<GLANCE_VIP>', glance_vip)
# FileUtil.replaceFileContent(nova_conf_file_path, '<NEUTRON_VIP>', localIP)
ShellCmdExecutor.execCmd("sudo chmod 644 %s" % nova_conf_file_path)
#special handling
PYTHON_SITE_PACKAGE_DIR = '/usr/lib/python2.6/site-packages'
if os.path.exists(PYTHON_SITE_PACKAGE_DIR) :
ShellCmdExecutor.execCmd('chmod 777 %s' % PYTHON_SITE_PACKAGE_DIR)
pass
LIB_NOVA_DIR = '/var/lib/nova'
if os.path.exists(LIB_NOVA_DIR) :
ShellCmdExecutor.execCmd('chown -R nova:nova %s' % LIB_NOVA_DIR)
pass
if os.path.exists('/etc/nova/') :
ShellCmdExecutor.execCmd("chown -R nova:nova /etc/nova")
pass
示例12: configureKeepalived
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configureKeepalived():
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
###################configure keepalived
keepalivedTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'keepalived.conf')
keepalivedConfFilePath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'KEEPALIVED_CONF_FILE_PATH')
print 'keepalivedConfFilePath=%s' % keepalivedConfFilePath
if not os.path.exists('/etc/keepalived') :
ShellCmdExecutor.execCmd('sudo mkdir /etc/keepalived')
pass
#configure haproxy check script in keepalived
checkHAProxyScriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'check_haproxy.sh')
ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (checkHAProxyScriptPath, '/etc/keepalived'))
if os.path.exists(keepalivedConfFilePath) :
ShellCmdExecutor.execCmd("sudo rm -rf %s" % keepalivedConfFilePath)
pass
ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (keepalivedTemplateFilePath, keepalivedConfFilePath))
print 'keepalivedTemplateFilePath=%s==========----' % keepalivedTemplateFilePath
print 'keepalivedConfFilePath=%s=============----' % keepalivedConfFilePath
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % keepalivedConfFilePath)
##configure
'''keepalived template====
global_defs {
router_id LVS-DEVEL
}
vrrp_script chk_haproxy {
script "/etc/keepalived/check_haproxy.sh"
interval 2
weight 2
}
vrrp_instance 42 {
virtual_router_id 42
# for electing MASTER, highest priority wins.
priority <KEYSTONE_WEIGHT>
state <KEYSTONE_STATE>
interface <INTERFACE>
track_script {
chk_haproxy
}
virtual_ipaddress {
<VIRTURL_IPADDR>
}
}
'''
#WEIGHT is from 300 to down, 300 belongs to MASTER, and then 299, 298, ...etc, belong to SLAVE
##Here: connect to ZooKeeper to coordinate the weight
ceilometer_vip = JSONUtility.getValue("ceilometer_vip")
ceilometer_vip_interface = JSONUtility.getValue("ceilometer_vip_interface")
weight_counter = 300
if CeilometerHA.isMasterNode() :
weight_counter = 300
state = 'MASTER'
pass
else :
index = CeilometerHA.getIndex() #get this host index which is indexed by the gid in /etc/astutue.yaml responding with this role
weight_counter = 300 - index
state = 'SLAVE' + str(index)
pass
FileUtil.replaceFileContent(keepalivedConfFilePath, '<WEIGHT>', str(weight_counter))
FileUtil.replaceFileContent(keepalivedConfFilePath, '<STATE>', state)
FileUtil.replaceFileContent(keepalivedConfFilePath, '<INTERFACE>', ceilometer_vip_interface)
FileUtil.replaceFileContent(keepalivedConfFilePath, '<VIRTURL_IPADDR>', ceilometer_vip)
##temporary: if current user is not root
ShellCmdExecutor.execCmd("sudo chmod 644 %s" % keepalivedConfFilePath)
#If keepalived need to support more VIP: append here
pass
示例13: configureHAProxy
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configureHAProxy():
####################configure haproxy
#server heat-01 192.168.1.137:8004 check inter 10s
ceilometer_vip = JSONUtility.getValue("ceilometer_vip")
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
HAProxyTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'haproxy.cfg')
haproxyConfFilePath = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'HAPROXY_CONF_FILE_PATH')
print 'haproxyConfFilePath=%s' % haproxyConfFilePath
if not os.path.exists('/etc/haproxy') :
ShellCmdExecutor.execCmd('sudo mkdir /etc/haproxy')
pass
if not os.path.exists(haproxyConfFilePath) :
ShellCmdExecutor.execCmd('cat %s > /tmp/haproxy.cfg' % HAProxyTemplateFilePath)
ShellCmdExecutor.execCmd('mv /tmp/haproxy.cfg /etc/haproxy/')
ShellCmdExecutor.execCmd('rm -rf /tmp/haproxy.cfg')
pass
ShellCmdExecutor.execCmd('sudo chmod 777 %s' % haproxyConfFilePath)
#############
ceilometerBackendApiStringTemplate = '''
listen ceilometer_api_cluster
bind <CEILOMETER_VIP>:8777
balance source
<CEILOMETER_API_SERVER_LIST>
'''
ceilometerBackendApiString = ceilometerBackendApiStringTemplate.replace('<CEILOMETER_VIP>', ceilometer_vip)
################new
ceilometer_ips = JSONUtility.getValue("ceilometer_ips")
ceilometer_ip_list = ceilometer_ips.strip().split(',')
serverCeilometerAPIBackendTemplate = 'server ceilometer-<INDEX> <SERVER_IP>:8777 check inter 2000 rise 2 fall 5'
ceilometerAPIServerListContent = ''
index = 1
for ip in ceilometer_ip_list:
print 'ceilometer_ip=%s' % ip
ceilometerAPIServerListContent += serverCeilometerAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', ip)
ceilometerAPIServerListContent += '\n'
ceilometerAPIServerListContent += ' '
index += 1
pass
ceilometerAPIServerListContent = ceilometerAPIServerListContent.strip()
print 'ceilometerAPIServerListContent=%s--' % ceilometerAPIServerListContent
ceilometerBackendApiString = ceilometerBackendApiString.replace('<CEILOMETER_API_SERVER_LIST>', ceilometerAPIServerListContent)
print 'ceilometerBackendApiString=%s--' % ceilometerBackendApiString
#append
# ShellCmdExecutor.execCmd('sudo echo "%s" >> %s' % (heatBackendApiString, haproxyConfFilePath))
if os.path.exists(haproxyConfFilePath) :
output, exitcode = ShellCmdExecutor.execCmd('cat %s' % haproxyConfFilePath)
else :
output, exitcode = ShellCmdExecutor.execCmd('cat %s' % HAProxyTemplateFilePath)
pass
haproxyNativeContent = output.strip()
haproxyContent = ''
haproxyContent += haproxyNativeContent
haproxyContent += '\n\n'
haproxyContent += ceilometerBackendApiString
FileUtil.writeContent('/tmp/haproxy.cfg', haproxyContent)
if os.path.exists(haproxyConfFilePath):
ShellCmdExecutor.execCmd("sudo rm -rf %s" % haproxyConfFilePath)
pass
ShellCmdExecutor.execCmd('mv /tmp/haproxy.cfg /etc/haproxy/')
ShellCmdExecutor.execCmd('rm -rf /tmp/haproxy.cfg')
ShellCmdExecutor.execCmd('sudo chmod 644 %s' % haproxyConfFilePath)
pass
示例14: configConfFile
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configConfFile():
mysql_vip = JSONUtility.getValue("mysql_vip")
mysql_password = JSONUtility.getValue("mysql_password")
rabbit_host = JSONUtility.getValue("rabbit_host")
# rabbit_vip = JSONUtility.getValue("rabbit_vip")
rabbit_hosts = JSONUtility.getValue("rabbit_hosts")
rabbit_userid = JSONUtility.getValue("rabbit_userid")
rabbit_password = JSONUtility.getValue("rabbit_password")
keystone_vip = JSONUtility.getValue("keystone_vip")
mongodb_vip = JSONUtility.getValue("mongodb_vip")
ceilometer_mongo_password = JSONUtility.getValue("ceilometer_mongo_password")
metering_secret = JSONUtility.getValue("ceilometer_metering_secret")
# metering_secret = Ceilometer.getMeteringSecret()
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
local_ip_file_path = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'LOCAL_IP_FILE_PATH')
output, exitcode = ShellCmdExecutor.execCmd('cat %s' % local_ip_file_path)
localIP = output.strip()
print 'mysql_vip=%s' % mysql_vip
print 'mysql_password=%s' % mysql_password
print 'rabbit_host=%s' % rabbit_host
print 'rabbit_hosts=%s' % rabbit_hosts
print 'rabbit_userid=%s' % rabbit_userid
print 'rabbit_password=%s' % rabbit_password
print 'keystone_vip=%s' % keystone_vip
print 'locaIP=%s' % localIP
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
ceilometer_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'ceilometer', 'ceilometer.conf')
print 'ceilometer_conf_template_file_path=%s' % ceilometer_conf_template_file_path
ceilometerConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'CEILOMETER_CONF_DIR')
print 'ceilometerConfDir=%s' % ceilometerConfDir #/etc/ceilometer
ceilometer_conf_file_path = os.path.join(ceilometerConfDir, 'ceilometer.conf')
print 'ceilometer_conf_file_path=%s' % ceilometer_conf_file_path
if not os.path.exists(ceilometerConfDir) :
ShellCmdExecutor.execCmd("sudo mkdir %s" % ceilometerConfDir)
pass
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % ceilometerConfDir)
if os.path.exists(ceilometer_conf_file_path) :
ShellCmdExecutor.execCmd("sudo rm -rf %s" % ceilometer_conf_file_path)
pass
# ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (ceilometer_conf_template_file_path, ceilometerConfDir))
ShellCmdExecutor.execCmd('cat %s > /tmp/ceilometer.conf' % ceilometer_conf_template_file_path)
ShellCmdExecutor.execCmd('mv -f /tmp/ceilometer.conf /etc/ceilometer/')
ShellCmdExecutor.execCmd('rm -rf /tmp/ceilometer.conf')
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % ceilometer_conf_file_path)
FileUtil.replaceFileContent(ceilometer_conf_file_path, '<MONGODB_VIP>', mongodb_vip)
FileUtil.replaceFileContent(ceilometer_conf_file_path, '<CEILOMETER_DBPASS>', ceilometer_mongo_password)
# FileUtil.replaceFileContent(ceilometer_conf_file_path, '<RABBIT_HOST>', rabbit_vip)
FileUtil.replaceFileContent(ceilometer_conf_file_path, '<RABBIT_HOSTS>', rabbit_hosts)
FileUtil.replaceFileContent(ceilometer_conf_file_path, '<RABBIT_USERID>', rabbit_userid)
FileUtil.replaceFileContent(ceilometer_conf_file_path, '<RABBIT_PASSWORD>', rabbit_password)
FileUtil.replaceFileContent(ceilometer_conf_file_path, '<KEYSTONE_VIP>', keystone_vip)
FileUtil.replaceFileContent(ceilometer_conf_file_path, '<METERING_SECRET>', metering_secret)
FileUtil.replaceFileContent(ceilometer_conf_file_path, '<LOCAL_IP>', localIP)
ShellCmdExecutor.execCmd("sudo chmod 644 %s" % ceilometer_conf_file_path)
pass
示例15: configConfFile
# 需要导入模块: from common.properties.PropertiesUtil import PropertiesUtility [as 别名]
# 或者: from common.properties.PropertiesUtil.PropertiesUtility import getOpenstackConfPropertiesFilePath [as 别名]
def configConfFile():
mysql_vip = JSONUtility.getValue("mysql_vip")
mysql_password = JSONUtility.getValue("mysql_password")
rabbit_host = JSONUtility.getValue("rabbit_host")
# rabbit_vip = JSONUtility.getValue("rabbit_vip")
rabbit_hosts = JSONUtility.getValue("rabbit_hosts")
rabbit_userid = JSONUtility.getValue("rabbit_userid")
rabbit_password = JSONUtility.getValue("rabbit_password")
keystone_vip = JSONUtility.getValue("keystone_vip")
glance_vip = JSONUtility.getValue("glance_vip")
heat_mysql_password = JSONUtility.getValue("heat_mysql_password")
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
local_ip_file_path = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'LOCAL_IP_FILE_PATH')
output, exitcode = ShellCmdExecutor.execCmd('cat %s' % local_ip_file_path)
localIP = output.strip()
print 'mysql_vip=%s' % mysql_vip
print 'mysql_password=%s' % mysql_password
print 'rabbit_host=%s' % rabbit_host
print 'rabbit_hosts=%s' % rabbit_hosts
print 'rabbit_userid=%s' % rabbit_userid
print 'rabbit_password=%s' % rabbit_password
print 'keystone_vip=%s' % keystone_vip
print 'locaIP=%s' % localIP
openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
heat_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'heat', 'heat.conf')
print 'heat_conf_template_file_path=%s' % heat_conf_template_file_path
heatConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'HEAT_CONF_DIR')
print 'heatConfDir=%s' % heatConfDir #/etc/heat
heat_conf_file_path = os.path.join(heatConfDir, 'heat.conf')
print 'heat_conf_file_path=%s' % heat_conf_file_path
if not os.path.exists(heatConfDir) :
ShellCmdExecutor.execCmd("sudo mkdir %s" % heatConfDir)
pass
ShellCmdExecutor.execCmd("sudo chmod 777 /etc/heat")
if os.path.exists(heat_conf_file_path) :
ShellCmdExecutor.execCmd("rm -rf %s" % heat_conf_file_path)
pass
ShellCmdExecutor.execCmd('sudo cp -r %s %s' % (heat_conf_template_file_path, heatConfDir))
ShellCmdExecutor.execCmd('cat %s > /tmp/heat.conf' % heat_conf_template_file_path)
ShellCmdExecutor.execCmd('mv /tmp/heat.conf /etc/heat/')
ShellCmdExecutor.execCmd("sudo chmod 777 %s" % heat_conf_file_path)
FileUtil.replaceFileContent(heat_conf_file_path, '<MYSQL_VIP>', mysql_vip)
FileUtil.replaceFileContent(heat_conf_file_path, '<MYSQL_PASSWORD>', mysql_password)
FileUtil.replaceFileContent(heat_conf_file_path, '<HEAT_MYSQL_PASSWORD>', heat_mysql_password)
# FileUtil.replaceFileContent(heat_conf_file_path, '<RABBIT_HOST>', rabbit_vip)
FileUtil.replaceFileContent(heat_conf_file_path, '<RABBIT_HOSTS>', rabbit_hosts)
FileUtil.replaceFileContent(heat_conf_file_path, '<RABBIT_USERID>', rabbit_userid)
FileUtil.replaceFileContent(heat_conf_file_path, '<RABBIT_PASSWORD>', rabbit_password)
FileUtil.replaceFileContent(heat_conf_file_path, '<KEYSTONE_VIP>', keystone_vip)
FileUtil.replaceFileContent(heat_conf_file_path, '<GLANCE_VIP>', glance_vip)
FileUtil.replaceFileContent(heat_conf_file_path, '<LOCAL_IP>', localIP)
ShellCmdExecutor.execCmd("sudo chmod 644 %s" % heat_conf_file_path)
pass