Esempio n. 1
0
	def addExcludedIp(self,ipStr,comment):
		'''
		Add an IP to the exclusion list	
		'''
		with MutexStore.getObjectLock(self.getLockIdentifier()):
			#Check is not already allocated
			if not  self.__isIpAvailable(ipStr):
				raise Exception("Ip already allocated or marked as excluded")

			#then forbidd
			if not IP4Utils.isIpInRange(ipStr,self.startIp,self.endIp):
				raise Exception("Ip is not in range")
			newIp = Ip4Slot.excludedIpFactory(self,ipStr,comment)
			self.ips.add(newIp)

			#if was nextSlot shift
			if self.nextAvailableIp == ipStr:
				try:
                        		it= IP4Utils.getIpIterator(self.nextAvailableIp,self.endIp,self.netMask)
					while True:
						ip = it.getNextIp()
						if self.__isIpAvailable(ip):
							break
					self.nextAvailableIp = ip
				except Exception as e:
					self.nextAvailableIp = None
			
			self.autoSave()