blob: 179fd0139552eccc689a54389b92c5e0bdfcfa8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# Copyright 2011, Infoblox, All Rights Reserved
#
# Open Source, see LICENSE
#
from xml.etree import ElementTree
class Response():
"""
Base class to handle and parse IF-MAP responses
"""
__xml = ""
def __init__(self, result):
"""
Take a result string and process it
"""
if result:
env = ElementTree.fromstring(result)
body = env.find('{http://www.w3.org/2003/05/soap-envelope}Body')
response = body.find('{http://www.trustedcomputinggroup.org/2010/IFMAP/2}response')
# xml.etree.ElementTree find is broken in python 2.6
children = response.findall('*')
if len(children):
self.__xml = children[0]
def element(self):
"""
Returns the raw Element object
"""
return self.__xml
def __str__(self):
"""
Print the XML tree as a string
"""
return ElementTree.tostring(self.__xml)
class newSessionResult(Response):
"""
newSessionResult
"""
def __init__(self, result):
#import pdb; pdb.set_trace()
self.__newSession = Response(result).element()
def get_session_id(self):
return self.__newSession.attrib['session-id']
def get_publisher_id(self):
return self.__newSession.attrib['ifmap-publisher-id']
|