2 Documentation Keywords used to create/modify flow objects. The object is defined in the
3 ... corresponding FlowLib.py library and contains pertinent fields and methods (e.g.,
4 ... cookie and barrier fields, string formatted xml that can be used to push to
10 ##default flow attributes ...
11 @{default_flow_fields} strict table_id id hard_timeout idle_timeout flow_name priority
12 ... barrier cookie cookie_mask
16 [Documentation] Calls FlowLib.Make_Flow_Object() function and initializes and sanitizes
17 ... the basic flow elements.
18 ${flow}= Make Flow Object
19 : FOR ${field} IN @{default_flow_fields}
20 \ Set "${flow}" "${field}" With "${flow.${field}}"
23 Set "${flow}" "${property}" With "${property_val}"
24 [Documentation] Embedded variables to make higher level keywords more readable.
25 ... There are some cases where the python attribute uses an underscore,
26 ... but a hyphen needs to be used. This seems inconsistent, and may need
27 ... to be looked at from the openflow plugin perspective.
29 ... At this point, this library will remove the element ${property} from the
30 ... xml representation of the flow and reset with the given value. \ It's not
31 ... possible, yet, to have multiple elements with the same name. \ That will
32 ... likely be needed in the future.
33 ${property} Run Keyword If "table_id" != "${property}" and "cookie_mask" != "${property}" Replace String ${property} _ -
34 ... ELSE Set Variable ${property}
35 Remove Flow XML Element ${flow} ${property}
36 Add Flow XML Element ${flow} ${property} ${property_val}
37 Set Flow Field ${flow} ${property} ${property_val}
41 [Arguments] ${flow} ${instruction_order} ${action_order} ${action} ${action_val}=${EMPTY}
42 [Documentation] Will remove the instruction element first, then add the proper xml structure
43 ... to implement the action as given in the arguments
44 ##For the case that any of the instruction/apply-actions/action elements are not there we need to add them'
45 Remove Flow XML Element ${flow} instruction
46 Add Flow XML Element ${flow} instruction ${EMPTY} instructions
47 Add Flow XML Element ${flow} order ${instruction_order} instructions/instruction
48 Add Flow XML Element ${flow} apply-actions ${EMPTY} instructions/instruction
49 Add Flow XML Element ${flow} action ${EMPTY} instructions/instruction/apply-actions
50 Add Flow XML Element ${flow} order ${action_order} instructions/instruction/apply-actions/action
51 Add Flow XML Element ${flow} ${action} ${action_val} instructions/instruction/apply-actions/action
54 Set Flow Ethernet Match
55 [Arguments] ${flow} ${match_value_dict}
56 [Documentation] Specific keyword for adding an ethernet match rules where the elements are given
57 ... in key/value pairs inside the ${match_value_dict} argument. This keyword will also remove any
58 ... existing ethernet-match elements from the flow before adding
59 Clear Flow Matches ${flow} match/ethernet-match
60 Add Flow XML Element ${flow} ethernet-match ${EMPTY} match
61 ${type}= Get From Dictionary ${match_value_dict} type
62 Add Flow XML Element ${flow} ethernet-type ${EMPTY} match/ethernet-match
63 Add Flow XML Element ${flow} type ${type} match/ethernet-match/ethernet-type
64 ${src}= Get From Dictionary ${match_value_dict} source
65 Add Flow XML Element ${flow} ethernet-source ${EMPTY} match/ethernet-match
66 Add Flow XML Element ${flow} address ${src} match/ethernet-match/ethernet-source
67 ${dst}= Get From Dictionary ${match_value_dict} destination
68 Add Flow XML Element ${flow} ethernet-destination ${EMPTY} match/ethernet-match
69 Add Flow XML Element ${flow} address ${dst} match/ethernet-match/ethernet-destination
73 [Arguments] ${flow} ${match_value_dict}
74 [Documentation] Specific keyword for adding an ipv4 match rules where the elements are given
75 ... in key/value pairs inside the ${match_value_dict} argument. This keyword will also remove any
76 ... existing ipv4 match elements from the flow before adding
77 Clear Flow Matches ${flow} match/ipv4-source
78 Clear Flow Matches ${flow} match/ipv4-destination
79 ${src}= Get From Dictionary ${match_value_dict} source
80 Add Flow XML Element ${flow} ipv4-source ${src} match
81 ${dst}= Get From Dictionary ${match_value_dict} destination
82 Add Flow XML Element ${flow} ipv4-destination ${dst} match
87 [Documentation] Will clean out any existing flow actions in the given ${flow} object
88 Remove Flow XML Element ${flow} instructions/instruction
92 [Arguments] ${flow} ${match_element}
93 [Documentation] Will clean out any existing flow matches in the given ${flow} object
94 Remove Flow XML Element ${flow} match/${match_element}
98 [Arguments] ${flow} ${element} ${element_val}=${EMPTY} ${xpath}=.
99 [Documentation] Will modify the current xml representation of the ${flow} object to contain
100 ... the given ${element} at the given ${xpath}. If the ${element} uses a value, that can be
101 ... passed eith the ${element_val} which defaults to ${EMPTY} if not used. NOTE: since there
102 ... are two default parameters to this keyword, if you have an ${xpath} to use, but no ${element_val}
103 ... you will still need to pass ${EMPTY} when invoking so that ${xpath} will end up at the right
104 ... location in the parameter list
105 ${flow_xml}= Parse XML ${flow.xml}
106 Add Element ${flow_xml} <${element}>${element_val}</${element}> xpath=${xpath}
107 ${xml_string}= Element To String ${flow_xml}
108 Set Flow Field ${flow} xml ${xml_string}
111 Remove Flow XML Element
112 [Arguments] ${flow} ${element_xpath}
113 [Documentation] Removes the element at the given ${element_xpath} within the given ${flow}
114 ... object. The ${flow} object's xml representation will be updated to reflect this removal.
115 ${flow_xml}= Parse XML ${flow.xml}
116 Run Keyword And Ignore Error Remove Elements ${flow_xml} xpath=${element_xpath}
117 ${xml_string}= Element To String ${flow_xml}
118 Set Flow Field ${flow} xml ${xml_string}