blob: 6bf67c060dc27b5b2f167edb27529fbdaacea5a2 [file] [log] [blame]
Sean Condonfae8e662016-12-15 10:25:13 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Sean Condonfae8e662016-12-15 10:25:13 +00003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.drivers.microsemi.yang;
17
Sean Condonfae8e662016-12-15 10:25:13 +000018import java.util.concurrent.CompletableFuture;
19import java.util.concurrent.atomic.AtomicInteger;
20import java.util.regex.Pattern;
21
Sean Condon1dbcd712017-10-19 12:09:21 +010022import org.onosproject.drivers.microsemi.EA1000CfmMepProgrammableTest;
Sean Condon06613e92017-06-09 15:14:01 +010023import org.onosproject.netconf.DatastoreId;
Sean Condonfae8e662016-12-15 10:25:13 +000024import org.onosproject.netconf.NetconfDeviceInfo;
25import org.onosproject.netconf.NetconfDeviceOutputEventListener;
26import org.onosproject.netconf.NetconfException;
Yuta HIGUCHIdd7c3f82017-09-03 14:18:01 -070027import org.onosproject.netconf.NetconfSessionAdapter;
Sean Condonfae8e662016-12-15 10:25:13 +000028import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
30
Yuta HIGUCHIdd7c3f82017-09-03 14:18:01 -070031public class MockNetconfSessionEa1000 extends NetconfSessionAdapter {
Sean Condonfae8e662016-12-15 10:25:13 +000032 private static final Logger log = LoggerFactory
33 .getLogger(MockNetconfSessionEa1000.class);
34
35 private static final String MESSAGE_ID_STRING = "message-id";
36 private static final String EQUAL = "=";
37 private static final String RPC_OPEN = "<rpc ";
38 private static final String RPC_CLOSE = "</rpc>";
39 private static final String GET_OPEN = "<get>";
40 private static final String GET_CLOSE = "</get>";
41 private static final String NEW_LINE = "\n";
42 private static final String SUBTREE_FILTER_OPEN = "<filter type=\"subtree\">";
43 private static final String SUBTREE_FILTER_CLOSE = "</filter>";
44 private static final String WITH_DEFAULT_OPEN = "<with-defaults ";
45 private static final String WITH_DEFAULT_CLOSE = "</with-defaults>";
46 private static final String EDIT_CONFIG_OPEN = "<edit-config>";
47 private static final String EDIT_CONFIG_CLOSE = "</edit-config>";
48 private static final String TARGET_OPEN = "<target>";
49 private static final String TARGET_CLOSE = "</target>";
50 private static final String DEFAULT_OPERATION_OPEN = "<default-operation>";
51 private static final String DEFAULT_OPERATION_CLOSE = "</default-operation>";
52 private static final String CONFIG_OPEN = "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">";
53 private static final String CONFIG_CLOSE = "</config>";
54
55 private static final String ENDPATTERN = "]]>]]>";
56 private static final String XML_HEADER =
57 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
58 private static final String NETCONF_BASE_NAMESPACE =
59 "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"";
60 private static final String NETCONF_WITH_DEFAULTS_NAMESPACE =
61 "xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\"";
62
63
64 private Pattern sampleXmlRegex1 =
65 Pattern.compile("(<\\?xml).*(<rpc).*(<get>).*(<filter).*"
66 + "(<system).*(<clock/>).*(</system>).*(</filter>)*.(</get>).*(</rpc).*(]]>){2}",
67 Pattern.DOTALL);
68
69 private Pattern sampleXmlRegex2 =
70 Pattern.compile("(<\\?xml).*(<rpc).*(<get>).*(<filter).*(<system-state).*(</system-state>).*"
71 + "(<system).*(</system>).*(</filter>).*(</get>).*(</rpc).*(]]>){2}",
72 Pattern.DOTALL);
73
74 private Pattern sampleXmlRegexSaFiltering =
75 Pattern.compile("(<\\?xml).*"
Sean Condon0e89bda2017-03-21 14:23:19 +000076 + "(<rpc).*(<get>)\\R?"
77 + "(<filter type=\"subtree\">)\\R?"
78 + "(<source-ipaddress-filtering).*(</source-ipaddress-filtering>)\\R?"
79 + "(</filter>)\\R?(</get>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
80
81 private Pattern sampleXmlRegexSaFilteringErrorScenario =
82 Pattern.compile("(<\\?xml).*"
83 + "(<rpc).*(<get>)\\R?"
84 + "(<filter type=\"subtree\">)\\R?"
85 + "(<source-ipaddress-filtering).*"
86 + "(<interface-eth0>)\\R?"
87 + "(<source-address-range>)\\R?"
88 + "(<range-id>)10(</range-id>)\\R?"
89 + "(</source-address-range>)\\R?"
90 + "(</interface-eth0>)\\R?"
91 + "(</source-ipaddress-filtering>)\\R?"
92 + "(</filter>)\\R?(</get>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
Sean Condonfae8e662016-12-15 10:25:13 +000093
94 private Pattern sampleXmlRegexEditConfigSaFilt =
95 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
96 + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
97 + "(<source-ipaddress-filtering).*(<interface-eth0>).*"
98 + "(<source-address-range>).*(<range-id>).*(</range-id>).*"
99 + "(<name>).*(</name>).*(<ipv4-address-prefix>).*(</ipv4-address-prefix>).*"
100 + "(</source-address-range>).*(</interface-eth0>)*(</source-ipaddress-filtering>).*"
101 + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
102
103 private Pattern sampleXmlRegexEditDeleteSaFilt =
Sean Condon06613e92017-06-09 15:14:01 +0100104 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
105 + "(<target><running/></target>)\\R?"
106 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000107 + "(<source-ipaddress-filtering "
Sean Condon06613e92017-06-09 15:14:01 +0100108 + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">)\\R?"
109 + "(<interface-eth0>)\\R?"
110 + "((<source-address-range nc:operation=\"delete\">)\\R?"
111 + "(<range-id>)[0-9]*(</range-id>)\\R?"
112 + "((<name>)[a-zA-Z0-9]*(</name>))?\\R?"
113 + "((<ipv4-address-prefix>)[0-9\\\\./]*(</ipv4-address-prefix>))?\\R?"
114 + "(</source-address-range>))++\\R?"
115 + "(</interface-eth0>)\\R?"
116 + "(</source-ipaddress-filtering>)\\R?"
117 + "(</config>)\\R?"
118 + "(</edit-config>)\\R?(</rpc>).*(]]>){2}", Pattern.DOTALL);
Sean Condonfae8e662016-12-15 10:25:13 +0000119
120 private Pattern sampleXmlRegexUniEvc =
121 Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?"
122 + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?"
123 + "(<filter type=\"subtree\">)\\R?"
124 + "(<mef-services "
125 + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\"/>)\\R?"
126 + "(</filter>)\\R?(</get-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
127
128 private Pattern sampleXmlRegexUniEvcUni =
129 Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?"
130 + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?"
131 + "(<filter type=\"subtree\">)\\R?"
132 + "(<mef-services "
133 + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?"
134 + "(<uni/>)\\R?"
135 + "(</mef-services>)\\R?"
136 + "(</filter>)\\R?(</get-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
137
138 private Pattern sampleXmlRegexEditConfigUni1Evc =
139 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
140 + "(<target><running/></target>)\\R?"
141 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
142 + "(<mef-services).*(<uni>)\\R?(<name>).*(</name>)\\R?"
143 + "(<evc>)\\R?(<evc-index>).*(</evc-index>)\\R?(<name>).*(</name>)\\R?"
144 + "(<evc-per-uni>)\\R?"
145 + "(<evc-per-uni-c>)\\R?"
Sean Condon06613e92017-06-09 15:14:01 +0100146 + "(<ce-vlan-map>)[0-9]*(</ce-vlan-map>)\\R?"
147 + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
148 + "(<tag-push>)\\R?(<push-tag-type>)pushStag(</push-tag-type>)\\R?"
149 + "(<outer-tag-vlan>)[0-9]*(</outer-tag-vlan>)\\R?(</tag-push>)\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000150 + "((<flow-mapping>)\\R?"
151 + "(<ce-vlan-id>)[0-9]*(</ce-vlan-id>)\\R?"
152 + "(<flow-id>)[0-9]*(</flow-id>)\\R?"
153 + "(</flow-mapping>)\\R?)*"
154 + "(</evc-per-uni-c>)\\R?"
155 + "(<evc-per-uni-n>)\\R?"
Sean Condon06613e92017-06-09 15:14:01 +0100156 + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
157 + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000158 + "(<tag-pop).*"
159 + "((<flow-mapping>)\\R?"
160 + "(<ce-vlan-id>)[0-9]*(</ce-vlan-id>)\\R?"
161 + "(<flow-id>)[0-9]*(</flow-id>)\\R?"
162 + "(</flow-mapping>)\\R?)*"
163 + "(</evc-per-uni-n>)\\R?"
164 + "(</evc-per-uni>)\\R?"
165 + "(</evc>)\\R?"
Sean Condon06613e92017-06-09 15:14:01 +0100166 + "(</uni>)\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000167 + "(</mef-services>)\\R?"
168 + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
169
170 private Pattern sampleXmlRegexEditConfigUni2Evc =
171 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
172 + "(<target><running/></target>)\\R?"
173 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
174 + "(<mef-services).*(<uni>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?"
175 + "(<evc>)\\R?(<evc-index>)[0-9]*(</evc-index>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?"
176 + "(<evc-per-uni>)\\R?"
177 + "(<evc-per-uni-c>)\\R?"
178 + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
179 + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
180 + "(</evc-per-uni-c>)\\R?"
181 + "(<evc-per-uni-n>)\\R?"
182 + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
183 + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
184 + "(<evc-per-uni-service-type>).*(</evc-per-uni-service-type>)\\R?"
185 + "(<tag-push>)\\R?(<push-tag-type>)pushStag(</push-tag-type>)\\R?(<outer-tag-vlan>).*"
186 + "(</outer-tag-vlan>)\\R?(</tag-push>)\\R?"
187 + "(</evc-per-uni-n>)\\R?"
188 + "(</evc-per-uni>)\\R?"
189 + "(</evc>)\\R?"
190 + "(<evc>)\\R?(<evc-index>)[0-9]*(</evc-index>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?"
191 + "(<evc-per-uni>)\\R?"
192 + "(<evc-per-uni-c>)\\R?"
193 + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
194 + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
195 + "(</evc-per-uni-c>)\\R?"
196 + "(<evc-per-uni-n>)\\R?"
197 + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?"
198 + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?"
199 + "(</evc-per-uni-n>)\\R?"
200 + "(</evc-per-uni>)\\R?"
201 + "(</evc>)\\R?(</uni>).*"
202 + "(</mef-services>)\\R?"
203 + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
204
205 private Pattern sampleXmlRegexEditConfigUniProfiles =
206 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
207 + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
208 + "(<mef-services).*(<profiles>).*"
209 + "(<bwp-group>).*(<group-index>).*(</group-index>).*(</bwp-group>).*"
210 + "(<bwp-group>).*(<group-index>).*(</group-index>).*"
211 + "(<bwp>).*(<cos-index>).*(</cos-index>).*(<color-mode>).*(</color-mode>).*(</bwp>).*"
212 + "(<bwp>).*(<cos-index>).*(</cos-index>).*(<color-mode>).*(</color-mode>).*(</bwp>).*"
213 + "(</bwp-group>).*"
214 + "(</profiles>).*(</mef-services>).*"
215 + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
216
217 private Pattern sampleXmlRegexEditConfigEvcDelete =
218 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
219 + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
220 + "(<mef-services).*"
221 + "(<uni>).*"
222 + "(<evc nc:operation=\"delete\">).*(<evc-index>).*(</evc-index>).*(</evc>).*"
223 + "(</uni>).*"
224 + "(</mef-services>).*"
225 + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
226
227 private Pattern sampleXmlRegexGetConfigCeVlanMapsEvc =
228 Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?"
229 + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?"
230 + "(<filter type=\"subtree\">)\\R?"
231 + "(<mef-services).*"
232 + "(<uni>)\\R?"
233 + "(<evc>)\\R?"
234 + "(<evc-index/>)\\R?"
235 + "(<evc-per-uni>)\\R?"
236 + "(<evc-per-uni-c><ce-vlan-map/><flow-mapping/><ingress-bwp-group-index/></evc-per-uni-c>)\\R?"
237 + "(<evc-per-uni-n><ce-vlan-map/><flow-mapping/><ingress-bwp-group-index/></evc-per-uni-n>)\\R?"
238 + "(</evc-per-uni>)\\R?"
239 + "(</evc>)\\R?"
240 + "(</uni>)\\R?"
241 + "(</mef-services>)\\R?"
242 + "(</filter>)\\R?"
243 + "(</get-config>)\\R?"
244 + "(</rpc>)\\R?"
245 + "(]]>){2}", Pattern.DOTALL);
246
247 //For test testRemoveEvcUniFlowEntries()
248 private Pattern sampleXmlRegexEditConfigCeVlanMapReplace =
249 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*"
250 + "(<target><running/></target>).*"
251 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*"
252 + "(<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">).*"
253 + "(<uni>).*"
254 + "(<evc nc:operation=\"delete\">).*(<evc-index>.*</evc-index>).*(</evc>).*"
255 + "(<evc nc:operation=\"delete\">).*(<evc-index>.*</evc-index>).*(</evc>).*"
256 + "(<evc>).*(<evc-index>).*(</evc-index>).*(<evc-per-uni>).*"
257 + "(<evc-per-uni-c>).*"
258 + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*"
259 + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*"
260 + "(</evc-per-uni-c>).*"
261 + "(<evc-per-uni-n>).*"
262 + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*"
263 + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*"
264 + "(</evc-per-uni-n>).*"
265 + "(</evc-per-uni>).*(</evc>).*"
266 + "(<evc>).*(<evc-index>).*(</evc-index>).*(<evc-per-uni>).*"
267 + "(<evc-per-uni-c>).*"
268 + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*"
269 + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*"
270 + "(</evc-per-uni-c>).*"
271 + "(<evc-per-uni-n>).*"
272 + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*"
273 + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*"
274 + "(</evc-per-uni-n>).*"
275 + "(</evc-per-uni>).*(</evc>).*"
276 + "(</uni>).*(</mef-services>).*"
277 + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL);
278
279
280 //For testPerformMeterOperationDeviceIdMeterAdd()
281 private Pattern sampleXmlRegexEditConfigBwpGroup1 =
282 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
283 + "(<target>\\R?<running/>\\R?</target>)\\R?"
284 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
285 + "(<mef-services "
286 + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?"
287 + "(<profiles>)\\R?"
288 + "(<bwp-group>)\\R?"
289 + "(<group-index>)[0-9]*(</group-index>)\\R?"
290 + "(<bwp>)\\R?"
291 + "(<cos-index>)[0-9]*(</cos-index>)\\R?"
292 + "(<name>).*(</name>)\\R?"
293 + "(<committed-information-rate>)[0-9]*(</committed-information-rate>)\\R?"
294 + "(<committed-burst-size>)[0-9]*(</committed-burst-size>)\\R?"
295 + "(<excess-information-rate>)[0-9]*(</excess-information-rate>)\\R?"
296 + "(<excess-burst-size>)[0-9]*(</excess-burst-size>)\\R?"
297 + "(</bwp>)\\R?"
298 + "(</bwp-group>)\\R?"
299 + "(<cos>)\\R?"
300 + "(<cos-index>)[0-9](</cos-index>)\\R?"
301 + "(<name>).*(</name>)\\R?"
302 + "(<outgoing-cos-value>)[0-9]*(</outgoing-cos-value>)\\R?"
303 + "(<color-aware>true</color-aware>)\\R?"
304 + "(<color-forward>true</color-forward>)\\R?"
305 + "(<evc-cos-type-all-8-prio-to-1-evc-color>)\\R?"
306 + "(<evc-all-8-color-to>green</evc-all-8-color-to>)\\R?"
307 + "(</evc-cos-type-all-8-prio-to-1-evc-color>)\\R?"
308 + "(</cos>)\\R?"
309 + "(</profiles>)\\R?"
310 + "(</mef-services>)\\R?"
311 + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
312
313 //For testPerformMeterOperationDeviceIdMeterRemove()
314 private Pattern sampleXmlRegexEditConfigBwpGroup1Delete =
315 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
316 + "(<target>\\R?<running/>\\R?</target>)\\R?"
317 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
318 + "(<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?"
319 + "(<profiles>)\\R?"
Sean Condon06613e92017-06-09 15:14:01 +0100320 + "((<bwp-group nc:operation=\"delete\">)\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000321 + "(<group-index>)[0-9]*(</group-index>)\\R?"
Sean Condon06613e92017-06-09 15:14:01 +0100322 + "(<bwp>.*</bwp>)?"
323 + "(</bwp-group>))++\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000324 + "(</profiles>)\\R?"
325 + "(</mef-services>)\\R?"
326 + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
327
328 private Pattern sampleXmlRegexSetCurrentDatetime =
329 Pattern.compile("(<\\?xml).*(<rpc).*"
330 + "(<set-current-datetime xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">)\\R?"
331 + "(<current-datetime>)"
332 + "[0-9]{4}-[0-9]{2}-[0-9]{2}(T)[0-9]{2}:[0-9]{2}:[0-9]{2}[+-][0-9]{2}:[0-9]{2}"
333 + "(</current-datetime>)\\R?"
334 + "(</set-current-datetime>)\\R?"
335 + "(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
336
337 //For testGetConfigMseaCfmEssentials
338 private Pattern sampleXmlRegexGetMseaCfmEssentials =
339 Pattern.compile("(<\\?xml).*(<rpc).*(<get>)\\R?"
340 + "(<filter type=\"subtree\">)\\R?"
341 + "(<mef-cfm).*"
342 + "(<maintenance-domain>)\\R?"
343 + "(<id/>)\\R?"
344 + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
Sean Condon0e89bda2017-03-21 14:23:19 +0000345 + "(<md-level/>)?\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000346 + "(<maintenance-association>)\\R?"
347 + "(<id/>)\\R?"
348 + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
Sean Condon06613e92017-06-09 15:14:01 +0100349 + "(<ccm-interval>)[0-9]{1,3}(ms</ccm-interval>)\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000350 + "(<remote-meps/>)\\R?"
351 + "(<component-list/>)\\R?"
352 + "(<maintenance-association-end-point>)\\R?"
353 + "(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)\\R?"
Sean Condon0e89bda2017-03-21 14:23:19 +0000354 + "(<mac-address/>)?\\R?"
355 + "((<remote-mep-database>)\\R?"
356 + "(<remote-mep>)\\R?"
357 + "(<remote-mep-id/>)\\R?"
358 + "(</remote-mep>)\\R?"
359 + "(</remote-mep-database>))?\\R?"
360 + "((<msea-soam-pm:delay-measurements>)\\R?"
361 + "(<msea-soam-pm:delay-measurement>)\\R?"
362 + "((<msea-soam-pm:dm-id/>)|(<msea-soam-pm:dm-id>[0-9]*</msea-soam-pm:dm-id>))\\R?"
363 + "(</msea-soam-pm:delay-measurement>)\\R?"
364 + "(</msea-soam-pm:delay-measurements>))?\\R?"
365 + "((<msea-soam-pm:loss-measurements>)\\R?"
366 + "(<msea-soam-pm:loss-measurement>)\\R?"
367 + "((<msea-soam-pm:lm-id/>)|(<msea-soam-pm:lm-id>[0-9]*</msea-soam-pm:lm-id>))\\R?"
368 + "(</msea-soam-pm:loss-measurement>)\\R?"
369 + "(</msea-soam-pm:loss-measurements>))?\\R?"
Sean Condonfae8e662016-12-15 10:25:13 +0000370 + "(</maintenance-association-end-point>)\\R?"
371 + "(</maintenance-association>)\\R?"
372 + "(</maintenance-domain>)\\R?"
373 + "(</mef-cfm>)\\R?"
374 + "(</filter>)\\R?"
375 + "(</get>)\\R?"
376 + "(</rpc>)\\R?"
377 + "(]]>){2}", Pattern.DOTALL);
378
Sean Condon1dbcd712017-10-19 12:09:21 +0100379 //For testGetMep
380 private String sampleXmlRegexGetMseaCfmFullStr =
381 "(<\\?xml).*(<rpc).*(<get>)\\R?"
382 + "(<filter type=\"subtree\">)\\R?"
383 + "(<mef-cfm).*"
384 + "(<maintenance-domain>)\\R?"
385 + "(<id/>)\\R?"
386 + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
387 + "(<md-level/>)?\\R?"
388 + "(<maintenance-association>)\\R?"
389 + "(<id/>)\\R?"
390 + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
391 + "(<maintenance-association-end-point>)\\R?"
392 + "(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)\\R?"
393 + "(<interface/>)?\\R?"
394 + "(<primary-vid/>)?\\R?"
395 + "(<administrative-state/>)?\\R?"
396 + "(<mac-address/>)?\\R?"
397 + "(<ccm-ltm-priority/>)?\\R?"
398 + "(<continuity-check/>)?\\R?"
399 + "(<loopback/>)?\\R?"
400 + "(<linktrace/>)?\\R?"
401 + "(<remote-mep-database/>)\\R?"
402 + "(<msea-soam-fm:operational-state/>)\\R?"
403 + "(<msea-soam-fm:connectivity-status/>)\\R?"
404 + "(<msea-soam-fm:port-status/>)\\R?"
405 + "(<msea-soam-fm:interface-status/>)\\R?"
406 + "(<msea-soam-fm:last-defect-sent/>)\\R?"
407 + "(<msea-soam-fm:rdi-transmit-status/>)\\R?"
408 + "(</maintenance-association-end-point>)\\R?"
409 + "(</maintenance-association>)\\R?"
410 + "(</maintenance-domain>)\\R?"
411 + "(</mef-cfm>)\\R?"
412 + "(</filter>)\\R?"
413 + "(</get>)\\R?"
414 + "(</rpc>)\\R?"
415 + "(]]>){2}";
416
Sean Condon0e89bda2017-03-21 14:23:19 +0000417 private Pattern sampleXmlRegexGetMseaCfmFull =
Sean Condon1dbcd712017-10-19 12:09:21 +0100418 Pattern.compile(sampleXmlRegexGetMseaCfmFullStr
419 .replace("(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)",
420 "(<mep-identifier>)" +
421 EA1000CfmMepProgrammableTest.MEP_111 +
422 "(</mep-identifier>)"),
423 Pattern.DOTALL);
424
425 private Pattern sampleXmlRegexGetMseaCfmFull2 =
426 Pattern.compile(sampleXmlRegexGetMseaCfmFullStr
427 .replace("(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)",
428 "(<mep-identifier>)" +
429 EA1000CfmMepProgrammableTest.MEP_112 +
430 "(</mep-identifier>)"),
431 Pattern.DOTALL);
Sean Condon0e89bda2017-03-21 14:23:19 +0000432
433 //For testGetConfigMseaCfmEssentials
434 private Pattern sampleXmlRegexGetMseaDelay =
435 Pattern.compile("(<\\?xml).*(<rpc).*(<get>)\\R?"
436 + "(<filter type=\"subtree\">)\\R?"
437 + "(<mef-cfm).*"
438 + "(<maintenance-domain>)\\R?"
439 + "(<id/>)\\R?"
440 + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
441 + "(<maintenance-association>)\\R?"
442 + "(<id/>)\\R?"
443 + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
444 + "(<maintenance-association-end-point>)\\R?"
445 + "(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)\\R?"
446 + "((<msea-soam-pm:delay-measurements>)\\R?"
447 + "(<msea-soam-pm:delay-measurement>)\\R?"
448 + "((<msea-soam-pm:dm-id/>)|(<msea-soam-pm:dm-id>[0-9]*</msea-soam-pm:dm-id>))\\R?"
449 + "(<msea-soam-pm:mep-id/>)\\R?"
450 + "(<msea-soam-pm:mac-address/>)\\R?"
451 + "(<msea-soam-pm:administrative-state/>)\\R?"
452 + "(<msea-soam-pm:measurement-enable/>)\\R?"
453 + "(<msea-soam-pm:message-period/>)\\R?"
454 + "(<msea-soam-pm:priority/>)\\R?"
455 + "(<msea-soam-pm:frame-size/>)\\R?"
456 + "(<msea-soam-pm:measurement-interval/>)\\R?"
457 + "(<msea-soam-pm:number-intervals-stored/>)\\R?"
458 + "(<msea-soam-pm:session-status/>)\\R?"
459 + "(<msea-soam-pm:frame-delay-two-way/>)\\R?"
460 + "(<msea-soam-pm:inter-frame-delay-variation-two-way/>)\\R?"
461 + "(<msea-soam-pm:current-stats/>)?\\R?"
462 + "(<msea-soam-pm:history-stats/>)?\\R?"
463 + "(</msea-soam-pm:delay-measurement>)\\R?"
464 + "(</msea-soam-pm:delay-measurements>))?\\R?"
465 + "(</maintenance-association-end-point>)\\R?"
466 + "(</maintenance-association>)\\R?"
467 + "(</maintenance-domain>)\\R?"
468 + "(</mef-cfm>)\\R?"
469 + "(</filter>)\\R?"
470 + "(</get>)\\R?"
471 + "(</rpc>)\\R?"
472 + "(]]>){2}", Pattern.DOTALL);
473
474 //For testGetConfigMseaCfmEssentials
475 private Pattern sampleXmlRegexDeleteMseaCfmMep =
476 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
477 + "(<target>\\R?<running/>\\R?</target>)\\R?"
478 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
479 + "(<mef-cfm).*"
480 + "(<maintenance-domain>)\\R?"
Sean Condon96b896d2017-12-11 12:44:29 -0800481 + "(<id>[0-9]{1,5}</id>)?\\R?"
482 + "((<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>))?\\R?"
Sean Condon0e89bda2017-03-21 14:23:19 +0000483 + "(<maintenance-association>)\\R?"
Sean Condon96b896d2017-12-11 12:44:29 -0800484 + "(<id>[0-9]{1,5}</id>)?\\R?"
485 + "((<name>[a-zA-Z0-9\\-:\\.]{1,48}</name>)|"
486 + "(<name-primary-vid>[0-9]{1,4}</name-primary-vid>))?\\R?"
Sean Condon0e89bda2017-03-21 14:23:19 +0000487 + "(<maintenance-association-end-point nc:operation=\"delete\">)\\R?"
488 + "(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)\\R?"
489 + "(</maintenance-association-end-point>)\\R?"
490 + "(</maintenance-association>)\\R?"
491 + "(</maintenance-domain>)\\R?"
492 + "(</mef-cfm>)\\R?"
493 + "(</config>)\\R?"
494 + "(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
495
Sean Condon96b896d2017-12-11 12:44:29 -0800496 //For testGetConfigMseaCfmEssentials
497 private Pattern sampleXmlRegexCreateMseaCfmMa =
498 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
499 + "(<target>\\R?<running/>\\R?</target>)\\R?"
500 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
501 + "(<mef-cfm).*"
502 + "(<maintenance-domain>)\\R?"
503 + "(<id>)([0-9]){1,4}(</id>)\\R?"
504 + "((<md-level>)([0-9]){1}(</md-level>))?\\R?"
505 + "((<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>))?\\R?"
506 + "((<maintenance-association>)\\R?"
507 + "(<id>)([0-9]){1,4}(</id>)\\R?"
508 + "((<ccm-interval>)(3.3ms)(</ccm-interval>))?\\R?"
509 + "((<remote-meps>)([0-9]){1,4}(</remote-meps>))*\\R?"
510 + "(((<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>))|"
511 + "((<name-primary-vid>)([0-9]){1,4}(</name-primary-vid>)))?\\R?"
512 + "((<component-list>)\\R?"
513 + "(<vid>)([0-9]){1,4}(</vid>)\\R?"
514 + "(</component-list>))?\\R?"
515 + "(</maintenance-association>))*\\R?"
516 + "(</maintenance-domain>)\\R?"
517 + "(</mef-cfm>)\\R?"
518 + "(</config>)\\R?"
519 + "(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
520
521 //For testGetConfigMseaCfmEssentials
522 private Pattern sampleXmlRegexDeleteMseaCfmMa =
523 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
524 + "(<target>\\R?<running/>\\R?</target>)\\R?"
525 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
526 + "(<mef-cfm).*"
527 + "(<maintenance-domain>)\\R?"
528 + "((<id/>)|((<id>)([0-9]){1,4}(</id>)))?\\R?"
529 + "((<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>))?\\R?"
530 + "(<maintenance-association nc:operation=\"delete\">)\\R?"
531 + "((<id/>)|((<id>)([0-9]){1,4}(</id>)))?\\R?"
532 + "(((<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>))|"
533 + "((<name-primary-vid>)([0-9]){1,4}(</name-primary-vid>)))?\\R?"
534 + "(</maintenance-association>)\\R?"
535 + "(</maintenance-domain>)\\R?"
536 + "(</mef-cfm>)\\R?"
537 + "(</config>)\\R?"
538 + "(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
539
540 //For testDeleteMseaMepRemoteMep
541 private Pattern sampleXmlRegexDeleteMseaCfmRmep =
542 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
543 + "(<target>\\R?<running/>\\R?</target>)\\R?"
544 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
545 + "(<mef-cfm).*"
546 + "(<maintenance-domain>)\\R?"
547 + "((<id>)[0-9]{1,4}(</id>))?\\R?"
548 + "((<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>))?\\R?"
549 + "(<maintenance-association>)\\R?"
550 + "((<id>)[0-9]{1,4}(</id>))?\\R?"
551 + "((<remote-meps nc:operation=\"delete\">)([0-9]){1,4}(</remote-meps>))*\\R?"
552 + "(((<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>))|"
553 + "((<name-primary-vid>)([0-9]){1,4}(</name-primary-vid>)))?\\R?"
554 + "(</maintenance-association>)\\R?"
555 + "(</maintenance-domain>)\\R?"
556 + "(</mef-cfm>)\\R?"
557 + "(</config>)\\R?"
558 + "(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
559
560 //For testDeleteMseaMd
561 private Pattern sampleXmlRegexDeleteMseaCfmMd =
562 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
563 + "(<target>\\R?<running/>\\R?</target>)\\R?"
564 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
565 + "(<mef-cfm).*"
566 + "(<maintenance-domain nc:operation=\"delete\">)\\R?"
567 + "((<id/>)|(<id>([0-9]){1,4}(</id>)))?\\R?"
568 + "(((<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>))|\\R?"
569 + "((<name-domain-name>)([a-zA-Z0-9\\-\\.]){1,48}(</name-domain-name>)))?\\R?"
570 + "(</maintenance-domain>)\\R?"
571 + "(</mef-cfm>)\\R?"
572 + "(</config>)\\R?"
573 + "(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
574
Sean Condon0e89bda2017-03-21 14:23:19 +0000575
576 private Pattern sampleXmlRegexTransmitLoopback =
577 Pattern.compile("(<\\?xml).*(<rpc).*\\R?"
578 + "(<transmit-loopback xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\">)\\R?"
579 + "((<number-of-messages>)[0-9]*(</number-of-messages>))?\\R?"
580 + "((<data-tlv>)[a-zA-Z0-9+=/]*(</data-tlv>))?\\R?"
581 + "((<vlan-priority>)[0-9]{1}(</vlan-priority>))?\\R?"
582 + "((<vlan-drop-eligible>)((true)|(false))(</vlan-drop-eligible>))?\\R?"
583 + "(<maintenance-association-end-point>)[0-9]{1,4}(</maintenance-association-end-point>)\\R?"
584 + "(<maintenance-association>)[0-9]{1,5}(</maintenance-association>)\\R?"
585 + "(<maintenance-domain>)[0-9]{1,5}(</maintenance-domain>)\\R?"
586 + "(<target-address>)\\R?"
587 + "((<mep-id>)[0-9]{1,4}(</mep-id>))?\\R?"
588 + "((<mac-address>)[a-fA-F0-9:-]{17}(</mac-address>))?\\R?"
589 + "(</target-address>)\\R?"
590 + "(</transmit-loopback>)\\R?"
591 + "(</rpc>)\\R?"
592 + "(]]>){2}", Pattern.DOTALL);
593
594 private Pattern sampleXmlRegexAbortLoopback =
595 Pattern.compile("(<\\?xml).*(<rpc).*\\R?"
596 + "(<abort-loopback xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\">)\\R?"
597 + "(<maintenance-association-end-point>)[0-9]{1,4}(</maintenance-association-end-point>)\\R?"
598 + "(<maintenance-association>)[0-9]{1,5}(</maintenance-association>)\\R?"
599 + "(<maintenance-domain>)[0-9]{1,5}(</maintenance-domain>)\\R?"
600 + "(</abort-loopback>)\\R?"
601 + "(</rpc>)\\R?"
602 + "(]]>){2}", Pattern.DOTALL);
603
604 //For testCreateDm()
605 private Pattern sampleXmlRegexEditConfigDmCreate =
606 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
607 + "(<target>\\R?<running/>\\R?</target>)\\R?"
608 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
609 + "(<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\">)\\R?"
610 + "(<maintenance-domain>)\\R?"
611 + "(<id>)[0-9]*(</id>)\\R?"
612 + "(<maintenance-association>)\\R?"
613 + "(<id>)[0-9]*(</id>)\\R?"
614 + "(<maintenance-association-end-point>)\\R?"
615 + "(<mep-identifier>)[0-9]*(</mep-identifier>)\\R?"
616 + "(<delay-measurements xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">)\\R?"
617 + "(<delay-measurement>)\\R?"
618 + "(<dm-id>)[0-9]*(</dm-id>)\\R?"
619 + "((<administrative-state>)(true|false)(</administrative-state>))?\\R?"
620 + "((<message-period>)(1000ms|100ms|10ms|3ms)(</message-period>))?\\R?"
621 + "(<priority>)[0-9]*(</priority>)\\R?"
622 + "((<frame-size>)[0-9]*(</frame-size>))?\\R?"
623 + "(<mep-id>)[0-9]*(</mep-id>)\\R?"
624 + "(</delay-measurement>)\\R?"
625 + "(</delay-measurements>)\\R?"
626 + "(</maintenance-association-end-point>)\\R?"
627 + "(</maintenance-association>)\\R?"
628 + "(</maintenance-domain>)\\R?"
629 + "(</mef-cfm>)\\R?"
630 + "(</config>)\\R?"
631 + "(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
632
Sean Condonfae8e662016-12-15 10:25:13 +0000633
634 private static final String SAMPLE_SYSTEM_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
635 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
636 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
637 + "<system xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">\n"
638 + "<clock><timezone-name>Etc/UTC</timezone-name></clock>\n"
639 + "</system>\n"
640 + "</data>\n"
641 + "</rpc-reply>";
642
643 private static final String SAMPLE_SYSTEM_REPLY_INIT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
644 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">"
645 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
646 + "<system xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">\n"
647 + "<longitude xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">-8.4683990</longitude>\n"
648 + "<latitude xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">51.9036140</latitude>\n"
649 + "</system>\n"
650 + "<system-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\""
651 + " xmlns:sysms=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">\n"
652 + "<platform>\n"
653 + "<os-release>4.4.0-53-generic</os-release>\n"
654 + "<sysms:device-identification>\n"
Sean Condon1dbcd712017-10-19 12:09:21 +0100655 + "<sysms:serial-number>EA1000 unit test.</sysms:serial-number>\n"
Sean Condonfae8e662016-12-15 10:25:13 +0000656 + "</sysms:device-identification>\n"
657 + "</platform>\n"
658 + "</system-state>\n"
659 + "</data>"
660 + "</rpc-reply>";
661
662 private static final String SAMPLE_MSEASAFILTERING_FE_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
663 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
664 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
665 + "<source-ipaddress-filtering "
666 + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">\n"
667 + "<interface-eth0>\n"
668 + "<filter-admin-state>inactive</filter-admin-state>\n"
669 + "<source-address-range>\n"
670 + "<range-id>1</range-id>\n"
671 + "<ipv4-address-prefix>10.10.10.10/16</ipv4-address-prefix>\n"
672 + "<name>Filter1</name>\n"
673 + "</source-address-range>\n"
674 + "<source-address-range>\n"
675 + "<range-id>2</range-id>\n"
676 + "<ipv4-address-prefix>20.30.40.50/18</ipv4-address-prefix>\n"
677 + "<name>Flow:5e0000abaa2772</name>\n"
678 + "</source-address-range>\n"
679 + "</interface-eth0>\n"
680 + "</source-ipaddress-filtering>\n"
681 + "</data>\n"
682 + "</rpc-reply>";
683
Sean Condon0e89bda2017-03-21 14:23:19 +0000684 private static final String SAMPLE_ERROR_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
685 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
686 + "<rpc-error>"
687 + "<error-type>application</error-type>"
688 + "<error-tag>data-missing</error-tag>"
689 + "<error-severity>error</error-severity>"
690 + "<error-message>Request could not be completed because " +
691 "the relevant data model content does not exist.</error-message>"
692 + "</rpc-error>"
693 + "</rpc-reply>";
694
Sean Condonfae8e662016-12-15 10:25:13 +0000695 private static final String SAMPLE_MSEAEVCUNI_REPLY_INIT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
696 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
697 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
698 + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\"/>"
699 + "</data>\n"
700 + "</rpc-reply>";
701
702 private static final String SAMPLE_MSEAEVCUNI_FE_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
703 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
704 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
705 + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">\n"
706 + "<uni>\n"
707 + "<name>Flow:7557655abfecd57865</name>\n"
708 + "<evc>\n"
709 + "<evc-index>7</evc-index\n>"
710 + "<name>evc-7</name>\n"
711 + "<evc-per-uni>\n"
712 + "<evc-per-uni-c>\n"
713 + "<ce-vlan-map>10</ce-vlan-map>\n"
714 + "<ingress-bwp-group-index>1</ingress-bwp-group-index>\n"
715 + "<tag-push>\n"
716 + "<push-tag-type>pushStag</push-tag-type>\n"
717 + "<outer-tag-vlan>3</outer-tag-vlan>\n"
718 + "</tag-push>\n"
719 + "<flow-mapping>\n"
720 + "<ce-vlan-id>10</ce-vlan-id>\n"
721 + "<flow-id>27021600672053710</flow-id>\n"
722 + "</flow-mapping>\n"
723 + "<evc-per-uni-service-type>epl</evc-per-uni-service-type>\n"
724 + "</evc-per-uni-c>\n"
725 + "<evc-per-uni-n>\n"
726 + "<ce-vlan-map>11</ce-vlan-map>\n"
727 + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
728 + "<flow-mapping>\n"
729 + "<ce-vlan-id>11</ce-vlan-id>\n"
730 + "<flow-id>27021600672053711</flow-id>\n"
731 + "</flow-mapping>\n"
732 + "</evc-per-uni-n>\n"
733 + "</evc-per-uni>\n"
734 + "<uni-evc-id>EA1000-Uni-from-ONOS_5</uni-evc-id>\n"
735 + "<evc-status>\n"
736 + "<operational-state>unknown</operational-state>\n"
737 + "<max-mtu-size>9600</max-mtu-size>\n"
738 + "<max-num-uni>2</max-num-uni>\n"
739 + "</evc-status>\n"
740 + "</evc>\n"
741 + "<evc>\n"
742 + "<evc-index>8</evc-index>\n"
743 + "<name>evc-8</name>\n"
744 + "<evc-per-uni>\n"
745 + "<evc-per-uni-c>\n"
746 + "<ce-vlan-map>12:14,20:22,25</ce-vlan-map>\n"
747 + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
748 + "<tag-pop />\n"
749 + "<evc-per-uni-service-type>epl</evc-per-uni-service-type>\n"
750 + "<flow-mapping>\n"
751 + "<ce-vlan-id>12</ce-vlan-id>\n"
752 + "<flow-id>27021600672053712</flow-id>\n"
753 + "</flow-mapping>\n"
754 + "<flow-mapping>\n"
755 + "<ce-vlan-id>13</ce-vlan-id>\n"
756 + "<flow-id>27021600672053713</flow-id>\n"
757 + "</flow-mapping>\n"
758 + "<flow-mapping>\n"
759 + "<ce-vlan-id>14</ce-vlan-id>\n"
760 + "<flow-id>27021600672053714</flow-id>\n"
761 + "</flow-mapping>\n"
762 + "<flow-mapping>\n"
763 + "<ce-vlan-id>20</ce-vlan-id>\n"
764 + "<flow-id>27021600672053720</flow-id>\n"
765 + "</flow-mapping>\n"
766 + "<flow-mapping>\n"
767 + "<ce-vlan-id>21</ce-vlan-id>\n"
768 + "<flow-id>27021600672053721</flow-id>\n"
769 + "</flow-mapping>\n"
770 + "<flow-mapping>\n"
771 + "<ce-vlan-id>22</ce-vlan-id>\n"
772 + "<flow-id>27021600672053722</flow-id>\n"
773 + "</flow-mapping>\n"
774 + "<flow-mapping>\n"
775 + "<ce-vlan-id>25</ce-vlan-id>\n"
776 + "<flow-id>27021600672053725</flow-id>\n"
777 + "</flow-mapping>\n"
778 + "</evc-per-uni-c>\n"
779 + "<evc-per-uni-n>\n"
780 + "<ce-vlan-map>13</ce-vlan-map>\n"
781 + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
782 + "<flow-mapping>\n"
783 + "<ce-vlan-id>13</ce-vlan-id>\n"
784 + "<flow-id>27021600672053713</flow-id>\n"
785 + "</flow-mapping>\n"
786 + "</evc-per-uni-n>\n"
787 + "</evc-per-uni>\n"
788 + "<uni-evc-id>EA1000-Uni-from-ONOS_5</uni-evc-id>\n"
789 + "<evc-status>\n"
790 + "<operational-state>unknown</operational-state>\n"
791 + "<max-mtu-size>9600</max-mtu-size>\n"
792 + "<max-num-uni>2</max-num-uni>\n"
793 + "</evc-status>\n"
794 + "</evc>\n"
795 + "</uni>\n"
796 + "<profiles>\n"
797 + "<bwp-group>\n"
798 + "<group-index>0</group-index>\n"
799 + "</bwp-group>\n"
800 + "</profiles>\n"
801 + "</mef-services>\n"
802 + "</data>\n"
803 + "</rpc-reply>";
804
805 private static final String SAMPLE_MSEAEVCUNI_CEVLANMAP_EVC_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
806 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
807 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
808 + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">\n"
809 + "<uni>\n"
810
811 + "<evc><evc-index>1</evc-index>\n"
812 + "<evc-per-uni>\n"
813 + "<evc-per-uni-c>\n"
814 + "<ce-vlan-map>101</ce-vlan-map>\n"
815 + "<flow-mapping>\n"
816 + "<ce-vlan-id>101</ce-vlan-id>\n"
817 + "<flow-id>27021598629213101</flow-id>\n"
818 + "</flow-mapping>\n"
819 + "</evc-per-uni-c>\n"
820 + "<evc-per-uni-n>\n"
821 + "<ce-vlan-map>102</ce-vlan-map>\n"
822 + "<flow-mapping>\n"
823 + "<ce-vlan-id>102</ce-vlan-id>\n"
824 + "<flow-id>27021598629213102</flow-id>\n"
825 + "</flow-mapping>\n"
826 + "</evc-per-uni-n>\n"
827 + "</evc-per-uni>\n"
828 + "</evc>\n"
829
830 + "<evc><evc-index>7</evc-index>\n"
831 + "<evc-per-uni>\n"
832 + "<evc-per-uni-c>\n"
833 + "<ce-vlan-map>700,710,720</ce-vlan-map>\n"
834 + "<flow-mapping>\n"
835 + "<ce-vlan-id>700</ce-vlan-id>\n"
836 + "<flow-id>27021598629213700</flow-id>\n"
837 + "</flow-mapping>\n"
838 + "<flow-mapping>\n"
839 + "<ce-vlan-id>710</ce-vlan-id>\n"
840 + "<flow-id>27021598629213710</flow-id>\n"
841 + "</flow-mapping>\n"
842 + "<flow-mapping>\n"
843 + "<ce-vlan-id>720</ce-vlan-id>\n"
844 + "<flow-id>27021598629213720</flow-id>\n"
845 + "</flow-mapping>\n"
846 + "</evc-per-uni-c>\n"
847 + "<evc-per-uni-n>\n"
848 + "<ce-vlan-map>701:703</ce-vlan-map>\n"
849 + "<flow-mapping>\n"
850 + "<ce-vlan-id>701</ce-vlan-id>\n"
851 + "<flow-id>27021598629213701</flow-id>\n"
852 + "</flow-mapping>\n"
853 + "<flow-mapping>\n"
854 + "<ce-vlan-id>702</ce-vlan-id>\n"
855 + "<flow-id>27021598629213702</flow-id>\n"
856 + "</flow-mapping>\n"
857 + "<flow-mapping>\n"
858 + "<ce-vlan-id>703</ce-vlan-id>\n"
859 + "<flow-id>27021598629213703</flow-id>\n"
860 + "</flow-mapping>\n"
861 + "</evc-per-uni-n>\n"
862 + "</evc-per-uni>\n"
863 + "</evc>\n"
864
865 + "<evc><evc-index>8</evc-index>\n"
866 + "<evc-per-uni>\n"
867 + "<evc-per-uni-c>\n<ce-vlan-map>800,810,820</ce-vlan-map>\n</evc-per-uni-c>\n"
868 + "<evc-per-uni-n>\n<ce-vlan-map>801:803</ce-vlan-map>\n</evc-per-uni-n>\n"
869 + "</evc-per-uni>\n"
870 + "</evc>\n"
871
872 + "</uni>\n"
873 + "</mef-services>\n"
874 + "</data>\n"
875 + "</rpc-reply>";
876
Sean Condon0e89bda2017-03-21 14:23:19 +0000877 private static final String SAMPLE_MSEACFM_MD_MA_MEP_ESSENTIALS_REPLY =
Sean Condonfae8e662016-12-15 10:25:13 +0000878 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
879 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
880 + "<data>"
881 + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
882 + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
883 + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
884 + "<maintenance-domain>"
885 + "<id>1</id>"
886 + "<name>md-1</name>"
Sean Condonfae8e662016-12-15 10:25:13 +0000887 + "<maintenance-association>"
888 + "<id>1</id>"
889 + "<name>ma-1-1</name>"
Sean Condonfae8e662016-12-15 10:25:13 +0000890 + "<maintenance-association-end-point>"
891 + "<mep-identifier>1</mep-identifier>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000892 + "<mac-address>00:b0:ae:03:ff:31</mac-address>"
Sean Condonfae8e662016-12-15 10:25:13 +0000893 + "<remote-mep-database>"
894 + "<remote-mep>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000895 + "<remote-mep-id>1</remote-mep-id>"
896 + "</remote-mep>"
897 + "<remote-mep>"
Sean Condonfae8e662016-12-15 10:25:13 +0000898 + "<remote-mep-id>2</remote-mep-id>"
Sean Condonfae8e662016-12-15 10:25:13 +0000899 + "</remote-mep>"
900 + "</remote-mep-database>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000901 + "<msea-soam-pm:delay-measurements>"
902 + "<msea-soam-pm:delay-measurement>"
903 + "<msea-soam-pm:dm-id>1</msea-soam-pm:dm-id>"
904 + "</msea-soam-pm:delay-measurement>"
905 + "</msea-soam-pm:delay-measurements>"
906 + "<msea-soam-pm:loss-measurements>"
907 + "<msea-soam-pm:loss-measurement>"
908 + "<msea-soam-pm:lm-id>1</msea-soam-pm:lm-id>"
909 + "</msea-soam-pm:loss-measurement>"
910 + "<msea-soam-pm:loss-measurement>"
911 + "<msea-soam-pm:lm-id>2</msea-soam-pm:lm-id>"
912 + "</msea-soam-pm:loss-measurement>"
913 + "</msea-soam-pm:loss-measurements>"
Sean Condonfae8e662016-12-15 10:25:13 +0000914 + "</maintenance-association-end-point>"
Sean Condonfae8e662016-12-15 10:25:13 +0000915 + "</maintenance-association>"
916 + "</maintenance-domain>"
917 + "</mef-cfm>"
918 + "</data>"
919 + "</rpc-reply>";
920
Sean Condon0e89bda2017-03-21 14:23:19 +0000921 private static final String SAMPLE_MSEACFM_MD_MA_MEP_FULL_REPLY =
Sean Condonfae8e662016-12-15 10:25:13 +0000922 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
923 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
924 + "<data>"
925 + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
926 + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
927 + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
928 + "<maintenance-domain>"
929 + "<id>1</id>"
Sean Condon1dbcd712017-10-19 12:09:21 +0100930 + "<name>" + EA1000CfmMepProgrammableTest.MD_ID_1 + "</name>"
Sean Condonfae8e662016-12-15 10:25:13 +0000931 + "<maintenance-association>"
932 + "<id>1</id>"
Sean Condon1dbcd712017-10-19 12:09:21 +0100933 + "<name>" + EA1000CfmMepProgrammableTest.MA_ID_11 + "</name>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000934 + "<ccm-interval>3.3ms</ccm-interval>"
Sean Condonfae8e662016-12-15 10:25:13 +0000935 + "<maintenance-association-end-point>"
Sean Condon1dbcd712017-10-19 12:09:21 +0100936 + "<mep-identifier>" + EA1000CfmMepProgrammableTest.MEP_111 + "</mep-identifier>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000937 + "<interface>eth0</interface>"
938 + "<primary-vid>20</primary-vid>"
Sean Condonfae8e662016-12-15 10:25:13 +0000939 + "<administrative-state>true</administrative-state>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000940 + "<mac-address>00:b0:ae:03:ff:31</mac-address>"
941 + "<ccm-ltm-priority>5</ccm-ltm-priority>"
Sean Condonfae8e662016-12-15 10:25:13 +0000942 + "<continuity-check>"
Sean Condon1dbcd712017-10-19 12:09:21 +0100943 + "<cci-enabled>true</cci-enabled>"
944 + "<fng-state>defect-reported</fng-state>"
945 + "<highest-priority-defect-found>remote-invalid-ccm</highest-priority-defect-found>"
946 + "<active-defects>remote-rdi remote-invalid-ccm</active-defects>"
947 + "<ccm-sequence-error-count>0</ccm-sequence-error-count>"
948 + "<sent-ccms>197</sent-ccms>"
Sean Condonfae8e662016-12-15 10:25:13 +0000949 + "</continuity-check>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000950 + "<loopback>"
951 + "</loopback>"
952 + "<linktrace>"
953 + "</linktrace>"
954 + "<remote-mep-database>"
955 + "<remote-mep>"
956 + "<remote-mep-id>1</remote-mep-id>"
957 + "<remote-mep-state>failed</remote-mep-state>"
958 + "<failed-ok-time>54654654</failed-ok-time>"
959 + "<mac-address>aa:bb:cc:dd:ee:ff</mac-address>"
960 + "<rdi>false</rdi>"
961 + "<port-status-tlv>no-status-tlv</port-status-tlv>"
962 + "<interface-status-tlv>dormant</interface-status-tlv>"
963 + "</remote-mep>"
964 + "<remote-mep>"
965 + "<remote-mep-id>2</remote-mep-id>"
966 + "<remote-mep-state>failed</remote-mep-state>"
967 + "<failed-ok-time>54654654</failed-ok-time>"
968 + "<mac-address>aa:bb:cc:dd:ee:ff</mac-address>"
969 + "<rdi>false</rdi>"
970 + "<port-status-tlv>no-status-tlv</port-status-tlv>"
971 + "<interface-status-tlv>dormant</interface-status-tlv>"
972 + "</remote-mep>"
973 + "</remote-mep-database>"
974 + "<msea-soam-fm:operational-state>enabled</msea-soam-fm:operational-state>"
975 + "<msea-soam-fm:connectivity-status>partially-active</msea-soam-fm:connectivity-status>"
Sean Condonfae8e662016-12-15 10:25:13 +0000976 + "<msea-soam-fm:port-status>up</msea-soam-fm:port-status>"
977 + "<msea-soam-fm:interface-status>up</msea-soam-fm:interface-status>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000978 + "<msea-soam-fm:last-defect-sent>remote-rdi remote-mac-error</msea-soam-fm:last-defect-sent>"
Sean Condonfae8e662016-12-15 10:25:13 +0000979 + "<msea-soam-fm:rdi-transmit-status>true</msea-soam-fm:rdi-transmit-status>"
Sean Condonfae8e662016-12-15 10:25:13 +0000980 + "</maintenance-association-end-point>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000981 + "</maintenance-association>"
982 + "</maintenance-domain>"
983 + "</mef-cfm>"
984 + "</data>"
985 + "</rpc-reply>";
986
Sean Condon1dbcd712017-10-19 12:09:21 +0100987
988 /**
989 * With an empty <last-defect-sent />. Retrieved from simulator.
990 */
991 private static final String SAMPLE_MSEACFM_MD_MA_MEP_FULL_REPLY2 =
992 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
993 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
994 + "<data>"
995 + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
996 + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
997 + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
998 + "<maintenance-domain>"
999 + "<id>1</id>"
1000 + "<name>" + EA1000CfmMepProgrammableTest.MD_ID_1 + "</name>"
1001 + "<maintenance-association>"
1002 + "<id>1</id>"
1003 + "<name>" + EA1000CfmMepProgrammableTest.MA_ID_11 + "</name>"
1004 + "<maintenance-association-end-point>"
1005 + "<mep-identifier>" + EA1000CfmMepProgrammableTest.MEP_112 + "</mep-identifier>"
1006 + "<interface>eth0</interface>"
1007 + "<administrative-state>true</administrative-state>"
1008 + "<ccm-ltm-priority>4</ccm-ltm-priority>"
1009 + "<continuity-check>"
1010 + "<cci-enabled>true</cci-enabled>"
1011 + "<fng-state>report-defect</fng-state>"
1012 + "<highest-priority-defect-found>remote-mac-error</highest-priority-defect-found>"
1013 + "<active-defects> remote-mac-error invalid-ccm</active-defects>"
1014 + "<last-error-ccm>U2FtcGxlIGxhc3QgZXJyb3IgY2NtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
1015 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
1016 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
1017 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
1018 + "</last-error-ccm>"
1019 + "<ccm-sequence-error-count>10</ccm-sequence-error-count>"
1020 + "<sent-ccms>15</sent-ccms>"
1021 + "</continuity-check>"
1022 + "<mac-address>53:65:61:6e:20:43</mac-address>"
1023 + "<msea-soam-fm:port-status>no-status-tlv</msea-soam-fm:port-status>"
1024 + "<msea-soam-fm:interface-status>no-status-tlv</msea-soam-fm:interface-status>"
1025 + "<msea-soam-fm:last-defect-sent />"
1026 + "<msea-soam-fm:rdi-transmit-status>false</msea-soam-fm:rdi-transmit-status>"
1027 + "<loopback>"
1028 + "<replies-received>123</replies-received>"
1029 + "<replies-transmitted>456</replies-transmitted>"
1030 + "</loopback>"
1031 + "<remote-mep-database>"
1032 + "<remote-mep>"
1033 + "<remote-mep-id>20</remote-mep-id>"
1034 + "<remote-mep-state>ok</remote-mep-state>"
1035 + "<failed-ok-time>150859498</failed-ok-time>"
1036 + "<mac-address>53:65:61:6e:20:43</mac-address>"
1037 + "<rdi>true</rdi>"
1038 + "<port-status-tlv>up</port-status-tlv>"
1039 + "<interface-status-tlv>no-status-tlv</interface-status-tlv>"
1040 + "</remote-mep>"
1041 + "<remote-mep>"
1042 + "<remote-mep-id>30</remote-mep-id>"
1043 + "<remote-mep-state>ok</remote-mep-state>"
1044 + "<failed-ok-time>150859498</failed-ok-time>"
1045 + "<mac-address>53:65:61:6e:20:43</mac-address>"
1046 + "<rdi>true</rdi>"
1047 + "<port-status-tlv>no-status-tlv</port-status-tlv>"
1048 + "<interface-status-tlv>down</interface-status-tlv>"
1049 + "</remote-mep>"
1050 + "</remote-mep-database>"
1051 + "<linktrace>"
1052 + "<unexpected-replies-received>0</unexpected-replies-received>"
1053 + "<msea-soam-fm:ltm-msgs-transmitted>2</msea-soam-fm:ltm-msgs-transmitted>"
1054 + "<msea-soam-fm:ltm-msgs-received>2</msea-soam-fm:ltm-msgs-received>"
1055 + "<msea-soam-fm:ltr-msgs-transmitted>2</msea-soam-fm:ltr-msgs-transmitted>"
1056 + "<msea-soam-fm:ltr-msgs-received>2</msea-soam-fm:ltr-msgs-received>"
1057 + "<linktrace-database />"
1058 + "</linktrace>"
1059 + "</maintenance-association-end-point>"
1060 + "</maintenance-association>"
1061 + "</maintenance-domain>"
1062 + "</mef-cfm>"
1063 + "</data>"
1064 + "</rpc-reply>";
1065
Sean Condon0e89bda2017-03-21 14:23:19 +00001066 private static final String SAMPLE_MSEACFM_DELAY_MEASUREMENT_FULL_REPLY =
1067 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
1068 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
1069 + "<data>"
1070 + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
1071 + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
1072 + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
1073 + "<maintenance-domain>"
1074 + "<id>1</id>"
1075 + "<name>md-1</name>"
1076 + "<maintenance-association>"
1077 + "<id>1</id>"
1078 + "<name>ma-1-1</name>"
1079 + "<maintenance-association-end-point>"
1080 + "<mep-identifier>1</mep-identifier>"
1081 + "<msea-soam-pm:delay-measurements>"
1082 + "<msea-soam-pm:delay-measurement>"
1083 + "<msea-soam-pm:dm-id>1</msea-soam-pm:dm-id>"
1084 + "<msea-soam-pm:mep-id>10</msea-soam-pm:mep-id>"
1085 + "<msea-soam-pm:administrative-state>true</msea-soam-pm:administrative-state>"
1086 + "<msea-soam-pm:measurement-enable>frame-delay-two-way-bins "
1087 + "frame-delay-two-way-max</msea-soam-pm:measurement-enable>"
1088 + "<msea-soam-pm:message-period>3ms</msea-soam-pm:message-period>"
1089 + "<msea-soam-pm:priority>6</msea-soam-pm:priority>"
1090 + "<msea-soam-pm:frame-size>1000</msea-soam-pm:frame-size>"
1091 + "<msea-soam-pm:measurement-interval>15</msea-soam-pm:measurement-interval>"
1092 + "<msea-soam-pm:number-intervals-stored>32</msea-soam-pm:number-intervals-stored>"
1093 + "<msea-soam-pm:session-status>active</msea-soam-pm:session-status>"
1094 + "<msea-soam-pm:frame-delay-two-way>100</msea-soam-pm:frame-delay-two-way>"
1095 + "<msea-soam-pm:inter-frame-delay-variation-two-way>101</msea-soam-pm:inter-frame-delay-variation-two-way>"
1096// + "<msea-soam-pm:current-stats>"
1097// + "</msea-soam-pm:current-stats>"
1098// + "<msea-soam-pm:history-stats>"
1099// + "</msea-soam-pm:history-stats>"
1100 + "</msea-soam-pm:delay-measurement>"
1101 + "</msea-soam-pm:delay-measurements>"
1102 + "</maintenance-association-end-point>"
Sean Condonfae8e662016-12-15 10:25:13 +00001103 + "</maintenance-association>"
1104 + "</maintenance-domain>"
1105 + "</mef-cfm>"
1106 + "</data>"
1107 + "</rpc-reply>";
1108
1109 private static final String SAMPLE_REPLY_OK = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1110 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"2\">"
1111 + "<ok/>"
1112 + "</rpc-reply>";
1113
1114 private NetconfDeviceInfo deviceInfo;
1115
1116 private final AtomicInteger messageIdInteger = new AtomicInteger(0);
1117
1118 public MockNetconfSessionEa1000(NetconfDeviceInfo deviceInfo) throws NetconfException {
1119 this.deviceInfo = deviceInfo;
1120 }
1121
1122 @Override
1123 public CompletableFuture<String> request(String request) throws NetconfException {
1124 // TODO Auto-generated method stub
1125 return null;
1126 }
1127
1128 @Override
1129 public String get(String request) throws NetconfException {
1130
1131 return sendRequest(request);
1132 }
1133
1134 @Override
1135 public String get(String filterSchema, String withDefaultsMode) throws NetconfException {
1136 StringBuilder rpc = new StringBuilder(XML_HEADER);
1137 rpc.append(RPC_OPEN);
1138 rpc.append(MESSAGE_ID_STRING);
1139 rpc.append(EQUAL);
1140 rpc.append("\"");
1141 rpc.append(messageIdInteger.get());
1142 rpc.append("\" ");
1143 rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
1144 rpc.append(GET_OPEN).append(NEW_LINE);
1145 if (filterSchema != null) {
1146 rpc.append(SUBTREE_FILTER_OPEN).append(NEW_LINE);
1147 rpc.append(filterSchema).append(NEW_LINE);
1148 rpc.append(SUBTREE_FILTER_CLOSE).append(NEW_LINE);
1149 }
1150 if (withDefaultsMode != null) {
1151 rpc.append(WITH_DEFAULT_OPEN).append(NETCONF_WITH_DEFAULTS_NAMESPACE).append(">");
1152 rpc.append(withDefaultsMode).append(WITH_DEFAULT_CLOSE).append(NEW_LINE);
1153 }
1154 rpc.append(GET_CLOSE).append(NEW_LINE);
1155 rpc.append(RPC_CLOSE).append(NEW_LINE);
1156 rpc.append(ENDPATTERN);
1157 String reply = sendRequest(rpc.toString());
1158 checkReply(reply);
1159 return reply;
1160 }
1161
1162 @Override
1163 public String doWrappedRpc(String request) throws NetconfException {
1164 StringBuilder rpc = new StringBuilder(XML_HEADER);
1165 rpc.append(RPC_OPEN);
1166 rpc.append(MESSAGE_ID_STRING);
1167 rpc.append(EQUAL);
1168 rpc.append("\"");
1169 rpc.append(messageIdInteger.get());
1170 rpc.append("\" ");
1171 rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
1172 rpc.append(request);
1173 rpc.append(RPC_CLOSE).append(NEW_LINE);
1174 rpc.append(ENDPATTERN);
1175 String reply = sendRequest(rpc.toString());
1176 checkReply(reply);
1177 return reply;
1178 }
1179
1180 @Override
1181 public String requestSync(String request) throws NetconfException {
1182 if (!request.contains(ENDPATTERN)) {
1183 request = request + NEW_LINE + ENDPATTERN;
1184 }
1185 String reply = sendRequest(request);
1186 checkReply(reply);
1187 return reply;
1188 }
1189
Sean Condonfae8e662016-12-15 10:25:13 +00001190 @Override
Sean Condon06613e92017-06-09 15:14:01 +01001191 public String getConfig(DatastoreId targetConfiguration, String configurationSchema) throws NetconfException {
Sean Condonfae8e662016-12-15 10:25:13 +00001192 StringBuilder rpc = new StringBuilder(XML_HEADER);
1193 rpc.append("<rpc ");
1194 rpc.append(MESSAGE_ID_STRING);
1195 rpc.append(EQUAL);
1196 rpc.append("\"");
1197 rpc.append(messageIdInteger.get());
1198 rpc.append("\" ");
1199 rpc.append("xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
1200 rpc.append("<get-config>\n");
1201 rpc.append("<source>\n");
1202 rpc.append("<").append(targetConfiguration).append("/>");
1203 rpc.append("</source>");
1204 if (configurationSchema != null) {
1205 rpc.append("<filter type=\"subtree\">\n");
1206 rpc.append(configurationSchema).append("\n");
1207 rpc.append("</filter>\n");
1208 }
1209 rpc.append("</get-config>\n");
1210 rpc.append("</rpc>\n");
1211 rpc.append(ENDPATTERN);
1212 String reply = sendRequest(rpc.toString());
1213 return checkReply(reply) ? reply : "ERROR " + reply;
1214 }
1215
1216 @Override
1217 public boolean editConfig(String newConfiguration) throws NetconfException {
Sean Condon06613e92017-06-09 15:14:01 +01001218 return editConfig(DatastoreId.RUNNING, null, newConfiguration);
Sean Condonfae8e662016-12-15 10:25:13 +00001219 }
1220
1221 @Override
Sean Condon06613e92017-06-09 15:14:01 +01001222 public boolean editConfig(DatastoreId targetConfiguration, String mode, String newConfiguration)
Sean Condonfae8e662016-12-15 10:25:13 +00001223 throws NetconfException {
1224 newConfiguration = newConfiguration.trim();
1225 StringBuilder rpc = new StringBuilder(XML_HEADER);
1226 rpc.append(RPC_OPEN);
1227 rpc.append(MESSAGE_ID_STRING);
1228 rpc.append(EQUAL);
1229 rpc.append("\"");
1230 rpc.append(messageIdInteger.get());
1231 rpc.append("\" ");
1232 rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
1233 rpc.append(EDIT_CONFIG_OPEN).append("\n");
1234 rpc.append(TARGET_OPEN);
1235 rpc.append("<").append(targetConfiguration).append("/>");
1236 rpc.append(TARGET_CLOSE).append("\n");
1237 if (mode != null) {
1238 rpc.append(DEFAULT_OPERATION_OPEN);
1239 rpc.append(mode);
1240 rpc.append(DEFAULT_OPERATION_CLOSE).append("\n");
1241 }
1242 rpc.append(CONFIG_OPEN).append("\n");
1243 rpc.append(newConfiguration);
1244 rpc.append(CONFIG_CLOSE).append("\n");
1245 rpc.append(EDIT_CONFIG_CLOSE).append("\n");
1246 rpc.append(RPC_CLOSE);
1247 rpc.append(ENDPATTERN);
1248 log.debug(rpc.toString());
1249 String reply = sendRequest(rpc.toString());
1250 return checkReply(reply);
1251 }
1252
1253 @Override
1254 public boolean copyConfig(String targetConfiguration, String newConfiguration) throws NetconfException {
Yuta HIGUCHIdd7c3f82017-09-03 14:18:01 -07001255 return copyConfig(DatastoreId.datastore(targetConfiguration), newConfiguration);
Sean Condonfae8e662016-12-15 10:25:13 +00001256 }
1257
1258 @Override
Sean Condonfae8e662016-12-15 10:25:13 +00001259 public void startSubscription() throws NetconfException {
1260 // TODO Auto-generated method stub
1261
1262 }
1263
1264 @Override
1265 public void startSubscription(String filterSchema) throws NetconfException {
1266 // TODO Auto-generated method stub
1267
1268 }
1269
1270 @Override
1271 public void endSubscription() throws NetconfException {
1272 // TODO Auto-generated method stub
1273
1274 }
1275
1276 @Override
Sean Condonfae8e662016-12-15 10:25:13 +00001277 public boolean lock() throws NetconfException {
1278 // TODO Auto-generated method stub
1279 return false;
1280 }
1281
1282 @Override
1283 public boolean unlock() throws NetconfException {
1284 // TODO Auto-generated method stub
1285 return false;
1286 }
1287
1288 @Override
1289 public boolean close() throws NetconfException {
1290 // TODO Auto-generated method stub
1291 return false;
1292 }
1293
1294 @Override
1295 public String getSessionId() {
1296 return "mockSessionId";
1297 }
1298
1299 @Override
Sean Condonfae8e662016-12-15 10:25:13 +00001300 public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
1301 // TODO Auto-generated method stub
1302
1303 }
1304
1305 @Override
1306 public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
1307 // TODO Auto-generated method stub
1308
1309 }
1310
1311 private boolean checkReply(String reply) throws NetconfException {
1312 if (reply != null) {
1313 if (!reply.contains("<rpc-error>")) {
1314 log.debug("Device {} sent reply {}", deviceInfo, reply);
1315 return true;
1316 } else if (reply.contains("<ok/>")
1317 || (reply.contains("<rpc-error>")
1318 && reply.contains("warning"))) {
1319 log.debug("Device {} sent reply {}", deviceInfo, reply);
1320 return true;
1321 }
1322 }
1323 log.warn("Device {} has error in reply {}", deviceInfo, reply);
1324 return false;
1325 }
1326
1327 private String sendRequest(String request) throws NetconfException {
1328 log.info("Mocking NETCONF Session send request: \n" + request);
1329
1330 if (sampleXmlRegex1.matcher(request).matches()) {
1331 return SAMPLE_SYSTEM_REPLY;
1332
1333 } else if (sampleXmlRegex2.matcher(request).matches()) {
1334 return SAMPLE_SYSTEM_REPLY_INIT;
1335
Sean Condon0e89bda2017-03-21 14:23:19 +00001336 } else if (sampleXmlRegexSaFilteringErrorScenario.matcher(request).matches()) {
1337 return SAMPLE_ERROR_REPLY;
1338
Sean Condonfae8e662016-12-15 10:25:13 +00001339 } else if (sampleXmlRegexSaFiltering.matcher(request).matches()) {
1340 return SAMPLE_MSEASAFILTERING_FE_REPLY;
1341
1342 } else if (sampleXmlRegexEditConfigSaFilt.matcher(request).matches()) {
1343 return SAMPLE_REPLY_OK;
1344
1345 } else if (sampleXmlRegexEditDeleteSaFilt.matcher(request).matches()) {
1346 return SAMPLE_REPLY_OK;
1347
1348 } else if (sampleXmlRegexUniEvc.matcher(request).matches()) {
1349 return SAMPLE_MSEAEVCUNI_REPLY_INIT;
1350
1351 } else if (sampleXmlRegexUniEvcUni.matcher(request).matches()) {
1352 return SAMPLE_MSEAEVCUNI_FE_REPLY;
1353
1354 } else if (sampleXmlRegexEditConfigUni1Evc.matcher(request).matches()) {
1355 return SAMPLE_REPLY_OK;
1356
1357 } else if (sampleXmlRegexEditConfigUni2Evc.matcher(request).matches()) {
1358 return SAMPLE_REPLY_OK;
1359
1360 } else if (sampleXmlRegexEditConfigUniProfiles.matcher(request).matches()) {
1361 return SAMPLE_REPLY_OK;
1362
1363 } else if (sampleXmlRegexEditConfigEvcDelete.matcher(request).matches()) {
1364 return SAMPLE_REPLY_OK;
1365
1366 } else if (sampleXmlRegexGetConfigCeVlanMapsEvc.matcher(request).matches()) {
1367 return SAMPLE_MSEAEVCUNI_CEVLANMAP_EVC_REPLY;
1368
1369 } else if (sampleXmlRegexEditConfigCeVlanMapReplace.matcher(request).matches()) {
1370 return SAMPLE_REPLY_OK;
1371
1372 } else if (sampleXmlRegexEditConfigBwpGroup1.matcher(request).matches()) {
1373 return SAMPLE_REPLY_OK;
1374
1375 } else if (sampleXmlRegexEditConfigBwpGroup1Delete.matcher(request).matches()) {
1376 return SAMPLE_REPLY_OK;
1377
1378 } else if (sampleXmlRegexSetCurrentDatetime.matcher(request).matches()) {
1379 return SAMPLE_REPLY_OK;
1380
1381 } else if (sampleXmlRegexGetMseaCfmEssentials.matcher(request).matches()) {
Sean Condon0e89bda2017-03-21 14:23:19 +00001382 return SAMPLE_MSEACFM_MD_MA_MEP_ESSENTIALS_REPLY;
1383
1384 } else if (sampleXmlRegexGetMseaCfmFull.matcher(request).matches()) {
1385 return SAMPLE_MSEACFM_MD_MA_MEP_FULL_REPLY;
1386
Sean Condon1dbcd712017-10-19 12:09:21 +01001387 } else if (sampleXmlRegexGetMseaCfmFull2.matcher(request).matches()) {
1388 return SAMPLE_MSEACFM_MD_MA_MEP_FULL_REPLY2;
1389
Sean Condon0e89bda2017-03-21 14:23:19 +00001390 } else if (sampleXmlRegexDeleteMseaCfmMep.matcher(request).matches()) {
1391 return SAMPLE_REPLY_OK;
1392
Sean Condon96b896d2017-12-11 12:44:29 -08001393 } else if (sampleXmlRegexCreateMseaCfmMa.matcher(request).matches()) {
1394 return SAMPLE_REPLY_OK;
1395
1396 } else if (sampleXmlRegexDeleteMseaCfmMa.matcher(request).matches()) {
1397 return SAMPLE_REPLY_OK;
1398
1399 } else if (sampleXmlRegexDeleteMseaCfmRmep.matcher(request).matches()) {
1400 return SAMPLE_REPLY_OK;
1401
1402 } else if (sampleXmlRegexDeleteMseaCfmMd.matcher(request).matches()) {
1403 return SAMPLE_REPLY_OK;
1404
Sean Condon0e89bda2017-03-21 14:23:19 +00001405 } else if (sampleXmlRegexGetMseaDelay.matcher(request).matches()) {
1406 return SAMPLE_MSEACFM_DELAY_MEASUREMENT_FULL_REPLY;
1407
1408 } else if (sampleXmlRegexEditConfigDmCreate.matcher(request).matches()) {
1409 return SAMPLE_REPLY_OK;
1410
1411 } else if (sampleXmlRegexTransmitLoopback.matcher(request).matches()) {
1412 return SAMPLE_REPLY_OK;
1413
1414 } else if (sampleXmlRegexAbortLoopback.matcher(request).matches()) {
1415 return SAMPLE_REPLY_OK;
Sean Condonfae8e662016-12-15 10:25:13 +00001416
1417 } else {
1418 throw new NetconfException("MocknetconfSession. No sendRequest() case for query: " +
1419 request);
1420 }
1421 }
1422}