Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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
Ejemplo n.º 8
0
    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
Ejemplo n.º 9
0
 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
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
    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
Ejemplo n.º 12
0
    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
Ejemplo n.º 13
0
    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
Ejemplo n.º 14
0
    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
Ejemplo n.º 15
0
    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
Ejemplo n.º 16
0
    def configConfFile():
        #RABBIT_HOSTS RABBIT_PASSWORD GLANCE_VIP GLANCE_DBPASS MYSQL_VIP KEYSTONE_VIP KEYSTONE_GLANCE_PASSWORD 
        print "configure glance conf file======"
        mysql_vip = JSONUtility.getValue("mysql_vip")
        glance_vip = JSONUtility.getValue("glance_vip")
        print "glance_vip=%s" % glance_vip
        glance_dbpass = JSONUtility.getValue("glance_dbpass")
        keystone_glance_password = JSONUtility.getValue("keystone_glance_password")
        glance_ips = JSONUtility.getValue("glance_ips")
        print "glance_ips=%s" % glance_ips
        
        keystone_vip = JSONUtility.getValue("keystone_vip")
        rabbit_hosts = JSONUtility.getValue("rabbit_hosts")
        rabbit_userid = "nova"
        rabbit_password = JSONUtility.getValue("rabbit_password")
        
        openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
        glanceConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'GLANCE_CONF_DIR')
        print 'glanceConfDir=%s' % glanceConfDir #/etc/glance
        
        glance_api_conf_file_path = os.path.join(glanceConfDir, 'glance-api.conf')
        glance_registry_conf_file_path = os.path.join(glanceConfDir, 'glance-registry.conf')
        
        if not os.path.exists(glanceConfDir) :
            os.system("sudo mkdir -p %s" % glanceConfDir)
            pass
        #if exist, remove original conf files
        if os.path.exists(glance_api_conf_file_path) :
            os.system("sudo rm -rf %s" % glance_api_conf_file_path)
            pass
        
        if os.path.exists(glance_registry_conf_file_path) :
            print 'tttttttt====='
            print 'glance_registry_conf_file_path=%s' % glance_registry_conf_file_path
            os.system("sudo rm -rf %s" % glance_registry_conf_file_path)
            pass
        
#         os.system("sudo cp -r %s %s" % (SOURCE_GLANE_API_CONF_FILE_TEMPLATE_PATH, glanceConfDir))
#         os.system("sudo cp -r %s %s" % (SOURCE_GLANE_REGISTRY_CONF_FILE_TEMPLATE_PATH, glanceConfDir))
        
        ShellCmdExecutor.execCmd('sudo chmod 777 %s' % glanceConfDir)
        
#         ShellCmdExecutor.execCmd("sudo cp -r %s %s" % (SOURCE_GLANE_API_CONF_FILE_TEMPLATE_PATH, glanceConfDir))
#         ShellCmdExecutor.execCmd("sudo cp -r %s %s" % (SOURCE_GLANE_REGISTRY_CONF_FILE_TEMPLATE_PATH, glanceConfDir))
        
        ######NEW
        
        ShellCmdExecutor.execCmd("cat %s > /tmp/glance-api.conf" % SOURCE_GLANE_API_CONF_FILE_TEMPLATE_PATH)
        ShellCmdExecutor.execCmd("cat %s > /tmp/glance-registry.conf" % SOURCE_GLANE_REGISTRY_CONF_FILE_TEMPLATE_PATH)
        
        ShellCmdExecutor.execCmd("mv /tmp/glance-api.conf /etc/glance/")
        ShellCmdExecutor.execCmd("mv /tmp/glance-registry.conf /etc/glance/")
        
        ShellCmdExecutor.execCmd('sudo chmod 777 %s' % glance_api_conf_file_path)
        ShellCmdExecutor.execCmd('sudo chmod 777 %s' % glance_registry_conf_file_path)
        ###########LOCAL_IP:retrieve it from one file, the LOCAL_IP file is generated when this project inits.
        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
        
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<LOCAL_IP>', localIP)
        FileUtil.replaceFileContent(glance_registry_conf_file_path, '<LOCAL_IP>', localIP)
        
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<GLANCE_VIP>', glance_vip)
        
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<KEYSTONE_VIP>', keystone_vip)
        FileUtil.replaceFileContent(glance_registry_conf_file_path, '<KEYSTONE_VIP>', keystone_vip)
        
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<MYSQL_VIP>', mysql_vip)
        FileUtil.replaceFileContent(glance_registry_conf_file_path, '<MYSQL_VIP>', mysql_vip)
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<GLANCE_DBPASS>', glance_dbpass)
        FileUtil.replaceFileContent(glance_registry_conf_file_path, '<GLANCE_DBPASS>', glance_dbpass)
        
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<KEYSTONE_GLANCE_PASSWORD>', keystone_glance_password)
        FileUtil.replaceFileContent(glance_registry_conf_file_path, '<KEYSTONE_GLANCE_PASSWORD>', keystone_glance_password)
        
#         FileUtil.replaceFileContent(glance_api_conf_file_path, '<RABBIT_HOST>', rabbit_vip)
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<RABBIT_HOSTS>', rabbit_hosts)
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<RABBIT_USERID>', rabbit_userid)
        FileUtil.replaceFileContent(glance_api_conf_file_path, '<RABBIT_PASSWORD>', rabbit_password)    
        
        ShellCmdExecutor.execCmd('sudo chmod 644 %s' % glance_api_conf_file_path)
        ShellCmdExecutor.execCmd('sudo chmod 644 %s' % glance_registry_conf_file_path)
        pass
Ejemplo n.º 17
0
    def configConfFile():
        # use conf template file to replace
        """
        MEMCACHED_LIST
        LOCAL_MANAGEMENT_IP
        GLANCE_VIP
        KEYSTONE_VIP
        KEYSTONE_NOVA_PASSWORD
        METADATA_SECRET
        NEUTRON_VIP
        KEYSTONE_NEUTRON_PASSWORD
        RABBIT_HOSTS
        RABBIT_PASSWORD
        NOVA_DBPASS
        MYSQL_VIP
        """
        mysql_vip = JSONUtility.getValue("ha_vip1")
        #         mysql_password = JSONUtility.getValue("mysql_password")

        #         rabbit_host = JSONUtility.getValue("rabbit_host")
        #         rabbit_vip = JSONUtility.getValue("rabbit_vip")
        rabbit_hosts = JSONUtility.getValue("rabbit_hosts")  # Like: 10.20.0.195:5672,10.20.0.194:5672
        #         rabbit_userid = JSONUtility.getValue("rabbit_userid")
        rabbit_password = JSONUtility.getValue("rabbit_password")

        keystone_vip = JSONUtility.getValue("keystone_vip")
        glance_vip = JSONUtility.getValue("glance_vip")
        neutron_vip = JSONUtility.getValue("neutron_vip")

        keystone_nova_password = JSONUtility.getValue("keystone_nova_password")
        keystone_neutron_password = JSONUtility.getValue("keystone_neutron_password")
        metadata_secret = "123456"  # JSONUtility.getValue("metadata_secret")    #the same with dhcp.ini in neutron

        nova_dbpass = JSONUtility.getValue("nova_dbpass")

        nova_ips = JSONUtility.getValue("nova_ips")
        nova_ip_list = nova_ips.strip().split(",")
        memcached_service_list = []
        for ip in nova_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()
        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 "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, "<MEMCACHED_LIST>", memcached_service_string)
        FileUtil.replaceFileContent(nova_conf_file_path, "<LOCAL_MANAGEMENT_IP>", localIP)
        FileUtil.replaceFileContent(nova_conf_file_path, "<GLANCE_VIP>", glance_vip)
        FileUtil.replaceFileContent(nova_conf_file_path, "<KEYSTONE_VIP>", keystone_vip)
        FileUtil.replaceFileContent(nova_conf_file_path, "<KEYSTONE_NOVA_PASSWORD>", keystone_nova_password)
        FileUtil.replaceFileContent(nova_conf_file_path, "<METADATA_SECRET>", metadata_secret)
        FileUtil.replaceFileContent(nova_conf_file_path, "<NEUTRON_VIP>", neutron_vip)
        FileUtil.replaceFileContent(nova_conf_file_path, "<KEYSTONE_NEUTRON_PASSWORD>", keystone_neutron_password)

        FileUtil.replaceFileContent(nova_conf_file_path, "<MYSQL_VIP>", mysql_vip)
        FileUtil.replaceFileContent(nova_conf_file_path, "<NOVA_DBPASS>", nova_dbpass)

        FileUtil.replaceFileContent(nova_conf_file_path, "<RABBIT_PASSWORD>", rabbit_password)
        FileUtil.replaceFileContent(nova_conf_file_path, "<RABBIT_HOSTS>", rabbit_hosts)

        ShellCmdExecutor.execCmd("sudo chmod 644 %s" % nova_conf_file_path)

        # special handling
        PYTHON_SITE_PACKAGE_DIR = "/usr/lib/python2.7/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
        pass
