예제 #1
0
    def DatabaseSubsystemCreateVM(self, req):
       
        # use vm_num to decide how to round robin to Rack
        # 3 is number of machines, replace with len(Machine_list)        
        if req.vm_num == 1:
            self.round_robin_machine = (self.round_robin_machine + 1) % 3 
        ### use hypervisor to replace!!!

        try:
            msg = Message.ClusterVirtualMachineManagerCreateVMreq(
                    vm_id = req.vm_id,
                    group_num =  req.group_num,
                    vm_num =  req.vm_num,
                    vm_name =  req.vm_name,
                    owner =  req.owner,
                    type =  req.type,
                    cpu =  req.cpu,
                    mem =  req.mem,
                    disk =  req.disk,
                    )
        
            rack_address = 'roystonea02', 9600
            sendonly_message(rack_address, msg) 
            
        except socket.error as e:
            print 'socket error'
            sleep(5)
예제 #2
0
파일: PMM.py 프로젝트: ot32em/Roystonea
    def sendStartupRequest(self, entry) :
    #''' ===== still have prombles I need to debug ===== '''
        print("Send request to {addr}".format( addr = entry.strAddr() ))

        script_dir = '/mnt/images/nfs/new_roystonea_script/roystonea_script/'
        script_file = self.convnameType2Script(entry.level)
        script_ab_file = script_dir + script_file
        log_ab_file = script_dir + "log/{host}-{port}-printout.txt".format(host=entry.host, port=entry.port);
        ssh_cmd = "nohup python {script_absolute_filepath} {host} {port} console_off > {log_ab} &".format( script_absolute_filepath = script_ab_file, host=entry.host, port=entry.port, log_ab=log_ab_file )
 
        print( ssh_cmd)

        account = 'ot32em'
        passwd = ''
        remote = pxssh.pxssh()
        t = remote.login( entry.host, account, passwd )
        print("Login done")
        remote.sendline( ssh_cmd )
        remote.prompt()
        remote.logout()
    
        print("Update the PM Relation to {host}:{port}.".format(host=entry.host, port=entry.port) )
        entry.dump_pretty()
        req = Message.CmdUpdatePMRelationReq(pm_relation=entry)
        res = Client.send_message( entry.addr, req )
예제 #3
0
 def shutdown(self, req):
     # execute xm shutdown req.vm_id
     shutdown = "xm shutdown " + str(req.vm_id)
     pexpect.run(shutdown)
     msg = Message.ShutdownRes(msg="Success",
                               hostname=req.node,
                               vm_id=req.vm_id)
     Client.sendonly_message(self.server.pm_relation.parent_addr)
예제 #4
0
 def RackVirtualMachineManagerCreateVM(self, req):
     msg = Message.ClusterDatabaseSubsystemCreateVMres(
             vm_id = req.vm_id,
             status = req.status
             )
     
     coordinator_address = 'roystonea01', 9000
     sendonly_message(coordinator_address, msg)
예제 #5
0
    def HypervisorReqHandler(self, request):
        print request

        if request.type == 'ubuntu':
            VM_initializer = VM_initializer_ubuntu(request.id, request.owner,
                                                   request.group_num,
                                                   request.vm_num, request.mem,
                                                   request.disk, request.cores,
                                                   request.hostmachine)
            VM_initializer.start()

        res = Message.NodeHypervisorRt(status='Success',
                                       msg=str(request.id) + '-' +
                                       request.owner,
                                       vm_id=request.id)
        print res.status
        print res.msg
        print request.id

        Client.sendonly_message(self.server.pm_relation.parent_addr, res)
예제 #6
0
class CloudCoordinator():
    def GetAvailableClusters(self, req, cfg):
        import _mysql
        list_avc = []
        try:
            db = _mysql.connect(host=cfg.rest.get('CloudDBIp'),
                                user=cfg.rest.get('CloudDBUsername'),
                                passwd=cfg.rest.get('CloudDBPassword'),
                                db=cfg.rest.get('CloudDBName'))
            sql_query = "SELECT * FROM %s WHERE state='available' ORDER BY id"\
                 %(cfg.rest.get('CloudDBClustersTb'))
            db.query(sql_query)
            req_res = db.store_result()
            list_avc = [x[1] for x in req_res.fetch_row(0)]
        except Exception, e:
            print str(e)

        x = Message.GetAvailableClustersRt(
            msg='i am GAC' + ' ' + cfg.rest['CloudComponentsPath'] + req.auth,
            status='good',
            avClusters=list_avc)
        return x
예제 #7
0
import socket
import pickle
from scripts.include import Message

HOST, PORT = "localhost", 7004

# Create a socket (SOCK_STREAM means a TCP socket)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))

req1 = Message.ClusterVirtualMachineManagerReq(id='86888',
                                               name='me',
                                               owner='elalic',
                                               type='gentoo',
                                               mem=4,
                                               disk=20,
                                               cores=4)
