From 82f1a7eb5535b30a95b1e71ff18c315d40d1e6f0 Mon Sep 17 00:00:00 2001 From: Stuart Mackie Date: Fri, 29 Jan 2016 16:00:57 -0800 Subject: OpenContrail test suite Change-Id: I61168093a2a05d47377ef47c8638ae1554b1a999 Signed-off-by: Stuart Mackie --- Testcases/cfgm_common/ifmap/id.py | 191 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 Testcases/cfgm_common/ifmap/id.py (limited to 'Testcases/cfgm_common/ifmap/id.py') diff --git a/Testcases/cfgm_common/ifmap/id.py b/Testcases/cfgm_common/ifmap/id.py new file mode 100644 index 0000000..7a71d51 --- /dev/null +++ b/Testcases/cfgm_common/ifmap/id.py @@ -0,0 +1,191 @@ +# +# 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 = "