Permalink
Browse files

CS-14724 : Making the default network label configurable, improving e…

…xception management

Please also see notes added to wiki.cloudstack.org/display/QA/Open+vSwitch+Tunnel+Manager
  • Loading branch information...
Salvatore Orlando
Salvatore Orlando committed May 2, 2012
1 parent 310a9fd commit a794e4954557dfa47b0310a910c8f655f8129627
@@ -4949,22 +4949,23 @@ private OvsSetTagAndFlowAnswer execute(OvsSetTagAndFlowCommand cmd) {
private OvsFetchInterfaceAnswer execute(OvsFetchInterfaceCommand cmd) {
String label = cmd.getLabel();
- s_logger.debug("### Will look for network with name-label:" + label + " on host " + _host.ip);
+ s_logger.debug("Will look for network with name-label:" + label + " on host " + _host.ip);
Connection conn = getConnection();
try {
XsLocalNetwork nw = this.getNetworkByName(conn, label);
- s_logger.debug("### Network object:" + nw.getNetwork().getUuid(conn));
+ s_logger.debug("Network object:" + nw.getNetwork().getUuid(conn));
PIF pif = nw.getPif(conn);
Record pifRec = pif.getRecord(conn);
- s_logger.debug("### PIF object:" + pifRec.uuid + "(" + pifRec.device + ")");
+ s_logger.debug("PIF object:" + pifRec.uuid + "(" + pifRec.device + ")");
return new OvsFetchInterfaceAnswer(cmd, true, "Interface " + pifRec.device + " retrieved successfully",
pifRec.IP, pifRec.netmask, pifRec.MAC);
} catch (Exception e) {
e.printStackTrace();
+ s_logger.error("An error occurred while fetching the interface for " +
+ label + " on host " + _host.ip + ":" + e.toString() +
+ "(" + e.getClass() + ")");
return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:" + e.getMessage());
}
-
-
}
@@ -4989,6 +4990,10 @@ private OvsCreateGreTunnelAnswer execute(OvsCreateGreTunnelCommand cmd) {
}
} catch (Exception e) {
e.printStackTrace();
+ s_logger.error("An error occurred while creating a GRE tunnel to " +
+ cmd.getRemoteIp() + " on host " + _host.ip + ":" + e.getMessage() +
+ "(" + e.getClass() + ")");
+
}
return new OvsCreateGreTunnelAnswer(cmd, false, "EXCEPTION", _host.ip, bridge);
@@ -88,7 +88,8 @@
NetworkThrottlingRate("Network", ManagementServer.class, Integer.class, "network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed in network.", null),
GuestDomainSuffix("Network", AgentManager.class, String.class, "guest.domain.suffix", "cloud.internal", "Default domain name for vms inside virtualized networks fronted by router", null),
DirectNetworkNoDefaultRoute("Network", ManagementServer.class, Boolean.class, "direct.network.no.default.route", "false", "Direct Network Dhcp Server should not send a default route", "true/false"),
- OvsTunnelNetwork("Network", ManagementServer.class, Boolean.class, "sdn.ovs.controller", "false", "enable/disable open vswitch tunnel network(no vlan)", null),
+ OvsTunnelNetwork("Network", ManagementServer.class, Boolean.class, "sdn.ovs.controller", "false", "Enable/Disable Open vSwitch SDN controller for L2-in-L3 overlay networks", null),
+ OvsTunnelNetworkDefaultLabel("Network", ManagementServer.class, String.class, "sdn.ovs.controller.default.label", "cloud-public", "Default network label to be used when fetching interface for GRE endpoints", null),
VmNetworkThrottlingRate("Network", ManagementServer.class, Integer.class, "vm.network.throttling.rate", "200", "Default data transfer rate in megabits per second allowed in User vm's default network.", null),
NetworkLockTimeout("Network", ManagementServer.class, Integer.class, "network.lock.timeout", "600", "Lock wait timeout (seconds) while implementing network", null),
@@ -0,0 +1,19 @@
+// Copyright 2012 Citrix Systems, Inc. Licensed under the
+// Apache License, Version 2.0 (the "License"); you may not use this
+// file except in compliance with the License. Citrix Systems, Inc.
+// reserves all rights not expressly granted by the License.
+// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Automatically generated by addcopyright.py at 04/03/2012
+package com.cloud.network.ovs;
+
+public class GreTunnelException extends Exception {
+ public GreTunnelException(String msg) {
+ super(msg);
+ }
+}
@@ -138,10 +138,19 @@ protected OvsTunnelInterfaceVO createInterfaceRecord(String ip,
private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId){
OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer) answers[0];
- OvsTunnelInterfaceVO ti =
- createInterfaceRecord(ans.getIp(), ans.getNetmask(),
- ans.getMac(), hostId, ans.getLabel());
- return ti.getIp();
+ if (ans.getResult()) {
+ if (ans.getIp() != null &&
+ !("".equals(ans.getIp()))) {
+ OvsTunnelInterfaceVO ti =
+ createInterfaceRecord(ans.getIp(), ans.getNetmask(),
+ ans.getMac(), hostId, ans.getLabel());
+ return ti.getIp();
+ }
+ }
+ // Fetch interface failed!
+ s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint" +
+ ans.getDetails());
+ return null;
}
private void handleCreateTunnelAnswer(Answer[] answers){
@@ -177,10 +186,8 @@ private void handleCreateTunnelAnswer(Answer[] answers){
private String getGreEndpointIP(Host host, Network nw) throws
AgentUnavailableException, OperationTimedoutException {
String endpointIp = null;
- // Fetch physical network and associated tags
- // If no tag specified, look for this network
- // Default name for network label
- String physNetLabel = "cloud-public";
+ // Fetch fefault name for network label from configuration
+ String physNetLabel = _configDao.getValue(Config.OvsTunnelNetworkDefaultLabel.key());
Long physNetId = nw.getPhysicalNetworkId();
PhysicalNetworkTrafficType physNetTT =
_physNetTTDao.findBy(physNetId, TrafficType.Guest);
@@ -310,13 +317,21 @@ protected void CheckAndCreateTunnel(VirtualMachine instance,
}
}
}
- //FIXME: Why are we cancelling the exception here?
- try {
+ //TODO: Should we propagate the exception here?
+ try {
String myIp = getGreEndpointIP(dest.getHost(), nw);
+ if (myIp == null)
+ throw new GreTunnelException("Unable to retrieve the source " +
+ "endpoint for the GRE tunnel." +
+ "Failure is on host:" + dest.getHost().getId());
boolean noHost = true;
for (Long i : toHostIds) {
HostVO rHost = _hostDao.findById(i);
String otherIp = getGreEndpointIP(rHost, nw);
+ if (otherIp == null)
+ throw new GreTunnelException("Unable to retrieve the remote " +
+ "endpoint for the GRE tunnel." +
+ "Failure is on host:" + rHost.getId());
Commands cmds = new Commands(
new OvsCreateTunnelCommand(otherIp, key,
Long.valueOf(hostId), i, nw.getId(), myIp));
@@ -351,7 +366,8 @@ protected void CheckAndCreateTunnel(VirtualMachine instance,
handleSetupBridgeAnswer(answers);
}
} catch (Exception e) {
- s_logger.warn("Ovs Tunnel network created tunnel failed", e);
+ // I really thing we should do a better handling of these exceptions
+ s_logger.warn("Ovs Tunnel network created tunnel failed", e);
}
}
@@ -24,7 +24,8 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'manag
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'secstorage.service.offering', NULL, 'Service offering used by secondary storage; if NULL - system offering will be used');
-INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'sdn.ovs.controller', NULL, 'Enabled Open vSwitch SDN controller for L2-in-L3 overlay networks');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'sdn.ovs.controller', NULL, 'Enable/Disable Open vSwitch SDN controller for L2-in-L3 overlay networks');
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'sdn.ovs.controller.default.label', NULL, 'Default network label to be used when fetching interface for GRE endpoints');
ALTER TABLE `cloud`.`user_vm` ADD COLUMN `update_parameters` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Defines if the parameters need to be set for the vm';
UPDATE `cloud`.`user_vm` SET update_parameters=0 where id>0;
View
@@ -3,7 +3,7 @@
# the following two variables are used by the target "waf dist"
# if you change 'em here, you need to change it also in cloud.spec, add a %changelog entry there, and add an entry in debian/changelog
-VERSION = '2.2.2'
+VERSION = '3.0.3'
APPNAME = 'cloud'
import shutil,os

0 comments on commit a794e49

Please sign in to comment.