Ejemplo n.º 18
0
    def configureHAProxy():
        ####################configure haproxy
        glance_vip = JSONUtility.getValue("glance_vip")
        
        openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
        glanceHAProxyTemplateFilePath = 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 -r %s %s' % (glanceHAProxyTemplateFilePath, '/etc/haproxy'))
            pass
        
        ShellCmdExecutor.execCmd('sudo chmod 777 %s' % haproxyConfFilePath)
        
        glance_ips = JSONUtility.getValue("glance_ips")
        glance_ip_list = glance_ips.strip().split(',')
        
        glanceBackendApiStringTemplate = '''
listen glance_api_cluster
  bind <GLANCE_VIP>:9292
  balance source
  <GLANCE_API_SERVER_LIST>
  '''
        glanceBackendRegistryApiStringTemplate = '''
listen glance_registry_cluster
  bind <GLANCE_VIP>:9191
  balance source
  <GLANCE_REGISTRY_API_SERVER_LIST>
        '''
        
        glanceBackendApiString = glanceBackendApiStringTemplate.replace('<GLANCE_VIP>', glance_vip)
        
        glanceBackendRegistryApiString = glanceBackendRegistryApiStringTemplate.replace('<GLANCE_VIP>', glance_vip)
        ###############
        
        serverGlanceRegistryAPIBackendTemplate = 'server glance-<INDEX> <SERVER_IP>:9191 check inter 2000 rise 2 fall 5'
        serverGlanceAPIBackendTemplate         = 'server glance-<INDEX> <SERVER_IP>:9292 check inter 2000 rise 2 fall 5'
        
        glanceRegistryAPIServerListContent = ''
        glanceAPIServerListContent = ''
        
        index = 1
        for glance_ip in glance_ip_list:
            print 'glance_ip=%s' % glance_ip
            glanceRegistryAPIServerListContent += serverGlanceRegistryAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', glance_ip)
            glanceAPIServerListContent += serverGlanceAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', glance_ip)
            
            glanceRegistryAPIServerListContent += '\n'
            glanceRegistryAPIServerListContent += '  '
            
            glanceAPIServerListContent += '\n'
            glanceAPIServerListContent += '  '
            
            index += 1
            pass
        
        glanceRegistryAPIServerListContent = glanceRegistryAPIServerListContent.strip()
        glanceAPIServerListContent = glanceAPIServerListContent.strip()
        print 'glanceRegistryAPIServerListContent=%s--' % glanceRegistryAPIServerListContent
        print 'glanceAPIServerListContent=%s--' % glanceAPIServerListContent
        
        glanceBackendRegistryApiString = glanceBackendRegistryApiString.replace('<GLANCE_REGISTRY_API_SERVER_LIST>', glanceRegistryAPIServerListContent)
        
        glanceBackendApiString = glanceBackendApiString.replace('<GLANCE_API_SERVER_LIST>', glanceAPIServerListContent)
        #append to haproxy.cfg
        if os.path.exists(haproxyConfFilePath) :
            output, exitcode = ShellCmdExecutor.execCmd('cat %s' % haproxyConfFilePath)
        else :
            output, exitcode = ShellCmdExecutor.execCmd('cat %s' % glanceHAProxyTemplateFilePath)
            pass
        
        haproxyNativeContent = output.strip()
        
        haproxyContent = ''
        haproxyContent += haproxyNativeContent
        haproxyContent += '\n\n'
        
        haproxyContent += glanceBackendRegistryApiString
        haproxyContent += glanceBackendApiString
        
        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/')
        ##############

        #Default: glance-api & glance-registry-api use the same vip
        ShellCmdExecutor.execCmd('sudo chmod 644 %s' % haproxyConfFilePath)
        pass
Ejemplo n.º 19
0
    def configureKeystoneHAProxy():
        keystone_vip = JSONUtility.getValue("keystone_vip")
        
        openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
        keystoneHAProxyTemplateFilePath = 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' % (keystoneHAProxyTemplateFilePath, haproxyConfFilePath))
            pass
        
        ShellCmdExecutor.execCmd('sudo chmod 777 %s' % haproxyConfFilePath)
        
        ####
        ##############new
        keystoneBackendAdminApiStringTemplate = '''
listen keystone_admin_cluster
  bind <KEYSTONE_VIP>:35357
  balance source
  <KEYSTONE_ADMIN_API_SERVER_LIST>
  '''
        keystoneBackendPublicApiStringTemplate = '''
listen keystone_public_internal_cluster
  bind <KEYSTONE_VIP>:5000
  <KEYSTONE_PUBLIC_API_SERVER_LIST>
  '''
        keystoneBackendAdminApiString = keystoneBackendAdminApiStringTemplate.replace('<KEYSTONE_VIP>', keystone_vip)
        keystoneBackendPublicApiString = keystoneBackendPublicApiStringTemplate.replace('<KEYSTONE_VIP>', keystone_vip)
        
        ################new
        keystone_ips = JSONUtility.getValue("keystone_ips")
        keystone_ip_list = keystone_ips.strip().split(',')
        
        serverKeystoneAdminAPIBackendTemplate   = 'server keystone-<INDEX> <SERVER_IP>:35357 check inter 2000 rise 2 fall 5'
        serverKeystonePublicAPIBackendTemplate  = 'server keystone-<INDEX> <SERVER_IP>:5000 check inter 2000 rise 2 fall 5'
        
        keystoneAdminAPIServerListContent = ''
        keystonePublicAPIServerListContent = ''
        
        index = 1
        for keystone_ip in keystone_ip_list:
            print 'keystone_ip=%s' % keystone_ip
            keystoneAdminAPIServerListContent += serverKeystoneAdminAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', keystone_ip)
            keystonePublicAPIServerListContent += serverKeystonePublicAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', keystone_ip)
            
            keystoneAdminAPIServerListContent += '\n'
            keystoneAdminAPIServerListContent += '  '
            
            keystonePublicAPIServerListContent += '\n'
            keystonePublicAPIServerListContent += '  '
            index += 1
            pass
        
        keystoneAdminAPIServerListContent = keystoneAdminAPIServerListContent.strip()
        keystonePublicAPIServerListContent = keystonePublicAPIServerListContent.strip()
        print 'keystoneAdminAPIServerListContent=%s--' % keystoneAdminAPIServerListContent
        print 'keystonePublicAPIServerListContent=%s--' % keystonePublicAPIServerListContent
        
        keystoneBackendAdminApiString = keystoneBackendAdminApiString.replace('<KEYSTONE_ADMIN_API_SERVER_LIST>', keystoneAdminAPIServerListContent)
        keystoneBackendPublicApiString = keystoneBackendPublicApiString.replace('<KEYSTONE_PUBLIC_API_SERVER_LIST>', keystonePublicAPIServerListContent)
        
        print 'keystoneBackendAdminApiString=%s--' % keystoneBackendAdminApiString
        print 'keystoneBackendPublicApiString=%s--' % keystoneBackendPublicApiString
        
        #append
        FileUtil.replaceFileContent(haproxyConfFilePath, '<KEYSTONE_ADMIN>', keystoneBackendAdminApiString)
        FileUtil.replaceFileContent(haproxyConfFilePath, '<KEYSTONE_PUBLIC>', keystoneBackendPublicApiString)
        
        ShellCmdExecutor.execCmd('sudo chmod 644 %s' % haproxyConfFilePath)
