Exemple #1
0
 def install():
     print 'NeutronServer.install start===='
     #Install Openstack network services
     yumCmd = "yum install openstack-neutron openstack-neutron-ml2 python-neutronclient which -y"
     ShellCmdExecutor.execCmd(yumCmd)
     print 'NeutronServer.install done####'
     pass
Exemple #2
0
 def stopNetworkManager():
     stopCmd = "service NetworkManager stop"
     chkconfigOffCmd = "chkconfig NetworkManager off"
     
     ShellCmdExecutor.execCmd(stopCmd)
     ShellCmdExecutor.execCmd(chkconfigOffCmd)
     pass
Exemple #3
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
Exemple #4
0
 def configConfFile():
     NeutronServer.configNeutronConfFile()
     
     NeutronServer.configML2()
     
     ShellCmdExecutor.execCmd('ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini')
     pass
Exemple #5
0
    def start():
        if debug == True :
            pass
        else :
            dashboard_vip_interface = JSONUtility.getValue("dashboard_vip_interface")
            dashboard_vip = JSONUtility.getValue("dashboard_vip")
            
            DashboardHA.addVIP(dashboard_vip, dashboard_vip_interface)
            
            if DashboardHA.isHAProxyRunning() :
                ShellCmdExecutor.execCmd('service haproxy restart')
            else :
                ShellCmdExecutor.execCmd('service haproxy start')
                pass
            
#             DashboardHA.deleteVIP(dashboard_vip, dashboard_vip_interface)
            
            if DashboardHA.isKeepalivedRunning() :
                ShellCmdExecutor.execCmd('service keepalived restart')
            else :
                ShellCmdExecutor.execCmd('service keepalived start')
                pass
            
            #Ensure only one VIP exists.
            isMasterNode = DashboardHA.isMasterNode()
            if isMasterNode == True :
                DashboardHA.restart()
                pass
            else :
                DashboardHA.deleteVIP(dashboard_vip, dashboard_vip_interface)
                pass
            pass
        ShellCmdExecutor.execCmd('service keepalived restart')
        pass
Exemple #6
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
Exemple #7
0
 def configureEnvVar():
     ShellCmdExecutor.execCmd('export OS_SERVICE_TOKEN=123456')
     template_string = 'export OS_SERVICE_ENDPOINT=http://<KEYSTONE_VIP>:35357/v2.0'
     keystone_vip = JSONUtility.getValue('keystone_vip')
     cmd = template_string.replace('<KEYSTONE_VIP>', keystone_vip)
     ShellCmdExecutor.execCmd(cmd)
     pass
Exemple #8
0
    def install():
        #KEYSTONE_ADMIN_PASSWORD
        print 'Cinder-storage.install start===='
        #
        keystone_vip = JSONUtility.getValue('keystone_vip')
        keystone_admin_password = JSONUtility.getValue('keystone_admin_password')
        print 'start to install prerequisites============='
        script_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 
                                                      'cinder-storage', 
                                                      'cinder_storage_service.sh')
        
        ShellCmdExecutor.execCmd('cp -r %s /opt/' % script_file_path)
        ShellCmdExecutor.execCmd('chmod 777 /opt/cinder_storage_service.sh')
        FileUtil.replaceFileContent('/opt/cinder_storage_service.sh', '<KEYSTONE_VIP>', keystone_vip)
        ShellCmdExecutor.execCmd('bash /opt/cinder_storage_service.sh')
        
        
        ShellCmdExecutor.execCmd("systemctl restart lvm2-lvmetad.service")
        
        #Default create volume
        #Create the LVM physical volume /dev/sdb1:
#         createCmd = 'pvcreate /dev/sdb1' 
#         ShellCmdExecutor.execCmd(createCmd)
        
#         createCmd = 'vgcreate cinder-volumes /dev/sdb1'
#         ShellCmdExecutor.execCmd(createCmd)
       
        yumCmd = 'yum install openstack-cinder targetcli python-oslo-db python-oslo-log MySQL-python -y'
        ShellCmdExecutor.execCmd(yumCmd)
        
        print 'Cinder-storage.install done####'
        pass
