blob: b9d43422501b514c07b4e143ad20af35c9a99c12 [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?"
481 + "(<id/>)?\\R?"
482 + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
483 + "(<maintenance-association>)\\R?"
484 + "(<id/>)?\\R?"
485 + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?"
486 + "(<maintenance-association-end-point nc:operation=\"delete\">)\\R?"
487 + "(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)\\R?"
488 + "(</maintenance-association-end-point>)\\R?"
489 + "(</maintenance-association>)\\R?"
490 + "(</maintenance-domain>)\\R?"
491 + "(</mef-cfm>)\\R?"
492 + "(</config>)\\R?"
493 + "(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
494
495
496 private Pattern sampleXmlRegexTransmitLoopback =
497 Pattern.compile("(<\\?xml).*(<rpc).*\\R?"
498 + "(<transmit-loopback xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\">)\\R?"
499 + "((<number-of-messages>)[0-9]*(</number-of-messages>))?\\R?"
500 + "((<data-tlv>)[a-zA-Z0-9+=/]*(</data-tlv>))?\\R?"
501 + "((<vlan-priority>)[0-9]{1}(</vlan-priority>))?\\R?"
502 + "((<vlan-drop-eligible>)((true)|(false))(</vlan-drop-eligible>))?\\R?"
503 + "(<maintenance-association-end-point>)[0-9]{1,4}(</maintenance-association-end-point>)\\R?"
504 + "(<maintenance-association>)[0-9]{1,5}(</maintenance-association>)\\R?"
505 + "(<maintenance-domain>)[0-9]{1,5}(</maintenance-domain>)\\R?"
506 + "(<target-address>)\\R?"
507 + "((<mep-id>)[0-9]{1,4}(</mep-id>))?\\R?"
508 + "((<mac-address>)[a-fA-F0-9:-]{17}(</mac-address>))?\\R?"
509 + "(</target-address>)\\R?"
510 + "(</transmit-loopback>)\\R?"
511 + "(</rpc>)\\R?"
512 + "(]]>){2}", Pattern.DOTALL);
513
514 private Pattern sampleXmlRegexAbortLoopback =
515 Pattern.compile("(<\\?xml).*(<rpc).*\\R?"
516 + "(<abort-loopback xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\">)\\R?"
517 + "(<maintenance-association-end-point>)[0-9]{1,4}(</maintenance-association-end-point>)\\R?"
518 + "(<maintenance-association>)[0-9]{1,5}(</maintenance-association>)\\R?"
519 + "(<maintenance-domain>)[0-9]{1,5}(</maintenance-domain>)\\R?"
520 + "(</abort-loopback>)\\R?"
521 + "(</rpc>)\\R?"
522 + "(]]>){2}", Pattern.DOTALL);
523
524 //For testCreateDm()
525 private Pattern sampleXmlRegexEditConfigDmCreate =
526 Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?"
527 + "(<target>\\R?<running/>\\R?</target>)\\R?"
528 + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?"
529 + "(<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\">)\\R?"
530 + "(<maintenance-domain>)\\R?"
531 + "(<id>)[0-9]*(</id>)\\R?"
532 + "(<maintenance-association>)\\R?"
533 + "(<id>)[0-9]*(</id>)\\R?"
534 + "(<maintenance-association-end-point>)\\R?"
535 + "(<mep-identifier>)[0-9]*(</mep-identifier>)\\R?"
536 + "(<delay-measurements xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">)\\R?"
537 + "(<delay-measurement>)\\R?"
538 + "(<dm-id>)[0-9]*(</dm-id>)\\R?"
539 + "((<administrative-state>)(true|false)(</administrative-state>))?\\R?"
540 + "((<message-period>)(1000ms|100ms|10ms|3ms)(</message-period>))?\\R?"
541 + "(<priority>)[0-9]*(</priority>)\\R?"
542 + "((<frame-size>)[0-9]*(</frame-size>))?\\R?"
543 + "(<mep-id>)[0-9]*(</mep-id>)\\R?"
544 + "(</delay-measurement>)\\R?"
545 + "(</delay-measurements>)\\R?"
546 + "(</maintenance-association-end-point>)\\R?"
547 + "(</maintenance-association>)\\R?"
548 + "(</maintenance-domain>)\\R?"
549 + "(</mef-cfm>)\\R?"
550 + "(</config>)\\R?"
551 + "(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL);
552
Sean Condonfae8e662016-12-15 10:25:13 +0000553
554 private static final String SAMPLE_SYSTEM_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
555 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
556 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
557 + "<system xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">\n"
558 + "<clock><timezone-name>Etc/UTC</timezone-name></clock>\n"
559 + "</system>\n"
560 + "</data>\n"
561 + "</rpc-reply>";
562
563 private static final String SAMPLE_SYSTEM_REPLY_INIT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
564 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">"
565 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
566 + "<system xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">\n"
567 + "<longitude xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">-8.4683990</longitude>\n"
568 + "<latitude xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">51.9036140</latitude>\n"
569 + "</system>\n"
570 + "<system-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\""
571 + " xmlns:sysms=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">\n"
572 + "<platform>\n"
573 + "<os-release>4.4.0-53-generic</os-release>\n"
574 + "<sysms:device-identification>\n"
Sean Condon1dbcd712017-10-19 12:09:21 +0100575 + "<sysms:serial-number>EA1000 unit test.</sysms:serial-number>\n"
Sean Condonfae8e662016-12-15 10:25:13 +0000576 + "</sysms:device-identification>\n"
577 + "</platform>\n"
578 + "</system-state>\n"
579 + "</data>"
580 + "</rpc-reply>";
581
582 private static final String SAMPLE_MSEASAFILTERING_FE_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
583 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
584 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
585 + "<source-ipaddress-filtering "
586 + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">\n"
587 + "<interface-eth0>\n"
588 + "<filter-admin-state>inactive</filter-admin-state>\n"
589 + "<source-address-range>\n"
590 + "<range-id>1</range-id>\n"
591 + "<ipv4-address-prefix>10.10.10.10/16</ipv4-address-prefix>\n"
592 + "<name>Filter1</name>\n"
593 + "</source-address-range>\n"
594 + "<source-address-range>\n"
595 + "<range-id>2</range-id>\n"
596 + "<ipv4-address-prefix>20.30.40.50/18</ipv4-address-prefix>\n"
597 + "<name>Flow:5e0000abaa2772</name>\n"
598 + "</source-address-range>\n"
599 + "</interface-eth0>\n"
600 + "</source-ipaddress-filtering>\n"
601 + "</data>\n"
602 + "</rpc-reply>";
603
Sean Condon0e89bda2017-03-21 14:23:19 +0000604 private static final String SAMPLE_ERROR_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
605 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
606 + "<rpc-error>"
607 + "<error-type>application</error-type>"
608 + "<error-tag>data-missing</error-tag>"
609 + "<error-severity>error</error-severity>"
610 + "<error-message>Request could not be completed because " +
611 "the relevant data model content does not exist.</error-message>"
612 + "</rpc-error>"
613 + "</rpc-reply>";
614
Sean Condonfae8e662016-12-15 10:25:13 +0000615 private static final String SAMPLE_MSEAEVCUNI_REPLY_INIT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
616 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
617 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
618 + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\"/>"
619 + "</data>\n"
620 + "</rpc-reply>";
621
622 private static final String SAMPLE_MSEAEVCUNI_FE_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
623 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
624 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
625 + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">\n"
626 + "<uni>\n"
627 + "<name>Flow:7557655abfecd57865</name>\n"
628 + "<evc>\n"
629 + "<evc-index>7</evc-index\n>"
630 + "<name>evc-7</name>\n"
631 + "<evc-per-uni>\n"
632 + "<evc-per-uni-c>\n"
633 + "<ce-vlan-map>10</ce-vlan-map>\n"
634 + "<ingress-bwp-group-index>1</ingress-bwp-group-index>\n"
635 + "<tag-push>\n"
636 + "<push-tag-type>pushStag</push-tag-type>\n"
637 + "<outer-tag-vlan>3</outer-tag-vlan>\n"
638 + "</tag-push>\n"
639 + "<flow-mapping>\n"
640 + "<ce-vlan-id>10</ce-vlan-id>\n"
641 + "<flow-id>27021600672053710</flow-id>\n"
642 + "</flow-mapping>\n"
643 + "<evc-per-uni-service-type>epl</evc-per-uni-service-type>\n"
644 + "</evc-per-uni-c>\n"
645 + "<evc-per-uni-n>\n"
646 + "<ce-vlan-map>11</ce-vlan-map>\n"
647 + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
648 + "<flow-mapping>\n"
649 + "<ce-vlan-id>11</ce-vlan-id>\n"
650 + "<flow-id>27021600672053711</flow-id>\n"
651 + "</flow-mapping>\n"
652 + "</evc-per-uni-n>\n"
653 + "</evc-per-uni>\n"
654 + "<uni-evc-id>EA1000-Uni-from-ONOS_5</uni-evc-id>\n"
655 + "<evc-status>\n"
656 + "<operational-state>unknown</operational-state>\n"
657 + "<max-mtu-size>9600</max-mtu-size>\n"
658 + "<max-num-uni>2</max-num-uni>\n"
659 + "</evc-status>\n"
660 + "</evc>\n"
661 + "<evc>\n"
662 + "<evc-index>8</evc-index>\n"
663 + "<name>evc-8</name>\n"
664 + "<evc-per-uni>\n"
665 + "<evc-per-uni-c>\n"
666 + "<ce-vlan-map>12:14,20:22,25</ce-vlan-map>\n"
667 + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
668 + "<tag-pop />\n"
669 + "<evc-per-uni-service-type>epl</evc-per-uni-service-type>\n"
670 + "<flow-mapping>\n"
671 + "<ce-vlan-id>12</ce-vlan-id>\n"
672 + "<flow-id>27021600672053712</flow-id>\n"
673 + "</flow-mapping>\n"
674 + "<flow-mapping>\n"
675 + "<ce-vlan-id>13</ce-vlan-id>\n"
676 + "<flow-id>27021600672053713</flow-id>\n"
677 + "</flow-mapping>\n"
678 + "<flow-mapping>\n"
679 + "<ce-vlan-id>14</ce-vlan-id>\n"
680 + "<flow-id>27021600672053714</flow-id>\n"
681 + "</flow-mapping>\n"
682 + "<flow-mapping>\n"
683 + "<ce-vlan-id>20</ce-vlan-id>\n"
684 + "<flow-id>27021600672053720</flow-id>\n"
685 + "</flow-mapping>\n"
686 + "<flow-mapping>\n"
687 + "<ce-vlan-id>21</ce-vlan-id>\n"
688 + "<flow-id>27021600672053721</flow-id>\n"
689 + "</flow-mapping>\n"
690 + "<flow-mapping>\n"
691 + "<ce-vlan-id>22</ce-vlan-id>\n"
692 + "<flow-id>27021600672053722</flow-id>\n"
693 + "</flow-mapping>\n"
694 + "<flow-mapping>\n"
695 + "<ce-vlan-id>25</ce-vlan-id>\n"
696 + "<flow-id>27021600672053725</flow-id>\n"
697 + "</flow-mapping>\n"
698 + "</evc-per-uni-c>\n"
699 + "<evc-per-uni-n>\n"
700 + "<ce-vlan-map>13</ce-vlan-map>\n"
701 + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n"
702 + "<flow-mapping>\n"
703 + "<ce-vlan-id>13</ce-vlan-id>\n"
704 + "<flow-id>27021600672053713</flow-id>\n"
705 + "</flow-mapping>\n"
706 + "</evc-per-uni-n>\n"
707 + "</evc-per-uni>\n"
708 + "<uni-evc-id>EA1000-Uni-from-ONOS_5</uni-evc-id>\n"
709 + "<evc-status>\n"
710 + "<operational-state>unknown</operational-state>\n"
711 + "<max-mtu-size>9600</max-mtu-size>\n"
712 + "<max-num-uni>2</max-num-uni>\n"
713 + "</evc-status>\n"
714 + "</evc>\n"
715 + "</uni>\n"
716 + "<profiles>\n"
717 + "<bwp-group>\n"
718 + "<group-index>0</group-index>\n"
719 + "</bwp-group>\n"
720 + "</profiles>\n"
721 + "</mef-services>\n"
722 + "</data>\n"
723 + "</rpc-reply>";
724
725 private static final String SAMPLE_MSEAEVCUNI_CEVLANMAP_EVC_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
726 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n"
727 + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
728 + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">\n"
729 + "<uni>\n"
730
731 + "<evc><evc-index>1</evc-index>\n"
732 + "<evc-per-uni>\n"
733 + "<evc-per-uni-c>\n"
734 + "<ce-vlan-map>101</ce-vlan-map>\n"
735 + "<flow-mapping>\n"
736 + "<ce-vlan-id>101</ce-vlan-id>\n"
737 + "<flow-id>27021598629213101</flow-id>\n"
738 + "</flow-mapping>\n"
739 + "</evc-per-uni-c>\n"
740 + "<evc-per-uni-n>\n"
741 + "<ce-vlan-map>102</ce-vlan-map>\n"
742 + "<flow-mapping>\n"
743 + "<ce-vlan-id>102</ce-vlan-id>\n"
744 + "<flow-id>27021598629213102</flow-id>\n"
745 + "</flow-mapping>\n"
746 + "</evc-per-uni-n>\n"
747 + "</evc-per-uni>\n"
748 + "</evc>\n"
749
750 + "<evc><evc-index>7</evc-index>\n"
751 + "<evc-per-uni>\n"
752 + "<evc-per-uni-c>\n"
753 + "<ce-vlan-map>700,710,720</ce-vlan-map>\n"
754 + "<flow-mapping>\n"
755 + "<ce-vlan-id>700</ce-vlan-id>\n"
756 + "<flow-id>27021598629213700</flow-id>\n"
757 + "</flow-mapping>\n"
758 + "<flow-mapping>\n"
759 + "<ce-vlan-id>710</ce-vlan-id>\n"
760 + "<flow-id>27021598629213710</flow-id>\n"
761 + "</flow-mapping>\n"
762 + "<flow-mapping>\n"
763 + "<ce-vlan-id>720</ce-vlan-id>\n"
764 + "<flow-id>27021598629213720</flow-id>\n"
765 + "</flow-mapping>\n"
766 + "</evc-per-uni-c>\n"
767 + "<evc-per-uni-n>\n"
768 + "<ce-vlan-map>701:703</ce-vlan-map>\n"
769 + "<flow-mapping>\n"
770 + "<ce-vlan-id>701</ce-vlan-id>\n"
771 + "<flow-id>27021598629213701</flow-id>\n"
772 + "</flow-mapping>\n"
773 + "<flow-mapping>\n"
774 + "<ce-vlan-id>702</ce-vlan-id>\n"
775 + "<flow-id>27021598629213702</flow-id>\n"
776 + "</flow-mapping>\n"
777 + "<flow-mapping>\n"
778 + "<ce-vlan-id>703</ce-vlan-id>\n"
779 + "<flow-id>27021598629213703</flow-id>\n"
780 + "</flow-mapping>\n"
781 + "</evc-per-uni-n>\n"
782 + "</evc-per-uni>\n"
783 + "</evc>\n"
784
785 + "<evc><evc-index>8</evc-index>\n"
786 + "<evc-per-uni>\n"
787 + "<evc-per-uni-c>\n<ce-vlan-map>800,810,820</ce-vlan-map>\n</evc-per-uni-c>\n"
788 + "<evc-per-uni-n>\n<ce-vlan-map>801:803</ce-vlan-map>\n</evc-per-uni-n>\n"
789 + "</evc-per-uni>\n"
790 + "</evc>\n"
791
792 + "</uni>\n"
793 + "</mef-services>\n"
794 + "</data>\n"
795 + "</rpc-reply>";
796
Sean Condon0e89bda2017-03-21 14:23:19 +0000797 private static final String SAMPLE_MSEACFM_MD_MA_MEP_ESSENTIALS_REPLY =
Sean Condonfae8e662016-12-15 10:25:13 +0000798 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
799 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
800 + "<data>"
801 + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
802 + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
803 + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
804 + "<maintenance-domain>"
805 + "<id>1</id>"
806 + "<name>md-1</name>"
Sean Condonfae8e662016-12-15 10:25:13 +0000807 + "<maintenance-association>"
808 + "<id>1</id>"
809 + "<name>ma-1-1</name>"
Sean Condonfae8e662016-12-15 10:25:13 +0000810 + "<maintenance-association-end-point>"
811 + "<mep-identifier>1</mep-identifier>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000812 + "<mac-address>00:b0:ae:03:ff:31</mac-address>"
Sean Condonfae8e662016-12-15 10:25:13 +0000813 + "<remote-mep-database>"
814 + "<remote-mep>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000815 + "<remote-mep-id>1</remote-mep-id>"
816 + "</remote-mep>"
817 + "<remote-mep>"
Sean Condonfae8e662016-12-15 10:25:13 +0000818 + "<remote-mep-id>2</remote-mep-id>"
Sean Condonfae8e662016-12-15 10:25:13 +0000819 + "</remote-mep>"
820 + "</remote-mep-database>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000821 + "<msea-soam-pm:delay-measurements>"
822 + "<msea-soam-pm:delay-measurement>"
823 + "<msea-soam-pm:dm-id>1</msea-soam-pm:dm-id>"
824 + "</msea-soam-pm:delay-measurement>"
825 + "</msea-soam-pm:delay-measurements>"
826 + "<msea-soam-pm:loss-measurements>"
827 + "<msea-soam-pm:loss-measurement>"
828 + "<msea-soam-pm:lm-id>1</msea-soam-pm:lm-id>"
829 + "</msea-soam-pm:loss-measurement>"
830 + "<msea-soam-pm:loss-measurement>"
831 + "<msea-soam-pm:lm-id>2</msea-soam-pm:lm-id>"
832 + "</msea-soam-pm:loss-measurement>"
833 + "</msea-soam-pm:loss-measurements>"
Sean Condonfae8e662016-12-15 10:25:13 +0000834 + "</maintenance-association-end-point>"
Sean Condonfae8e662016-12-15 10:25:13 +0000835 + "</maintenance-association>"
836 + "</maintenance-domain>"
837 + "</mef-cfm>"
838 + "</data>"
839 + "</rpc-reply>";
840
Sean Condon0e89bda2017-03-21 14:23:19 +0000841 private static final String SAMPLE_MSEACFM_MD_MA_MEP_FULL_REPLY =
Sean Condonfae8e662016-12-15 10:25:13 +0000842 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
843 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
844 + "<data>"
845 + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
846 + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
847 + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
848 + "<maintenance-domain>"
849 + "<id>1</id>"
Sean Condon1dbcd712017-10-19 12:09:21 +0100850 + "<name>" + EA1000CfmMepProgrammableTest.MD_ID_1 + "</name>"
Sean Condonfae8e662016-12-15 10:25:13 +0000851 + "<maintenance-association>"
852 + "<id>1</id>"
Sean Condon1dbcd712017-10-19 12:09:21 +0100853 + "<name>" + EA1000CfmMepProgrammableTest.MA_ID_11 + "</name>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000854 + "<ccm-interval>3.3ms</ccm-interval>"
Sean Condonfae8e662016-12-15 10:25:13 +0000855 + "<maintenance-association-end-point>"
Sean Condon1dbcd712017-10-19 12:09:21 +0100856 + "<mep-identifier>" + EA1000CfmMepProgrammableTest.MEP_111 + "</mep-identifier>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000857 + "<interface>eth0</interface>"
858 + "<primary-vid>20</primary-vid>"
Sean Condonfae8e662016-12-15 10:25:13 +0000859 + "<administrative-state>true</administrative-state>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000860 + "<mac-address>00:b0:ae:03:ff:31</mac-address>"
861 + "<ccm-ltm-priority>5</ccm-ltm-priority>"
Sean Condonfae8e662016-12-15 10:25:13 +0000862 + "<continuity-check>"
Sean Condon1dbcd712017-10-19 12:09:21 +0100863 + "<cci-enabled>true</cci-enabled>"
864 + "<fng-state>defect-reported</fng-state>"
865 + "<highest-priority-defect-found>remote-invalid-ccm</highest-priority-defect-found>"
866 + "<active-defects>remote-rdi remote-invalid-ccm</active-defects>"
867 + "<ccm-sequence-error-count>0</ccm-sequence-error-count>"
868 + "<sent-ccms>197</sent-ccms>"
Sean Condonfae8e662016-12-15 10:25:13 +0000869 + "</continuity-check>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000870 + "<loopback>"
871 + "</loopback>"
872 + "<linktrace>"
873 + "</linktrace>"
874 + "<remote-mep-database>"
875 + "<remote-mep>"
876 + "<remote-mep-id>1</remote-mep-id>"
877 + "<remote-mep-state>failed</remote-mep-state>"
878 + "<failed-ok-time>54654654</failed-ok-time>"
879 + "<mac-address>aa:bb:cc:dd:ee:ff</mac-address>"
880 + "<rdi>false</rdi>"
881 + "<port-status-tlv>no-status-tlv</port-status-tlv>"
882 + "<interface-status-tlv>dormant</interface-status-tlv>"
883 + "</remote-mep>"
884 + "<remote-mep>"
885 + "<remote-mep-id>2</remote-mep-id>"
886 + "<remote-mep-state>failed</remote-mep-state>"
887 + "<failed-ok-time>54654654</failed-ok-time>"
888 + "<mac-address>aa:bb:cc:dd:ee:ff</mac-address>"
889 + "<rdi>false</rdi>"
890 + "<port-status-tlv>no-status-tlv</port-status-tlv>"
891 + "<interface-status-tlv>dormant</interface-status-tlv>"
892 + "</remote-mep>"
893 + "</remote-mep-database>"
894 + "<msea-soam-fm:operational-state>enabled</msea-soam-fm:operational-state>"
895 + "<msea-soam-fm:connectivity-status>partially-active</msea-soam-fm:connectivity-status>"
Sean Condonfae8e662016-12-15 10:25:13 +0000896 + "<msea-soam-fm:port-status>up</msea-soam-fm:port-status>"
897 + "<msea-soam-fm:interface-status>up</msea-soam-fm:interface-status>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000898 + "<msea-soam-fm:last-defect-sent>remote-rdi remote-mac-error</msea-soam-fm:last-defect-sent>"
Sean Condonfae8e662016-12-15 10:25:13 +0000899 + "<msea-soam-fm:rdi-transmit-status>true</msea-soam-fm:rdi-transmit-status>"
Sean Condonfae8e662016-12-15 10:25:13 +0000900 + "</maintenance-association-end-point>"
Sean Condon0e89bda2017-03-21 14:23:19 +0000901 + "</maintenance-association>"
902 + "</maintenance-domain>"
903 + "</mef-cfm>"
904 + "</data>"
905 + "</rpc-reply>";
906
Sean Condon1dbcd712017-10-19 12:09:21 +0100907
908 /**
909 * With an empty <last-defect-sent />. Retrieved from simulator.
910 */
911 private static final String SAMPLE_MSEACFM_MD_MA_MEP_FULL_REPLY2 =
912 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
913 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
914 + "<data>"
915 + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
916 + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
917 + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
918 + "<maintenance-domain>"
919 + "<id>1</id>"
920 + "<name>" + EA1000CfmMepProgrammableTest.MD_ID_1 + "</name>"
921 + "<maintenance-association>"
922 + "<id>1</id>"
923 + "<name>" + EA1000CfmMepProgrammableTest.MA_ID_11 + "</name>"
924 + "<maintenance-association-end-point>"
925 + "<mep-identifier>" + EA1000CfmMepProgrammableTest.MEP_112 + "</mep-identifier>"
926 + "<interface>eth0</interface>"
927 + "<administrative-state>true</administrative-state>"
928 + "<ccm-ltm-priority>4</ccm-ltm-priority>"
929 + "<continuity-check>"
930 + "<cci-enabled>true</cci-enabled>"
931 + "<fng-state>report-defect</fng-state>"
932 + "<highest-priority-defect-found>remote-mac-error</highest-priority-defect-found>"
933 + "<active-defects> remote-mac-error invalid-ccm</active-defects>"
934 + "<last-error-ccm>U2FtcGxlIGxhc3QgZXJyb3IgY2NtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
935 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
936 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
937 + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
938 + "</last-error-ccm>"
939 + "<ccm-sequence-error-count>10</ccm-sequence-error-count>"
940 + "<sent-ccms>15</sent-ccms>"
941 + "</continuity-check>"
942 + "<mac-address>53:65:61:6e:20:43</mac-address>"
943 + "<msea-soam-fm:port-status>no-status-tlv</msea-soam-fm:port-status>"
944 + "<msea-soam-fm:interface-status>no-status-tlv</msea-soam-fm:interface-status>"
945 + "<msea-soam-fm:last-defect-sent />"
946 + "<msea-soam-fm:rdi-transmit-status>false</msea-soam-fm:rdi-transmit-status>"
947 + "<loopback>"
948 + "<replies-received>123</replies-received>"
949 + "<replies-transmitted>456</replies-transmitted>"
950 + "</loopback>"
951 + "<remote-mep-database>"
952 + "<remote-mep>"
953 + "<remote-mep-id>20</remote-mep-id>"
954 + "<remote-mep-state>ok</remote-mep-state>"
955 + "<failed-ok-time>150859498</failed-ok-time>"
956 + "<mac-address>53:65:61:6e:20:43</mac-address>"
957 + "<rdi>true</rdi>"
958 + "<port-status-tlv>up</port-status-tlv>"
959 + "<interface-status-tlv>no-status-tlv</interface-status-tlv>"
960 + "</remote-mep>"
961 + "<remote-mep>"
962 + "<remote-mep-id>30</remote-mep-id>"
963 + "<remote-mep-state>ok</remote-mep-state>"
964 + "<failed-ok-time>150859498</failed-ok-time>"
965 + "<mac-address>53:65:61:6e:20:43</mac-address>"
966 + "<rdi>true</rdi>"
967 + "<port-status-tlv>no-status-tlv</port-status-tlv>"
968 + "<interface-status-tlv>down</interface-status-tlv>"
969 + "</remote-mep>"
970 + "</remote-mep-database>"
971 + "<linktrace>"
972 + "<unexpected-replies-received>0</unexpected-replies-received>"
973 + "<msea-soam-fm:ltm-msgs-transmitted>2</msea-soam-fm:ltm-msgs-transmitted>"
974 + "<msea-soam-fm:ltm-msgs-received>2</msea-soam-fm:ltm-msgs-received>"
975 + "<msea-soam-fm:ltr-msgs-transmitted>2</msea-soam-fm:ltr-msgs-transmitted>"
976 + "<msea-soam-fm:ltr-msgs-received>2</msea-soam-fm:ltr-msgs-received>"
977 + "<linktrace-database />"
978 + "</linktrace>"
979 + "</maintenance-association-end-point>"
980 + "</maintenance-association>"
981 + "</maintenance-domain>"
982 + "</mef-cfm>"
983 + "</data>"
984 + "</rpc-reply>";
985
Sean Condon0e89bda2017-03-21 14:23:19 +0000986 private static final String SAMPLE_MSEACFM_DELAY_MEASUREMENT_FULL_REPLY =
987 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
988 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">"
989 + "<data>"
990 + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" "
991 + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" "
992 + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">"
993 + "<maintenance-domain>"
994 + "<id>1</id>"
995 + "<name>md-1</name>"
996 + "<maintenance-association>"
997 + "<id>1</id>"
998 + "<name>ma-1-1</name>"
999 + "<maintenance-association-end-point>"
1000 + "<mep-identifier>1</mep-identifier>"
1001 + "<msea-soam-pm:delay-measurements>"
1002 + "<msea-soam-pm:delay-measurement>"
1003 + "<msea-soam-pm:dm-id>1</msea-soam-pm:dm-id>"
1004 + "<msea-soam-pm:mep-id>10</msea-soam-pm:mep-id>"
1005 + "<msea-soam-pm:administrative-state>true</msea-soam-pm:administrative-state>"
1006 + "<msea-soam-pm:measurement-enable>frame-delay-two-way-bins "
1007 + "frame-delay-two-way-max</msea-soam-pm:measurement-enable>"
1008 + "<msea-soam-pm:message-period>3ms</msea-soam-pm:message-period>"
1009 + "<msea-soam-pm:priority>6</msea-soam-pm:priority>"
1010 + "<msea-soam-pm:frame-size>1000</msea-soam-pm:frame-size>"
1011 + "<msea-soam-pm:measurement-interval>15</msea-soam-pm:measurement-interval>"
1012 + "<msea-soam-pm:number-intervals-stored>32</msea-soam-pm:number-intervals-stored>"
1013 + "<msea-soam-pm:session-status>active</msea-soam-pm:session-status>"
1014 + "<msea-soam-pm:frame-delay-two-way>100</msea-soam-pm:frame-delay-two-way>"
1015 + "<msea-soam-pm:inter-frame-delay-variation-two-way>101</msea-soam-pm:inter-frame-delay-variation-two-way>"
1016// + "<msea-soam-pm:current-stats>"
1017// + "</msea-soam-pm:current-stats>"
1018// + "<msea-soam-pm:history-stats>"
1019// + "</msea-soam-pm:history-stats>"
1020 + "</msea-soam-pm:delay-measurement>"
1021 + "</msea-soam-pm:delay-measurements>"
1022 + "</maintenance-association-end-point>"
Sean Condonfae8e662016-12-15 10:25:13 +00001023 + "</maintenance-association>"
1024 + "</maintenance-domain>"
1025 + "</mef-cfm>"
1026 + "</data>"
1027 + "</rpc-reply>";
1028
1029 private static final String SAMPLE_REPLY_OK = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
1030 + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"2\">"
1031 + "<ok/>"
1032 + "</rpc-reply>";
1033
1034 private NetconfDeviceInfo deviceInfo;
1035
1036 private final AtomicInteger messageIdInteger = new AtomicInteger(0);
1037
1038 public MockNetconfSessionEa1000(NetconfDeviceInfo deviceInfo) throws NetconfException {
1039 this.deviceInfo = deviceInfo;
1040 }
1041
1042 @Override
1043 public CompletableFuture<String> request(String request) throws NetconfException {
1044 // TODO Auto-generated method stub
1045 return null;
1046 }
1047
1048 @Override
1049 public String get(String request) throws NetconfException {
1050
1051 return sendRequest(request);
1052 }
1053
1054 @Override
1055 public String get(String filterSchema, String withDefaultsMode) throws NetconfException {
1056 StringBuilder rpc = new StringBuilder(XML_HEADER);
1057 rpc.append(RPC_OPEN);
1058 rpc.append(MESSAGE_ID_STRING);
1059 rpc.append(EQUAL);
1060 rpc.append("\"");
1061 rpc.append(messageIdInteger.get());
1062 rpc.append("\" ");
1063 rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
1064 rpc.append(GET_OPEN).append(NEW_LINE);
1065 if (filterSchema != null) {
1066 rpc.append(SUBTREE_FILTER_OPEN).append(NEW_LINE);
1067 rpc.append(filterSchema).append(NEW_LINE);
1068 rpc.append(SUBTREE_FILTER_CLOSE).append(NEW_LINE);
1069 }
1070 if (withDefaultsMode != null) {
1071 rpc.append(WITH_DEFAULT_OPEN).append(NETCONF_WITH_DEFAULTS_NAMESPACE).append(">");
1072 rpc.append(withDefaultsMode).append(WITH_DEFAULT_CLOSE).append(NEW_LINE);
1073 }
1074 rpc.append(GET_CLOSE).append(NEW_LINE);
1075 rpc.append(RPC_CLOSE).append(NEW_LINE);
1076 rpc.append(ENDPATTERN);
1077 String reply = sendRequest(rpc.toString());
1078 checkReply(reply);
1079 return reply;
1080 }
1081
1082 @Override
1083 public String doWrappedRpc(String request) throws NetconfException {
1084 StringBuilder rpc = new StringBuilder(XML_HEADER);
1085 rpc.append(RPC_OPEN);
1086 rpc.append(MESSAGE_ID_STRING);
1087 rpc.append(EQUAL);
1088 rpc.append("\"");
1089 rpc.append(messageIdInteger.get());
1090 rpc.append("\" ");
1091 rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
1092 rpc.append(request);
1093 rpc.append(RPC_CLOSE).append(NEW_LINE);
1094 rpc.append(ENDPATTERN);
1095 String reply = sendRequest(rpc.toString());
1096 checkReply(reply);
1097 return reply;
1098 }
1099
1100 @Override
1101 public String requestSync(String request) throws NetconfException {
1102 if (!request.contains(ENDPATTERN)) {
1103 request = request + NEW_LINE + ENDPATTERN;
1104 }
1105 String reply = sendRequest(request);
1106 checkReply(reply);
1107 return reply;
1108 }
1109
Sean Condonfae8e662016-12-15 10:25:13 +00001110 @Override
Sean Condon06613e92017-06-09 15:14:01 +01001111 public String getConfig(DatastoreId targetConfiguration, String configurationSchema) throws NetconfException {
Sean Condonfae8e662016-12-15 10:25:13 +00001112 StringBuilder rpc = new StringBuilder(XML_HEADER);
1113 rpc.append("<rpc ");
1114 rpc.append(MESSAGE_ID_STRING);
1115 rpc.append(EQUAL);
1116 rpc.append("\"");
1117 rpc.append(messageIdInteger.get());
1118 rpc.append("\" ");
1119 rpc.append("xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
1120 rpc.append("<get-config>\n");
1121 rpc.append("<source>\n");
1122 rpc.append("<").append(targetConfiguration).append("/>");
1123 rpc.append("</source>");
1124 if (configurationSchema != null) {
1125 rpc.append("<filter type=\"subtree\">\n");
1126 rpc.append(configurationSchema).append("\n");
1127 rpc.append("</filter>\n");
1128 }
1129 rpc.append("</get-config>\n");
1130 rpc.append("</rpc>\n");
1131 rpc.append(ENDPATTERN);
1132 String reply = sendRequest(rpc.toString());
1133 return checkReply(reply) ? reply : "ERROR " + reply;
1134 }
1135
1136 @Override
1137 public boolean editConfig(String newConfiguration) throws NetconfException {
Sean Condon06613e92017-06-09 15:14:01 +01001138 return editConfig(DatastoreId.RUNNING, null, newConfiguration);
Sean Condonfae8e662016-12-15 10:25:13 +00001139 }
1140
1141 @Override
Sean Condon06613e92017-06-09 15:14:01 +01001142 public boolean editConfig(DatastoreId targetConfiguration, String mode, String newConfiguration)
Sean Condonfae8e662016-12-15 10:25:13 +00001143 throws NetconfException {
1144 newConfiguration = newConfiguration.trim();
1145 StringBuilder rpc = new StringBuilder(XML_HEADER);
1146 rpc.append(RPC_OPEN);
1147 rpc.append(MESSAGE_ID_STRING);
1148 rpc.append(EQUAL);
1149 rpc.append("\"");
1150 rpc.append(messageIdInteger.get());
1151 rpc.append("\" ");
1152 rpc.append(NETCONF_BASE_NAMESPACE).append(">\n");
1153 rpc.append(EDIT_CONFIG_OPEN).append("\n");
1154 rpc.append(TARGET_OPEN);
1155 rpc.append("<").append(targetConfiguration).append("/>");
1156 rpc.append(TARGET_CLOSE).append("\n");
1157 if (mode != null) {
1158 rpc.append(DEFAULT_OPERATION_OPEN);
1159 rpc.append(mode);
1160 rpc.append(DEFAULT_OPERATION_CLOSE).append("\n");
1161 }
1162 rpc.append(CONFIG_OPEN).append("\n");
1163 rpc.append(newConfiguration);
1164 rpc.append(CONFIG_CLOSE).append("\n");
1165 rpc.append(EDIT_CONFIG_CLOSE).append("\n");
1166 rpc.append(RPC_CLOSE);
1167 rpc.append(ENDPATTERN);
1168 log.debug(rpc.toString());
1169 String reply = sendRequest(rpc.toString());
1170 return checkReply(reply);
1171 }
1172
1173 @Override
1174 public boolean copyConfig(String targetConfiguration, String newConfiguration) throws NetconfException {
Yuta HIGUCHIdd7c3f82017-09-03 14:18:01 -07001175 return copyConfig(DatastoreId.datastore(targetConfiguration), newConfiguration);
Sean Condonfae8e662016-12-15 10:25:13 +00001176 }
1177
1178 @Override
Sean Condonfae8e662016-12-15 10:25:13 +00001179 public void startSubscription() throws NetconfException {
1180 // TODO Auto-generated method stub
1181
1182 }
1183
1184 @Override
1185 public void startSubscription(String filterSchema) throws NetconfException {
1186 // TODO Auto-generated method stub
1187
1188 }
1189
1190 @Override
1191 public void endSubscription() throws NetconfException {
1192 // TODO Auto-generated method stub
1193
1194 }
1195
1196 @Override
Sean Condonfae8e662016-12-15 10:25:13 +00001197 public boolean lock() throws NetconfException {
1198 // TODO Auto-generated method stub
1199 return false;
1200 }
1201
1202 @Override
1203 public boolean unlock() throws NetconfException {
1204 // TODO Auto-generated method stub
1205 return false;
1206 }
1207
1208 @Override
1209 public boolean close() throws NetconfException {
1210 // TODO Auto-generated method stub
1211 return false;
1212 }
1213
1214 @Override
1215 public String getSessionId() {
1216 return "mockSessionId";
1217 }
1218
1219 @Override
Sean Condonfae8e662016-12-15 10:25:13 +00001220 public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
1221 // TODO Auto-generated method stub
1222
1223 }
1224
1225 @Override
1226 public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) {
1227 // TODO Auto-generated method stub
1228
1229 }
1230
1231 private boolean checkReply(String reply) throws NetconfException {
1232 if (reply != null) {
1233 if (!reply.contains("<rpc-error>")) {
1234 log.debug("Device {} sent reply {}", deviceInfo, reply);
1235 return true;
1236 } else if (reply.contains("<ok/>")
1237 || (reply.contains("<rpc-error>")
1238 && reply.contains("warning"))) {
1239 log.debug("Device {} sent reply {}", deviceInfo, reply);
1240 return true;
1241 }
1242 }
1243 log.warn("Device {} has error in reply {}", deviceInfo, reply);
1244 return false;
1245 }
1246
1247 private String sendRequest(String request) throws NetconfException {
1248 log.info("Mocking NETCONF Session send request: \n" + request);
1249
1250 if (sampleXmlRegex1.matcher(request).matches()) {
1251 return SAMPLE_SYSTEM_REPLY;
1252
1253 } else if (sampleXmlRegex2.matcher(request).matches()) {
1254 return SAMPLE_SYSTEM_REPLY_INIT;
1255
Sean Condon0e89bda2017-03-21 14:23:19 +00001256 } else if (sampleXmlRegexSaFilteringErrorScenario.matcher(request).matches()) {
1257 return SAMPLE_ERROR_REPLY;
1258
Sean Condonfae8e662016-12-15 10:25:13 +00001259 } else if (sampleXmlRegexSaFiltering.matcher(request).matches()) {
1260 return SAMPLE_MSEASAFILTERING_FE_REPLY;
1261
1262 } else if (sampleXmlRegexEditConfigSaFilt.matcher(request).matches()) {
1263 return SAMPLE_REPLY_OK;
1264
1265 } else if (sampleXmlRegexEditDeleteSaFilt.matcher(request).matches()) {
1266 return SAMPLE_REPLY_OK;
1267
1268 } else if (sampleXmlRegexUniEvc.matcher(request).matches()) {
1269 return SAMPLE_MSEAEVCUNI_REPLY_INIT;
1270
1271 } else if (sampleXmlRegexUniEvcUni.matcher(request).matches()) {
1272 return SAMPLE_MSEAEVCUNI_FE_REPLY;
1273
1274 } else if (sampleXmlRegexEditConfigUni1Evc.matcher(request).matches()) {
1275 return SAMPLE_REPLY_OK;
1276
1277 } else if (sampleXmlRegexEditConfigUni2Evc.matcher(request).matches()) {
1278 return SAMPLE_REPLY_OK;
1279
1280 } else if (sampleXmlRegexEditConfigUniProfiles.matcher(request).matches()) {
1281 return SAMPLE_REPLY_OK;
1282
1283 } else if (sampleXmlRegexEditConfigEvcDelete.matcher(request).matches()) {
1284 return SAMPLE_REPLY_OK;
1285
1286 } else if (sampleXmlRegexGetConfigCeVlanMapsEvc.matcher(request).matches()) {
1287 return SAMPLE_MSEAEVCUNI_CEVLANMAP_EVC_REPLY;
1288
1289 } else if (sampleXmlRegexEditConfigCeVlanMapReplace.matcher(request).matches()) {
1290 return SAMPLE_REPLY_OK;
1291
1292 } else if (sampleXmlRegexEditConfigBwpGroup1.matcher(request).matches()) {
1293 return SAMPLE_REPLY_OK;
1294
1295 } else if (sampleXmlRegexEditConfigBwpGroup1Delete.matcher(request).matches()) {
1296 return SAMPLE_REPLY_OK;
1297
1298 } else if (sampleXmlRegexSetCurrentDatetime.matcher(request).matches()) {
1299 return SAMPLE_REPLY_OK;
1300
1301 } else if (sampleXmlRegexGetMseaCfmEssentials.matcher(request).matches()) {
Sean Condon0e89bda2017-03-21 14:23:19 +00001302 return SAMPLE_MSEACFM_MD_MA_MEP_ESSENTIALS_REPLY;
1303
1304 } else if (sampleXmlRegexGetMseaCfmFull.matcher(request).matches()) {
1305 return SAMPLE_MSEACFM_MD_MA_MEP_FULL_REPLY;
1306
Sean Condon1dbcd712017-10-19 12:09:21 +01001307 } else if (sampleXmlRegexGetMseaCfmFull2.matcher(request).matches()) {
1308 return SAMPLE_MSEACFM_MD_MA_MEP_FULL_REPLY2;
1309
Sean Condon0e89bda2017-03-21 14:23:19 +00001310 } else if (sampleXmlRegexDeleteMseaCfmMep.matcher(request).matches()) {
1311 return SAMPLE_REPLY_OK;
1312
1313 } else if (sampleXmlRegexGetMseaDelay.matcher(request).matches()) {
1314 return SAMPLE_MSEACFM_DELAY_MEASUREMENT_FULL_REPLY;
1315
1316 } else if (sampleXmlRegexEditConfigDmCreate.matcher(request).matches()) {
1317 return SAMPLE_REPLY_OK;
1318
1319 } else if (sampleXmlRegexTransmitLoopback.matcher(request).matches()) {
1320 return SAMPLE_REPLY_OK;
1321
1322 } else if (sampleXmlRegexAbortLoopback.matcher(request).matches()) {
1323 return SAMPLE_REPLY_OK;
Sean Condonfae8e662016-12-15 10:25:13 +00001324
1325 } else {
1326 throw new NetconfException("MocknetconfSession. No sendRequest() case for query: " +
1327 request);
1328 }
1329 }
1330}