Пример #1
0
 def activate_trial_license(self):
     is_license = self.check_trial_license()
     if not is_license:
         #print "activate trial0 license"
         do_cmd("activate_license -k CLLT3L-CSKKEY-2B1MWZ-TP2FGO-1BL8ZY-FF0U08-CIWNIA -f trial0")
     else:
         print "License existed"
Пример #2
0
 def set_hostname(self, hostname):
     hostname_path = "/etc/hostname"
     cur_hostname = do_cmd("hostname")
     cur_hostname = cur_hostname.rstrip()
     if hostname:
         if hostname != cur_hostname:
             #set hostname
             do_cmd("hostname {}".format(hostname))
             do_cmd("echo {} > {}".format(hostname, hostname_path))
Пример #3
0
 def get_productname(self):
     productNamePath = ("/tmp/productname")
     productnameFileExisted = os.path.isfile(productNamePath)
     if productnameFileExisted:
         productname = do_cmd("cat {}".format(productNamePath))
         productname = productname.rstrip()
     else:
         productname = do_cmd("/promise/bin/amidelnx/amidelnx_26_64 /SP | grep SP |grep \"R\"| sed \'s/.*Done   //\'| awk -F\'\"\' \'{print $2}\' ")
         productname = productname.rstrip()
         os.system("echo {} > {}".format(productname, productNamePath))
     return productname
Пример #4
0
    def check_RAID(self, productname):
#        if productname == A1100_productname:
        if A1100_productname in productname:
            is_OK = do_cmd("cliib -u admin -p password -C array -a list |grep -E '0'.*'OK' |  awk '{ print $2}' | head -n 1")
            is_OK2 = do_cmd("cliib -u admin -p password -C spare |grep -E '0'.*'OK' |  awk '{ print $2}' | head -n 1")
            if is_OK == "OK\n" and is_OK2 == "OK\n":
                return 1
            else:
                return 0
        else:#A1970
            is_VD = do_cmd("{}/check_mcli_array.sh".format(exe_path))
            if is_VD == "VD\nVD\nVD\n":
                return 1
            else:
                return 0
Пример #5
0
 def GET(self):
     api_name = web.ctx.path.split("/")[-1]
     command = os.path.abspath(api_name)
     if os.path.exists(command):
         output = do_cmd(command)
         return ''.join([e.strip() for e in output.splitlines()[1:]])
     else:
         raise web.notfound()
Пример #6
0
 def check_cluster_existed(self):
     enabledRolesFileExisted = os.path.isfile("/etc/ezs3/enabled_roles")
     if enabledRolesFileExisted:
         enabledRoles = do_cmd("cat /etc/ezs3/enabled_roles")
         enabledRoles = enabledRoles.rstrip()
     if enabledRoles == "ezs3 ezgateway" or  enabledRoles == "ezs3":
         return 1
     else: 
         return 0
Пример #7
0
 def activate_perpetual_lic(self, is_connected):
     if is_connected:
         run_license = ""
         run_license = raw_input("Run perpetual license activation?(yes/no, default: no)\n")
         if not run_license:
             run_license = "no"
             print run_license
         if run_license == "yes" or run_license == "y":
             print "retrieving licenese from CRM..."
             logger.info("retrieving licenese from CRM...")
             do_cmd("clm -a retrievelic -t")
             print "activating license..."
             logger.info("activating license...")
             do_cmd("clm -a activatelic")
     else:
         print "\n------------------------------------------------------------------------------------\n"
         print("No access from outside network, please contact PROMISE Tech. for perpetual license.")
         print "\n------------------------------------------------------------------------------------\n"
Пример #8
0
    def create_volume(self):    
        print "creating storage volume..."
        storage_path = "/etc/ezs3/storage.conf"
        storage_path_existed = os.path.isfile(storage_path)
        if not storage_path_existed:
            do_cmd("echo \"[]\" > /etc/ezs3/storage.conf")
        size_storage_file = os.path.getsize('/etc/ezs3/storage.conf')
        #cw = ClusterWizard()#A1100
        #dev_mapper = "222590001553018d6"
        #dev_mapper_path = cw.get_dev_path()
