2 Library for dynamic flow construction.
3 Authors: james.luhrsen@hp.com
7 xmltodict and json libs not needed at this point, but may be useful in
14 from robot.libraries.BuiltIn import BuiltIn
16 ##bare bones xml for building a flow xml for flow:inventory
17 flow_xml_skeleton = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' + \
18 '<flow xmlns="urn:opendaylight:flow:inventory">' + \
19 '<instructions></instructions>' + \
23 input_xml_skeleton = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' + \
24 '<input xmlns="urn:opendaylight:flow:service">' + \
30 Flow class for creating and interacting with OpenFlow flows
50 def set_field(self, field, value):
52 allows for generically setting any attribute in this
53 class based on the 'field' passed in. In the future,
54 adding a new attribute only requires that single line
55 addition. no need for additional setter.
57 setattr(self, field, value)
59 def Make_Inventory_Flow():
61 Robot Keyword to create and return an instance of the Flow
65 flow.xml = flow_xml_skeleton
68 def Make_Service_Flow():
70 Robot Keyword to create an input XML that can be used to
71 directly send to flow:service for things like accessing
72 the remove-flow RPC via restconf
75 flow.xml = input_xml_skeleton
78 def Set_Flow_Field(flow, field, value):
80 Robot Keyword to allow the modification (setting) of the
81 flow object attributes
83 flow.set_field(field,value)
87 #def Convert_Flow_XML_To_Json(flow):
89 # There may be a need in the future to use json to push
90 # flows, as opposed to xml format that is prevalent in
91 # test code at this point. This function will give a
92 # conversion, but unsure if it's proper. Also, unsure
93 # if the xmltodict library is viable in the CSIT environment
95 # flowXmlDict = xmltodict.parse(flow.xml)
96 # flow.json = json.dumps(flowXmlDict)