Updated Branches: refs/heads/vpc bda8fc1e0 -> 9b4375339
VPC : handle Revoke rules for staticroute Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/9b437533 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/9b437533 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/9b437533 Branch: refs/heads/vpc Commit: 9b4375339937ca38022d3798cb3730a63445439a Parents: 0c9d5f5 Author: anthony <[email protected]> Authored: Thu Aug 2 18:59:26 2012 -0700 Committer: anthony <[email protected]> Committed: Thu Aug 2 18:59:49 2012 -0700 ---------------------------------------------------------------------- .../agent/api/routing/SetStaticRouteCommand.java | 21 +++---- .../debian/config/opt/cloud/bin/vpc_staticroute.sh | 4 +- .../xen/resource/CitrixResourceBase.java | 43 ++++++--------- 3 files changed, 27 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9b437533/api/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java b/api/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java index c063812..2418048 100644 --- a/api/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java +++ b/api/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java @@ -42,25 +42,22 @@ public class SetStaticRouteCommand extends NetworkElementCommand{ return staticRoutes; } - public boolean isEmpty() { - if(staticRoutes == null || staticRoutes.length == 0 ) { - return true; - } - return false; - } public String[][] generateSRouteRules() { String [][] result = new String [2][]; Set<String> toAdd = new HashSet<String>(); for (StaticRouteProfile route: staticRoutes) { /* example : ip:gateway:cidr, */ - if( route.getState() == StaticRoute.State.Active || route.getState() == StaticRoute.State.Add ) { - String cidr = route.getCidr(); - String subnet = NetUtils.getCidrSubNet(cidr); - String cidrSize = cidr.split("\\/")[1]; - String entry = route.getIp4Address()+ ":" + route.getGateway() + ":" + subnet + "/" + cidrSize; - toAdd.add(entry); + String cidr = route.getCidr(); + String subnet = NetUtils.getCidrSubNet(cidr); + String cidrSize = cidr.split("\\/")[1]; + String entry; + if (route.getState() == StaticRoute.State.Active || route.getState() == StaticRoute.State.Add) { + entry = route.getIp4Address() + ":" + route.getGateway() + ":" + subnet + "/" + cidrSize; + } else { + entry = "Revoke:" + route.getGateway() + ":" + subnet + "/" + cidrSize; } + toAdd.add(entry); } result[0] = toAdd.toArray(new String[toAdd.size()]); return result; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9b437533/patches/systemvm/debian/config/opt/cloud/bin/vpc_staticroute.sh ---------------------------------------------------------------------- diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vpc_staticroute.sh b/patches/systemvm/debian/config/opt/cloud/bin/vpc_staticroute.sh index 542c0c6..b75c0fb 100755 --- a/patches/systemvm/debian/config/opt/cloud/bin/vpc_staticroute.sh +++ b/patches/systemvm/debian/config/opt/cloud/bin/vpc_staticroute.sh @@ -60,11 +60,11 @@ restore_table() { static_route() { local rule=$1 - if [ "$rule" == "none" ] + local ip=$(echo $rule | cut -d: -f1) + if [ $ip == "Revoke" ] then return 0 fi - local ip=$(echo $rule | cut -d: -f1) local gateway=$(echo $rule | cut -d: -f2) local cidr=$(echo $rule | cut -d: -f3) logger -t cloud "$(basename $0): static route: public ip=$ip \ http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9b437533/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index f6e9540..7c42e76 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -7542,35 +7542,24 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe Connection conn = getConnection(); String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); try { - if ( !cmd.isEmpty() ) { - String[] results = new String[cmd.getStaticRoutes().length]; - String [][] rules = cmd.generateSRouteRules(); - StringBuilder sb = new StringBuilder(); - String[] srRules = rules[0]; - for (int i = 0; i < srRules.length; i++) { - sb.append(srRules[i]).append(','); - } - String args = "vpc_staticroute.sh " + routerIp; - args += " -a " + sb.toString(); - callResult = callHostPlugin(conn, "vmops", "routerProxy", "args", args); - if (callResult == null || callResult.isEmpty()) { - //FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails - for (int i=0; i < results.length; i++) { - results[i] = "Failed"; - } - return new SetStaticRouteAnswer(cmd, false, results); - } - return new SetStaticRouteAnswer(cmd, true, results); - } else { - String args = "vpc_staticroute.sh " + routerIp; - args += " -a none"; - callResult = callHostPlugin(conn, "vmops", "routerProxy", "args", args); - if (callResult == null || callResult.isEmpty()) { - return new SetStaticRouteAnswer(cmd, false, null); + String[] results = new String[cmd.getStaticRoutes().length]; + String [][] rules = cmd.generateSRouteRules(); + StringBuilder sb = new StringBuilder(); + String[] srRules = rules[0]; + for (int i = 0; i < srRules.length; i++) { + sb.append(srRules[i]).append(','); + } + String args = "vpc_staticroute.sh " + routerIp; + args += " -a " + sb.toString(); + callResult = callHostPlugin(conn, "vmops", "routerProxy", "args", args); + if (callResult == null || callResult.isEmpty()) { + //FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails + for (int i=0; i < results.length; i++) { + results[i] = "Failed"; } - return new SetStaticRouteAnswer(cmd, true, null); + return new SetStaticRouteAnswer(cmd, false, results); } - + return new SetStaticRouteAnswer(cmd, true, results); } catch (Exception e) { String msg = "SetStaticRoute failed due to " + e.toString(); s_logger.error(msg, e);