#        if productname == A1100_productname:
        if A1100_productname in productname:
            dev_mapper_path = cw.get_dev_path()
            if (size_storage_file <4):#if /etc/ezs3/storage.conf no storage configuration
                #os.system("/root/cluster_wizard/create_volume -p %s -n %s" %(dev_mapper_path , storage_vol_name))
                if self.check_dev_mapper_A1100():
                    i=0
                    for dmp in dev_mapper_path:
                        os.system("{}/create_volume -p {} -n {}-{}".format(exe_path, dmp , storage_vol_name, i))
                        i = i+1
                        print ""
                    #os.system("./create_volume -p %s -n %s" %(dev_mapper_path , storage_vol_name))
                    #print ""
                    print "Creating storage volume done "
                else:
                    #print "Number of device mapper: {}".format(self.count_dev_mapper())
                    #print "Number of drive: {}".format(self.count_phydrv_A1100())
                    print "Number of device mapper is incorrect, please check it or reboot."
                    sys.exit(0)
            else:
                print "Storage volume exsisted"
        else:#A1970
            dev_mapper_path_A1970 = cw.get_dev_path_A1970()
            if (size_storage_file <4):#if /etc/ezs3/storage.conf no storage configuration
                i=0
                for dmpA in dev_mapper_path_A1970:
                    #do_cmd("/root/cluster_wizard/create_volume -p {} -n {}{}".format(dmpA , storage_vol_name, i))
                    os.system("{}/create_volume -p {} -n {}-{}".format(exe_path, dmpA , storage_vol_name, i))
                    i = i+1
                    print ""
                print "Creating storage volume done "
            else:
                print "Storage volume exsisted"
Пример #9
0
 def count_phydrv_A1100(self):
     phydrv = do_cmd("cliib -u admin -p password -C phydrv")
     #print phydrv
     file_ = open('/tmp/cnt_drv', 'w')
     file_.write("{}".format(phydrv))
     line_count = 0
     file_.close()
     with open('/tmp/cnt_drv') as infp:
         for line in infp:
            if line.strip():
               line_count += 1
     line_count = line_count-3
     logger.info("count_phydrv_A1100: {}".format(line_count))
     return line_count
Пример #10
0
 def set_timezone(self):
     print "Setting timezone..."
     c_timezone = do_cmd("cat /etc/timezone")
     c_timezone = c_timezone.rstrip()
     print ("----------------------------------------------")
     print ("The current timezone is {}".format(c_timezone))
     print ("----------------------------------------------")
     reset_tz = raw_input("Would you like to set timezone? (yes/no, default: no):\n")
     if reset_tz == "yes" or reset_tz == "y":
         os.system("dpkg-reconfigure tzdata")
         #print "restart cron"
         os.system("service cron restart")
         "Setting timezone done"
     else:
         print "No set timezone"
Пример #11
0
 def set_timezone_auto(self):# needs to access outside network
     print "Setting timezone automatically..."
     T_Z = do_cmd("wget -O - -q http://geoip.ubuntu.com/lookup | sed -n -e \'s/.*<TimeZone>\\(.*\\)<\\/TimeZone>.*/\\1/p\'")
     T_Z = T_Z.rstrip()
     os.system("cp /usr/share/zoneinfo/{} /etc/localtime".format(T_Z))
     time.strftime('%X %x %Z')
     os.environ['TZ'] = '{}'.format(T_Z)
     time.tzset()
     time.strftime('%X %x %Z')
     #tz = get_localzone()
     #print "tz: {}".format(tz)
     os.system("echo {} >  /etc/timezone".format(T_Z))
     new_time_zone = self.get_timezone()
     print "Your time zone is {}.".format(new_time_zone)
     #_timezone = do_cmd("cat /etc/timezone")
     print "Setting timezone automatically done..."