Ejemplo n.º 20
0
    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")
        cinder_mysql_password = JSONUtility.getValue("cinder_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()
        cinder_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'cinder-storage', 'cinder.conf')
        print 'cinder_conf_template_file_path=%s' % cinder_conf_template_file_path
        
        cinderConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'CINDER_CONF_DIR')
        print 'cinderConfDir=%s' % cinderConfDir #/etc/cinder
        
        cinder_conf_file_path = os.path.join(cinderConfDir, 'cinder.conf')
        print 'cinder_conf_file_path=%s' % cinder_conf_file_path
        
        if not os.path.exists(cinderConfDir) :
            ShellCmdExecutor.execCmd("sudo mkdir %s" % cinderConfDir)
            pass
        
        if os.path.exists(cinder_conf_file_path) :
            ShellCmdExecutor.execCmd("rm -rf %s" % cinder_conf_file_path)
            pass
        
        ShellCmdExecutor.execCmd("chmod 777 /etc/cinder")
        ShellCmdExecutor.execCmd('cat %s > /tmp/cinder.conf' % cinder_conf_template_file_path)
        ShellCmdExecutor.execCmd('mv /tmp/cinder.conf /etc/cinder/')
        ShellCmdExecutor.execCmd('rm -rf /tmp/cinder.conf')
#         ShellCmdExecutor.execCmd('sudo cp -rf %s %s' % (cinder_conf_template_file_path, cinderConfDir))
        ShellCmdExecutor.execCmd("sudo chmod 777 %s" % cinder_conf_file_path)
        
        FileUtil.replaceFileContent(cinder_conf_file_path, '<MYSQL_VIP>', mysql_vip)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<MYSQL_PASSWORD>', mysql_password)
        
        FileUtil.replaceFileContent(cinder_conf_file_path, '<CINDER_MYSQL_PASSWORD>', cinder_mysql_password)
        
#         FileUtil.replaceFileContent(cinder_conf_file_path, '<RABBIT_HOST>', rabbit_vip)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<RABBIT_HOSTS>', rabbit_hosts)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<RABBIT_USERID>', rabbit_userid)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<RABBIT_PASSWORD>', rabbit_password)
        
        FileUtil.replaceFileContent(cinder_conf_file_path, '<KEYSTONE_VIP>', keystone_vip)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<GLANCE_VIP>', glance_vip)
        
        FileUtil.replaceFileContent(cinder_conf_file_path, '<LOCAL_IP>', localIP)
        
        ShellCmdExecutor.execCmd("sudo chmod 644 %s" % cinder_conf_file_path)
        
        #If add filter, if necessary, modify /etc/lvm/lvm.conf
        '''
        filter = [ "a/sda/", "a/sdb/", "r/.*/"]
        '''
        pass
Ejemplo n.º 21
0
    def configureKeystoneHAProxy():
        glance_vip = JSONUtility.getValue("glance_vip")
        
        openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
        glanceHAProxyTemplateFilePath = 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' % (glanceHAProxyTemplateFilePath, haproxyConfFilePath))
            pass
        
        ShellCmdExecutor.execCmd('sudo chmod 777 %s' % haproxyConfFilePath)
        
        glance_ips = JSONUtility.getValue("glance_ips")
        glance_ip_list = glance_ips.strip().split(',')
        
        glanceBackendApiStringTemplate = '''
listen glance_api_cluster
  bind <GLANCE_VIP>:9292
  balance source
  <GLANCE_API_SERVER_LIST>
  '''
        glanceBackendRegistryApiStringTemplate = '''
listen glance_registry_cluster
  bind <GLANCE_VIP>:9191
  balance source
  <GLANCE_REGISTRY_API_SERVER_LIST>
        '''
        
        glanceBackendApiString = glanceBackendApiStringTemplate.replace('<GLANCE_VIP>', glance_vip)
        
        glanceBackendRegistryApiString = glanceBackendRegistryApiStringTemplate.replace('<GLANCE_VIP>', glance_vip)
        ###############
        
        serverGlanceRegistryAPIBackendTemplate = 'server glance-<INDEX> <SERVER_IP>:9191 check inter 2000 rise 2 fall 5'
        serverGlanceAPIBackendTemplate         = 'server glance-<INDEX> <SERVER_IP>:9292 check inter 2000 rise 2 fall 5'
        
        glanceRegistryAPIServerListContent = ''
        glanceAPIServerListContent = ''
        
        index = 1
        for glance_ip in glance_ip_list:
            print 'glance_ip=%s' % glance_ip
            glanceRegistryAPIServerListContent += serverGlanceRegistryAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', glance_ip)
            glanceAPIServerListContent += serverGlanceAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', glance_ip)
            
            glanceRegistryAPIServerListContent += '\n'
            glanceRegistryAPIServerListContent += '  '
            
            glanceAPIServerListContent += '\n'
            glanceAPIServerListContent += '  '
            
            index += 1
            pass
        
        glanceRegistryAPIServerListContent = glanceRegistryAPIServerListContent.strip()
        glanceAPIServerListContent = glanceAPIServerListContent.strip()
        print 'glanceRegistryAPIServerListContent=%s--' % glanceRegistryAPIServerListContent
        print 'glanceAPIServerListContent=%s--' % glanceAPIServerListContent
        
        glanceBackendRegistryApiString = glanceBackendRegistryApiString.replace('<GLANCE_REGISTRY_API_SERVER_LIST>', glanceRegistryAPIServerListContent)
        
        glanceBackendApiString = glanceBackendApiString.replace('<GLANCE_API_SERVER_LIST>', glanceAPIServerListContent)
        #append
        FileUtil.replaceFileContent(haproxyConfFilePath, '<GLANCE_API>', glanceBackendApiString)
        FileUtil.replaceFileContent(haproxyConfFilePath, '<GLANCE_REGISTRY>', glanceBackendRegistryApiString)
        
        ShellCmdExecutor.execCmd('sudo chmod 644 %s' % haproxyConfFilePath)