req3 = Message.GetAvailableClustersReq(auth='i am Cloud_client')
data = pickle.dumps(req3)
sock.send(data)
sock.shutdown(socket.SHUT_WR)

# Receive data from the server and shut down
received = ''
input = True
while input:
    input = sock.recv(1024)
    received += input
ret = pickle.loads(received)
sock.close()
예제 #8
0
    def GetAvailablePhysicalMachine(self, req, cfg):
        import _mysql

        x = Message.GetAvailablePhysicalMachineRt(
            msg='i am GAPM' + ' ' + cfg.rest['ClusterBalancerPath'] + req.auth)
        return x
예제 #9
0
 def GetAvailableVirtualMachinePrototype(self, req, cfg):
     return Message.GetAvailableVirtualMachinePrototypeRt(
         msg='i am GAVMP: ' + req.auth)
예제 #10
0
 def CreateVmByCluster(self, CreateVmByClusterReq):
     destRack = self.selectRackByAlgorithm(vm)
     CreateVmByRackReq = Message.CreateVmByRackReq(vm)
     Client.sendonly( CreateVmByRackReq, DestRack.address)
예제 #11
0
            'DatabaseSubsystemCreateVMreq': self.DatabaseSubsystemCreateVM,
            'RackVirtualMachineManagerCreateVMres': self.RackVirtualMachineManagerCreateVM,
        })
        self.startup_functions.extend((
            self.sayHello, # hello function 
        ))
   
    # @author ot32em
    def CreateVmByCluster(self, CreateVmByClusterReq):
        destRack = self.selectRackByAlgorithm(vm)
        CreateVmByRackReq = Message.CreateVmByRackReq(vm)
        Client.sendonly( CreateVmByRackReq, DestRack.address)

    # @author ot32em
    def selectRackByAlgorithm(self, vm)
        selectRackReq = Message.SelectRackReq(vm)
        selectRackRes = Client.send( selectRrackReq, algorithm.address )
        return selectRackRes.rack
        
    def DatabaseSubsystemCreateVM(self, req):
       
        # use vm_num to decide how to round robin to Rack
        # 3 is number of machines, replace with len(Machine_list)        
        if req.vm_num == 1:
            self.round_robin_machine = (self.round_robin_machine + 1) % 3 
        ### use hypervisor to replace!!!

        try:
            msg = Message.ClusterVirtualMachineManagerCreateVMreq(
                    vm_id = req.vm_id,
                    group_num =  req.group_num,
예제 #12
0
import socket
import pickle
from scripts.include import Message

HOST, PORT = "localhost", 7003

# Create a socket (SOCK_STREAM means a TCP socket)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))

req1 = Message.ClusterVirtualMachineManagerReq(id='86888',
                                               name='me',
                                               owner='elalic',
                                               type='gentoo',
                                               mem=4,
                                               disk=20,
                                               cores=4)
req3 = Message.GetAvailablePhysicalMachineReq(auth='hi')
data = pickle.dumps(req3)
sock.send(data)
sock.shutdown(socket.SHUT_WR)

# Receive data from the server and shut down
received = ''
input = True
while input:
    input = sock.recv(1024)
    received += input
ret = pickle.loads(received)
sock.close()
예제 #13
0
파일: PMM.py 프로젝트: ot32em/Roystonea
 def sendShutdownRequest(self, entry) :  
     cmdreq = Message.CmdShutdownReq(after_secs=0)
     cmdres = Client.send_object( entry.addr, cmdreq )
예제 #14
0
파일: PMM.py 프로젝트: ot32em/Roystonea
 def sendReconfigRequest(self, entry) :    # reconfig
     cmdreq = Message.CmdSetPMRelationReq(pm_relation=entry)
     cmdres = Client.send_object( entry.addr, cmdreq )
예제 #15
0
import socket
import pickle
from scripts.include import Message

HOST, PORT = "localhost", 7001

# Create a socket (SOCK_STREAM means a TCP socket)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))

req1 = Message.NodeHypervisorReq(id='86888',
                                 name='me',
                                 owner='elalic',
                                 type='gentoo',
                                 mem=4,
                                 disk=20,
                                 cores=4)
req2 = Message.NodeStorageReq()
data = pickle.dumps(req1)
sock.send(data)
sock.shutdown(socket.SHUT_WR)

# Receive data from the server and shut down
received = ''
input = True
while input:
    input = sock.recv(1024)
    received += input
ret = pickle.loads(received)
sock.close()
예제 #16
0
def RackBalancer(req):
    return Message.RackHypervisorRt(status='good',
                                    msg='i am RB ' + str(req.name) * 3)
예제 #17
0
def ClusterBalancer(req):
	return Message.ClusterHyperVisorRt(status='Cool', msg=str(req.name)*3)