Пример #12
0
 def join_cluster(self, join_cluster_name):
     enabledRolesFileExisted = os.path.isfile("/etc/ezs3/enabled_roles")
     if enabledRolesFileExisted:
         enabledRoles = do_cmd("cat /etc/ezs3/enabled_roles")
         enabledRoles = enabledRoles.rstrip()
     if enabledRoles == "ezs3 ezgateway" or  enabledRoles == "ezs3":
         print "cluster existed"
     else:
         print "joining a cluster {}...".format(join_cluster_name)
         #if productname == A1100_productname:
         if A1100_productname in productname:
             #do_cmd("/root/cluster_wizard/join_cluster -p bond0 -s bond1 -n {}").format(join_cluster_name)
             os.system("{}/join_cluster -p bond0 -s bond1 -n {}".format(exe_path, join_cluster_name))
             print "joining a cluster {} done".format(join_cluster_name)
         else: #A1970
             os.system("{}/join_cluster -p bond0 -s bond1 -n {}".format(exe_path, join_cluster_name))
             print "joining a cluster {} done".format(join_cluster_name)
             print ""
Пример #13
0
def rescan_multipath():
    sg = do_cmd("lsscsi -g |grep /dev/sg | grep Promise |awk  '{ print $8}' | cut -c6-8")
    host = do_cmd("ls -l /sys/class/fc_host | grep host | awk '{print $9}'")
    #print s
    sg_l = []
    host_l = []
    host_l.append(host.splitlines()[0])
    host_l.append(host.splitlines()[1])
    sg_l.append(sg.splitlines()[0])
    sg_l.append(sg.splitlines()[1])
    print "echo \"1\" > /sys/class/scsi_generic/sgx/device/delete"
    for l in sg_l:
        do_cmd("echo \"1\" > /sys/class/scsi_generic/{}/device/delete".format(l))
    print "echo \"- - -\" > /sys/class/scsi_host/hostx/scan"
    for k in host_l:
       do_cmd("echo \"- - -\" > /sys/class/scsi_host/{}/scan".format(k))
Пример #14
0
 def get_timezone(self):
     c_timezone = do_cmd("cat /etc/timezone")
     c_timezone = c_timezone.rstrip()
     return c_timezone
Пример #15
0
def rescan_multipath():
    sg = do_cmd("lsscsi -g |grep /dev/sg | grep Promise |awk  '{ print $8}' | cut -c6-8")
    host = do_cmd("ls -l /sys/class/fc_host | grep host | awk '{print $9}'")
    #print s
    sg_l = []
    host_l = []
    host_l.append(host.splitlines()[0])
    host_l.append(host.splitlines()[1])
    sg_l.append(sg.splitlines()[0])
    sg_l.append(sg.splitlines()[1])
    print "echo \"1\" > /sys/class/scsi_generic/sgx/device/delete"
    for l in sg_l:
        do_cmd("echo \"1\" > /sys/class/scsi_generic/{}/device/delete".format(l))
    print "echo \"- - -\" > /sys/class/scsi_host/hostx/scan"
    for k in host_l:
       do_cmd("echo \"- - -\" > /sys/class/scsi_host/{}/scan".format(k))

if __name__ == "__main__":
#    print "destroying node"
#    do_cmd("./destroy_node")
#    print "deleting storage volume"
#    do_cmd("echo \"[]\" > /etc/ezs3/storage.conf ")
#    print "deleting license file"
#    do_cmd("rm /etc/ezs3/license")
#    print "destroying node"
    print "destroying RAID"
    do_cmd("multipath -F")
    do_cmd("cliib -u admin -p password -C array -a del -d 0")
    rescan_multipath()
    print "rescan_multipath done"
Пример #16
0
#!/usr/bin/env python
import os, sys
import json
import StringIO
#from ConfigParser import SafeConfigParser
from ezs3.defaults import BigTeraDefaultSettings as defaults
import logging
from ezs3.log import EZLog
from ezs3.command import do_cmd
from ezs3.log import EZLog
from ezs3.utils import * #define logger
from local_network_config_class import *
from delete_array import *


#logger = EZLog.get_logger(__name__)