Ejemplo n.º 22
0
 def produce():
     print 'produe role ip list in /opt/{role}_ip_list======='
     for role in ParamsProducer.OPENSTACK_ROLES :
         if YAMLUtil.hasRoleInNodes(role) :
             YAMLUtil.writeIPList(role)
             pass
         pass
     
     print 'produce local ip in /opt/localip'
     localIPPath = '/opt/localip'
     FileUtil.writeContent(localIPPath, YAMLUtil.getLocalIP())    
     
     print 'produce all params in /opt/openstack_conf/openstack_params.json'
     paramsMap = {}
     #global variables
     print 'global==========================='
     admin_token = YAMLUtil.getValue('global', 'admin_token')
     paramsMap['admin_token'] = admin_token
     
     cinder_dbpass = YAMLUtil.getValue('global', 'cinder_dbpass')
     paramsMap['cinder_dbpass'] = cinder_dbpass
     
     keystone_heat_password = YAMLUtil.getValue('global', 'keystone_heat_password')
     paramsMap['keystone_heat_password'] = keystone_heat_password
     
     keystone_neutron_password = YAMLUtil.getValue('global', 'keystone_neutron_password')
     paramsMap['keystone_neutron_password'] = keystone_neutron_password
     
     keystone_admin_password = YAMLUtil.getValue('global', 'keystone_admin_password')
     paramsMap['keystone_admin_password'] = keystone_admin_password
     
     keystone_glance_password = YAMLUtil.getValue('global', 'keystone_glance_password')
     paramsMap['keystone_glance_password'] = keystone_glance_password
     
     neutron_dbpass = YAMLUtil.getValue('global', 'neutron_dbpass')
     paramsMap['neutron_dbpass'] = neutron_dbpass
     
     keystone_cinder_password = YAMLUtil.getValue('global', 'keystone_cinder_password')
     paramsMap['keystone_cinder_password'] = keystone_cinder_password
     
     nova_dbpass = YAMLUtil.getValue('global', 'nova_dbpass')
     paramsMap['nova_dbpass'] = nova_dbpass
     
     keystone_nova_password = YAMLUtil.getValue('global', 'keystone_nova_password')
     paramsMap['keystone_nova_password'] = keystone_nova_password
     
     ceilometer_dbpass = YAMLUtil.getValue('global', 'ceilometer_dbpass')
     paramsMap['ceilometer_dbpass'] = ceilometer_dbpass
     
     heat_dbpass = YAMLUtil.getValue('global', 'heat_dbpass')
     paramsMap['heat_dbpass'] = heat_dbpass
     
     bclinux_repo_url = YAMLUtil.getValue('global', 'bclinux_repo_url')
     paramsMap['bclinux_repo_url'] = bclinux_repo_url
     
     glance_dbpass = YAMLUtil.getValue('global', 'glance_dbpass')
     paramsMap['glance_dbpass'] = glance_dbpass
     
     keystone_dbpass = YAMLUtil.getValue('global', 'keystone_dbpass')
     paramsMap['keystone_dbpass'] = keystone_dbpass
     
     keystone_ceilometer_password = YAMLUtil.getValue('global', 'keystone_ceilometer_password')
     paramsMap['keystone_ceilometer_password'] = keystone_ceilometer_password
     
     cluster_id = YAMLUtil.getValue('global', 'cluster_id')
     paramsMap['cluster_id'] = cluster_id
     
     fuel_master_ip = YAMLUtil.getValue('global', 'fuel_master_ip')
     paramsMap['fuel_master_ip'] = fuel_master_ip
     
     print 'mysql============================'
     #Judge whether current host is mysql role
     role = 'mysql'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'mysql_vip'
         mysql_vip = YAMLUtil.getValue(role, key)
         
         key = 'mysql_vip_interface'
         mysql_vip_interface = YAMLUtil.getValue(role, key)
         
         key = 'root_password'
         mysql_root_password = YAMLUtil.getValue(role, key)
         print 'mysql_vip=%s--' % mysql_vip
         print 'mysql_vip_interface=%s--' % mysql_vip_interface
         print 'mysql_password=%s--' % mysql_root_password
         
         mysql_ips_list = YAMLUtil.getRoleIPList(role)
         #Judge mysql master ip
         mysql_master_ip = mysql_ips_list[0]
         FileUtil.writeContent('/opt/mysql_master_ip', mysql_master_ip)
         
         mysql_ips = ','.join(mysql_ips_list)
         print 'mysql_ips=%s' % mysql_ips
         paramsMap['mysql_vip'] = mysql_vip
         paramsMap['mysql_vip_interface'] = mysql_vip_interface
         paramsMap['mysql_password'] = mysql_root_password
         paramsMap['mysql_ips'] = mysql_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), mysql_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
 #         else:
 #             FileUtil.writeContent(is_mysql_role_file_path, 'false')
 #             pass
 #         pass
 #     else :
 #         FileUtil.writeContent(is_mysql_role_file_path, 'false')
 #         pass
         
     print 'rabbitmq========================'
     role = 'rabbitmq'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'rabbit_userid'
         rabbit_userid = YAMLUtil.getValue(role, key)
         
         key = 'rabbit_password'
         rabbit_password = YAMLUtil.getValue(role, key)
         
         key = 'rabbit_vip'
         rabbit_vip = YAMLUtil.getValue(role, key)
         
         key = 'rabbit_vip_interface'
         rabbit_vip_interface = YAMLUtil.getValue(role, key)
         
         rabbit_ips_list = YAMLUtil.getRabbitRoleIPList(role)
         rabbit_ips = ','.join(rabbit_ips_list)
         
         #Judge rabbitmq master ip
         rabbit_master_ip = rabbit_ips_list[0]
         FileUtil.writeContent('/opt/rabbitmq_master_ip', rabbit_master_ip)
         
         print 'rabbit_userid=%s--' % rabbit_userid
         print 'rabbit_vip=%s--' % rabbit_vip
         print 'rabbit_vip_interface=%s--' % rabbit_vip_interface
         print 'rabbit_password=%s--' % rabbit_password
         print 'rabbit_ips=%s--' % rabbit_ips
         
         rabbit_hosts_list = [] #rabbit_ip1:5672,rabbit_ip2:5672
         
         for ip in rabbit_ips_list :
             rabbit_with_port = '%s:5672' % ip
             rabbit_hosts_list.append(rabbit_with_port)
             pass
         paramsMap['rabbit_hosts'] = ','.join(rabbit_hosts_list)
         paramsMap['rabbit_host'] = rabbit_ips_list[0]
         paramsMap['rabbit_vip'] = rabbit_vip
         paramsMap['rabbit_vip_interface'] = rabbit_vip_interface
         paramsMap['rabbit_userid'] = rabbit_userid
         paramsMap['rabbit_password'] = rabbit_password
         paramsMap['rabbitmq_ips'] = rabbit_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), rabbit_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     print 'keystone========================='
     role = 'keystone'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'keystone_vip'
         keystone_vip = YAMLUtil.getValue(role, key)
         
         key = 'keystone_vip_interface'
         keystone_vip_interface = YAMLUtil.getValue(role, key)
         
         key = 'keystone_mysql_user'
         keystone_mysql_user = YAMLUtil.getValue(role, key)
         
         key = 'keystone_mysql_password'
         keystone_mysql_password = YAMLUtil.getValue(role, key)
         
         keystone_ips_list = YAMLUtil.getRoleIPList(role)
         keystone_ips = ','.join(keystone_ips_list)
         
         print 'keystone_vip=%s--' % keystone_vip
         print 'keystone_vip_interface=%s--' % keystone_vip_interface
         print 'keystone_mysql_user=%s--' % keystone_mysql_user 
         print 'keystone_ips=%s--' % keystone_ips
         
         paramsMap['keystone_vip'] = keystone_vip
         paramsMap['keystone_vip_interface'] = keystone_vip_interface
         paramsMap['keystone_mysql_user'] = keystone_mysql_user
         paramsMap['keystone_mysql_password'] = keystone_mysql_password
         paramsMap['keystone_ips'] = keystone_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), keystone_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
 #         else:
 #             FileUtil.writeContent(is_keystone_role_file_path, 'false')
 #             pass
 #         pass
 #     else :
 #         FileUtil.writeContent(is_keystone_role_file_path, 'false')
 #         pass
     
     print 'glance====================================='
     role = 'glance'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'glance_vip'
         glance_vip = YAMLUtil.getValue(role, key)
         
         key = 'glance_vip_interface'
         glance_vip_interface = YAMLUtil.getValue(role, key)
         
         key = 'glance_mysql_user'
         glance_mysql_user = YAMLUtil.getValue(role, key)
         
         key = 'glance_mysql_password'
         glance_mysql_password = YAMLUtil.getValue(role, key)
         
         glance_ips_list = YAMLUtil.getRoleIPList(role)
         glance_ips = ','.join(glance_ips_list)
         
         print 'glance_vip=%s--' % glance_vip
         print 'glance_vip_interface=%s--' % glance_vip_interface
         print 'glance_mysql_user=%s--' % glance_mysql_user
         print 'glance_mysql_password=%s--' % glance_mysql_password 
         print 'glance_ips=%s--' % glance_ips
         paramsMap['glance_vip'] = glance_vip
         paramsMap['glance_vip_interface'] = glance_vip_interface
         paramsMap['glance_mysql_user'] = glance_mysql_user
         paramsMap['glance_mysql_password'] = glance_mysql_password
         paramsMap['glance_ips'] = glance_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), glance_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
 
     print 'neutron-server========================================='
     role = 'neutron-server'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'neutron_vip'
         neutron_vip = YAMLUtil.getValue(role, key)
         
         key = 'neutron_vip_interface'
         neutron_vip_interface = YAMLUtil.getValue(role, key)
         
         key = 'neutron_network_mode'
         neutron_network_mode = YAMLUtil.getValue(role, key)
         
         key = 'neutron_mysql_user'
         neutron_mysql_user = YAMLUtil.getValue(role, key)
         key = 'neutron_mysql_password'
         neutron_mysql_password = YAMLUtil.getValue(role, key)
         
         neutron_ip_list = YAMLUtil.getRoleIPList(role)
         neutron_ips = ','.join(neutron_ip_list)
         
         print 'neutron_vip=%s--' % neutron_vip
         print 'neutron_vip_interface=%s--' % neutron_vip_interface
         print 'neutron_network_mode=%s--' % neutron_network_mode
         
         print 'neutron_mysql_user=%s--' % neutron_mysql_user
         print 'neutron_mysql_user_password=%s--' % neutron_mysql_password
         
         print 'neutron_ips=%s--' % neutron_ips
         paramsMap['neutron_vip'] = neutron_vip
         paramsMap['neutron_vip_interface'] = neutron_vip_interface
         paramsMap['neutron_mysql_user'] = neutron_mysql_user
         paramsMap['neutron_mysql_password'] = neutron_mysql_password
         paramsMap['neutron_network_mode'] = neutron_network_mode
         paramsMap['neutron_ips'] = neutron_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), neutron_ip_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     print 'nova-api========================================='
     role = 'nova-api'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'nova_vip'
         nova_vip = YAMLUtil.getValue(role, key)
         
         key = 'nova_vip_interface'
         nova_vip_interface = YAMLUtil.getValue(role, key)
         
         key = 'nova_mysql_user'
         nova_mysql_user = YAMLUtil.getValue(role, key)
         
         key = 'nova_mysql_password'
         nova_mysql_password = YAMLUtil.getValue(role, key)
         
         nova_ip_list = YAMLUtil.getRoleIPList(role)
         nova_ips = ','.join(nova_ip_list)
         
         print 'nova_vip=%s--' % nova_vip
         print 'nova_vip_interface=%s--' % nova_vip_interface
         print 'nova_mysql_user=%s--' % nova_mysql_user
         print 'nova_mysql_password=%s--' % nova_mysql_password
         
         print 'nova_ips=%s--' % nova_ips
         print YAMLUtil.hasRoleInNodes('nova-api')
         paramsMap['nova_vip'] = nova_vip
         paramsMap['nova_vip_interface'] = nova_vip_interface
         paramsMap['nova_mysql_user'] = nova_mysql_user
         paramsMap['nova_mysql_password'] = nova_mysql_password
         paramsMap['nova_ips'] = nova_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), nova_ip_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     print 'nova-compute============================================='
     role = 'nova-compute'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'virt_type'
         virt_type= YAMLUtil.getValue(role, key)
         print 'virt_type=%s' % virt_type
         
         nova_compute_ip_list = YAMLUtil.getRoleIPList(role)
         nova_compute_ips = ','.join(nova_compute_ip_list)
         print 'nova_compute_ips=%s--' % nova_compute_ips
         paramsMap['virt_type'] = virt_type
         paramsMap['nova_compute_ips'] = nova_compute_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), nova_compute_ip_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     role = 'horizon'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'dashboard_vip'
         dashboard_vip= YAMLUtil.getValue(role, key)
         key = 'dashboard_vip_interface'
         dashboard_vip_interface = YAMLUtil.getValue(role, key)
         
         dashboard_ips_list = YAMLUtil.getRoleIPList(role)
         dashboard_ips = ','.join(dashboard_ips_list)
         print 'dashboard_vip=%s--' % dashboard_vip
         print 'dashboard_vip_interface=%s--' % dashboard_vip_interface
         print 'dashboard_ips=%s--' % dashboard_ips
         paramsMap['dashboard_vip'] = dashboard_vip
         paramsMap['dashboard_vip_interface'] = dashboard_vip_interface
         paramsMap['dashboard_ips'] = dashboard_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), dashboard_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
         
     print 'cinder============================================'
     role = 'cinder-api'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'cinder_vip'
         cinder_vip = YAMLUtil.getValue(role, key)
         
         key = 'cinder_vip_interface'
         cinder_vip_interface = YAMLUtil.getValue(role, key)
         
         key = 'cinder_mysql_user'
         cinder_mysql_user = YAMLUtil.getValue(role, key)
         
         key = 'cinder_mysql_password'
         cinder_mysql_password = YAMLUtil.getValue(role, key)
         
         cinder_ips_list = YAMLUtil.getRoleIPList(role)
         cinder_ips = ','.join(cinder_ips_list)
         print 'cinder_vip=%s-' % cinder_vip
         print 'cinder_vip_interface=%s--' % cinder_vip_interface
         print 'cinder_mysql_user=%s--' % cinder_mysql_user
         print 'cinder_mysql_password=%s--' % cinder_mysql_password
         print 'cinder_ips=%s--' % cinder_ips
         paramsMap['cinder_vip'] = cinder_vip
         paramsMap['cinder_vip_interface'] = cinder_vip_interface
         paramsMap['cinder_mysql_user'] = cinder_mysql_user
         paramsMap['cinder_mysql_password'] = cinder_mysql_password
         paramsMap['cinder_ips'] = cinder_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), cinder_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     print 'cinder-storage============================================'
     role = 'cinder-storage'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         cinder_storage_ips_list = YAMLUtil.getRoleIPList(role)
         cinder_storage_ips = ','.join(cinder_storage_ips_list)
         paramsMap['cinder_storage_ips'] = cinder_storage_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), cinder_storage_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     print 'heat============================================'
     role = 'heat'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         heat_ips_list = YAMLUtil.getRoleIPList(role)
         heat_ips = ','.join(heat_ips_list)
         print 'heat_ips=%s--' % heat_ips
         
         key = 'heat_vip'
         heat_vip = YAMLUtil.getValue(role, key)
         
         key = 'heat_vip_interface'
         heat_vip_interface = YAMLUtil.getValue(role, key)
         
         key = 'heat_mysql_user'
         heat_mysql_user = YAMLUtil.getValue(role, key)
         
         key = 'heat_mysql_password'
         heat_mysql_password = YAMLUtil.getValue(role, key)
         
         paramsMap['heat_ips'] = heat_ips
         paramsMap['heat_vip'] = heat_vip
         paramsMap['heat_vip_interface'] = heat_vip_interface
         paramsMap['heat_mysql_user'] = heat_mysql_user
         paramsMap['heat_mysql_password'] = heat_mysql_password
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), heat_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     print 'neutron-agent============================================'
     role = 'neutron-agent'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         neutron_service_ips_list = YAMLUtil.getRoleIPList(role)
         neutron_service_ips = ','.join(neutron_service_ips_list)
         print 'neutron_service_ips=%s--' % neutron_service_ips
         paramsMap['neutron_service_ips'] = neutron_service_ips
         
         #REFACTOR LATER
         paramsMap['metadata_secret'] = '123456'
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), neutron_service_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     print 'mongodb==========================================='
     role = 'mongodb'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         #refactor later
 #         key = 'mongodb_vip'
 #         mongodb_vip = YAMLUtil.getValue(role, key)
 #         
 #         key = 'mongodb_vip_interface'
 #         mongodb_vip_interface = YAMLUtil.getValue(role, key)
         
         mongodb_ips_list = YAMLUtil.getRoleIPList(role)
         mongodb_ips = ','.join(mongodb_ips_list)
         
         #refactor later
         mongodb_vip = mongodb_ips_list[0]
         mongodb_vip_interface = 'eth0'
         print 'mongodb_vip=%s-' % mongodb_vip
         print 'mongodb_vip_interface=%s--' % mongodb_vip_interface
         paramsMap['mongodb_vip'] = mongodb_vip
         paramsMap['mongodb_vip_interface'] = mongodb_vip_interface
         paramsMap['mongodb_ips'] = mongodb_ips
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), mongodb_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
             pass
         pass
     
     print 'ceilometer==========================================='
     role = 'ceilometer'
     is_role_file_path = '/opt/is_{rolename}_role'.format(rolename=role).replace('-', '_')
     if YAMLUtil.hasRoleInNodes(role):
         key = 'ceilometer_vip'
         ceilometer_vip = YAMLUtil.getValue(role, key)
         
         key = 'ceilometer_vip_interface'
         ceilometer_vip_interface = YAMLUtil.getValue(role, key)
         
         key = 'ceilometer_mongo_user'
         ceilometer_mongo_user = YAMLUtil.getValue(role, key)
         
         key = 'ceilometer_mongo_password'
         ceilometer_mongo_password = YAMLUtil.getValue(role, key)
         
         ceilometer_ips_list = YAMLUtil.getRoleIPList(role)
         ceilometer_ips = ','.join(ceilometer_ips_list)
         print 'ceilometer_vip=%s-' % ceilometer_vip
         print 'ceilometer_vip_interface=%s--' % ceilometer_vip_interface
         print 'ceilometer_mongo_user=%s--' % ceilometer_mongo_user
         print 'ceilometer_mongo_password=%s--' % ceilometer_mongo_password
         print 'ceilometer_ips=%s--' % ceilometer_ips
         paramsMap['ceilometer_vip'] = ceilometer_vip
         paramsMap['ceilometer_vip_interface'] = ceilometer_vip_interface
         paramsMap['ceilometer_mongo_user'] = ceilometer_mongo_user
         paramsMap['ceilometer_mongo_password'] = ceilometer_mongo_password
         paramsMap['ceilometer_ips'] = ceilometer_ips
         
         #REFACTOR LATER
         ceilometer_metering_secret = '7c1edcdfc1b2841c21ff'
         paramsMap['ceilometer_metering_secret'] = ceilometer_metering_secret
         
         if ParamsProducer.isExistElementInArray(YAMLUtil.getLocalIP(), ceilometer_ips_list) :
             FileUtil.writeContent(is_role_file_path, 'true')
         pass
     
     print 'get global var==========================================='
     role = 'global'
     neutron_dbpass = YAMLUtil.getValue(role, 'neutron_dbpass')
     nova_dbpass = YAMLUtil.getValue(role, 'nova_dbpass')
     
     paramsMap['neutron_dbpass'] = YAMLUtil.getValue(role, 'neutron_dbpass')
     paramsMap['nova_dbpass'] =  YAMLUtil.getValue(role, 'nova_dbpass')
         
     #HA: only 2,master-backup mutually
     print 'haproxy-keepalived=================='
     role = 'haproxy-keepalived'
     if YAMLUtil.hasRoleInNodes(role):
         ha_vip1 = YAMLUtil.getValue(role, 'haproxy_vip1')
         ha_vip2 = YAMLUtil.getValue(role, 'haproxy_vip2')
         ha_vip1_interface = YAMLUtil.getValue(role, 'haproxy_vipinterface1')
         ha_vip2_interface = YAMLUtil.getValue(role, 'haproxy_vipinterface2')
         
         paramsMap['ha_vip1'] = ha_vip1
         paramsMap['ha_vip2'] = ha_vip2
         paramsMap['ha_vip1_interface'] = ha_vip1_interface
         paramsMap['ha_vip2_interface'] = ha_vip2_interface
         
         #dispatch vip
         paramsMap['mysql_vip'] = ha_vip1
         paramsMap['rabbit_vip'] = ha_vip1
         paramsMap['keystone_vip'] = ha_vip1
         paramsMap['glance_vip'] = ha_vip1
         paramsMap['neutron_vip'] = ha_vip1
         paramsMap['nova_vip'] = ha_vip1
         paramsMap['dashboard_vip'] = ha_vip1
         paramsMap['cinder_vip'] = ha_vip1
         paramsMap['heat_vip'] = ha_vip1
         paramsMap['mongodb_vip'] = ha_vip2
         paramsMap['ceilometer_vip'] = ha_vip2
         pass
     
     openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
     admin_email = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'ADMIN_EMAIL')
     
     paramsMap['admin_email'] = admin_email
     
     import json
     jsonParams = json.dumps(paramsMap,indent=4)
     print jsonParams
     print type(jsonParams)
     
     openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
     openstackConfBaseDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'OPENSTACK_CONF_BASE_DIR')
     if not os.path.exists(openstackConfBaseDir) :
         ShellCmdExecutor.execCmd("mkdir %s" % openstackConfBaseDir)
         pass
     openstackParamsFilePath = os.path.join(openstackConfBaseDir, 'openstack_params.json')
     FileUtil.writeContent(openstackParamsFilePath, jsonParams)
     
     print 'produce role list done#######'
     
     ###zgf add
     YAMLUtil.setHosts()