Exemple #9
0
 def start():
     if debug == True :
         pass
     else :
         nova_vip_interface = JSONUtility.getValue("nova_vip_interface")
         nova_vip = JSONUtility.getValue("nova_vip")
         
         NovaHA.addVIP(nova_vip, nova_vip_interface)
         
         if NovaHA.isHAProxyRunning() :
             ShellCmdExecutor.execCmd('service haproxy restart')
         else :
             ShellCmdExecutor.execCmd('service haproxy start')
             pass
         
         if NovaHA.isKeepalivedRunning() :
             ShellCmdExecutor.execCmd('service keepalived restart')
         else :
             ShellCmdExecutor.execCmd('service keepalived start')
             pass
         
         #Ensure only one VIP exists.
         isMasterNode = NovaHA.isMasterNode()
         if isMasterNode == True :
             NovaHA.restart()
         else :
             NovaHA.deleteVIP(nova_vip, nova_vip_interface)
         pass
     ShellCmdExecutor.execCmd('service keepalived restart')
     pass
Exemple #10
0
 def start():
     if debug == True :
         pass
     else :
         neutron_vip_interface = JSONUtility.getValue("neutron_vip_interface")
         neutron_vip = JSONUtility.getValue("neutron_vip")
         
         NeutronServerHA.addVIP(neutron_vip, neutron_vip_interface)
         
         if NeutronServerHA.isHAProxyRunning() :
             ShellCmdExecutor.execCmd('service haproxy restart')
         else :
             ShellCmdExecutor.execCmd('service haproxy start')
             pass
         
         if NeutronServerHA.isKeepalivedRunning() :
             ShellCmdExecutor.execCmd('service keepalived restart')
         else :
             ShellCmdExecutor.execCmd('service keepalived start')
             pass
         
         isMasterNode = NeutronServerHA.isMasterNode()
         if isMasterNode == True :
             NeutronServerHA.restart()
             pass
         else :
             NeutronServerHA.deleteVIP(neutron_vip, neutron_vip_interface)
             pass
         pass
     ShellCmdExecutor.execCmd('service keepalived restart')
     pass
Exemple #11
0
    def start():
        if debug == True :
            pass
        else :
            keystone_vip_interface = JSONUtility.getValue("keystone_vip_interface")
            keystone_vip = JSONUtility.getValue("keystone_vip")
            
            KeystoneHA.addVIP(keystone_vip, keystone_vip_interface)
            
            if KeystoneHA.isHAProxyRunning() :
                ShellCmdExecutor.execCmd('service haproxy restart')
            else :
                ShellCmdExecutor.execCmd('service haproxy start')
                pass
            
#             KeystoneHA.deleteVIP(keystone_vip, keystone_vip_interface)
            
            if KeystoneHA.isKeepalivedRunning() :
                ShellCmdExecutor.execCmd('service keepalived restart')
            else :
                ShellCmdExecutor.execCmd('service keepalived start')
                pass
            
            isMasterNode = KeystoneHA.isMasterNode()
            if isMasterNode == True :
                KeystoneHA.restart()
                pass
            else :
                KeystoneHA.deleteVIP(keystone_vip, keystone_vip_interface)
                pass
            pass
        ShellCmdExecutor.execCmd('service keepalived restart')
        pass
Exemple #12
0
 def importKeystoneDBSchema():
     #Before import,detect the database rights for mysql user keystone.
     
     ##
     importCmd = 'su -s /bin/sh -c "keystone-manage db_sync" keystone'
     ShellCmdExecutor.execCmd(importCmd)
     pass
Exemple #13
0
 def installWSGI():
     ShellCmdExecutor.execCmd('mkdir -p /var/www/cgi-bin/keystone')
     main_python_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'keystone', 'main')
     ShellCmdExecutor.execCmd('cp -r %s /var/www/cgi-bin/keystone' % main_python_file_path)
     ShellCmdExecutor.execCmd('cp /var/www/cgi-bin/keystone/main /var/www/cgi-bin/keystone/admin')
     ShellCmdExecutor.execCmd('chown -R keystone:keystone /var/www/cgi-bin/keystone')
     ShellCmdExecutor.execCmd('chmod 755 /var/www/cgi-bin/keystone/*')
     pass