if __name__ == "__main__":
    print "destroying node"
    do_cmd("./destroy_node")
    print "deleting storage volume"
    do_cmd("echo \"[]\" > /etc/ezs3/storage.conf ")
    print "deleting license file"
    do_cmd("rm /etc/ezs3/license")
    print "destroying node"
    print "destroying RAID"
    do_cmd("./delete_array.py")
    #do_cmd("cliib -u admin -p password -C array -a del -d 0")
Пример #17
0
 def get_hostname(self):
     hostname = do_cmd("hostname")
     hostname = hostname.rstrip()
     return hostname
Пример #18
0
 def set_RAID(self, productname):	    
     #phdrv_count_A1100 = self.count_phydrv_A1100()
     print "Setting RAID..."
     logger.info("Setting RAID...")
     #if productname == A1100_productname:
     if A1100_productname in productname:
         phdrv_count_A1100 = self.count_phydrv_A1100()
         is_OK_1_array = do_cmd("cliib -u admin -p password -C array -a list |grep -E '0'.*'OK' |  awk '{ print $2}' | head -n 1")
         is_OK_1_spare = do_cmd("cliib -u admin -p password -C spare |grep -E '0'.*'OK' |  awk '{ print $2}' | head -n 1")
         #if is_OK == "OK\n":
         #    print("RAID existed")
         if phdrv_count_A1100 ==16:
             is_OK_1_array = do_cmd("cliib -u admin -p password -C array -a list |grep -E '0'.*'OK' |  awk '{ print $2}' | head -n 1")
             if is_OK_1_array == "OK\n":
                 print("RAID existed")
             else:
                 do_cmd("cliib -u admin -p password -C array -a add -p1~15 -l\\\"raid=5\\\"")
                 self.rescan_multipath()
         elif phdrv_count_A1100 ==32:
             if is_OK_1_array == "OK\n":#need to grep and check 2 OK in the future 
                 print("RAID existed")
             else:
                 do_cmd("cliib -u admin -p password -C array -a add -p1~15 -l\\\"raid=5\\\"")                
                 do_cmd("cliib -u admin -p password -C array -a add -p17~31 -l\\\"raid=5\\\"")
                 self.rescan_multipath()
         elif  phdrv_count_A1100 ==48:
             if is_OK_1_array == "OK\n":#need to grep and check 3 OK in the future 
                 print("RAID existed")
             else:
                 do_cmd("cliib -u admin -p password -C array -a add -p1~15 -l\\\"raid=5\\\"")                
                 do_cmd("cliib -u admin -p password -C array -a add -p17~31 -l\\\"raid=5\\\"")
                 do_cmd("cliib -u admin -p password -C array -a add -p33~47 -l\\\"raid=5\\\"")
                 self.rescan_multipath()
         elif  phdrv_count_A1100 ==64:
             if is_OK_1_array == "OK\n":#need to grep and check 4 OK in the future 
                 print("RAID existed")
             else:
                 do_cmd("cliib -u admin -p password -C array -a add -p1~15 -l\\\"raid=5\\\"")                
                 do_cmd("cliib -u admin -p password -C array -a add -p17~31 -l\\\"raid=5\\\"")
                 do_cmd("cliib -u admin -p password -C array -a add -p33~47 -l\\\"raid=5\\\"")
                 do_cmd("cliib -u admin -p password -C array -a add -p49~63 -l\\\"raid=5\\\"")
                 self.rescan_multipath()
         elif  phdrv_count_A1100 ==13: #test version
             if is_OK_1_array == "OK\n":#need to grep and check 4 OK in the future 
                 print("RAID existed")
             else:
                 do_cmd("cliib -u admin -p password -C array -a add -p5~15 -l\\\"raid=5\\\"")                
                 self.rescan_multipath()
         else:
             print("Physical drives are not enough")
             sys.exit(0)
         #spare drive
         if phdrv_count_A1100 ==16:
             is_OK_1_spare = do_cmd("cliib -u admin -p password -C spare |grep -E '0'.*'OK' |  awk '{ print $2}' | head -n 1")
             if is_OK_1_spare == "OK\n":
                 print("Hot spare drive existed")
             else:
                 do_cmd("cliib -u admin -p password -C spare -a add -p 16 -t g -r y")
         elif phdrv_count_A1100 ==32:
             if is_OK_1_spare == "OK\n":#need to grep and check 2 OK in the future
                 print("Hot spare drive existed")
             else:
                 do_cmd("cliib -u admin -p password -C spare -a add -p 16 -t g -r y")
                 do_cmd("cliib -u admin -p password -C spare -a add -p 32 -t g -r y")
         elif phdrv_count_A1100 ==48:
             if is_OK_1_spare == "OK\n":#need to grep and check 3 OK in the future
                 print("Hot spare drive existed")
             else:
                 do_cmd("cliib -u admin -p password -C spare -a add -p 16 -t g -r y")
                 do_cmd("cliib -u admin -p password -C spare -a add -p 32 -t g -r y")
                 do_cmd("cliib -u admin -p password -C spare -a add -p 48 -t g -r y")
         elif phdrv_count_A1100 ==64:
             if is_OK_1_spare == "OK\n":#need to grep and check 4 OK in the future
                 print("Hot spare drive existed")
             else:
                 do_cmd("cliib -u admin -p password -C spare -a add -p 16 -t g -r y")
                 do_cmd("cliib -u admin -p password -C spare -a add -p 32 -t g -r y")
                 do_cmd("cliib -u admin -p password -C spare -a add -p 48 -t g -r y")
                 do_cmd("cliib -u admin -p password -C spare -a add -p 64 -t g -r y")
         elif phdrv_count_A1100 ==13:#test version
             print ("pd = 13")
             if is_OK_1_spare == "OK\n":#need to grep and check 4 OK in the future
                 print("Hot spare drive existed")
             else:
                 do_cmd("cliib -u admin -p password -C spare -a add -p 16 -t g -r y")
         else:
             print("Physical drives are not enough")
             sys.exit(0)
             
     else:#A1970
         is_VD = do_cmd("{}/check_mcli_array.sh".format(exe_path))
         if is_VD == "VD\nVD\nVD\n":
             print("RAID existed")
         else:
             do_cmd("{}/run_mcli.sh".format(exe_path))
     print "Setting RAID done"
     logger.info("Setting RAID done")
    def set_network(self, pub_ip, netmask_pub_ip,gateway_pub_ip,dns_pub_ip, storage_ip, netmask_storage_ip,  productname, A1100_productname):
        TEST198_IP = 0
        tmp_path = "/tmp/network/interfaces"
        net_path= "/etc/network/interfaces"
        interfaces_exist= os.path.isfile(tmp_path)
        dir_exist = os.path.isdir("/tmp/network")
        if not dir_exist:
            do_cmd("mkdir /tmp/network/")
	if not interfaces_exist:
            do_cmd("touch /tmp/network/interfaces")        
 #       print "productname = %s" % (productname)