Ejemplo n.º 23
0
    def configureHAProxy():
        ####################configure haproxy
        nova_vip = JSONUtility.getValue("nova_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 %s' % haproxyConfFilePath)
        
        nova_ips = JSONUtility.getValue("nova_ips")
        nova_ip_list = nova_ips.strip().split(',')
        
        novaEC2ApiBackendStringTemplate = '''
listen nova_ec2_api_cluster
  bind <NOVA_VIP>:8773
  balance source
  <NOVA_EC2_API_SERVER_LIST>
  '''
        novaComputeApiBackendStringTemplate = '''
listen nova_compute_api_cluster
  bind <NOVA_VIP>:8774
  balance source
  <NOVA_COMPUTE_API_SERVER_LIST>
        '''
        
        novaMetadataApiBackendStringTemplate = '''
listen nova_metadata_api_cluster
  bind <NOVA_VIP>:8775
  balance source
  <NOVA_METADATA_API_SERVER_LIST>
        '''
        
        vncBackendStringTemplate = '''
listen vnc_cluster
  bind <NOVA_VIP>:6080
  balance source
  option tcpka
  option tcplog
  <VNC_SERVER_LIST>
        '''
        
        novaEC2ApiBackendString = novaEC2ApiBackendStringTemplate.replace('<NOVA_VIP>', nova_vip)
        novaComputeApiBackendString = novaComputeApiBackendStringTemplate.replace('<NOVA_VIP>', nova_vip)
        novaMetadataApiBackendString = novaMetadataApiBackendStringTemplate.replace('<NOVA_VIP>', nova_vip)
        vncBackendString = vncBackendStringTemplate.replace('<NOVA_VIP>', nova_vip)
        ###############
        
        serverNovaEC2APIBackendTemplate = 'server nova-<INDEX> <SERVER_IP>:8773 check inter 2000 rise 2 fall 5'
        serverNovaComputeAPIBackendTemplate = 'server nova-<INDEX> <SERVER_IP>:8774 check inter 2000 rise 2 fall 5'
        serverNovaMetadataAPIBackendTemplate = 'server nova-<INDEX> <SERVER_IP>:8775 check inter 2000 rise 2 fall 5'
        serverVNCBackendTemplate = 'server nova-<INDEX> <SERVER_IP>:6080 check inter 2000 rise 2 fall 5'
        
        novaEC2APIServerListContent = ''
        novaComputeAPIServerListContent = ''
        novaMetadataAPIServerListContent = ''
        vncServerListContent = ''
        
        index = 1
        for ip in nova_ip_list:
            print 'nova_ip=%s' % ip
            novaEC2APIServerListContent += serverNovaEC2APIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', ip)
            novaComputeAPIServerListContent += serverNovaComputeAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', ip)
            novaMetadataAPIServerListContent += serverNovaMetadataAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', ip)
            vncServerListContent += serverVNCBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', ip)
            
            novaEC2APIServerListContent += '\n'
            novaEC2APIServerListContent += '  '
            
            novaComputeAPIServerListContent += '\n'
            novaComputeAPIServerListContent += '  '
            
            novaMetadataAPIServerListContent += '\n'
            novaMetadataAPIServerListContent += '  '
            
            vncServerListContent += '\n'
            vncServerListContent += '  '
            
            index += 1
            pass
        
        novaEC2APIServerListContent = novaEC2APIServerListContent.strip()
        novaComputeAPIServerListContent = novaComputeAPIServerListContent.strip()
        novaMetadataAPIServerListContent = novaMetadataAPIServerListContent.strip()
        
        novaEC2ApiBackendString = novaEC2ApiBackendString.replace('<NOVA_EC2_API_SERVER_LIST>', novaEC2APIServerListContent)
        novaComputeApiBackendString = novaComputeApiBackendString.replace('<NOVA_COMPUTE_API_SERVER_LIST>', novaComputeAPIServerListContent)
        novaMetadataApiBackendString = novaMetadataApiBackendString.replace('<NOVA_METADATA_API_SERVER_LIST>', novaMetadataAPIServerListContent)
        vncBackendString = vncBackendString.replace('<VNC_SERVER_LIST>', vncServerListContent)
        
        #append to haproxy.cfg
        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 += novaEC2ApiBackendString
        haproxyContent += novaComputeApiBackendString
        haproxyContent += novaMetadataApiBackendString
        haproxyContent += vncBackendString
        
        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
Ejemplo n.º 24
0
    def configureHAProxy():
        ####################configure haproxy
        neutron_vip = JSONUtility.getValue("neutron_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 -r %s %s' % (HAProxyTemplateFilePath, '/etc/haproxy'))
            pass
        
        ShellCmdExecutor.execCmd('sudo chmod 777 %s' % haproxyConfFilePath)
        
        ####
        ##############new
        neutronApiBackendStringTemplate = '''
listen neutron_api_cluster
  bind <NEUTRON_VIP>:9696
  balance source
  <NEUTRON_API_SERVER_LIST>
  '''

        neutronApiBackendString = neutronApiBackendStringTemplate.replace('<NEUTRON_VIP>', neutron_vip)
        
        ################new
        neutron_ips = JSONUtility.getValue("neutron_ips")
        neutron_ip_list = neutron_ips.strip().split(',')
        
        serverNeutronAPIBackendTemplate   = 'server neutron-<INDEX> <SERVER_IP>:9696 check inter 2000 rise 2 fall 5'
        neutronAPIServerListContent = ''
        index = 1
        for ip in neutron_ip_list:
            print 'neutron_ip=%s' % ip
            neutronAPIServerListContent += serverNeutronAPIBackendTemplate.replace('<INDEX>', str(index)).replace('<SERVER_IP>', ip)
            
            neutronAPIServerListContent += '\n'
            neutronAPIServerListContent += '  '
            index += 1
            pass
        
        neutronAPIServerListContent = neutronAPIServerListContent.strip()
        print 'neutronAPIServerListContent=%s--' % neutronAPIServerListContent
        
        neutronApiBackendString = neutronApiBackendString.replace('<NEUTRON_API_SERVER_LIST>', neutronAPIServerListContent)
        
        print 'neutronApiBackendString=%s--' % neutronApiBackendString
        
        #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 += neutronApiBackendString
        
        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
Ejemplo n.º 25
0
    def configNeutronConfFile():
        '''
        NEUTRON_DBPASS
        MYSQL_VIP
        RABBIT_HOSTS
        RABBIT_PASSWORD
        KEYSTONE_VIP
        KEYSTONE_NEUTRON_PASSWORD
        '''
        mysql_vip = JSONUtility.getValue("mysql_vip")
        neutron_dbpass = JSONUtility.getValue("neutron_dbpass")
        
        rabbit_hosts = JSONUtility.getValue("rabbit_hosts")
        rabbit_password = JSONUtility.getValue("rabbit_password")
        
        keystone_vip = JSONUtility.getValue("keystone_vip")
        nova_vip = JSONUtility.getValue("nova_vip")
        keystone_neutron_password = JSONUtility.getValue("keystone_neutron_password")
        
        output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip')
        localIP = output.strip()
        print 'mysql_vip=%s' % mysql_vip
        print 'rabbit_hosts=%s' % rabbit_hosts
        print 'rabbit_password=%s' % rabbit_password
        print 'keystone_vip=%s' % keystone_vip
        print 'nova_vip=%s' % nova_vip
        print 'locaIP=%s' % localIP
        
        openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
        neutron_server_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'neutron-server', 'neutron.conf')
        print 'neutron_server_conf_template_file_path=%s' % neutron_server_conf_template_file_path
        
        neutronConfDir = '/etc/neutron'
        if not os.path.exists(neutronConfDir) :
            ShellCmdExecutor.execCmd("sudo mkdir %s" % neutronConfDir)
            pass
        
        ShellCmdExecutor.execCmd("sudo chmod 777 %s" % neutronConfDir)
        
        neutron_conf_file_path = os.path.join(neutronConfDir, 'neutron.conf')
        if os.path.exists(neutron_conf_file_path) :
            ShellCmdExecutor.execCmd("sudo rm -rf %s" % neutron_conf_file_path)
            pass
        
        ShellCmdExecutor.execCmd("cat %s > /tmp/neutron.conf" % neutron_server_conf_template_file_path)
        ShellCmdExecutor.execCmd("mv /tmp/neutron.conf /etc/neutron/")
        
        FileUtil.replaceFileContent(neutron_conf_file_path, '<MYSQL_VIP>', mysql_vip)
        FileUtil.replaceFileContent(neutron_conf_file_path, '<RABBIT_HOSTS>', rabbit_hosts)
#         FileUtil.replaceFileContent(neutron_conf_file_path, '<RABBIT_USERID>', rabbit_userid)
        FileUtil.replaceFileContent(neutron_conf_file_path, '<RABBIT_PASSWORD>', rabbit_password)
        
        FileUtil.replaceFileContent(neutron_conf_file_path, '<KEYSTONE_VIP>', keystone_vip)
#         FileUtil.replaceFileContent(neutron_conf_file_path, '<NOVA_VIP>', nova_vip)
        FileUtil.replaceFileContent(neutron_conf_file_path, '<NEUTRON_DBPASS>', neutron_dbpass)
        FileUtil.replaceFileContent(neutron_conf_file_path, '<KEYSTONE_NEUTRON_PASSWORD>', keystone_neutron_password)
        
#         FileUtil.replaceFileContent(neutron_conf_file_path, '<LOCAL_IP>', localIP)
        
        ShellCmdExecutor.execCmd("chmod 644 %s" % neutron_conf_file_path)
        ShellCmdExecutor.execCmd("chown -R neutron:neutron /etc/neutron/")
        pass
Ejemplo n.º 26
0
 def getLocalIP():
     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()
     return localIP
Ejemplo n.º 27
0
    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 -rf %s %s' % (checkHAProxyScriptPath, '/etc/keepalived'))
        if os.path.exists(keepalivedConfFilePath) :
            ShellCmdExecutor.execCmd("sudo rm -rf %s" % keepalivedConfFilePath)
            pass
        
        ShellCmdExecutor.execCmd('sudo cp -rf %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>
  }
}
        '''
        #GLANCE_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
        keystone_vip = JSONUtility.getValue("keystone_vip")
        keystone_vip_interface = JSONUtility.getValue("keystone_vip_interface")
        #Call ZooKeeper lock & counter services
        keystone_weight_counter = Keystone.getWeightCounter()
        if keystone_weight_counter == 300 : #This is MASTER
            FileUtil.replaceFileContent(keepalivedConfFilePath, '<WEIGHT>', '300')
            FileUtil.replaceFileContent(keepalivedConfFilePath, '<STATE>', 'MASTER')
            FileUtil.replaceFileContent(keepalivedConfFilePath, '<INTERFACE>', keystone_vip_interface)
            FileUtil.replaceFileContent(keepalivedConfFilePath, '<VIRTURL_IPADDR>', keystone_vip)
        else :
            #
            #
            index = 300 - keystone_weight_counter
            state = 'SLAVE' + str(index)
            FileUtil.replaceFileContent(keepalivedConfFilePath, '<WEIGHT>', str(keystone_weight_counter))
            FileUtil.replaceFileContent(keepalivedConfFilePath, '<STATE>', state)
            FileUtil.replaceFileContent(keepalivedConfFilePath, '<INTERFACE>', keystone_vip_interface)
            FileUtil.replaceFileContent(keepalivedConfFilePath, '<VIRTURL_IPADDR>', keystone_vip)
            pass
        
        ##temporary: if current user is not root
        ShellCmdExecutor.execCmd("sudo chmod 644 %s" % keepalivedConfFilePath)
        
        #If keepalived need to support more VIP: append here
        pass
Ejemplo n.º 28
0
    def configConfFile():
        #use conf template file to replace <CONTROLLER_IP>
        '''
        #modify nova.conf:

