# # Copyright 2011, Infoblox, All Rights Reserved # # Open Source, see LICENSE # Module with ID factories for creating IF-MAP Identifiers. # Identifiers are used, for example, when publishing to an IF-MAP server, to represent an IP address. # The XML for such the IP address identifier would be generated by ifmap.id.IPAddress # example: # >>> print ifmap.id.IPAdress('10.0.0.1') from util import attr class ifmapIDFactory: pass class IPAddress(ifmapIDFactory): """ XML Factory for an IP Address IF-MAP Identifier """ def __init__(self, ip_address, type=None, administrative_domain=None): self.__ip_address = ip_address self.__type = type self.__administrative_domain = administrative_domain def administrative_domain(self): return self.__administrative_domain def ip_address(self): return self.__ip_address def type(self): return self.__type def __str__(self): _attr = attr({'value':self.__ip_address,'type':self.__type,'administrative-domain':self.__administrative_domain}) return '' class MACAddress(ifmapIDFactory): """ XML Factory for a MAC Address IF-MAP Identifier """ def __init__(self, mac_address, administrative_domain=None): self.__mac_address = mac_address self.__administrative_domain = administrative_domain return None; def administrative_domain(self): return self.__administrative_domain def mac_address(self): return self.__mac_address def __str__(self): _attr = attr({'value':self.__mac_address,'administrative-domain':self.__administrative_domain}) return '' class Device(ifmapIDFactory): """ XML Factory for a Device IF-MAP Identifier """ def __init__(self, name, aik_name=None): self.__name = name self.__aik_name = aik_name return None; def aik_name(self): return self.__aik_name def name(self): return self.__name def __str__(self): self.__XML = "" self.__XML += ''+self.__name+'' # aik_name is optional if self.__aik_name: self.__XML += ''+self.__aik_name+'' self.__XML += "" return self.__XML class AccessRequest(ifmapIDFactory): """ XML Factory for an Access Request IF-MAP Identifier """ def __init__(self, name, administrative_domain=None): self.__name = name self.__administrative_domain = administrative_domain return None; def administrative_domain(self): return self.__administrative_domain def name(self): return self.__name def __str__(self): self.__XML = "