#        print pub_ip
        #if productname == A1100_productname:
        if A1100_productname in productname:
	        #turn off eth0~eth3 to avoid avahi issue
            do_cmd("ifconfig eth0 0.0.0.0; ifconfig eth0 down")
            do_cmd("ifconfig eth1 0.0.0.0; ifconfig eth1 down")
            do_cmd("ifconfig eth2 0.0.0.0; ifconfig eth2 down")
            do_cmd("ifconfig eth3 0.0.0.0; ifconfig eth3 down")
            #print productname
            file = open(tmp_path, 'w')
    	    file.write("auto lo eth7 eth6 eth5 eth4 bond0 bond1\n")
			#if TEST198_IP:
			#    file.write("eth0\n")
    	    file.write("iface bond0 inet static\n")
    	    file.write("        bond_miimon 100\n")
    	    file.write("        bond_slaves none\n")
            if dns_pub_ip:
    	        file.write("        dns-nameservers %s\n" % (dns_pub_ip))
    	    file.write("        bond_mode balance-alb\n")
    	    file.write("        address %s \n" % (pub_ip))
    	    file.write("        netmask %s \n" % (netmask_pub_ip))
            if gateway_pub_ip:
                file.write("        gateway %s \n" % (gateway_pub_ip))
    	    file.write("iface bond1 inet static\n")
    	    file.write("        bond_miimon 100\n")
    	    file.write("        bond_slaves none\n")
    	    file.write("        bond_mode balance-alb\n")
    	    file.write("        address %s \n" % (storage_ip))
    	    file.write("        netmask %s \n" % (netmask_storage_ip))
    	    file.write("iface lo inet loopback\n")
    	    file.write("iface eth7 inet manual\n")
    	    file.write("        bond_master bond1\n")
    	    file.write("iface eth6 inet manual\n")
    	    file.write("        bond_master bond1\n")
    	    file.write("iface eth5 inet manual\n")
    	    file.write("        bond_master bond0\n")
    	    file.write("iface eth4 inet manual\n")
    	    file.write("        bond_master bond0\n")
            #if TEST198_IP:
            #     file.write("iface eth0 inet static\n")
            #     file.write("        address 192.168.205.198\n")
            #     file.write("        netmask 255.255.255.0\n")
            #     file.write("        gateway 192.168.205.254\n")
            #     file.write("        dns-nameservers 192.168.202.108\n")
    	    file.close()
        else: #A1970
            file = open(tmp_path, 'w')
            file.write("auto lo eth3 eth2 eth1 eth0 bond0 bond1\n")
            file.write("iface bond0 inet static\n")
            file.write("        bond_miimon 100\n")
            file.write("        bond_slaves none\n")
            if dns_pub_ip:
    	        file.write("        dns-nameservers %s\n" % (dns_pub_ip))
            file.write("        bond_mode balance-alb\n")
            file.write("        address %s \n" % (pub_ip))
            file.write("        netmask %s \n" % (netmask_pub_ip))
            if gateway_pub_ip:
                file.write("        gateway %s \n" % (gateway_pub_ip))
            file.write("iface bond1 inet static\n")
            file.write("        bond_miimon 100\n")
            file.write("        bond_slaves none\n")
            file.write("        bond_mode balance-alb\n")
            file.write("        address %s \n" % (storage_ip))
            file.write("        netmask %s \n" % (netmask_storage_ip))
            file.write("iface lo inet loopback\n")
            file.write("iface eth3 inet manual\n")
            file.write("        bond_master bond1\n")
            file.write("iface eth2 inet manual\n")
            file.write("        bond_master bond1\n")
            file.write("iface eth1 inet manual\n")
            file.write("        bond_master bond0\n")
            file.write("iface eth0 inet manual\n")
            file.write("        bond_master bond0\n")
            file.close()

        tmp_network_interface = do_cmd("cat /tmp/network/interfaces")
        etc_network_interface = do_cmd("cat /etc/network/interfaces")
        if tmp_network_interface != etc_network_interface:
            #print ("copy network interfaces")
	    do_cmd("cp /tmp/network/interfaces /etc/network/interfaces")
	    do_cmd("/etc/init.d/networking restart")
    def set_network_quorum(self, storage_ip, netmask_storage_ip, storage_nic):
        TEST198_IP = 0
        TEST35_IP = 0
        tmp_path = "/tmp/network/interfaces"
        net_path= "/etc/network/interfaces"
        interfaces_exist= os.path.isfile(tmp_path)
        dir_exist = os.path.isdir("/tmp/network")
        if not dir_exist:
            do_cmd("mkdir /tmp/network/")
	if not interfaces_exist:
            do_cmd("touch /tmp/network/interfaces")        
 #       print "productname = %s" % (productname)
