示例#1
0
 def run(self):
     import lease
     self.dbthr.postinit()
     for thr in [ self.svrthr, self.sslsvrthr, self.dbthr, self.httpsvrthr ]:
         thr.start()
     heartbeat = 0
     gm = gmetric.gmetric()
     gaddr = self.conf.gangliaaddr
     gport = self.conf.gangliaport
     gheartbeat = self.conf.gangliaheartbeat
     nodemgr_tag = self.conf.nodemgr_tag
     leases_tag = self.conf.leases_tag
     slivers_tag = self.conf.slivers_tag
     while 1:
         now = time.asctime(time.gmtime())
         leases = ""
         for leasedata in self.dbthr.getleases():
             l = lease.lease(leasedata)
             leases = leases + " " + l.slice
         leases = leases.strip()
         slivers = ""
         for s in self.dbthr.getslivers():
             slivers = slivers + " " + s
         slivers = slivers.strip()
         gm.sendsimple(gaddr, gport, nodemgr_tag, `heartbeat`, gheartbeat, gheartbeat)
         if leases != "": 
             gm.send(gaddr, gport, leases_tag, leases, gheartbeat, gheartbeat, self.ip)
         if slivers != "": 
             gm.send(gaddr, gport, slivers_tag, slivers, gheartbeat, gheartbeat, self.ip)
         time.sleep(gheartbeat)
         heartbeat += 1
示例#2
0
 def updateslices(self):
     """Extract names of active slices (allocated VMs) on PlanetLab"""
     import gmetric, string
     slices = {}
     metric = gmetric.gmetric()
     ipstoslices = metric.recvall(self.host, self.port, self.slivers_tag)
     slicestoips = {}
     for ip in ipstoslices.keys():
         ipstoslices[ip] = string.split(ipstoslices[ip])
         for slice in ipstoslices[ip]:
             if slice not in slicestoips:
                 slicestoips[slice] = [ ip ]
             else:
                 slicestoips[slice].append(ip)
     self.lock.acquire()
     self.ipstoslices = ipstoslices
     self.slicestoips = slicestoips
     self.lock.release()
示例#3
0
 def updateleases(self):
     """Extract names of active leases on PlanetLab"""
     import gmetric, string
     leases = {}
     metric = gmetric.gmetric()
     ipstoleases = metric.recvall(self.host, self.port, self.leases_tag)
     leasestoips = {}
     for ip in ipstoleases.keys():
         ipstoleases[ip] = string.split(ipstoleases[ip])
         for lease in ipstoleases[ip]:
             if lease not in leasestoips:
                 leasestoips[lease] = [ ip ]
             else:
                 leasestoips[lease].append(ip)
     self.lock.acquire()
     self.ipstoleases = ipstoleases
     self.leasestoips = leasestoips
     self.lock.release()
示例#4
0
 def updateslices(self):
     """Extract names of active slices (allocated VMs) on PlanetLab"""
     import gmetric, string
     slices = {}
     metric = gmetric.gmetric()
     ipstoslices = metric.recvall(self.host, self.port, self.slivers_tag)
     slicestoips = {}
     for ip in ipstoslices.keys():
         ipstoslices[ip] = string.split(ipstoslices[ip])
         for slice in ipstoslices[ip]:
             if slice not in slicestoips:
                 slicestoips[slice] = [ip]
             else:
                 slicestoips[slice].append(ip)
     self.lock.acquire()
     self.ipstoslices = ipstoslices
     self.slicestoips = slicestoips
     self.lock.release()
示例#5
0
 def updateleases(self):
     """Extract names of active leases on PlanetLab"""
     import gmetric, string
     leases = {}
     metric = gmetric.gmetric()
     ipstoleases = metric.recvall(self.host, self.port, self.leases_tag)
     leasestoips = {}
     for ip in ipstoleases.keys():
         ipstoleases[ip] = string.split(ipstoleases[ip])
         for lease in ipstoleases[ip]:
             if lease not in leasestoips:
                 leasestoips[lease] = [ip]
             else:
                 leasestoips[lease].append(ip)
     self.lock.acquire()
     self.ipstoleases = ipstoleases
     self.leasestoips = leasestoips
     self.lock.release()