String bridge = "unknown";
try {
Network nw = findOrCreateTunnelNetwork(conn, cmd.getNetworkName());
if (nw == null) {
s_logger.debug("Error during bridge setup");
return new OvsCreateTunnelAnswer(cmd, false, "Cannot create network", bridge);
}
configureTunnelNetwork(conn, cmd.getNetworkId(), cmd.getFrom(), cmd.getNetworkName());
bridge = nw.getBridge(conn);
String result =
callHostPlugin(conn, "ovstunnel", "create_tunnel", "bridge", bridge, "remote_ip", cmd.getRemoteIp(),
"key", cmd.getKey().toString(), "from",
cmd.getFrom().toString(), "to", cmd.getTo().toString(), "cloudstack-network-id",
cmd.getNetworkUuid());
String[] res = result.split(":");
if (res.length == 2 && res[0].equalsIgnoreCase("SUCCESS")) {
return new OvsCreateTunnelAnswer(cmd, true, result, res[1], bridge);
} else {
return new OvsCreateTunnelAnswer(cmd, false, result, bridge);
}
} catch (Exception e) {
s_logger.debug("Error during tunnel setup");
s_logger.warn("Caught execption when creating ovs tunnel", e);
return new OvsCreateTunnelAnswer(cmd, false, e.getMessage(), bridge);
}
}