Beispiel #1
0
    def place_job(self, host, cpu, mem, io):
        node_dict = {}
        node_dict = GetNodeDict()
        print " DECISION MAKER "
        for key, value in node_dict.iteritems():
            print key, value.max_cpu, value.max_memory, value.max_io, value.avail_cpu, value.avail_memory, value.avail_io
        print " DECISION MAKER END "
        for key, value in node_dict.iteritems():
            if (key == host):
                print "Test Host" + str(value.hostname)
                print value
                print "avail CPU : " + str(value.avail_cpu)
                print ''
                pickleAddOrUpdateDictionary(
                    value.hostname, str(value.ip_address),
                    float(value.max_cpu), float(value.max_memory),
                    float(value.max_io),
                    float(value.avail_cpu) - float(cpu),
                    float(value.avail_memory) - float(mem),
                    float(value.avail_io) - float(io))
                #value.avail_cpu= int(value.avail_cpu) - int(cpu)
                #value.avail_memory = int(value.avail_memory) - int(mem)
                #value.avail_io = int(value.avail_io) -  int(io)

                #Code to update the dictionary again
                #with open('node_dict.pkl','w') as node_pickle_out:
                #	pickle.dump(node_dict,node_pickle_out)
                return value.hostname
        return None
Beispiel #2
0
def setupAll():
	
	cmd= 'python ../setup/bridge_setup.py'
	uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)
	username = '******'
	password = '******'
	
	cmd= '../setup/SSHPasswordless.sh -h '+'localhost'+' -u '+username+' -p '+password
	uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)
	cmd= 'cp -f ../setup/SSHPasswordless.sh /root/'
	uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)
	
	cmd= '../nfs_client_setup.sh'
	uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)

	node_dict=GetNodeDict('../framework/node_dict.pkl')
	all_address = []
	for key, value in node_dict.iteritems() :
		all_address.append(key)
	for node in all_address:
		cmd= '../setup/SSHPasswordless.sh -h '+node+' -u '+username+' -p '+password
		uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)
		cmd= 'scp ../setup/SSHPasswordless.sh root@'+node+':/root/'
		uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)
		cmd= 'scp ../setup/ifcfg* root@'+node+':/root/'
		uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)
		cmd= 'scp ../setup/bridge_setup.py root@'+node+':/root/'
		uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)
	for n in itertools.permutations(all_address, 2):
		cmd= 'ssh root@'+n[0]+' \"/root/SSHPasswordless.sh -h '+n[0]+' -u '+username+' -p '+password+'\"'
		uuid = subprocess.check_output(cmd, shell=True, stderr=subprocess.PIPE)
Beispiel #3
0
	def is_space_available_for_vm(self, cpu, mem, io):
        	node_dict={}
        	node_dict=GetNodeDict()
        	for key, value in node_dict.iteritems() :
            		if ( float(cpu) <= float(value.avail_cpu) and float(	mem) <= float(value.avail_memory) and float(io) <= float(value.avail_io)) :
                		return value.hostname
        	return None
Beispiel #4
0
 def is_mem_available_on_host(self, host, memory):
     node_dict = {}
     node_dict = GetNodeDict()
     for key, value in node_dict.iteritems():
         if key == host:
             if (float(memory) < float(value.avail_memory)):
                 return True
     return False
Beispiel #5
0
 def is_cpu_available_on_host(self, host, cpu):
     node_dict = {}
     node_dict = GetNodeDict()
     for key, value in node_dict.iteritems():
         if key == host:
             if (float(cpu) <= float(value.avail_cpu)):
                 return True
     return False
Beispiel #6
0
	def is_mem_available_on_host(self, host, memory):
        	node_dict={}
        	node_dict=GetNodeDict()
        	for key, value in node_dict.iteritems() :
			if key == host:
           			if ( float(memory) < float(value.avail_memory) ):
           				return True
        	return False
Beispiel #7
0
	def is_cpu_available_on_host(self, host, cpu):
        	node_dict={}
        	node_dict=GetNodeDict()
        	for key, value in node_dict.iteritems() :
			if key == host:
            			if ( float(cpu) <= float(value.avail_cpu) ):
					return True
        	return False
