Sean Condon | fae8e66 | 2016-12-15 10:25:13 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 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 | */ |
| 16 | package org.onosproject.drivers.microsemi.yang; |
| 17 | |
| 18 | import java.util.List; |
| 19 | import java.util.concurrent.CompletableFuture; |
| 20 | import java.util.concurrent.atomic.AtomicInteger; |
| 21 | import java.util.regex.Pattern; |
| 22 | |
| 23 | import org.onosproject.netconf.NetconfDeviceInfo; |
| 24 | import org.onosproject.netconf.NetconfDeviceOutputEventListener; |
| 25 | import org.onosproject.netconf.NetconfException; |
| 26 | import org.onosproject.netconf.NetconfSession; |
| 27 | import org.onosproject.netconf.TargetConfig; |
| 28 | import org.slf4j.Logger; |
| 29 | import org.slf4j.LoggerFactory; |
| 30 | |
| 31 | public class MockNetconfSessionEa1000 implements NetconfSession { |
| 32 | 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).*" |
| 76 | + "(<rpc).*(<get>).*" |
| 77 | + "(<filter type=\"subtree\">).*(<source-ipaddress-filtering).*" |
| 78 | + "(</filter>).*(</get>).*(</rpc>).*" |
| 79 | + "(]]>){2}", Pattern.DOTALL); |
| 80 | |
| 81 | private Pattern sampleXmlRegexEditConfigSaFilt = |
| 82 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*" |
| 83 | + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*" |
| 84 | + "(<source-ipaddress-filtering).*(<interface-eth0>).*" |
| 85 | + "(<source-address-range>).*(<range-id>).*(</range-id>).*" |
| 86 | + "(<name>).*(</name>).*(<ipv4-address-prefix>).*(</ipv4-address-prefix>).*" |
| 87 | + "(</source-address-range>).*(</interface-eth0>)*(</source-ipaddress-filtering>).*" |
| 88 | + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL); |
| 89 | |
| 90 | private Pattern sampleXmlRegexEditDeleteSaFilt = |
| 91 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*" |
| 92 | + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*" |
| 93 | + "(<source-ipaddress-filtering " |
| 94 | + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">).*" |
| 95 | + "(<interface-eth0>).*" |
| 96 | + "(<source-address-range nc:operation=\"delete\">).*(<range-id>).*(</range-id>).*" |
| 97 | + "(</source-address-range>).*" |
| 98 | + "(<source-address-range nc:operation=\"delete\">).*(<range-id>).*(</range-id>).*" |
| 99 | + "(</source-address-range>).*" |
| 100 | + "(</interface-eth0>).*(</source-ipaddress-filtering>).*" |
| 101 | + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL); |
| 102 | |
| 103 | private Pattern sampleXmlRegexUniEvc = |
| 104 | Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?" |
| 105 | + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?" |
| 106 | + "(<filter type=\"subtree\">)\\R?" |
| 107 | + "(<mef-services " |
| 108 | + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\"/>)\\R?" |
| 109 | + "(</filter>)\\R?(</get-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL); |
| 110 | |
| 111 | private Pattern sampleXmlRegexUniEvcUni = |
| 112 | Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?" |
| 113 | + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?" |
| 114 | + "(<filter type=\"subtree\">)\\R?" |
| 115 | + "(<mef-services " |
| 116 | + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?" |
| 117 | + "(<uni/>)\\R?" |
| 118 | + "(</mef-services>)\\R?" |
| 119 | + "(</filter>)\\R?(</get-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL); |
| 120 | |
| 121 | private Pattern sampleXmlRegexEditConfigUni1Evc = |
| 122 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?" |
| 123 | + "(<target><running/></target>)\\R?" |
| 124 | + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?" |
| 125 | + "(<mef-services).*(<uni>)\\R?(<name>).*(</name>)\\R?" |
| 126 | + "(<evc>)\\R?(<evc-index>).*(</evc-index>)\\R?(<name>).*(</name>)\\R?" |
| 127 | + "(<evc-per-uni>)\\R?" |
| 128 | + "(<evc-per-uni-c>)\\R?" |
| 129 | + "(<ce-vlan-map>).*(</ce-vlan-map>)\\R?" |
| 130 | + "(<ingress-bwp-group-index>).*(</ingress-bwp-group-index>)\\R?" |
| 131 | + "(<tag-push>)\\R?(<push-tag-type>)pushStag(</push-tag-type>)\\R?(<outer-tag-vlan>).*" |
| 132 | + "(</outer-tag-vlan>)\\R?(</tag-push>)\\R?" |
| 133 | + "((<flow-mapping>)\\R?" |
| 134 | + "(<ce-vlan-id>)[0-9]*(</ce-vlan-id>)\\R?" |
| 135 | + "(<flow-id>)[0-9]*(</flow-id>)\\R?" |
| 136 | + "(</flow-mapping>)\\R?)*" |
| 137 | + "(</evc-per-uni-c>)\\R?" |
| 138 | + "(<evc-per-uni-n>)\\R?" |
| 139 | + "(<ce-vlan-map>).*(</ce-vlan-map>)\\R?" |
| 140 | + "(<ingress-bwp-group-index>).*(</ingress-bwp-group-index>)\\R?" |
| 141 | + "(<tag-pop).*" |
| 142 | + "((<flow-mapping>)\\R?" |
| 143 | + "(<ce-vlan-id>)[0-9]*(</ce-vlan-id>)\\R?" |
| 144 | + "(<flow-id>)[0-9]*(</flow-id>)\\R?" |
| 145 | + "(</flow-mapping>)\\R?)*" |
| 146 | + "(</evc-per-uni-n>)\\R?" |
| 147 | + "(</evc-per-uni>)\\R?" |
| 148 | + "(</evc>)\\R?" |
| 149 | + "(</uni>).*" |
| 150 | + "(</mef-services>)\\R?" |
| 151 | + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL); |
| 152 | |
| 153 | private Pattern sampleXmlRegexEditConfigUni2Evc = |
| 154 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?" |
| 155 | + "(<target><running/></target>)\\R?" |
| 156 | + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?" |
| 157 | + "(<mef-services).*(<uni>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?" |
| 158 | + "(<evc>)\\R?(<evc-index>)[0-9]*(</evc-index>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?" |
| 159 | + "(<evc-per-uni>)\\R?" |
| 160 | + "(<evc-per-uni-c>)\\R?" |
| 161 | + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?" |
| 162 | + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?" |
| 163 | + "(</evc-per-uni-c>)\\R?" |
| 164 | + "(<evc-per-uni-n>)\\R?" |
| 165 | + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?" |
| 166 | + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?" |
| 167 | + "(<evc-per-uni-service-type>).*(</evc-per-uni-service-type>)\\R?" |
| 168 | + "(<tag-push>)\\R?(<push-tag-type>)pushStag(</push-tag-type>)\\R?(<outer-tag-vlan>).*" |
| 169 | + "(</outer-tag-vlan>)\\R?(</tag-push>)\\R?" |
| 170 | + "(</evc-per-uni-n>)\\R?" |
| 171 | + "(</evc-per-uni>)\\R?" |
| 172 | + "(</evc>)\\R?" |
| 173 | + "(<evc>)\\R?(<evc-index>)[0-9]*(</evc-index>)\\R?(<name>)[0-9a-zA-Z\\-\\:]*(</name>)\\R?" |
| 174 | + "(<evc-per-uni>)\\R?" |
| 175 | + "(<evc-per-uni-c>)\\R?" |
| 176 | + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?" |
| 177 | + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?" |
| 178 | + "(</evc-per-uni-c>)\\R?" |
| 179 | + "(<evc-per-uni-n>)\\R?" |
| 180 | + "(<ce-vlan-map>)[0-9\\:\\,]*(</ce-vlan-map>)\\R?" |
| 181 | + "(<ingress-bwp-group-index>)[0-9]*(</ingress-bwp-group-index>)\\R?" |
| 182 | + "(</evc-per-uni-n>)\\R?" |
| 183 | + "(</evc-per-uni>)\\R?" |
| 184 | + "(</evc>)\\R?(</uni>).*" |
| 185 | + "(</mef-services>)\\R?" |
| 186 | + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL); |
| 187 | |
| 188 | private Pattern sampleXmlRegexEditConfigUniProfiles = |
| 189 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*" |
| 190 | + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*" |
| 191 | + "(<mef-services).*(<profiles>).*" |
| 192 | + "(<bwp-group>).*(<group-index>).*(</group-index>).*(</bwp-group>).*" |
| 193 | + "(<bwp-group>).*(<group-index>).*(</group-index>).*" |
| 194 | + "(<bwp>).*(<cos-index>).*(</cos-index>).*(<color-mode>).*(</color-mode>).*(</bwp>).*" |
| 195 | + "(<bwp>).*(<cos-index>).*(</cos-index>).*(<color-mode>).*(</color-mode>).*(</bwp>).*" |
| 196 | + "(</bwp-group>).*" |
| 197 | + "(</profiles>).*(</mef-services>).*" |
| 198 | + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL); |
| 199 | |
| 200 | private Pattern sampleXmlRegexEditConfigEvcDelete = |
| 201 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*" |
| 202 | + "(<target><running/></target>).*(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*" |
| 203 | + "(<mef-services).*" |
| 204 | + "(<uni>).*" |
| 205 | + "(<evc nc:operation=\"delete\">).*(<evc-index>).*(</evc-index>).*(</evc>).*" |
| 206 | + "(</uni>).*" |
| 207 | + "(</mef-services>).*" |
| 208 | + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL); |
| 209 | |
| 210 | private Pattern sampleXmlRegexGetConfigCeVlanMapsEvc = |
| 211 | Pattern.compile("(<\\?xml).*(<rpc).*(<get-config>)\\R?" |
| 212 | + "(<source>)\\R?(<running/>)\\R?(</source>)\\R?" |
| 213 | + "(<filter type=\"subtree\">)\\R?" |
| 214 | + "(<mef-services).*" |
| 215 | + "(<uni>)\\R?" |
| 216 | + "(<evc>)\\R?" |
| 217 | + "(<evc-index/>)\\R?" |
| 218 | + "(<evc-per-uni>)\\R?" |
| 219 | + "(<evc-per-uni-c><ce-vlan-map/><flow-mapping/><ingress-bwp-group-index/></evc-per-uni-c>)\\R?" |
| 220 | + "(<evc-per-uni-n><ce-vlan-map/><flow-mapping/><ingress-bwp-group-index/></evc-per-uni-n>)\\R?" |
| 221 | + "(</evc-per-uni>)\\R?" |
| 222 | + "(</evc>)\\R?" |
| 223 | + "(</uni>)\\R?" |
| 224 | + "(</mef-services>)\\R?" |
| 225 | + "(</filter>)\\R?" |
| 226 | + "(</get-config>)\\R?" |
| 227 | + "(</rpc>)\\R?" |
| 228 | + "(]]>){2}", Pattern.DOTALL); |
| 229 | |
| 230 | //For test testRemoveEvcUniFlowEntries() |
| 231 | private Pattern sampleXmlRegexEditConfigCeVlanMapReplace = |
| 232 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>).*" |
| 233 | + "(<target><running/></target>).*" |
| 234 | + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">).*" |
| 235 | + "(<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">).*" |
| 236 | + "(<uni>).*" |
| 237 | + "(<evc nc:operation=\"delete\">).*(<evc-index>.*</evc-index>).*(</evc>).*" |
| 238 | + "(<evc nc:operation=\"delete\">).*(<evc-index>.*</evc-index>).*(</evc>).*" |
| 239 | + "(<evc>).*(<evc-index>).*(</evc-index>).*(<evc-per-uni>).*" |
| 240 | + "(<evc-per-uni-c>).*" |
| 241 | + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*" |
| 242 | + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*" |
| 243 | + "(</evc-per-uni-c>).*" |
| 244 | + "(<evc-per-uni-n>).*" |
| 245 | + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*" |
| 246 | + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*" |
| 247 | + "(</evc-per-uni-n>).*" |
| 248 | + "(</evc-per-uni>).*(</evc>).*" |
| 249 | + "(<evc>).*(<evc-index>).*(</evc-index>).*(<evc-per-uni>).*" |
| 250 | + "(<evc-per-uni-c>).*" |
| 251 | + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*" |
| 252 | + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*" |
| 253 | + "(</evc-per-uni-c>).*" |
| 254 | + "(<evc-per-uni-n>).*" |
| 255 | + "(<ce-vlan-map nc:operation=\"replace\">).*(</ce-vlan-map>).*" |
| 256 | + "(<flow-mapping nc:operation=\"delete\">).*(<ce-vlan-id>).*(</ce-vlan-id>).*(</flow-mapping>).*" |
| 257 | + "(</evc-per-uni-n>).*" |
| 258 | + "(</evc-per-uni>).*(</evc>).*" |
| 259 | + "(</uni>).*(</mef-services>).*" |
| 260 | + "(</config>).*(</edit-config>).*(</rpc>).*(]]>){2}", Pattern.DOTALL); |
| 261 | |
| 262 | |
| 263 | //For testPerformMeterOperationDeviceIdMeterAdd() |
| 264 | private Pattern sampleXmlRegexEditConfigBwpGroup1 = |
| 265 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?" |
| 266 | + "(<target>\\R?<running/>\\R?</target>)\\R?" |
| 267 | + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?" |
| 268 | + "(<mef-services " |
| 269 | + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?" |
| 270 | + "(<profiles>)\\R?" |
| 271 | + "(<bwp-group>)\\R?" |
| 272 | + "(<group-index>)[0-9]*(</group-index>)\\R?" |
| 273 | + "(<bwp>)\\R?" |
| 274 | + "(<cos-index>)[0-9]*(</cos-index>)\\R?" |
| 275 | + "(<name>).*(</name>)\\R?" |
| 276 | + "(<committed-information-rate>)[0-9]*(</committed-information-rate>)\\R?" |
| 277 | + "(<committed-burst-size>)[0-9]*(</committed-burst-size>)\\R?" |
| 278 | + "(<excess-information-rate>)[0-9]*(</excess-information-rate>)\\R?" |
| 279 | + "(<excess-burst-size>)[0-9]*(</excess-burst-size>)\\R?" |
| 280 | + "(</bwp>)\\R?" |
| 281 | + "(</bwp-group>)\\R?" |
| 282 | + "(<cos>)\\R?" |
| 283 | + "(<cos-index>)[0-9](</cos-index>)\\R?" |
| 284 | + "(<name>).*(</name>)\\R?" |
| 285 | + "(<outgoing-cos-value>)[0-9]*(</outgoing-cos-value>)\\R?" |
| 286 | + "(<color-aware>true</color-aware>)\\R?" |
| 287 | + "(<color-forward>true</color-forward>)\\R?" |
| 288 | + "(<evc-cos-type-all-8-prio-to-1-evc-color>)\\R?" |
| 289 | + "(<evc-all-8-color-to>green</evc-all-8-color-to>)\\R?" |
| 290 | + "(</evc-cos-type-all-8-prio-to-1-evc-color>)\\R?" |
| 291 | + "(</cos>)\\R?" |
| 292 | + "(</profiles>)\\R?" |
| 293 | + "(</mef-services>)\\R?" |
| 294 | + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL); |
| 295 | |
| 296 | //For testPerformMeterOperationDeviceIdMeterRemove() |
| 297 | private Pattern sampleXmlRegexEditConfigBwpGroup1Delete = |
| 298 | Pattern.compile("(<\\?xml).*(<rpc).*(<edit-config>)\\R?" |
| 299 | + "(<target>\\R?<running/>\\R?</target>)\\R?" |
| 300 | + "(<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">)\\R?" |
| 301 | + "(<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">)\\R?" |
| 302 | + "(<profiles>)\\R?" |
| 303 | + "(<bwp-group nc:operation=\"delete\">)\\R?" |
| 304 | + "(<group-index>)[0-9]*(</group-index>)\\R?" |
| 305 | + "(</bwp-group>)\\R?" |
| 306 | + "(</profiles>)\\R?" |
| 307 | + "(</mef-services>)\\R?" |
| 308 | + "(</config>)\\R?(</edit-config>)\\R?(</rpc>)\\R?(]]>){2}", Pattern.DOTALL); |
| 309 | |
| 310 | private Pattern sampleXmlRegexSetCurrentDatetime = |
| 311 | Pattern.compile("(<\\?xml).*(<rpc).*" |
| 312 | + "(<set-current-datetime xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">)\\R?" |
| 313 | + "(<current-datetime>)" |
| 314 | + "[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}" |
| 315 | + "(</current-datetime>)\\R?" |
| 316 | + "(</set-current-datetime>)\\R?" |
| 317 | + "(</rpc>)\\R?(]]>){2}", Pattern.DOTALL); |
| 318 | |
| 319 | //For testGetConfigMseaCfmEssentials |
| 320 | private Pattern sampleXmlRegexGetMseaCfmEssentials = |
| 321 | Pattern.compile("(<\\?xml).*(<rpc).*(<get>)\\R?" |
| 322 | + "(<filter type=\"subtree\">)\\R?" |
| 323 | + "(<mef-cfm).*" |
| 324 | + "(<maintenance-domain>)\\R?" |
| 325 | + "(<id/>)\\R?" |
| 326 | + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?" |
| 327 | + "(<md-level/>)\\R?" |
| 328 | + "(<maintenance-association>)\\R?" |
| 329 | + "(<id/>)\\R?" |
| 330 | + "(<name>)([a-zA-Z0-9\\-:\\.]){1,48}(</name>)\\R?" |
| 331 | // rpc.append("<ccm-interval>10ms</ccm-interval>\n"); //Have to omit for the moment - YMS problem |
| 332 | + "(<remote-meps/>)\\R?" |
| 333 | + "(<component-list/>)\\R?" |
| 334 | + "(<maintenance-association-end-point>)\\R?" |
| 335 | + "(<mep-identifier>)[0-9]{1,4}(</mep-identifier>)\\R?" |
| 336 | + "(<interface/>)\\R?" |
| 337 | + "(<primary-vid/>)\\R?" |
| 338 | + "(<administrative-state/>)\\R?" |
| 339 | + "(<ccm-ltm-priority/>)\\R?" |
| 340 | + "(<continuity-check/>)\\R?" |
| 341 | + "(<mac-address/>)\\R?" |
| 342 | + "(<msea-soam-fm:port-status/>)\\R?" |
| 343 | + "(<msea-soam-fm:interface-status/>)\\R?" |
| 344 | // rpc.append("<msea-soam-fm:last-defect-sent/>\n");//Have to omit for the moment - YMS problem |
| 345 | + "(<msea-soam-fm:rdi-transmit-status/>)\\R?" |
| 346 | + "(<loopback/>)\\R?" |
| 347 | + "(<remote-mep-database/>)\\R?" |
| 348 | + "(<linktrace/>)\\R?" |
| 349 | + "(</maintenance-association-end-point>)\\R?" |
| 350 | + "(</maintenance-association>)\\R?" |
| 351 | + "(</maintenance-domain>)\\R?" |
| 352 | + "(</mef-cfm>)\\R?" |
| 353 | + "(</filter>)\\R?" |
| 354 | + "(</get>)\\R?" |
| 355 | + "(</rpc>)\\R?" |
| 356 | + "(]]>){2}", Pattern.DOTALL); |
| 357 | |
| 358 | |
| 359 | private static final String SAMPLE_SYSTEM_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 360 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" |
| 361 | + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" |
| 362 | + "<system xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">\n" |
| 363 | + "<clock><timezone-name>Etc/UTC</timezone-name></clock>\n" |
| 364 | + "</system>\n" |
| 365 | + "</data>\n" |
| 366 | + "</rpc-reply>"; |
| 367 | |
| 368 | private static final String SAMPLE_SYSTEM_REPLY_INIT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
| 369 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">" |
| 370 | + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" |
| 371 | + "<system xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">\n" |
| 372 | + "<longitude xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">-8.4683990</longitude>\n" |
| 373 | + "<latitude xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">51.9036140</latitude>\n" |
| 374 | + "</system>\n" |
| 375 | + "<system-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\"" |
| 376 | + " xmlns:sysms=\"http://www.microsemi.com/microsemi-edge-assure/msea-system\">\n" |
| 377 | + "<platform>\n" |
| 378 | + "<os-release>4.4.0-53-generic</os-release>\n" |
| 379 | + "<sysms:device-identification>\n" |
| 380 | + "<sysms:serial-number>Eagle Simulator.</sysms:serial-number>\n" |
| 381 | + "</sysms:device-identification>\n" |
| 382 | + "</platform>\n" |
| 383 | + "</system-state>\n" |
| 384 | + "</data>" |
| 385 | + "</rpc-reply>"; |
| 386 | |
| 387 | private static final String SAMPLE_MSEASAFILTERING_FE_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 388 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" |
| 389 | + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" |
| 390 | + "<source-ipaddress-filtering " |
| 391 | + "xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-sa-filtering\">\n" |
| 392 | + "<interface-eth0>\n" |
| 393 | + "<filter-admin-state>inactive</filter-admin-state>\n" |
| 394 | + "<source-address-range>\n" |
| 395 | + "<range-id>1</range-id>\n" |
| 396 | + "<ipv4-address-prefix>10.10.10.10/16</ipv4-address-prefix>\n" |
| 397 | + "<name>Filter1</name>\n" |
| 398 | + "</source-address-range>\n" |
| 399 | + "<source-address-range>\n" |
| 400 | + "<range-id>2</range-id>\n" |
| 401 | + "<ipv4-address-prefix>20.30.40.50/18</ipv4-address-prefix>\n" |
| 402 | + "<name>Flow:5e0000abaa2772</name>\n" |
| 403 | + "</source-address-range>\n" |
| 404 | + "</interface-eth0>\n" |
| 405 | + "</source-ipaddress-filtering>\n" |
| 406 | + "</data>\n" |
| 407 | + "</rpc-reply>"; |
| 408 | |
| 409 | private static final String SAMPLE_MSEAEVCUNI_REPLY_INIT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 410 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" |
| 411 | + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" |
| 412 | + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\"/>" |
| 413 | + "</data>\n" |
| 414 | + "</rpc-reply>"; |
| 415 | |
| 416 | private static final String SAMPLE_MSEAEVCUNI_FE_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 417 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" |
| 418 | + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" |
| 419 | + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">\n" |
| 420 | + "<uni>\n" |
| 421 | + "<name>Flow:7557655abfecd57865</name>\n" |
| 422 | + "<evc>\n" |
| 423 | + "<evc-index>7</evc-index\n>" |
| 424 | + "<name>evc-7</name>\n" |
| 425 | + "<evc-per-uni>\n" |
| 426 | + "<evc-per-uni-c>\n" |
| 427 | + "<ce-vlan-map>10</ce-vlan-map>\n" |
| 428 | + "<ingress-bwp-group-index>1</ingress-bwp-group-index>\n" |
| 429 | + "<tag-push>\n" |
| 430 | + "<push-tag-type>pushStag</push-tag-type>\n" |
| 431 | + "<outer-tag-vlan>3</outer-tag-vlan>\n" |
| 432 | + "</tag-push>\n" |
| 433 | + "<flow-mapping>\n" |
| 434 | + "<ce-vlan-id>10</ce-vlan-id>\n" |
| 435 | + "<flow-id>27021600672053710</flow-id>\n" |
| 436 | + "</flow-mapping>\n" |
| 437 | + "<evc-per-uni-service-type>epl</evc-per-uni-service-type>\n" |
| 438 | + "</evc-per-uni-c>\n" |
| 439 | + "<evc-per-uni-n>\n" |
| 440 | + "<ce-vlan-map>11</ce-vlan-map>\n" |
| 441 | + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n" |
| 442 | + "<flow-mapping>\n" |
| 443 | + "<ce-vlan-id>11</ce-vlan-id>\n" |
| 444 | + "<flow-id>27021600672053711</flow-id>\n" |
| 445 | + "</flow-mapping>\n" |
| 446 | + "</evc-per-uni-n>\n" |
| 447 | + "</evc-per-uni>\n" |
| 448 | + "<uni-evc-id>EA1000-Uni-from-ONOS_5</uni-evc-id>\n" |
| 449 | + "<evc-status>\n" |
| 450 | + "<operational-state>unknown</operational-state>\n" |
| 451 | + "<max-mtu-size>9600</max-mtu-size>\n" |
| 452 | + "<max-num-uni>2</max-num-uni>\n" |
| 453 | + "</evc-status>\n" |
| 454 | + "</evc>\n" |
| 455 | + "<evc>\n" |
| 456 | + "<evc-index>8</evc-index>\n" |
| 457 | + "<name>evc-8</name>\n" |
| 458 | + "<evc-per-uni>\n" |
| 459 | + "<evc-per-uni-c>\n" |
| 460 | + "<ce-vlan-map>12:14,20:22,25</ce-vlan-map>\n" |
| 461 | + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n" |
| 462 | + "<tag-pop />\n" |
| 463 | + "<evc-per-uni-service-type>epl</evc-per-uni-service-type>\n" |
| 464 | + "<flow-mapping>\n" |
| 465 | + "<ce-vlan-id>12</ce-vlan-id>\n" |
| 466 | + "<flow-id>27021600672053712</flow-id>\n" |
| 467 | + "</flow-mapping>\n" |
| 468 | + "<flow-mapping>\n" |
| 469 | + "<ce-vlan-id>13</ce-vlan-id>\n" |
| 470 | + "<flow-id>27021600672053713</flow-id>\n" |
| 471 | + "</flow-mapping>\n" |
| 472 | + "<flow-mapping>\n" |
| 473 | + "<ce-vlan-id>14</ce-vlan-id>\n" |
| 474 | + "<flow-id>27021600672053714</flow-id>\n" |
| 475 | + "</flow-mapping>\n" |
| 476 | + "<flow-mapping>\n" |
| 477 | + "<ce-vlan-id>20</ce-vlan-id>\n" |
| 478 | + "<flow-id>27021600672053720</flow-id>\n" |
| 479 | + "</flow-mapping>\n" |
| 480 | + "<flow-mapping>\n" |
| 481 | + "<ce-vlan-id>21</ce-vlan-id>\n" |
| 482 | + "<flow-id>27021600672053721</flow-id>\n" |
| 483 | + "</flow-mapping>\n" |
| 484 | + "<flow-mapping>\n" |
| 485 | + "<ce-vlan-id>22</ce-vlan-id>\n" |
| 486 | + "<flow-id>27021600672053722</flow-id>\n" |
| 487 | + "</flow-mapping>\n" |
| 488 | + "<flow-mapping>\n" |
| 489 | + "<ce-vlan-id>25</ce-vlan-id>\n" |
| 490 | + "<flow-id>27021600672053725</flow-id>\n" |
| 491 | + "</flow-mapping>\n" |
| 492 | + "</evc-per-uni-c>\n" |
| 493 | + "<evc-per-uni-n>\n" |
| 494 | + "<ce-vlan-map>13</ce-vlan-map>\n" |
| 495 | + "<ingress-bwp-group-index>0</ingress-bwp-group-index>\n" |
| 496 | + "<flow-mapping>\n" |
| 497 | + "<ce-vlan-id>13</ce-vlan-id>\n" |
| 498 | + "<flow-id>27021600672053713</flow-id>\n" |
| 499 | + "</flow-mapping>\n" |
| 500 | + "</evc-per-uni-n>\n" |
| 501 | + "</evc-per-uni>\n" |
| 502 | + "<uni-evc-id>EA1000-Uni-from-ONOS_5</uni-evc-id>\n" |
| 503 | + "<evc-status>\n" |
| 504 | + "<operational-state>unknown</operational-state>\n" |
| 505 | + "<max-mtu-size>9600</max-mtu-size>\n" |
| 506 | + "<max-num-uni>2</max-num-uni>\n" |
| 507 | + "</evc-status>\n" |
| 508 | + "</evc>\n" |
| 509 | + "</uni>\n" |
| 510 | + "<profiles>\n" |
| 511 | + "<bwp-group>\n" |
| 512 | + "<group-index>0</group-index>\n" |
| 513 | + "</bwp-group>\n" |
| 514 | + "</profiles>\n" |
| 515 | + "</mef-services>\n" |
| 516 | + "</data>\n" |
| 517 | + "</rpc-reply>"; |
| 518 | |
| 519 | private static final String SAMPLE_MSEAEVCUNI_CEVLANMAP_EVC_REPLY = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 520 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" |
| 521 | + "<data xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" |
| 522 | + "<mef-services xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-uni-evc-service\">\n" |
| 523 | + "<uni>\n" |
| 524 | |
| 525 | + "<evc><evc-index>1</evc-index>\n" |
| 526 | + "<evc-per-uni>\n" |
| 527 | + "<evc-per-uni-c>\n" |
| 528 | + "<ce-vlan-map>101</ce-vlan-map>\n" |
| 529 | + "<flow-mapping>\n" |
| 530 | + "<ce-vlan-id>101</ce-vlan-id>\n" |
| 531 | + "<flow-id>27021598629213101</flow-id>\n" |
| 532 | + "</flow-mapping>\n" |
| 533 | + "</evc-per-uni-c>\n" |
| 534 | + "<evc-per-uni-n>\n" |
| 535 | + "<ce-vlan-map>102</ce-vlan-map>\n" |
| 536 | + "<flow-mapping>\n" |
| 537 | + "<ce-vlan-id>102</ce-vlan-id>\n" |
| 538 | + "<flow-id>27021598629213102</flow-id>\n" |
| 539 | + "</flow-mapping>\n" |
| 540 | + "</evc-per-uni-n>\n" |
| 541 | + "</evc-per-uni>\n" |
| 542 | + "</evc>\n" |
| 543 | |
| 544 | + "<evc><evc-index>7</evc-index>\n" |
| 545 | + "<evc-per-uni>\n" |
| 546 | + "<evc-per-uni-c>\n" |
| 547 | + "<ce-vlan-map>700,710,720</ce-vlan-map>\n" |
| 548 | + "<flow-mapping>\n" |
| 549 | + "<ce-vlan-id>700</ce-vlan-id>\n" |
| 550 | + "<flow-id>27021598629213700</flow-id>\n" |
| 551 | + "</flow-mapping>\n" |
| 552 | + "<flow-mapping>\n" |
| 553 | + "<ce-vlan-id>710</ce-vlan-id>\n" |
| 554 | + "<flow-id>27021598629213710</flow-id>\n" |
| 555 | + "</flow-mapping>\n" |
| 556 | + "<flow-mapping>\n" |
| 557 | + "<ce-vlan-id>720</ce-vlan-id>\n" |
| 558 | + "<flow-id>27021598629213720</flow-id>\n" |
| 559 | + "</flow-mapping>\n" |
| 560 | + "</evc-per-uni-c>\n" |
| 561 | + "<evc-per-uni-n>\n" |
| 562 | + "<ce-vlan-map>701:703</ce-vlan-map>\n" |
| 563 | + "<flow-mapping>\n" |
| 564 | + "<ce-vlan-id>701</ce-vlan-id>\n" |
| 565 | + "<flow-id>27021598629213701</flow-id>\n" |
| 566 | + "</flow-mapping>\n" |
| 567 | + "<flow-mapping>\n" |
| 568 | + "<ce-vlan-id>702</ce-vlan-id>\n" |
| 569 | + "<flow-id>27021598629213702</flow-id>\n" |
| 570 | + "</flow-mapping>\n" |
| 571 | + "<flow-mapping>\n" |
| 572 | + "<ce-vlan-id>703</ce-vlan-id>\n" |
| 573 | + "<flow-id>27021598629213703</flow-id>\n" |
| 574 | + "</flow-mapping>\n" |
| 575 | + "</evc-per-uni-n>\n" |
| 576 | + "</evc-per-uni>\n" |
| 577 | + "</evc>\n" |
| 578 | |
| 579 | + "<evc><evc-index>8</evc-index>\n" |
| 580 | + "<evc-per-uni>\n" |
| 581 | + "<evc-per-uni-c>\n<ce-vlan-map>800,810,820</ce-vlan-map>\n</evc-per-uni-c>\n" |
| 582 | + "<evc-per-uni-n>\n<ce-vlan-map>801:803</ce-vlan-map>\n</evc-per-uni-n>\n" |
| 583 | + "</evc-per-uni>\n" |
| 584 | + "</evc>\n" |
| 585 | |
| 586 | + "</uni>\n" |
| 587 | + "</mef-services>\n" |
| 588 | + "</data>\n" |
| 589 | + "</rpc-reply>"; |
| 590 | |
| 591 | private static final String SAMPLE_MSEACFM_MD_MA_MEP_REPLY = |
| 592 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
| 593 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">" |
| 594 | + "<data>" |
| 595 | + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" " |
| 596 | + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" " |
| 597 | + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">" |
| 598 | + "<maintenance-domain>" |
| 599 | + "<id>1</id>" |
| 600 | + "<name>md-1</name>" |
| 601 | + "<md-level>3</md-level>" |
| 602 | + "<maintenance-association>" |
| 603 | + "<id>1</id>" |
| 604 | + "<name>ma-1-1</name>" |
| 605 | + "<ccm-interval>10ms</ccm-interval>" //Causing problems on create of MA |
| 606 | + "<remote-meps>1</remote-meps>" |
| 607 | + "<remote-meps>2</remote-meps>" |
| 608 | + "<component-list>" |
| 609 | + "<vid>100</vid>" |
| 610 | + "<tag-type>vlan-stag</tag-type>" |
| 611 | + "</component-list>" |
| 612 | + "<maintenance-association-end-point>" |
| 613 | + "<mep-identifier>1</mep-identifier>" |
| 614 | + "<interface>eth1</interface>" |
| 615 | + "<primary-vid>100</primary-vid>" |
| 616 | + "<administrative-state>true</administrative-state>" |
| 617 | + "<ccm-ltm-priority>4</ccm-ltm-priority>" |
| 618 | + "<continuity-check>" |
| 619 | + "<cci-enabled>true</cci-enabled>" |
| 620 | + "<fng-state>report-defect</fng-state>" |
| 621 | + "<highest-priority-defect-found>remote-mac-error</highest-priority-defect-found>" |
| 622 | + "<active-defects> remote-mac-error invalid-ccm</active-defects>" |
| 623 | + "<last-error-ccm>U2FtcGxlIGxhc3QgZXJyb3IgY2NtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" |
| 624 | + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" |
| 625 | + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" |
| 626 | + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA==</last-error-ccm>" |
| 627 | + "<ccm-sequence-error-count>10</ccm-sequence-error-count>" |
| 628 | + "<sent-ccms>15</sent-ccms>" |
| 629 | + "</continuity-check>" |
| 630 | + "<mac-address>53:65:61:6e:20:43</mac-address>" |
| 631 | + "<msea-soam-fm:port-status>no-status-tlv</msea-soam-fm:port-status>" |
| 632 | + "<msea-soam-fm:interface-status>no-status-tlv</msea-soam-fm:interface-status>" |
| 633 | // + "<msea-soam-fm:last-defect-sent/>" --Can't handle this at the moment |
| 634 | + "<msea-soam-fm:rdi-transmit-status>false</msea-soam-fm:rdi-transmit-status>" |
| 635 | + "<loopback>" |
| 636 | + "<replies-received>123</replies-received>" |
| 637 | + "<replies-transmitted>456</replies-transmitted>" |
| 638 | + "</loopback>" |
| 639 | + "<remote-mep-database>" |
| 640 | + "<remote-mep>" |
| 641 | + "<remote-mep-id>2</remote-mep-id>" |
| 642 | + "<remote-mep-state>ok</remote-mep-state>" |
| 643 | + "<failed-ok-time>1490692834</failed-ok-time>" |
| 644 | + "<mac-address>53:65:61:6e:20:43</mac-address>" |
| 645 | + "<rdi>true</rdi>" |
| 646 | + "<port-status-tlv>up</port-status-tlv>" |
| 647 | + "<interface-status-tlv>dormant</interface-status-tlv>" |
| 648 | + "</remote-mep>" |
| 649 | + "</remote-mep-database>" |
| 650 | + "<linktrace>" |
| 651 | + "<unexpected-replies-received>0</unexpected-replies-received>" |
| 652 | + "<msea-soam-fm:ltm-msgs-transmitted>2</msea-soam-fm:ltm-msgs-transmitted>" |
| 653 | + "<msea-soam-fm:ltm-msgs-received>2</msea-soam-fm:ltm-msgs-received>" |
| 654 | + "<msea-soam-fm:ltr-msgs-transmitted>2</msea-soam-fm:ltr-msgs-transmitted>" |
| 655 | + "<msea-soam-fm:ltr-msgs-received>2</msea-soam-fm:ltr-msgs-received>" |
| 656 | + "<linktrace-database/>" |
| 657 | + "</linktrace>" |
| 658 | + "</maintenance-association-end-point>" |
| 659 | + "<remote-meps>4</remote-meps>" |
| 660 | + "</maintenance-association>" |
| 661 | + "</maintenance-domain>" |
| 662 | + "</mef-cfm>" |
| 663 | + "</data>" |
| 664 | + "</rpc-reply>"; |
| 665 | |
| 666 | private static final String SAMPLE_MSEACFM_MD_MA_MEP_REPLY2 = |
| 667 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
| 668 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"47\">" |
| 669 | + "<data>" |
| 670 | + "<mef-cfm xmlns=\"http://www.microsemi.com/microsemi-edge-assure/msea-cfm\" " |
| 671 | + "xmlns:msea-soam-fm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-fm\" " |
| 672 | + "xmlns:msea-soam-pm=\"http://www.microsemi.com/microsemi-edge-assure/msea-soam-pm\">" |
| 673 | + "<maintenance-domain>" |
| 674 | + "<id>1</id>" |
| 675 | + "<name>Microsemi</name>" |
| 676 | + "<md-level>2</md-level>" |
| 677 | + "<maintenance-association>" |
| 678 | + "<id>1</id>" |
| 679 | + "<name>example-ma</name>" |
| 680 | + "<remote-meps>1</remote-meps>" |
| 681 | + "<remote-meps>2</remote-meps>" |
| 682 | + "<component-list>" |
| 683 | + "<vid>100</vid>" |
| 684 | + "<tag-type>vlan-stag</tag-type>" |
| 685 | + "</component-list>" |
| 686 | + "<maintenance-association-end-point>" |
| 687 | + "<mep-identifier>4</mep-identifier>" |
| 688 | + "<interface>eth1</interface>" |
| 689 | + "<primary-vid>100</primary-vid>" |
| 690 | + "<administrative-state>true</administrative-state>" |
| 691 | + "<ccm-ltm-priority>4</ccm-ltm-priority>" |
| 692 | + "<continuity-check>" |
| 693 | + "<cci-enabled>true</cci-enabled>" |
| 694 | + "<fng-state>defect-reported</fng-state>" |
| 695 | + "<highest-priority-defect-found>remote-invalid-ccm</highest-priority-defect-found>" |
| 696 | // + "<active-defects> remote-invalid-ccm</active-defects>" |
| 697 | + "<active-defects/>" |
| 698 | + "<ccm-sequence-error-count>0</ccm-sequence-error-count>" |
| 699 | + "<sent-ccms>41013</sent-ccms>" |
| 700 | + "</continuity-check>" |
| 701 | + "<mac-address>00:b0:ae:03:ff:31</mac-address>" |
| 702 | + "<msea-soam-fm:port-status>up</msea-soam-fm:port-status>" |
| 703 | + "<msea-soam-fm:interface-status>up</msea-soam-fm:interface-status>" |
| 704 | + "<msea-soam-fm:rdi-transmit-status>true</msea-soam-fm:rdi-transmit-status>" |
| 705 | + "<loopback>" |
| 706 | + "<replies-received>0</replies-received>" |
| 707 | + "<replies-transmitted>0</replies-transmitted>" |
| 708 | + "</loopback>" |
| 709 | + "<remote-mep-database>" |
| 710 | + "<remote-mep>" |
| 711 | + "<remote-mep-id>1</remote-mep-id>" |
| 712 | + "<remote-mep-state>failed</remote-mep-state>" |
| 713 | + "<failed-ok-time>26315533</failed-ok-time>" |
| 714 | + "<mac-address>00:00:00:00:00:00</mac-address>" |
| 715 | + "<rdi>false</rdi>" |
| 716 | + "<port-status-tlv>no-status-tlv</port-status-tlv>" |
| 717 | + "<interface-status-tlv>no-status-tlv</interface-status-tlv>" |
| 718 | + "</remote-mep>" |
| 719 | + "<remote-mep>" |
| 720 | + "<remote-mep-id>2</remote-mep-id>" |
| 721 | + "<remote-mep-state>failed</remote-mep-state>" |
| 722 | + "<failed-ok-time>26315541</failed-ok-time>" |
| 723 | + "<mac-address>00:00:00:00:00:00</mac-address>" |
| 724 | + "<rdi>false</rdi>" |
| 725 | + "<port-status-tlv>no-status-tlv</port-status-tlv>" |
| 726 | + "<interface-status-tlv>no-status-tlv</interface-status-tlv>" |
| 727 | + "</remote-mep>" |
| 728 | + "</remote-mep-database>" |
| 729 | + "<linktrace />" |
| 730 | + "</maintenance-association-end-point>" |
| 731 | + "<remote-meps>4</remote-meps>" |
| 732 | + "</maintenance-association>" |
| 733 | + "</maintenance-domain>" |
| 734 | + "</mef-cfm>" |
| 735 | + "</data>" |
| 736 | + "</rpc-reply>"; |
| 737 | |
| 738 | private static final String SAMPLE_REPLY_OK = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 739 | + "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"2\">" |
| 740 | + "<ok/>" |
| 741 | + "</rpc-reply>"; |
| 742 | |
| 743 | private NetconfDeviceInfo deviceInfo; |
| 744 | |
| 745 | private final AtomicInteger messageIdInteger = new AtomicInteger(0); |
| 746 | |
| 747 | public MockNetconfSessionEa1000(NetconfDeviceInfo deviceInfo) throws NetconfException { |
| 748 | this.deviceInfo = deviceInfo; |
| 749 | } |
| 750 | |
| 751 | @Override |
| 752 | public CompletableFuture<String> request(String request) throws NetconfException { |
| 753 | // TODO Auto-generated method stub |
| 754 | return null; |
| 755 | } |
| 756 | |
| 757 | @Override |
| 758 | public String get(String request) throws NetconfException { |
| 759 | |
| 760 | return sendRequest(request); |
| 761 | } |
| 762 | |
| 763 | @Override |
| 764 | public String get(String filterSchema, String withDefaultsMode) throws NetconfException { |
| 765 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
| 766 | rpc.append(RPC_OPEN); |
| 767 | rpc.append(MESSAGE_ID_STRING); |
| 768 | rpc.append(EQUAL); |
| 769 | rpc.append("\""); |
| 770 | rpc.append(messageIdInteger.get()); |
| 771 | rpc.append("\" "); |
| 772 | rpc.append(NETCONF_BASE_NAMESPACE).append(">\n"); |
| 773 | rpc.append(GET_OPEN).append(NEW_LINE); |
| 774 | if (filterSchema != null) { |
| 775 | rpc.append(SUBTREE_FILTER_OPEN).append(NEW_LINE); |
| 776 | rpc.append(filterSchema).append(NEW_LINE); |
| 777 | rpc.append(SUBTREE_FILTER_CLOSE).append(NEW_LINE); |
| 778 | } |
| 779 | if (withDefaultsMode != null) { |
| 780 | rpc.append(WITH_DEFAULT_OPEN).append(NETCONF_WITH_DEFAULTS_NAMESPACE).append(">"); |
| 781 | rpc.append(withDefaultsMode).append(WITH_DEFAULT_CLOSE).append(NEW_LINE); |
| 782 | } |
| 783 | rpc.append(GET_CLOSE).append(NEW_LINE); |
| 784 | rpc.append(RPC_CLOSE).append(NEW_LINE); |
| 785 | rpc.append(ENDPATTERN); |
| 786 | String reply = sendRequest(rpc.toString()); |
| 787 | checkReply(reply); |
| 788 | return reply; |
| 789 | } |
| 790 | |
| 791 | @Override |
| 792 | public String doWrappedRpc(String request) throws NetconfException { |
| 793 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
| 794 | rpc.append(RPC_OPEN); |
| 795 | rpc.append(MESSAGE_ID_STRING); |
| 796 | rpc.append(EQUAL); |
| 797 | rpc.append("\""); |
| 798 | rpc.append(messageIdInteger.get()); |
| 799 | rpc.append("\" "); |
| 800 | rpc.append(NETCONF_BASE_NAMESPACE).append(">\n"); |
| 801 | rpc.append(request); |
| 802 | rpc.append(RPC_CLOSE).append(NEW_LINE); |
| 803 | rpc.append(ENDPATTERN); |
| 804 | String reply = sendRequest(rpc.toString()); |
| 805 | checkReply(reply); |
| 806 | return reply; |
| 807 | } |
| 808 | |
| 809 | @Override |
| 810 | public String requestSync(String request) throws NetconfException { |
| 811 | if (!request.contains(ENDPATTERN)) { |
| 812 | request = request + NEW_LINE + ENDPATTERN; |
| 813 | } |
| 814 | String reply = sendRequest(request); |
| 815 | checkReply(reply); |
| 816 | return reply; |
| 817 | } |
| 818 | |
| 819 | @Override |
| 820 | public String getConfig(String targetConfiguration) throws NetconfException { |
| 821 | return getConfig(TargetConfig.valueOf(targetConfiguration), null); |
| 822 | } |
| 823 | |
| 824 | @Override |
| 825 | public String getConfig(String targetConfiguration, String configurationSchema) throws NetconfException { |
| 826 | return getConfig(TargetConfig.valueOf(targetConfiguration), null); |
| 827 | } |
| 828 | |
| 829 | @Override |
| 830 | public String getConfig(TargetConfig targetConfiguration) throws NetconfException { |
| 831 | return getConfig(targetConfiguration, null); |
| 832 | } |
| 833 | |
| 834 | @Override |
| 835 | public String getConfig(TargetConfig targetConfiguration, String configurationSchema) throws NetconfException { |
| 836 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
| 837 | rpc.append("<rpc "); |
| 838 | rpc.append(MESSAGE_ID_STRING); |
| 839 | rpc.append(EQUAL); |
| 840 | rpc.append("\""); |
| 841 | rpc.append(messageIdInteger.get()); |
| 842 | rpc.append("\" "); |
| 843 | rpc.append("xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"); |
| 844 | rpc.append("<get-config>\n"); |
| 845 | rpc.append("<source>\n"); |
| 846 | rpc.append("<").append(targetConfiguration).append("/>"); |
| 847 | rpc.append("</source>"); |
| 848 | if (configurationSchema != null) { |
| 849 | rpc.append("<filter type=\"subtree\">\n"); |
| 850 | rpc.append(configurationSchema).append("\n"); |
| 851 | rpc.append("</filter>\n"); |
| 852 | } |
| 853 | rpc.append("</get-config>\n"); |
| 854 | rpc.append("</rpc>\n"); |
| 855 | rpc.append(ENDPATTERN); |
| 856 | String reply = sendRequest(rpc.toString()); |
| 857 | return checkReply(reply) ? reply : "ERROR " + reply; |
| 858 | } |
| 859 | |
| 860 | @Override |
| 861 | public boolean editConfig(String newConfiguration) throws NetconfException { |
| 862 | return editConfig(TargetConfig.RUNNING, null, newConfiguration); |
| 863 | } |
| 864 | |
| 865 | @Override |
| 866 | public boolean editConfig(String targetConfiguration, String mode, String newConfiguration) |
| 867 | throws NetconfException { |
| 868 | return editConfig(TargetConfig.valueOf(targetConfiguration), mode, newConfiguration); |
| 869 | } |
| 870 | @Override |
| 871 | public boolean editConfig(TargetConfig targetConfiguration, String mode, String newConfiguration) |
| 872 | throws NetconfException { |
| 873 | newConfiguration = newConfiguration.trim(); |
| 874 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
| 875 | rpc.append(RPC_OPEN); |
| 876 | rpc.append(MESSAGE_ID_STRING); |
| 877 | rpc.append(EQUAL); |
| 878 | rpc.append("\""); |
| 879 | rpc.append(messageIdInteger.get()); |
| 880 | rpc.append("\" "); |
| 881 | rpc.append(NETCONF_BASE_NAMESPACE).append(">\n"); |
| 882 | rpc.append(EDIT_CONFIG_OPEN).append("\n"); |
| 883 | rpc.append(TARGET_OPEN); |
| 884 | rpc.append("<").append(targetConfiguration).append("/>"); |
| 885 | rpc.append(TARGET_CLOSE).append("\n"); |
| 886 | if (mode != null) { |
| 887 | rpc.append(DEFAULT_OPERATION_OPEN); |
| 888 | rpc.append(mode); |
| 889 | rpc.append(DEFAULT_OPERATION_CLOSE).append("\n"); |
| 890 | } |
| 891 | rpc.append(CONFIG_OPEN).append("\n"); |
| 892 | rpc.append(newConfiguration); |
| 893 | rpc.append(CONFIG_CLOSE).append("\n"); |
| 894 | rpc.append(EDIT_CONFIG_CLOSE).append("\n"); |
| 895 | rpc.append(RPC_CLOSE); |
| 896 | rpc.append(ENDPATTERN); |
| 897 | log.debug(rpc.toString()); |
| 898 | String reply = sendRequest(rpc.toString()); |
| 899 | return checkReply(reply); |
| 900 | } |
| 901 | |
| 902 | @Override |
| 903 | public boolean copyConfig(String targetConfiguration, String newConfiguration) throws NetconfException { |
| 904 | return copyConfig(TargetConfig.valueOf(targetConfiguration), newConfiguration); |
| 905 | } |
| 906 | |
| 907 | @Override |
| 908 | public boolean copyConfig(TargetConfig targetConfiguration, String newConfiguration) throws NetconfException { |
| 909 | // TODO Auto-generated method stub |
| 910 | return false; |
| 911 | } |
| 912 | |
| 913 | @Override |
| 914 | public boolean deleteConfig(String targetConfiguration) throws NetconfException { |
| 915 | return deleteConfig(TargetConfig.valueOf(targetConfiguration)); |
| 916 | } |
| 917 | |
| 918 | @Override |
| 919 | public boolean deleteConfig(TargetConfig targetConfiguration) throws NetconfException { |
| 920 | // TODO Auto-generated method stub |
| 921 | return false; |
| 922 | } |
| 923 | |
| 924 | @Override |
| 925 | public void startSubscription() throws NetconfException { |
| 926 | // TODO Auto-generated method stub |
| 927 | |
| 928 | } |
| 929 | |
| 930 | @Override |
| 931 | public void startSubscription(String filterSchema) throws NetconfException { |
| 932 | // TODO Auto-generated method stub |
| 933 | |
| 934 | } |
| 935 | |
| 936 | @Override |
| 937 | public void endSubscription() throws NetconfException { |
| 938 | // TODO Auto-generated method stub |
| 939 | |
| 940 | } |
| 941 | |
| 942 | @Override |
| 943 | public boolean lock(String configType) throws NetconfException { |
| 944 | // TODO Auto-generated method stub |
| 945 | return false; |
| 946 | } |
| 947 | |
| 948 | @Override |
| 949 | public boolean unlock(String configType) throws NetconfException { |
| 950 | // TODO Auto-generated method stub |
| 951 | return false; |
| 952 | } |
| 953 | |
| 954 | @Override |
| 955 | public boolean lock() throws NetconfException { |
| 956 | // TODO Auto-generated method stub |
| 957 | return false; |
| 958 | } |
| 959 | |
| 960 | @Override |
| 961 | public boolean unlock() throws NetconfException { |
| 962 | // TODO Auto-generated method stub |
| 963 | return false; |
| 964 | } |
| 965 | |
| 966 | @Override |
| 967 | public boolean close() throws NetconfException { |
| 968 | // TODO Auto-generated method stub |
| 969 | return false; |
| 970 | } |
| 971 | |
| 972 | @Override |
| 973 | public String getSessionId() { |
| 974 | return "mockSessionId"; |
| 975 | } |
| 976 | |
| 977 | @Override |
| 978 | public String getServerCapabilities() { |
| 979 | // TODO Auto-generated method stub |
| 980 | return null; |
| 981 | } |
| 982 | |
| 983 | @Override |
| 984 | public void setDeviceCapabilities(List<String> capabilities) { |
| 985 | // TODO Auto-generated method stub |
| 986 | |
| 987 | } |
| 988 | |
| 989 | @Override |
| 990 | public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) { |
| 991 | // TODO Auto-generated method stub |
| 992 | |
| 993 | } |
| 994 | |
| 995 | @Override |
| 996 | public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) { |
| 997 | // TODO Auto-generated method stub |
| 998 | |
| 999 | } |
| 1000 | |
| 1001 | private boolean checkReply(String reply) throws NetconfException { |
| 1002 | if (reply != null) { |
| 1003 | if (!reply.contains("<rpc-error>")) { |
| 1004 | log.debug("Device {} sent reply {}", deviceInfo, reply); |
| 1005 | return true; |
| 1006 | } else if (reply.contains("<ok/>") |
| 1007 | || (reply.contains("<rpc-error>") |
| 1008 | && reply.contains("warning"))) { |
| 1009 | log.debug("Device {} sent reply {}", deviceInfo, reply); |
| 1010 | return true; |
| 1011 | } |
| 1012 | } |
| 1013 | log.warn("Device {} has error in reply {}", deviceInfo, reply); |
| 1014 | return false; |
| 1015 | } |
| 1016 | |
| 1017 | private String sendRequest(String request) throws NetconfException { |
| 1018 | log.info("Mocking NETCONF Session send request: \n" + request); |
| 1019 | |
| 1020 | if (sampleXmlRegex1.matcher(request).matches()) { |
| 1021 | return SAMPLE_SYSTEM_REPLY; |
| 1022 | |
| 1023 | } else if (sampleXmlRegex2.matcher(request).matches()) { |
| 1024 | return SAMPLE_SYSTEM_REPLY_INIT; |
| 1025 | |
| 1026 | } else if (sampleXmlRegexSaFiltering.matcher(request).matches()) { |
| 1027 | return SAMPLE_MSEASAFILTERING_FE_REPLY; |
| 1028 | |
| 1029 | } else if (sampleXmlRegexEditConfigSaFilt.matcher(request).matches()) { |
| 1030 | return SAMPLE_REPLY_OK; |
| 1031 | |
| 1032 | } else if (sampleXmlRegexEditDeleteSaFilt.matcher(request).matches()) { |
| 1033 | return SAMPLE_REPLY_OK; |
| 1034 | |
| 1035 | } else if (sampleXmlRegexUniEvc.matcher(request).matches()) { |
| 1036 | return SAMPLE_MSEAEVCUNI_REPLY_INIT; |
| 1037 | |
| 1038 | } else if (sampleXmlRegexUniEvcUni.matcher(request).matches()) { |
| 1039 | return SAMPLE_MSEAEVCUNI_FE_REPLY; |
| 1040 | |
| 1041 | } else if (sampleXmlRegexEditConfigUni1Evc.matcher(request).matches()) { |
| 1042 | return SAMPLE_REPLY_OK; |
| 1043 | |
| 1044 | } else if (sampleXmlRegexEditConfigUni2Evc.matcher(request).matches()) { |
| 1045 | return SAMPLE_REPLY_OK; |
| 1046 | |
| 1047 | } else if (sampleXmlRegexEditConfigUniProfiles.matcher(request).matches()) { |
| 1048 | return SAMPLE_REPLY_OK; |
| 1049 | |
| 1050 | } else if (sampleXmlRegexEditConfigEvcDelete.matcher(request).matches()) { |
| 1051 | return SAMPLE_REPLY_OK; |
| 1052 | |
| 1053 | } else if (sampleXmlRegexGetConfigCeVlanMapsEvc.matcher(request).matches()) { |
| 1054 | return SAMPLE_MSEAEVCUNI_CEVLANMAP_EVC_REPLY; |
| 1055 | |
| 1056 | } else if (sampleXmlRegexEditConfigCeVlanMapReplace.matcher(request).matches()) { |
| 1057 | return SAMPLE_REPLY_OK; |
| 1058 | |
| 1059 | } else if (sampleXmlRegexEditConfigBwpGroup1.matcher(request).matches()) { |
| 1060 | return SAMPLE_REPLY_OK; |
| 1061 | |
| 1062 | } else if (sampleXmlRegexEditConfigBwpGroup1Delete.matcher(request).matches()) { |
| 1063 | return SAMPLE_REPLY_OK; |
| 1064 | |
| 1065 | } else if (sampleXmlRegexSetCurrentDatetime.matcher(request).matches()) { |
| 1066 | return SAMPLE_REPLY_OK; |
| 1067 | |
| 1068 | } else if (sampleXmlRegexGetMseaCfmEssentials.matcher(request).matches()) { |
| 1069 | return SAMPLE_MSEACFM_MD_MA_MEP_REPLY2; |
| 1070 | |
| 1071 | } else { |
| 1072 | throw new NetconfException("MocknetconfSession. No sendRequest() case for query: " + |
| 1073 | request); |
| 1074 | } |
| 1075 | } |
| 1076 | } |