andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.netconf.ctl; |
| 18 | |
| 19 | import ch.ethz.ssh2.Connection; |
| 20 | import ch.ethz.ssh2.Session; |
| 21 | import com.google.common.base.Preconditions; |
| 22 | import org.onosproject.netconf.NetconfDeviceInfo; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 23 | import org.onosproject.netconf.NetconfDeviceOutputEvent; |
| 24 | import org.onosproject.netconf.NetconfDeviceOutputEventListener; |
| 25 | import org.onosproject.netconf.NetconfException; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 26 | import org.onosproject.netconf.NetconfSession; |
| 27 | import org.slf4j.Logger; |
| 28 | import org.slf4j.LoggerFactory; |
| 29 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 30 | import java.io.IOException; |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 31 | import java.util.ArrayList; |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 32 | import java.util.Collections; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 33 | import java.util.HashMap; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 34 | import java.util.List; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 35 | import java.util.Map; |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 36 | import java.util.Optional; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 37 | import java.util.concurrent.CompletableFuture; |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 38 | import java.util.concurrent.ExecutionException; |
| 39 | import java.util.concurrent.TimeUnit; |
| 40 | import java.util.concurrent.TimeoutException; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 41 | import java.util.concurrent.atomic.AtomicInteger; |
| 42 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Implementation of a NETCONF session to talk to a device. |
| 46 | */ |
| 47 | public class NetconfSessionImpl implements NetconfSession { |
| 48 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 49 | private static final Logger log = LoggerFactory |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 50 | .getLogger(NetconfSessionImpl.class); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 51 | |
| 52 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 53 | private static final int CONNECTION_TIMEOUT = 0; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 54 | private static final String ENDPATTERN = "]]>]]>"; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 55 | private static final String MESSAGE_ID_STRING = "message-id"; |
Andrea Campanella | 1311ea0 | 2016-03-04 17:51:25 -0800 | [diff] [blame] | 56 | private static final String HELLO = "<hello"; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 57 | private static final String NEW_LINE = "\n"; |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 58 | private static final String END_OF_RPC_OPEN_TAG = "\">"; |
| 59 | private static final String EQUAL = "="; |
| 60 | private static final String NUMBER_BETWEEN_QUOTES_MATCHER = "\"+([0-9]+)+\""; |
Akihiro Yamanouchi | 5e5d4df | 2016-06-08 17:06:33 +0900 | [diff] [blame] | 61 | private static final String RPC_OPEN = "<rpc "; |
| 62 | private static final String RPC_CLOSE = "</rpc>"; |
| 63 | private static final String GET_OPEN = "<get>"; |
| 64 | private static final String GET_CLOSE = "</get>"; |
| 65 | private static final String WITH_DEFAULT_OPEN = "<with-defaults "; |
| 66 | private static final String WITH_DEFAULT_CLOSE = "</with-defaults>"; |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 67 | private static final String DEFAULT_OPERATION_OPEN = "<default-operation>"; |
| 68 | private static final String DEFAULT_OPERATION_CLOSE = "</default-operation>"; |
Akihiro Yamanouchi | 5e5d4df | 2016-06-08 17:06:33 +0900 | [diff] [blame] | 69 | private static final String FILTER_OPEN = "<filter type=\"subtree\">"; |
| 70 | private static final String FILTER_CLOSE = "</filter>"; |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 71 | private static final String EDIT_CONFIG_OPEN = "<edit-config>"; |
| 72 | private static final String EDIT_CONFIG_CLOSE = "</edit-config>"; |
| 73 | private static final String TARGET_OPEN = "<target>"; |
| 74 | private static final String TARGET_CLOSE = "</target>"; |
| 75 | private static final String CONFIG_OPEN = "<config>"; |
| 76 | private static final String CONFIG_CLOSE = "</config>"; |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 77 | private static final String XML_HEADER = |
| 78 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
Akihiro Yamanouchi | 5e5d4df | 2016-06-08 17:06:33 +0900 | [diff] [blame] | 79 | private static final String NETCONF_BASE_NAMESPACE = |
| 80 | "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\""; |
| 81 | private static final String NETCONF_WITH_DEFAULTS_NAMESPACE = |
| 82 | "xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 83 | |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 84 | private final AtomicInteger messageIdInteger = new AtomicInteger(0); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 85 | private Connection netconfConnection; |
| 86 | private NetconfDeviceInfo deviceInfo; |
| 87 | private Session sshSession; |
| 88 | private boolean connectionActive; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 89 | private List<String> deviceCapabilities = |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 90 | Collections.singletonList("urn:ietf:params:netconf:base:1.0"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 91 | private String serverCapabilities; |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 92 | private NetconfStreamHandler streamHandler; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 93 | private Map<Integer, CompletableFuture<String>> replies; |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 94 | private List<String> errorReplies; |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 95 | private boolean subscriptionConnected = false; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 96 | |
| 97 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 98 | public NetconfSessionImpl(NetconfDeviceInfo deviceInfo) throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 99 | this.deviceInfo = deviceInfo; |
Akihiro Yamanouchi | 5e5d4df | 2016-06-08 17:06:33 +0900 | [diff] [blame] | 100 | this.netconfConnection = null; |
| 101 | this.sshSession = null; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 102 | connectionActive = false; |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 103 | replies = new HashMap<>(); |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 104 | errorReplies = new ArrayList<>(); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 105 | startConnection(); |
| 106 | } |
| 107 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 108 | private void startConnection() throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 109 | if (!connectionActive) { |
| 110 | netconfConnection = new Connection(deviceInfo.ip().toString(), deviceInfo.port()); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 111 | try { |
| 112 | netconfConnection.connect(null, CONNECTION_TIMEOUT, 5000); |
| 113 | } catch (IOException e) { |
| 114 | throw new NetconfException("Cannot open a connection with device" + deviceInfo, e); |
| 115 | } |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 116 | boolean isAuthenticated; |
| 117 | try { |
| 118 | if (deviceInfo.getKeyFile() != null) { |
| 119 | isAuthenticated = netconfConnection.authenticateWithPublicKey( |
| 120 | deviceInfo.name(), deviceInfo.getKeyFile(), |
| 121 | deviceInfo.password()); |
| 122 | } else { |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 123 | log.debug("Authenticating to device {} with username {}", |
Andrea Campanella | 50d2521 | 2016-02-26 13:06:23 -0800 | [diff] [blame] | 124 | deviceInfo.getDeviceId(), deviceInfo.name()); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 125 | isAuthenticated = netconfConnection.authenticateWithPassword( |
| 126 | deviceInfo.name(), deviceInfo.password()); |
| 127 | } |
| 128 | } catch (IOException e) { |
Andrea Campanella | d264b49 | 2016-03-01 09:46:06 -0800 | [diff] [blame] | 129 | log.error("Authentication connection to device {} failed: {} ", |
Akihiro Yamanouchi | 5e5d4df | 2016-06-08 17:06:33 +0900 | [diff] [blame] | 130 | deviceInfo.getDeviceId(), e.getMessage()); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 131 | throw new NetconfException("Authentication connection to device " + |
| 132 | deviceInfo.getDeviceId() + " failed", e); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | connectionActive = true; |
| 136 | Preconditions.checkArgument(isAuthenticated, |
Andrea Campanella | d264b49 | 2016-03-01 09:46:06 -0800 | [diff] [blame] | 137 | "Authentication to device %s with username " + |
| 138 | "%s failed", |
Andrea Campanella | 50d2521 | 2016-02-26 13:06:23 -0800 | [diff] [blame] | 139 | deviceInfo.getDeviceId(), deviceInfo.name()); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 140 | startSshSession(); |
| 141 | } |
| 142 | } |
| 143 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 144 | private void startSshSession() throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 145 | try { |
| 146 | sshSession = netconfConnection.openSession(); |
| 147 | sshSession.startSubSystem("netconf"); |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 148 | streamHandler = new NetconfStreamThread(sshSession.getStdout(), sshSession.getStdin(), |
| 149 | sshSession.getStderr(), deviceInfo, |
| 150 | new NetconfSessionDelegateImpl()); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 151 | this.addDeviceOutputListener(new NetconfDeviceOutputEventListenerImpl(deviceInfo)); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 152 | sendHello(); |
| 153 | } catch (IOException e) { |
Andrea Campanella | 1311ea0 | 2016-03-04 17:51:25 -0800 | [diff] [blame] | 154 | log.error("Failed to create ch.ethz.ssh2.Session session." + e.getMessage()); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 155 | throw new NetconfException("Failed to create ch.ethz.ssh2.Session session with device" + |
| 156 | deviceInfo, e); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 160 | private void startSubscriptionConnection() throws NetconfException { |
| 161 | if (!serverCapabilities.contains("interleave")) { |
| 162 | throw new NetconfException("Device" + deviceInfo + "does not support interleave"); |
| 163 | } |
| 164 | String reply = sendRequest(createSubscriptionString()); |
| 165 | if (!checkReply(reply)) { |
| 166 | throw new NetconfException("Subscription not successful with device " |
| 167 | + deviceInfo + " with reply " + reply); |
| 168 | } |
| 169 | subscriptionConnected = true; |
| 170 | } |
| 171 | |
| 172 | public void startSubscription() throws NetconfException { |
| 173 | if (!subscriptionConnected) { |
| 174 | startSubscriptionConnection(); |
| 175 | } |
| 176 | streamHandler.setEnableNotifications(true); |
| 177 | } |
| 178 | |
| 179 | private String createSubscriptionString() { |
| 180 | StringBuilder subscriptionbuffer = new StringBuilder(); |
| 181 | subscriptionbuffer.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"); |
| 182 | subscriptionbuffer.append(" <create-subscription\n"); |
| 183 | subscriptionbuffer.append("xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">\n"); |
| 184 | subscriptionbuffer.append(" </create-subscription>\n"); |
| 185 | subscriptionbuffer.append("</rpc>\n"); |
| 186 | subscriptionbuffer.append(ENDPATTERN); |
| 187 | return subscriptionbuffer.toString(); |
| 188 | } |
| 189 | |
| 190 | @Override |
| 191 | public void endSubscription() throws NetconfException { |
| 192 | if (subscriptionConnected) { |
| 193 | streamHandler.setEnableNotifications(false); |
| 194 | } else { |
| 195 | throw new NetconfException("Subscription does not exist."); |
| 196 | } |
| 197 | } |
| 198 | |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 199 | private void sendHello() throws NetconfException { |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 200 | serverCapabilities = sendRequest(createHelloString()); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | private String createHelloString() { |
| 204 | StringBuilder hellobuffer = new StringBuilder(); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 205 | hellobuffer.append(XML_HEADER); |
| 206 | hellobuffer.append("\n"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 207 | hellobuffer.append("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"); |
| 208 | hellobuffer.append(" <capabilities>\n"); |
| 209 | deviceCapabilities.forEach( |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 210 | cap -> hellobuffer.append(" <capability>") |
| 211 | .append(cap) |
| 212 | .append("</capability>\n")); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 213 | hellobuffer.append(" </capabilities>\n"); |
| 214 | hellobuffer.append("</hello>\n"); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 215 | hellobuffer.append(ENDPATTERN); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 216 | return hellobuffer.toString(); |
| 217 | |
| 218 | } |
| 219 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 220 | private void checkAndRestablishSession() throws NetconfException { |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 221 | if (sshSession.getState() != 2) { |
| 222 | try { |
| 223 | startSshSession(); |
| 224 | } catch (IOException e) { |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 225 | log.debug("The connection with {} had to be reopened", deviceInfo.getDeviceId()); |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 226 | try { |
| 227 | startConnection(); |
| 228 | } catch (IOException e2) { |
Andrea Campanella | 50d2521 | 2016-02-26 13:06:23 -0800 | [diff] [blame] | 229 | log.error("No connection {} for device", netconfConnection, e2); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 230 | throw new NetconfException("Cannot re-open the connection with device" + deviceInfo, e); |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 236 | @Override |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 237 | public String requestSync(String request) throws NetconfException { |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 238 | if (!request.contains(ENDPATTERN)) { |
| 239 | request = request + NEW_LINE + ENDPATTERN; |
| 240 | } |
| 241 | String reply = sendRequest(request); |
Andreas Papazois | 2e557be | 2016-06-04 15:39:56 +0300 | [diff] [blame] | 242 | checkReply(reply); |
| 243 | return reply; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | @Override |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 247 | public CompletableFuture<String> request(String request) { |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 248 | CompletableFuture<String> ftrep = streamHandler.sendMessage(request); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 249 | replies.put(messageIdInteger.get(), ftrep); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 250 | return ftrep; |
| 251 | } |
| 252 | |
| 253 | private String sendRequest(String request) throws NetconfException { |
| 254 | checkAndRestablishSession(); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 255 | request = formatRequestMessageId(request); |
| 256 | request = formatXmlHeader(request); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 257 | CompletableFuture<String> futureReply = request(request); |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 258 | messageIdInteger.incrementAndGet(); |
Andreas Papazois | 4752cfa | 2016-04-25 14:52:12 +0300 | [diff] [blame] | 259 | int replyTimeout = NetconfControllerImpl.netconfReplyTimeout; |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 260 | String rp; |
| 261 | try { |
Andreas Papazois | 4752cfa | 2016-04-25 14:52:12 +0300 | [diff] [blame] | 262 | rp = futureReply.get(replyTimeout, TimeUnit.SECONDS); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 263 | } catch (InterruptedException | ExecutionException | TimeoutException e) { |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 264 | throw new NetconfException("No matching reply for request " + request, e); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 265 | } |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 266 | log.debug("Result {} from request {} to device {}", rp, request, deviceInfo); |
Andrea Campanella | 50d2521 | 2016-02-26 13:06:23 -0800 | [diff] [blame] | 267 | return rp.trim(); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 268 | } |
| 269 | |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 270 | private String formatRequestMessageId(String request) { |
| 271 | if (request.contains(MESSAGE_ID_STRING)) { |
| 272 | //FIXME if application provieds his own counting of messages this fails that count |
| 273 | request = request.replaceFirst(MESSAGE_ID_STRING + EQUAL + NUMBER_BETWEEN_QUOTES_MATCHER, |
| 274 | MESSAGE_ID_STRING + EQUAL + "\"" + messageIdInteger.get() + "\""); |
| 275 | } else if (!request.contains(MESSAGE_ID_STRING) && !request.contains(HELLO)) { |
| 276 | //FIXME find out a better way to enforce the presence of message-id |
| 277 | request = request.replaceFirst(END_OF_RPC_OPEN_TAG, "\" " + MESSAGE_ID_STRING + EQUAL + "\"" |
| 278 | + messageIdInteger.get() + "\"" + ">"); |
| 279 | } |
| 280 | return request; |
| 281 | } |
| 282 | |
| 283 | private String formatXmlHeader(String request) { |
| 284 | if (!request.contains(XML_HEADER)) { |
| 285 | //FIXME if application provieds his own XML header of different type there is a clash |
| 286 | request = XML_HEADER + "\n" + request; |
| 287 | } |
| 288 | return request; |
| 289 | } |
| 290 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 291 | @Override |
| 292 | public String get(String request) throws NetconfException { |
| 293 | return requestSync(request); |
| 294 | } |
| 295 | |
| 296 | @Override |
Akihiro Yamanouchi | 5e5d4df | 2016-06-08 17:06:33 +0900 | [diff] [blame] | 297 | public String get(String filterSchema, String withDefaultsMode) throws NetconfException { |
| 298 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
| 299 | rpc.append(RPC_OPEN); |
| 300 | rpc.append(MESSAGE_ID_STRING); |
| 301 | rpc.append(EQUAL); |
| 302 | rpc.append("\""); |
| 303 | rpc.append(messageIdInteger.get()); |
| 304 | rpc.append("\" "); |
| 305 | rpc.append(NETCONF_BASE_NAMESPACE).append(">\n"); |
| 306 | rpc.append(GET_OPEN).append(NEW_LINE); |
| 307 | if (filterSchema != null) { |
| 308 | rpc.append(FILTER_OPEN).append(NEW_LINE); |
| 309 | rpc.append(filterSchema).append(NEW_LINE); |
| 310 | rpc.append(FILTER_CLOSE).append(NEW_LINE); |
| 311 | } |
| 312 | if (withDefaultsMode != null) { |
| 313 | rpc.append(WITH_DEFAULT_OPEN).append(NETCONF_WITH_DEFAULTS_NAMESPACE).append(">"); |
| 314 | rpc.append(withDefaultsMode).append(WITH_DEFAULT_CLOSE).append(NEW_LINE); |
| 315 | } |
| 316 | rpc.append(GET_CLOSE).append(NEW_LINE); |
| 317 | rpc.append(RPC_CLOSE).append(NEW_LINE); |
| 318 | rpc.append(ENDPATTERN); |
| 319 | String reply = sendRequest(rpc.toString()); |
| 320 | checkReply(reply); |
| 321 | return reply; |
| 322 | } |
| 323 | |
| 324 | @Override |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 325 | public String getConfig(String targetConfiguration) throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 326 | return getConfig(targetConfiguration, null); |
| 327 | } |
| 328 | |
| 329 | @Override |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 330 | public String getConfig(String targetConfiguration, String configurationSchema) throws NetconfException { |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 331 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
| 332 | rpc.append("<rpc "); |
| 333 | rpc.append(MESSAGE_ID_STRING); |
| 334 | rpc.append(EQUAL); |
| 335 | rpc.append("\""); |
| 336 | rpc.append(messageIdInteger.get()); |
| 337 | rpc.append("\" "); |
| 338 | rpc.append("xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 339 | rpc.append("<get-config>\n"); |
| 340 | rpc.append("<source>\n"); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 341 | rpc.append("<").append(targetConfiguration).append("/>"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 342 | rpc.append("</source>"); |
| 343 | if (configurationSchema != null) { |
| 344 | rpc.append("<filter type=\"subtree\">\n"); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 345 | rpc.append(configurationSchema).append("\n"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 346 | rpc.append("</filter>\n"); |
| 347 | } |
| 348 | rpc.append("</get-config>\n"); |
| 349 | rpc.append("</rpc>\n"); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 350 | rpc.append(ENDPATTERN); |
| 351 | String reply = sendRequest(rpc.toString()); |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 352 | return checkReply(reply) ? reply : "ERROR " + reply; |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | @Override |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 356 | public boolean editConfig(String newConfiguration) throws NetconfException { |
| 357 | newConfiguration = newConfiguration + ENDPATTERN; |
| 358 | return checkReply(sendRequest(newConfiguration)); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | @Override |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 362 | public boolean editConfig(String targetConfiguration, String mode, String newConfiguration) |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 363 | throws NetconfException { |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 364 | newConfiguration = newConfiguration.trim(); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 365 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 366 | rpc.append(RPC_OPEN); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 367 | rpc.append(MESSAGE_ID_STRING); |
| 368 | rpc.append(EQUAL); |
| 369 | rpc.append("\""); |
| 370 | rpc.append(messageIdInteger.get()); |
| 371 | rpc.append("\" "); |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 372 | rpc.append(NETCONF_BASE_NAMESPACE).append(">\n"); |
| 373 | rpc.append(EDIT_CONFIG_OPEN).append("\n"); |
| 374 | rpc.append(TARGET_OPEN); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 375 | rpc.append("<").append(targetConfiguration).append("/>"); |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 376 | rpc.append(TARGET_CLOSE).append("\n"); |
| 377 | if (mode != null) { |
| 378 | rpc.append(DEFAULT_OPERATION_OPEN); |
| 379 | rpc.append(mode); |
| 380 | rpc.append(DEFAULT_OPERATION_CLOSE).append("\n"); |
| 381 | } |
| 382 | rpc.append(CONFIG_OPEN).append("\n"); |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 383 | rpc.append(newConfiguration); |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 384 | rpc.append(CONFIG_CLOSE).append("\n"); |
| 385 | rpc.append(EDIT_CONFIG_CLOSE).append("\n"); |
| 386 | rpc.append(RPC_CLOSE); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 387 | rpc.append(ENDPATTERN); |
Andrea Campanella | 50d2521 | 2016-02-26 13:06:23 -0800 | [diff] [blame] | 388 | log.info(rpc.toString()); |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 389 | String reply = sendRequest(rpc.toString()); |
| 390 | return checkReply(reply); |
Andrea Campanella | f4fd035 | 2015-12-14 17:03:05 -0800 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | @Override |
Andrea Campanella | 1cd641b | 2015-12-07 17:28:34 -0800 | [diff] [blame] | 394 | public boolean copyConfig(String targetConfiguration, String newConfiguration) |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 395 | throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 396 | newConfiguration = newConfiguration.trim(); |
| 397 | if (!newConfiguration.startsWith("<configuration>")) { |
| 398 | newConfiguration = "<configuration>" + newConfiguration |
| 399 | + "</configuration>"; |
| 400 | } |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 401 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 402 | rpc.append("<rpc>"); |
| 403 | rpc.append("<copy-config>"); |
| 404 | rpc.append("<target>"); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 405 | rpc.append("<").append(targetConfiguration).append("/>"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 406 | rpc.append("</target>"); |
| 407 | rpc.append("<source>"); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 408 | rpc.append("<").append(newConfiguration).append("/>"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 409 | rpc.append("</source>"); |
| 410 | rpc.append("</copy-config>"); |
| 411 | rpc.append("</rpc>"); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 412 | rpc.append(ENDPATTERN); |
| 413 | return checkReply(sendRequest(rpc.toString())); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | @Override |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 417 | public boolean deleteConfig(String targetConfiguration) throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 418 | if (targetConfiguration.equals("running")) { |
| 419 | log.warn("Target configuration for delete operation can't be \"running\"", |
| 420 | targetConfiguration); |
| 421 | return false; |
| 422 | } |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 423 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 424 | rpc.append("<rpc>"); |
| 425 | rpc.append("<delete-config>"); |
| 426 | rpc.append("<target>"); |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 427 | rpc.append("<").append(targetConfiguration).append("/>"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 428 | rpc.append("</target>"); |
| 429 | rpc.append("</delete-config>"); |
| 430 | rpc.append("</rpc>"); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 431 | rpc.append(ENDPATTERN); |
| 432 | return checkReply(sendRequest(rpc.toString())); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | @Override |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 436 | public boolean lock(String configType) throws NetconfException { |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 437 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 438 | rpc.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 439 | rpc.append("<lock>"); |
| 440 | rpc.append("<target>"); |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 441 | rpc.append("<"); |
| 442 | rpc.append(configType); |
| 443 | rpc.append("/>"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 444 | rpc.append("</target>"); |
| 445 | rpc.append("</lock>"); |
| 446 | rpc.append("</rpc>"); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 447 | rpc.append(ENDPATTERN); |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 448 | String lockReply = sendRequest(rpc.toString()); |
| 449 | return checkReply(lockReply); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | @Override |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 453 | public boolean unlock(String configType) throws NetconfException { |
Andrea Campanella | b029b9e | 2016-01-29 11:05:36 -0800 | [diff] [blame] | 454 | StringBuilder rpc = new StringBuilder(XML_HEADER); |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 455 | rpc.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 456 | rpc.append("<unlock>"); |
| 457 | rpc.append("<target>"); |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 458 | rpc.append("<"); |
| 459 | rpc.append(configType); |
| 460 | rpc.append("/>"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 461 | rpc.append("</target>"); |
| 462 | rpc.append("</unlock>"); |
| 463 | rpc.append("</rpc>"); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 464 | rpc.append(ENDPATTERN); |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 465 | String unlockReply = sendRequest(rpc.toString()); |
| 466 | return checkReply(unlockReply); |
| 467 | } |
| 468 | |
| 469 | @Override |
| 470 | public boolean lock() throws NetconfException { |
| 471 | return lock("running"); |
| 472 | } |
| 473 | |
| 474 | @Override |
| 475 | public boolean unlock() throws NetconfException { |
| 476 | return unlock("running"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | @Override |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 480 | public boolean close() throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 481 | return close(false); |
| 482 | } |
| 483 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 484 | private boolean close(boolean force) throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 485 | StringBuilder rpc = new StringBuilder(); |
Andrea Campanella | 7e6200a | 2016-03-21 09:48:40 -0700 | [diff] [blame] | 486 | rpc.append("<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 487 | if (force) { |
Andrea Campanella | 7e6200a | 2016-03-21 09:48:40 -0700 | [diff] [blame] | 488 | rpc.append("<kill-session/>"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 489 | } else { |
Andrea Campanella | 7e6200a | 2016-03-21 09:48:40 -0700 | [diff] [blame] | 490 | rpc.append("<close-session/>"); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 491 | } |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 492 | rpc.append("</rpc>"); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 493 | rpc.append(ENDPATTERN); |
| 494 | return checkReply(sendRequest(rpc.toString())) || close(true); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | @Override |
| 498 | public String getSessionId() { |
| 499 | if (serverCapabilities.contains("<session-id>")) { |
| 500 | String[] outer = serverCapabilities.split("<session-id>"); |
| 501 | Preconditions.checkArgument(outer.length != 1, |
| 502 | "Error in retrieving the session id"); |
| 503 | String[] value = outer[1].split("</session-id>"); |
| 504 | Preconditions.checkArgument(value.length != 1, |
| 505 | "Error in retrieving the session id"); |
| 506 | return value[0]; |
| 507 | } else { |
| 508 | return String.valueOf(-1); |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | @Override |
| 513 | public String getServerCapabilities() { |
| 514 | return serverCapabilities; |
| 515 | } |
| 516 | |
| 517 | @Override |
| 518 | public void setDeviceCapabilities(List<String> capabilities) { |
| 519 | deviceCapabilities = capabilities; |
| 520 | } |
| 521 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 522 | @Override |
| 523 | public void addDeviceOutputListener(NetconfDeviceOutputEventListener listener) { |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 524 | streamHandler.addDeviceEventListener(listener); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | @Override |
| 528 | public void removeDeviceOutputListener(NetconfDeviceOutputEventListener listener) { |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 529 | streamHandler.removeDeviceEventListener(listener); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | private boolean checkReply(String reply) throws NetconfException { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 533 | if (reply != null) { |
| 534 | if (!reply.contains("<rpc-error>")) { |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 535 | log.debug("Device {} sent reply {}", deviceInfo, reply); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 536 | return true; |
| 537 | } else if (reply.contains("<ok/>") |
| 538 | || (reply.contains("<rpc-error>") |
| 539 | && reply.contains("warning"))) { |
Akihiro Yamanouchi | d491284 | 2016-07-01 10:38:46 +0900 | [diff] [blame] | 540 | log.debug("Device {} sent reply {}", deviceInfo, reply); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 541 | return true; |
| 542 | } |
| 543 | } |
Andrea Campanella | d264b49 | 2016-03-01 09:46:06 -0800 | [diff] [blame] | 544 | log.warn("Device {} has error in reply {}", deviceInfo, reply); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 545 | return false; |
| 546 | } |
| 547 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 548 | public class NetconfSessionDelegateImpl implements NetconfSessionDelegate { |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 549 | |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 550 | @Override |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 551 | public void notify(NetconfDeviceOutputEvent event) { |
| 552 | Optional<Integer> messageId = event.getMessageID(); |
helenyrwu | 0407c64 | 2016-06-09 12:01:30 -0700 | [diff] [blame] | 553 | |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 554 | if (!messageId.isPresent()) { |
| 555 | errorReplies.add(event.getMessagePayload()); |
Andrea Campanella | d264b49 | 2016-03-01 09:46:06 -0800 | [diff] [blame] | 556 | log.error("Device {} sent error reply {}", |
| 557 | event.getDeviceInfo(), event.getMessagePayload()); |
Andreas Papazois | d4712e2 | 2016-02-10 15:59:55 +0200 | [diff] [blame] | 558 | return; |
| 559 | } |
| 560 | CompletableFuture<String> completedReply = |
| 561 | replies.get(messageId.get()); |
Andrea Campanella | 101417d | 2015-12-11 17:58:07 -0800 | [diff] [blame] | 562 | completedReply.complete(event.getMessagePayload()); |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 563 | } |
| 564 | } |
andrea | eb70a94 | 2015-10-16 21:34:46 -0700 | [diff] [blame] | 565 | } |