Exemple #14
0
 def install():
     print "Nova.install start===="
     yumCmd = "yum install openstack-nova-api openstack-nova-cert openstack-nova-conductor \
     openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler \
     python-novaclient -y"
     ShellCmdExecutor.execCmd(yumCmd)
     print "Nova.install done####"
     pass
Exemple #15
0
    def install():
        print 'Network.install start===='
        #Install Openstack network services
        yumCmd = "yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch -y"
        ShellCmdExecutor.execCmd(yumCmd)
#         Network.configConfFile()
        print 'Network.install done####'
        pass
 def configureML2():
     ml2ConfTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'nova-compute', 'ml2_conf.ini')
     ShellCmdExecutor.execCmd('cp -r %s /etc/neutron/plugins/ml2/' % ml2ConfTemplatePath)
     
     output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip')
     localIP = output.strip()
     FileUtil.replaceFileContent('/etc/neutron/plugins/ml2/ml2_conf.ini', '<INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS>', localIP)
     pass
Exemple #17
0
    def restart():
#         ShellCmdExecutor.execCmd('/etc/init.d/lvm2-lvmetad restart')
#         ShellCmdExecutor.execCmd('/etc/init.d/tgtd restart')
#         ShellCmdExecutor.execCmd("service openstack-cinder-volume restart")
        initCinderVolumeStorageFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'cinder-storage', 'init_cinder_storage_service.sh')
        print 'initCinderVolumeStorageFilePath=%s---' % initCinderVolumeStorageFilePath
        ShellCmdExecutor.execCmd("bash %s" % initCinderVolumeStorageFilePath)
        pass
Exemple #18
0
 def configML2():
     if os.path.exists(NeutronServer.NEUTRON_ML2_CONF_FILE_PATH) :
         ShellCmdExecutor.execCmd('rm -rf %s' % NeutronServer.NEUTRON_ML2_CONF_FILE_PATH)
         pass
     
     NEUTRON_ML2_CONF_DIR = '/etc/neutron/plugins/ml2/'
     neutron_server_ml2_template_file_path = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'neutron-server', 'ml2_conf.ini')
     ShellCmdExecutor.execCmd('cp -r %s %s' % (neutron_server_ml2_template_file_path, NEUTRON_ML2_CONF_DIR))
     pass
Exemple #19
0
   def install():
       print 'Ceilometer.install start===='
       yumCmd = 'yum install openstack-ceilometer-api openstack-ceilometer-collector \
 openstack-ceilometer-notification openstack-ceilometer-central openstack-ceilometer-alarm \
 python-ceilometerclient -y'
 
       ShellCmdExecutor.execCmd(yumCmd)
       print 'Ceilometer.install done####'
       pass
Exemple #20
0
 def prepareAdminOpenrc():
     adminOpenrcTemplateFilePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'admin-openrc.sh')
     ShellCmdExecutor.execCmd('cp -r %s /opt/openstack_conf' % adminOpenrcTemplateFilePath)
     
     keystone_admin_password = JSONUtility.getValue('keystone_admin_password')
     keystone_vip = JSONUtility.getValue('keystone_vip')
     FileUtil.replaceFileContent('/opt/openstack_conf/admin-openrc.sh', '<KEYSTONE_ADMIN_PASSWORD>', keystone_admin_password)
     FileUtil.replaceFileContent('/opt/openstack_conf/admin-openrc.sh', '<KEYSTONE_VIP>', keystone_vip)
     pass
Exemple #21
0
 def configureDashboardRights():
     if os.path.exists("/var/lib/openstack-dashboard") :
         ShellCmdExecutor.execCmd("chmod 777 /var/lib/openstack-dashboard")
         pass
     
     if os.path.exists("/usr/share/openstack-dashboard/openstack_dashboard/local") :
         ShellCmdExecutor.execCmd("chmod 777 /usr/share/openstack-dashboard/openstack_dashboard/local")
         pass
     pass
