Пример #1
0
	def releaseIp(self,ipObj):
		'''
		Releases an IP address of the range (but it does not destroy the object!!)	
		'''
		with MutexStore.getObjectLock(self.getLockIdentifier()):
			ipStr = ipObj.getIp()
			if not self.ips.filter(ip=ipStr,isExcluded=False).count() > 0:
				raise Exception("Cannot release Ip %s. Reason may be is unallocated or is an excluded Ip",ipStr)
					
			self.ips.remove(ipObj)
				
			#Determine new available Ip
			if not self.nextAvailableIp == None:
				if IP4Utils.compareIps(ipStr,self.nextAvailableIp) > 0:
					#Do nothing
					pass
				else:	
					self.nextAvailableIp = ipStr
			else:
				#No more gaps
				self.nextAvailableIp = ipStr

			self.autoSave()
Пример #2
0
	def removeExcludedIp(self,ipObj):
		'''
		Deletes an IP from the exclusion list (but it does not destroy the object!!)
		'''	
		with MutexStore.getObjectLock(self.getLockIdentifier()):
			ipStr = ipObj.getIp()
			if not self.ips.get(ip=ipStr).isExcludedIp():
				raise Exception("Cannot release Ip. Reason may be is unallocated or is not excluded Ip")
	
			self.ips.remove(ipObj)

			#Determine new available Ip
			if not self.nextAvailableIp == None:
				if IP4Utils.compareIps(ipStr,self.nextAvailableIp) > 0:
					#Do nothing
					pass
				else:	
					self.nextAvailableIp = ipStr
			else:
				#No more gaps
				self.nextAvailableIp = ipStr

	
			self.autoSave()