Пример #1
0
 def install():
     #######prerequisites
     ###do bond: refactor later
     
     #########################
     
     ###bind bclinux repo url
     
     ########################
     
     ShellCmdExecutor.execCmd('yum clean all && yum makecache')
     
     ShellCmdExecutor.execCmd('yum install tar -y')
     
     #memcache
     from openstack.kilo.memcached.memcached import Memcached
     Memcached.install()
     Memcached.start()
     
     #ssh root user mutual trust
     print 'do ssh mutual trust====='
     SSH.sshMutualTrust()
     print 'do ssh mutual trust#####'
     #iptables
     IPTables.apply()
     
     #keep log on disk
     print 'do keep log on disk======='
     ShellCmdExecutor.execCmd('mkdir -p /var/log/journal')
     ShellCmdExecutor.execCmd('systemctl restart systemd-journald')
     print 'do keep log on disk####'
     
     #sysctl
     print 'do sysctl============='
     sysctlConfFileTemplatePath = os.path.join(OPENSTACK_CONF_FILE_TEMPLATE_DIR, 'sysctl', 'sysctl.conf')
     ShellCmdExecutor.execCmd('cp -r %s /etc/' % sysctlConfFileTemplatePath)
     ShellCmdExecutor.execCmd('sysctl -p')
     print 'do sysctl####'
     
     #######produce params
     print 'produce openstack params========'
     ParamsProducer.produce()
     print 'done to produce openstack params####'
     pass
Пример #2
0
 def start():
     from openstack.common.serverSequence import ServerSequence
     mysql_ips = JSONUtility.getValue("mysql_ips")
     print 'mysql_ips=%s---' % mysql_ips
     mysql_ip_list = mysql_ips.strip().split(',')
     print 'mysql_ip_list=%s--' % mysql_ip_list
     
     output, exitcode = ShellCmdExecutor.execCmd('cat /opt/localip')
     local_management_ip = output.strip()
     
     index = ServerSequence.getIndex(mysql_ip_list, local_management_ip)
     print 'mysql index=%s--' % str(index)
     #Judge master
     if not os.path.exists('/opt/openstack_conf/tag/') :
         ShellCmdExecutor.execCmd('mkdir -p /opt/openstack_conf/tag/')
         pass
     
     from openstack.kilo.ssh.SSH import SSH
     if index == 0 :
         print 'start to launch mysql master==============='
         start_cmd = '/opt/bcrdb/support-files/mysql.server bootstrap'
         ShellCmdExecutor.execCmd(start_cmd)
         
         #Mutual trust has been established when execute prerequisites.py, then send tag to the rest bcrdb servers
         #to mark that the first bcrdb server has been launched.
         tag_file_name = 'bcrdb_0' #The first server of bcrdb cluster
         #mark master
         mark_cmd = 'touch /opt/openstack_conf/tag/{file}'.format(file=tag_file_name)
         os.system(mark_cmd)
         #mark slave
         slave_mysql_server_list = mysql_ip_list[1:]
         for slave_ip in slave_mysql_server_list :
             SSH.sendTagTo(slave_ip, tag_file_name)
             pass
         
         keystone_ips = JSONUtility.getValue("keystone_ips")
         keystone_ip_list = keystone_ips.strip().split(',')
         #send tag to first server of keystone cluster
         SSH.sendTagTo(keystone_ip_list[0], tag_file_name)
         pass
     else :
         print 'start to launch mysql slave================'
         #wait bcrdb first server launched
         file_path = '/opt/openstack_conf/tag/bcrdb_0'
         time_count = 0
         while True:
             flag = os.path.exists(file_path)
             if flag == True :
                 print 'wait time: %s second(s).' % time_count
                 print 'If first mysql is launched,then start mysql slave========='
                 start_cmd = '/opt/bcrdb/support-files/mysql.server start'
                 ShellCmdExecutor.execCmd(start_cmd)
                 print 'done to start mysql slave######'
                 break
             else :
                 step = 1
     #             print 'wait %s second(s)......' % step
                 time_count += step
                 time.sleep(1)
                 pass
             
             if time_count == BCRDB.TIMEOUT :
                 print 'Do nothing!timeout=%s.' % BCRDB.TIMEOUT
                 break
             pass
         
         #send tag to the first server of keystone cluster:
         #when all servers are launched,keystone is used to register info to RDB.
         index = ServerSequence.getIndex(mysql_ip_list, local_management_ip)
         tag_file_name = 'bcrdb_{index}'.format(index=str(index))
         print 'slave mysql tag_file_name=%s' % tag_file_name
         SSH.sendTagTo(keystone_ip_list[0], tag_file_name)
         
         print 'send tag to first mysql===='
         SSH.sendTagTo(mysql_ip_list[0], tag_file_name)
         print 'done to send tag to first mysql####'
         pass
     pass