Exemple #22
0
 def install():
     print 'Nova.install on compute node start========'
     yumCmd = "yum install openstack-nova-compute -y"
     ShellCmdExecutor.execCmd(yumCmd)
     Nova.configConfFile()
     Nova.start()
     
     Nova.configAfterNetworkNodeConfiguration()
     print 'Nova.install on compute node done####'
     pass
Exemple #23
0
 def start():
     print "start keystone========="
     if debug == True :
         print 'DEBUG=True.On local dev env, do test===='
         pass
     else :
         ShellCmdExecutor.execCmd('service openstack-keystone start')
         ShellCmdExecutor.execCmd('chkconfig openstack-keystone on')
     print "start keystone done####"
     pass
Exemple #24
0
    def restart():
        # support vxlan network mode
        if VXLANConfig.isNeutronServerRole():
            ShellCmdExecutor.execCmd("/etc/init.d/neutron-server restart")
            pass

        if VXLANConfig.isNovaComputeRole() or VXLANConfig.isNeutronAgentRole():
            ShellCmdExecutor.execCmd("/etc/init.d/neutron-openvswitch-agent restart")
            pass
        pass
Exemple #25
0
 def install():
     print 'NeutronServer.install start===='
     #Install Openstack network services
     yumCmd = "yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch python-neutronclient which -y"
     ShellCmdExecutor.execCmd(yumCmd)
     
     NeutronServer.configConfFile()
     #On Controller node, do Nova.configAfterNetworkNodeConfiguration(), Nova.restart()
     print 'NeutronServer.install done####'
     pass
Exemple #26
0
 def sourceAdminOpenRC():
     adminOpenRCScriptPath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'admin_openrc.sh')
     print 'adminOpenRCScriptPath=%s' % adminOpenRCScriptPath
     
     ShellCmdExecutor.execCmd('cp -rf %s /opt/' % adminOpenRCScriptPath)
     
     keystone_vip = JSONUtility.getValue("keystone_vip")
     FileUtil.replaceFileContent('/opt/admin_openrc.sh', '<KEYSTONE_VIP>', keystone_vip)
     time.sleep(2)
     ShellCmdExecutor.execCmd('source /opt/admin_openrc.sh')
     pass
Exemple #27
0
 def deleteVIP(vip, interface):
     result = NovaHA.getVIPFormatString(vip, interface)
     print 'result===%s--' % result
     if NovaHA.isExistVIP(vip, interface) :
         deleteVIPCmd = 'ip addr delete {format_vip} dev {interface}'.format(format_vip=result, interface=interface)
         print 'deleteVIPCmd=%s--' % deleteVIPCmd
         ShellCmdExecutor.execCmd(deleteVIPCmd)
         pass
     else :
         print 'The VIP %s does not exist on interface %s.' % (vip, interface)
         pass
     pass
Exemple #28
0
    def configSysCtlConfFile():
        #Use sysctl conf file template to replace original conf file
        '''
1.modify sysctl.conf
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
        '''
        
        #reload sys configuration
        ShellCmdExecutor.execCmd("sysctl -p")
        pass
Exemple #29
0
    def configure():
        Dashboard.configConfFile()
        
        #assign network connect
        ShellCmdExecutor.execCmd("setsebool -P httpd_can_network_connect on")
        
        #Due to a packaging bug, the dashboard CSS fails to load properly. 
        #Run the following command to resolve this issue:
        ShellCmdExecutor.execCmd("chown -R apache:apache /usr/share/openstack-dashboard/static")
        
#         Dashboard.configHttpdConfFile()
        pass
Exemple #30
0
 def getMeteringSecret():
     if not os.path.exists(Ceilometer.METERING_SECRET_FILE_PATH) :
         output, exitcode = ShellCmdExecutor.execCmd("openssl rand -hex 10")
         meteringSecret = output.strip()
         FileUtil.writeContent(Ceilometer.METERING_SECRET_FILE_PATH, meteringSecret)
         pass
     
     output, exitcode = ShellCmdExecutor.execCmd('cat %s' % Ceilometer.METERING_SECRET_FILE_PATH)
     
     meteringSecret = output.strip()
     
     return meteringSecret