Beispiel #8
0
 def is_space_available_for_vm(self, cpu, mem, io):
     node_dict = {}
     node_dict = GetNodeDict()
     for key, value in node_dict.iteritems():
         if (float(cpu) <= float(value.avail_cpu)
                 and float(mem) <= float(value.avail_memory)
                 and float(io) <= float(value.avail_io)):
             return value.hostname
     return None
def get_overall_pm_utilization(host):
    node_dict = GetNodeDict()
    for key, value in node_dict.iteritems() :
	if key == host:
	    if max(value.avail_cpu, value.avail_memory, value.avail_io)> HIGH:
		print 'HIGH'
	    elif max(value.avail_cpu, value.avail_memory, value.avail_io)> MEDIUM:
		print 'MEDIUM'
	    elif max(value.avail_cpu, value.avail_memory, value.avail_io)> LOW:
		print 'LOW'


                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             def start_server():
Beispiel #10
0
	def place_job(self, host, cpu, mem, io) :
		node_dict={}
		node_dict=GetNodeDict()	
		print " DECISION MAKER "
		for key, value in node_dict.iteritems() :
    			print key, value.max_cpu, value.max_memory, value.max_io, value.avail_cpu, value.avail_memory, value.avail_io
		print " DECISION MAKER END "
		for key, value in node_dict.iteritems() :
			if ( key == host ):
				print "Test Host"+str(value.hostname)
				print value
				print "avail CPU : "+str(value.avail_cpu)
				print ''
				pickleAddOrUpdateDictionary(value.hostname, str(value.ip_address), float(value.max_cpu), float(value.max_memory), float(value.max_io), float(value.avail_cpu) - float(cpu), float(value.avail_memory) - float(mem), float(value.avail_io) -  float(io))			
				#value.avail_cpu= int(value.avail_cpu) - int(cpu)
				#value.avail_memory = int(value.avail_memory) - int(mem)
				#value.avail_io = int(value.avail_io) -  int(io)

				#Code to update the dictionary again
				#with open('node_dict.pkl','w') as node_pickle_out:
    				#	pickle.dump(node_dict,node_pickle_out)
				return value.hostname
		return None
def show_host_info(host_name):
	node_dict = GetNodeDict()
	for node, value in node_dict.iteritems() :
		if node == host_name:
			value = node_dict[host_name]
			print '%s%s' %(str('Host Name:').ljust(30),host_name)
			print '--------------------------------------------'
			print '%s%s' %(str('Host IP:').ljust(30),value.ip_address)
			print '%s%s' %(str('Available CPU [core]:').ljust(30),value.avail_cpu)
			print '%s%s' %(str('Maximum CPU [core]:').ljust(30),value.max_cpu)
			print '%s%s' %(str('Available Memory [KiB]:').ljust(30),value.avail_memory)
			print '%s%s' %(str('Maximum Memory [KiB]:').ljust(30),value.max_memory)
			print '%s%s' %(str('Available Disk Space [KiB]:').ljust(30),value.avail_io)
			print '%s%s' %(str('Maximum Disk Space [KiB]:').ljust(30),value.max_io)
			#print '--------------------------------------------'
			return True
	return False
Beispiel #12
0
def addOrUpdateDictionaryOfVM(hostName, vmid, guest):
    # code to add the dictionary elements
    host_vm_dict = getHostVMDict()
    node_dict = GetNodeDict()

    for key, value in node_dict.iteritems():
        if key not in host_vm_dict:
            host_vm_dict[key] = {}
            # For Testing
            # host_vm_dict[key]={"vm1":Guest("192.168.1.14","vm1", float(1), float(3),float(42424),float(424242),float(1))}
    if guest == None:
        del host_vm_dict[hostName][vmid]
        pickleNodeVMDictionary(host_vm_dict)
    else:
        host_vm_dict[hostName][vmid] = guest
        pickleNodeVMDictionary(host_vm_dict)
    print host_vm_dict
