Ejemplo n.º 1
0
	def synchronize(self):
		try:
			if not self.topology_element and not self.topology_connection:
				self.remove()
				return
			self.updateInfo()
		except:
			logging.logException(host=self.host.name)
Ejemplo n.º 2
0
def synchronizeHost(host):
	#TODO: implement more than resource sync
	try:
		host.update()
		host.synchronizeResources()
	except:
		logging.logException(host=host.address)
		print "Error updating information from %s" % host
	host.checkProblems()
Ejemplo n.º 3
0
def handleError(error, function, args, kwargs):
	if isinstance(error, xmlrpclib.Fault):
		fault.errors_add(error, traceback.format_exc())
	else:
		if not (isinstance(error, TypeError) and function.__name__ in str(error)):
			# not a wrong API call
			fault.errors_add(error, traceback.format_exc())
		logging.logException()
		return fault.wrap(error)
Ejemplo n.º 4
0
	def getAllowedActions(self):
		try:
			caps = self.host.getElementCapabilities(self.type)["actions"]
			res = []
			for key, states in caps.iteritems():
				if self.state in states:
					res.append(key)
			return res
		except:
			self.host.incrementErrors()
			logging.logException(host=self.host.address)
			return []
Ejemplo n.º 5
0
def synchronize():
    logging.logMessage("sync begin", category="accounting")        
    from . import host, elements, connections, topology
    now = time.time()
    for h in host.getAll():
        try:
            h.updateAccountingData(now)
        except:
            logging.logException(host=h.address)
            print "Error fetching accounting data from %s" % h
    for el in elements.getAll():
        el.updateUsage(now-900)
    for con in connections.getAll():
        con.updateUsage(now-900)
    for top in topology.getAll():
        top.updateUsage(now-900)
    logging.logMessage("sync end", category="accounting")        
Ejemplo n.º 6
0
def synchronizeHost(host):
	with checkingHostsLock:
		if host in checkingHosts:
			return
		checkingHosts.add(host)
	try:
		try:
			host.update()
			host.synchronizeResources()
			host.updateAccountingData()
		except:
			import traceback

			traceback.print_exc()
			logging.logException(host=host.name)
			print "Error updating information from %s" % host
		host.checkProblems()
	finally:
		with checkingHostsLock:
			checkingHosts.remove(host)
Ejemplo n.º 7
0
def handleError():
    import traceback
    traceback.print_exc()
    dump.dumpException()
    logging.logException()
Ejemplo n.º 8
0
def handleError():
    logging.logException()
Ejemplo n.º 9
0
	def synchronize(self):
		try:
			self.updateInfo()
		except:
			logging.logException(host=self.host.address)
Ejemplo n.º 10
0
		for el in elements.getAll():
			if self in el.getHostElements():
				return ("element", el.id)
		for con in connections.getAll():
			if self in el.getHostElements():
				return ("connection", con.id)
		return (None, None)
	
	def synchronize(self):
		try:
			self.modify({"timeout": time.time() + 14 * 24 * 60 * 60})
		except xmlrpclib.Fault, f:
			if f.faultCode != fault.UNSUPPORTED_ATTRIBUTE:
				raise
		except:
			logging.logException(host=self.host.address)
		
class HostConnection(attributes.Mixin, models.Model):
	host = models.ForeignKey(Host, null=False, related_name="connections")
	num = models.IntegerField(null=False) #not id, since this is reserved
	usageStatistics = models.OneToOneField(UsageStatistics, null=True, related_name='+')
	attrs = db.JSONField()
	elements = attributes.attribute("elements", list)
	state = attributes.attribute("state", str)
	type = attributes.attribute("type", str) #@ReservedAssignment
	
	class Meta:
		unique_together = (("host", "num"),)

	def modify(self, attrs):
		logging.logMessage("connection_modify", category="host", host=self.host.address, id=self.num, attrs=attrs)
Ejemplo n.º 11
0
def handleError():
	logging.logException()
	dump.dumpException()
Ejemplo n.º 12
0
def handleError():
	import traceback
	traceback.print_exc()
	dump.dumpException()
	logging.logException()