[database]
connection=mysql://nova:123456@controller/nova

[DEFAULT]
rpc_backend=rabbit
rabbit_host=<CONTROLLER_IP>
rabbit_password=123456
my_ip=<CONTROLLER_IP>
vncserver_listen=<CONTROLLER_IP>
vncserver_proxyclient_address=<CONTROLLER_IP>
#########
#
rpc_backend=rabbit
rabbit_host=<CONTROLLER_IP>
rabbit_password=123456
my_ip=<CONTROLLER_IP>
vncserver_listen=<CONTROLLER_IP>
vncserver_proxyclient_address=<CONTROLLER_IP>

5).modify nova.conf: set the auth info of keystone:

[DEFAULT]
auth_strategy=keystone

[keystone_authtoken]
auth_uri=http://controller:5000
auth_host=<CONTROLLER_IP>
auth_protocal=http
auth_port=35357
admin_tenant_name=service
admin_user=nova
admin_password=123456
        '''
        mysql_vip = JSONUtility.getValue("mysql_vip")
        mysql_password = JSONUtility.getValue("mysql_password")
        nova_mysql_password = JSONUtility.getValue("nova_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")
        
        glance_vip = JSONUtility.getValue("glance_vip")
        keystone_vip = JSONUtility.getValue("keystone_vip")
        nova_vip = JSONUtility.getValue("nova_vip")
        
        virt_type = JSONUtility.getValue("virt_type")
        
        output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip')
        localIP = output.strip()
        
        print 'nova compute configuration========='
        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 'nova_vip=%s' % nova_vip
        print 'locaIP=%s' % localIP
        
        openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
        nova_api_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-compute', '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("sudo chmod 777 %s" % nova_conf_file_path)
        
        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_HOSTS>', rabbit_hosts)
        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, '<KEYSTONE_VIP>', keystone_vip)
        
        FileUtil.replaceFileContent(nova_conf_file_path, '<GLANCE_VIP>', glance_vip)
        FileUtil.replaceFileContent(nova_conf_file_path, '<VIRT_TYPE>', virt_type)
        FileUtil.replaceFileContent(nova_conf_file_path, '<LOCAL_IP>', localIP)
        FileUtil.replaceFileContent(nova_conf_file_path, '<NOVA_VIP>', nova_vip)
        
        ShellCmdExecutor.execCmd("sudo chmod 644 %s" % nova_conf_file_path)
        
        #configure libvirtd.conf
        libvirtd_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-compute', 'libvirtd.conf')
        libvirtd_conf_file_path = '/etc/libvirt/libvirtd.conf'
        print "libvirtd_conf_template_file_path=%s--" % libvirtd_conf_template_file_path
        
        if os.path.exists(libvirtd_conf_file_path) :
            ShellCmdExecutor.execCmd("rm -rf %s" % libvirtd_conf_file_path)
            pass
        
        ShellCmdExecutor.execCmd('cat %s > /tmp/libvirtd.conf' % libvirtd_conf_template_file_path)
        ShellCmdExecutor.execCmd('mv /tmp/libvirtd.conf /etc/libvirt/')
        
        #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
        pass
Ejemplo n.º 29
0
    def configConfFile():
        '''
        LOCAL_MANAGEMENT_IP
        CINDER_DBPASS
        MYSQL_VIP
        KEYSTONE_VIP
        KEYSTONE_CINDER_PASSWORD
        RABBIT_HOSTS
        RABBIT_PASSWORD
        '''
        ha_vip1 = JSONUtility.getValue("ha_vip1")
        ha_vip2 = JSONUtility.getValue("ha_vip2")
        
        mysql_vip = ha_vip1
        cinder_dbpass = JSONUtility.getValue("cinder_dbpass")
        keystone_cinder_password = JSONUtility.getValue("keystone_cinder_password")
#         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")
        
        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 'rabbit_hosts=%s' % rabbit_hosts
        print 'rabbit_password=%s' % rabbit_password
        print 'keystone_vip=%s' % keystone_vip
        print 'locaIP=%s' % localIP
        
        openstackConfPopertiesFilePath = PropertiesUtility.getOpenstackConfPropertiesFilePath()
        cinder_conf_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'cinder', 'cinder.conf')
        print 'cinder_conf_template_file_path=%s' % cinder_conf_template_file_path
        
        cinderConfDir = PropertiesUtility.getValue(openstackConfPopertiesFilePath, 'CINDER_CONF_DIR')
        print 'cinderConfDir=%s' % cinderConfDir #/etc/cinder
        
        cinder_conf_file_path = os.path.join(cinderConfDir, 'cinder.conf')
        print 'cinder_conf_file_path=%s' % cinder_conf_file_path
        
        if not os.path.exists(cinderConfDir) :
            ShellCmdExecutor.execCmd("sudo mkdir %s" % cinderConfDir)
            pass
        
        ShellCmdExecutor.execCmd("sudo chmod 777 %s" % cinderConfDir)
        
        if os.path.exists(cinder_conf_file_path) :
            ShellCmdExecutor.execCmd("rm -rf %s" % cinder_conf_file_path)
            pass
        
        ShellCmdExecutor.execCmd('cat %s > /tmp/cinder.conf' % cinder_conf_template_file_path)
        ShellCmdExecutor.execCmd('mv /tmp/cinder.conf /etc/cinder/')
        ShellCmdExecutor.execCmd('rm -rf /tmp/cinder.conf')
        
#         ShellCmdExecutor.execCmd('sudo cp -rf %s %s' % (cinder_conf_template_file_path, cinderConfDir))
        ShellCmdExecutor.execCmd("sudo chmod 777 %s" % cinder_conf_file_path)
        
        FileUtil.replaceFileContent(cinder_conf_file_path, '<LOCAL_MANAGEMENT_IP>', localIP)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<MYSQL_VIP>', mysql_vip)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<CINDER_DBPASS>', cinder_dbpass)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<KEYSTONE_VIP>', keystone_vip)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<KEYSTONE_CINDER_PASSWORD>', keystone_cinder_password)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<RABBIT_HOSTS>', rabbit_hosts)
        FileUtil.replaceFileContent(cinder_conf_file_path, '<RABBIT_PASSWORD>', rabbit_password)
        
        ShellCmdExecutor.execCmd("chmod 644 %s" % cinder_conf_file_path)
        ShellCmdExecutor.execCmd("chown -R cinder:cinder %s" % cinder_conf_file_path)
        pass