def list_host_domain_information():
	node_dict = GetNodeDict()
	print '----------------------------------------------------------'
	print '%s%s%s%s' %(str('Host Name').ljust(12), str(' Id').ljust(7),str('Domain Name').ljust(32),'Status')
	print '----------------------------------------------------------'
	for node, value in node_dict.iteritems() :
	    #print 'Host Name : '+str(node)
	    host = " "+str(node)+"     "
            #print '-------------------------------------------------'
            list_cmd="virsh --connect qemu+ssh://host_node/system list | tail -n +3 |  sed '/^$/d'  | sed \'s/^/ "+host+"/\'"
	    list_cmd = list_cmd.replace("host_node", node.strip());
	    #print list_cmd
	    #print list_cmd
	    running_domains = subprocess.check_output(list_cmd, shell=True, stderr=subprocess.PIPE)
	    #print running_domains
	    running_domains = "  "+str(running_domains.strip())
	    print(running_domains.decode(sys.stdout.encoding))
            list_cmd="virsh --connect qemu+ssh://host_node/system list | tail -n +3 |  sed '/^$/d'  | sed \'s/^/ "+host+"/\'"
Beispiel #14
0
def addOrUpdateDictionaryOfVM(hostName, vmid, guest):
    #code to add the dictionary elements
    host_vm_dict = getHostVMDict()
    node_dict = GetNodeDict()

    for key, value in node_dict.iteritems():
        if key not in host_vm_dict:
            host_vm_dict[key] = {}

#For Testing
            #host_vm_dict[key]={"vm1":Guest("192.168.1.14","vm1", float(1), float(3),float(42424),float(424242),float(1))}
    if (guest == None):
        del host_vm_dict[hostName][vmid]
        pickleNodeVMDictionary(host_vm_dict)
    else:
        host_vm_dict[hostName][vmid] = guest
        pickleNodeVMDictionary(host_vm_dict)
    print host_vm_dict
def list_host_domain_information():
    node_dict = GetNodeDict()
    print '----------------------------------------------------------'
    print '%s%s%s%s' % (str('Host Name').ljust(12), str(' Id').ljust(7),
                        str('Domain Name').ljust(32), 'Status')
    print '----------------------------------------------------------'
    for node, value in node_dict.iteritems():
        #print 'Host Name : '+str(node)
        host = " " + str(node) + "     "
        #print '-------------------------------------------------'
        list_cmd = "virsh --connect qemu+ssh://host_node/system list | tail -n +3 |  sed '/^$/d'  | sed \'s/^/ " + host + "/\'"
        list_cmd = list_cmd.replace("host_node", node.strip())
        #print list_cmd
        #print list_cmd
        running_domains = subprocess.check_output(list_cmd,
                                                  shell=True,
                                                  stderr=subprocess.PIPE)
        #print running_domains
        running_domains = "  " + str(running_domains.strip())
        print(running_domains.decode(sys.stdout.encoding))
        list_cmd = "virsh --connect qemu+ssh://host_node/system list | tail -n +3 |  sed '/^$/d'  | sed \'s/^/ " + host + "/\'"
def show_host_info(host_name):
    node_dict = GetNodeDict()
    for node, value in node_dict.iteritems():
        if node == host_name:
            value = node_dict[host_name]
            print '%s%s' % (str('Host Name:').ljust(30), host_name)
            print '--------------------------------------------'
            print '%s%s' % (str('Host IP:').ljust(30), value.ip_address)
            print '%s%s' % (str('Available CPU [core]:').ljust(30),
                            value.avail_cpu)
            print '%s%s' % (str('Maximum CPU [core]:').ljust(30),
                            value.max_cpu)
            print '%s%s' % (str('Available Memory [KiB]:').ljust(30),
                            value.avail_memory)
            print '%s%s' % (str('Maximum Memory [KiB]:').ljust(30),
                            value.max_memory)
            print '%s%s' % (str('Available Disk Space [KiB]:').ljust(30),
                            value.avail_io)
            print '%s%s' % (str('Maximum Disk Space [KiB]:').ljust(30),
                            value.max_io)
            #print '--------------------------------------------'
            return True
    return False