#        print pub_ip
        
        if storage_nic =="bond0":
            file = open(tmp_path, 'w')
    	    file.write("auto lo eth5 eth4 bond0\n")
            if TEST35_IP:
                file.write("auto eth0\n")
            if TEST198_IP:
                file.write("auto eth0\n")
    	    file.write("iface bond0 inet static\n")
    	    file.write("        bond_miimon 100\n")
    	    file.write("        bond_slaves none\n")
    	    file.write("        bond_mode balance-alb\n")
    	    file.write("        address %s \n" % (storage_ip))
    	    file.write("        netmask %s \n" % (netmask_storage_ip))
    	    file.write("iface lo inet loopback\n")
    	    file.write("iface eth5 inet manual\n")
    	    file.write("        bond_master bond0\n")
    	    file.write("iface eth4 inet manual\n")
    	    file.write("        bond_master bond0\n")
            if TEST35_IP:
                 file.write("iface eth0 inet static\n")
                 file.write("        address 192.168.205.35\n")
                 file.write("        netmask 255.255.255.0\n")
                 file.write("        gateway 192.168.205.254\n")
                 file.write("        dns-nameservers 192.168.202.108\n")
            if TEST198_IP:
                 file.write("iface eth0 inet static\n")
                 file.write("        address 192.168.205.198\n")
                 file.write("        netmask 255.255.255.0\n")
                 file.write("        gateway 192.168.205.254\n")
                 file.write("        dns-nameservers 192.168.202.108\n")
    	    file.close()
        elif "eth" in straoge_nic:
            file = open(tmp_path, 'w')
            file.write("auto lo eth7 eth6 %s eth4 eth0 bond1\n" %(straoge_nic))
            file.write("iface lo inet loopback\n")
            file.write("iface %s inet static\n" % (storage_nic))
    	    file.write("        address %s \n" % (storage_ip))
    	    file.write("        netmask %s \n" % (netmask_storage_ip))
            if TEST198_IP:
                 file.write("iface eth0 inet static\n")
                 file.write("        address 192.168.205.198\n")
                 file.write("        netmask 255.255.255.0\n")
                 file.write("        gateway 192.168.205.254\n")
                 file.write("        dns-nameservers 192.168.202.108\n")
            if TEST35_IP:
                 file.write("iface eth0 inet static\n")
                 file.write("        address 192.168.205.35\n")
                 file.write("        netmask 255.255.255.0\n")
                 file.write("        gateway 192.168.205.254\n")
                 file.write("        dns-nameservers 192.168.202.108\n")

            
    	    file.close()

        tmp_network_interface = do_cmd("cat /tmp/network/interfaces")
        etc_network_interface = do_cmd("cat /etc/network/interfaces")
        if tmp_network_interface != etc_network_interface:
            #print ("copy network interfaces")
	    do_cmd("cp /tmp/network/interfaces /etc/network/interfaces")
	    do_cmd("/etc/init.d/networking restart")
