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