Пример #3
0
             break
         else :
             step = 1
 #             print 'wait %s second(s)......' % step
             time_count += step
             time.sleep(1)
             pass
         
         if time_count == timeout :
             print 'Do nothing!timeout=%s.' % timeout
             break
         pass
     
     if len(neutron_ip_list) > 1 :
         for neutron_ip in neutron_ip_list[1:] :
             SSH.sendTagTo(neutron_ip, first_neutron_launched_mark_file)
             pass
         pass
     
     NeutronServer.start()
     pass
 else :
     timeout = TIMEOUT
     time_count = 0
     print 'test timeout==='
     while True:
         #first neutron server is launched
         flag = os.path.exists(first_neutron_launched_mark_file)
         if flag == True :
             print 'wait time: %s second(s).' % time_count
             NeutronServer.start()
Пример #4
0
                    break
                else:
                    step = 1
                    #             print 'wait %s second(s)......' % step
                    time_count += step
                    time.sleep(1)
                    pass

                if time_count == timeout:
                    print "Do nothing!timeout=%s." % timeout
                    break
                pass

            if len(nova_ip_list) > 1:
                for nova_ip in nova_ip_list[1:]:
                    SSH.sendTagTo(nova_ip, first_nova_launched_mark_file)
                    pass
                pass

            Nova.start()
            pass
        else:
            timeout = TIMEOUT
            time_count = 0
            print "test timeout==="
            while True:
                # first nova controller is launched
                flag = os.path.exists(first_nova_launched_mark_file)
                if flag == True:
                    print "wait time: %s second(s)." % time_count
                    Nova.start()
Пример #5
0
             pass
         
         if time_count == timeout :
             print 'Do nothing!timeout=%s.' % timeout
             break
         pass
     
     Glance.start()
     
     #To send to the rest glance
     glance_ips = JSONUtility.getValue('glance_ips')
     glance_ip_list = glance_ips.split(',')
     
     if len(glance_ip_list) > 1 :
         for glance_ip in glance_ip_list[1:] :
             SSH.sendTagTo(glance_ip, first_glance_launched_mark_file)
             pass
         pass
     
     ###########
     pass
 else :
     TIMEOUT = 1800 #0.5 hour for test
     timeout = TIMEOUT
     time_count = 0
     print 'test timeout==='
     while True:
         flag = os.path.exists(first_glance_launched_mark_file)
         if flag == True :
             print 'wait time: %s second(s).' % time_count
             Glance.start()
Пример #6
0
 
 Keystone.installWSGI()
 
 Keystone.startHttp()
 
 if Keystone.getServerIndex() == 0 :
     from openstack.kilo.keystone.initKeystone import InitKeystone
     InitKeystone.init()
     
     tag_file_name = 'keystone0_launched'
     from common.yaml.YAMLUtil import YAMLUtil
     #send to first glance
     if YAMLUtil.hasRoleInNodes('glance'):
         glance_ips = JSONUtility.getValue('glance_ips')
         glance_ip_list = glance_ips.split(',')
         SSH.sendTagTo(glance_ip_list[0], tag_file_name)
     
     #send to first neutron-server
     if YAMLUtil.hasRoleInNodes('neutron-server'):
         neutron_ips = JSONUtility.getValue('neutron_ips')
         neutron_ip_list = neutron_ips.split(',')
         SSH.sendTagTo(neutron_ip_list[0], tag_file_name)
     
     #send to first nova-api
     if YAMLUtil.hasRoleInNodes('nova-api'):
         nova_ips = JSONUtility.getValue('nova_ips')
         nova_ip_list = nova_ips.split(',')
         SSH.sendTagTo(nova_ip_list[0], tag_file_name)
         
     #send to first cinder
     if YAMLUtil.hasRoleInNodes('cinder'):
Пример #7
0
             break
         else :
             step = 1
 #             print 'wait %s second(s)......' % step
             time_count += step
             time.sleep(1)
             pass
         
         if time_count == timeout :
             print 'Do nothing!timeout=%s.' % timeout
             break
         pass
     
     if len(cinder_ip_list) > 1 :
         for cinder_ip in cinder_ip_list[1:] :
             SSH.sendTagTo(cinder_ip, first_cinder_launched_mark_file)
             pass
         pass
     
     Cinder.start()
     pass
 else :
     timeout = TIMEOUT
     time_count = 0
     print 'test timeout==='
     while True:
         #first neutron server is launched
         flag = os.path.exists(first_cinder_launched_mark_file)
         if flag == True :
             print 'wait time: %s second(s).' % time_count
             Cinder.start()