Пример #21
0
 if is_clus_existed:
     print "Cluster existed"
     print "Exit the wizard"
     sys.exit(0)
 replication = ""
 EZLog.init_handler(
     logging.DEBUG, "/var/log/ezcloudstor/promise.log"
 )
 productname = cw.get_productname()
 print "Running cluster wizard..."
 logger.info("Running cluster wizard...")
 logger.info("Setting Network...")
 lnc = Local_network_config()
 netmask_pub_ip = "255.255.255.0"
 netmask_storage_ip = "255.255.255.0"
 c_pub_ip = do_cmd("/sbin/ifconfig bond0 | grep \'inet addr:\' | cut -d: -f2 | awk \'{ print $1}\'")
 c_pub_ip = c_pub_ip.rstrip()
 current_pub_ip = c_pub_ip.rstrip()
 c_storage_ip = do_cmd("/sbin/ifconfig bond1 | grep \'inet addr:\' | cut -d: -f2 | awk \'{ print $1}\'")
 c_storage_ip = c_storage_ip.rstrip()
 current_storage_ip = c_storage_ip.rstrip()
 hostname = cw.get_hostname()
 new_hostname = raw_input("Please enter a new hostname (e.g., hostname01) or accept the current hostname: {} with Enter.\n".format(hostname))
 if not new_hostname:
     new_hostname = hostname
 lnc.print_pub_ip_description()
 # Input pub IP
 if not current_pub_ip:
     pub_ip = raw_input("Please enter a public IP (e.g., 10.0.0.10):")
     while not cw.is_valid_ipv4_address(pub_ip):
         pub_ip = raw_input("Please enter a valid public IP (e.g., 10.0.0.10):")