当前位置: 首页>>代码示例>>Python>>正文


Python PropertiesUtil.PropertiesUtility类代码示例

本文整理汇总了Python中common.properties.PropertiesUtil.PropertiesUtility的典型用法代码示例。如果您正苦于以下问题:Python PropertiesUtility类的具体用法?Python PropertiesUtility怎么用?Python PropertiesUtility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PropertiesUtility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initNeutron

 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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:26,代码来源:initKeystone.py

示例2: install

 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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:30,代码来源:nova.py

示例3: configureKeystoneHAProxy

    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)
开发者ID:zbwzy,项目名称:fuel-python,代码行数:56,代码来源:dashboardHAProxy.py

示例4: configConfFile

    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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:55,代码来源:keystone.py

示例5: getIndex

 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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:14,代码来源:nova.py

示例6: configureKeepalived

 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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:46,代码来源:nova.py

示例7: getValue

 def getValue(key):
     openstackConfFileDir = PropertiesUtility.getOpenstackConfBaseDir()
     openstack_params_file_path = os.path.join(openstackConfFileDir, "openstack_params.json")
     jsonContent = JSONUtility.getContent(openstack_params_file_path)
     
     try :
         jsonDict = json.loads(jsonContent)
     except Exception, e :
         print 'Exception happens when do json loads file %s' % openstack_params_file_path
         print 'Exception:%s' % str(e)
开发者ID:zbwzy,项目名称:fuel-python,代码行数:10,代码来源:JSONUtil.py

示例8: configConfFile

    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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:41,代码来源:keystone.py

示例9: configConfFile

 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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:23,代码来源:mongodb.py

示例10: initNova

 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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:24,代码来源:initKeystone.py

示例11: configureKeepalived

    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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:73,代码来源:ceilometer.py

示例12: configureHAProxy

    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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:80,代码来源:ceilometer.py

示例13: configConfFile

    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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:76,代码来源:ceilometer.py

示例14: configConfFile

    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
开发者ID:zbwzy,项目名称:fuel-python,代码行数:73,代码来源:heat.py

示例15: configureHAProxy

    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
#.........这里部分代码省略.........
开发者ID:zbwzy,项目名称:fuel-python,代码行数:101,代码来源:nova.py


注:本文中的common.properties.PropertiesUtil.PropertiesUtility类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。