You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2014/02/20 20:17:07 UTC
[01/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Repository: cloudstack
Updated Branches:
refs/heads/ui-restyle 849d601cc -> c64bfa5d8
findbugs findings
Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5a6ad11f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5a6ad11f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5a6ad11f
Branch: refs/heads/ui-restyle
Commit: 5a6ad11fa2ca3de64b94095c628bd3ba12e618c3
Parents: 33c2c87
Author: Ian Southam <is...@schubergphilis.com>
Authored: Wed Feb 12 17:08:52 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:46 2014 +0100
----------------------------------------------------------------------
framework/db/src/com/cloud/utils/db/Filter.java | 2 +-
.../src/com/cloud/utils/db/GenericDaoBase.java | 27 ++++++++++++--------
2 files changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a6ad11f/framework/db/src/com/cloud/utils/db/Filter.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/Filter.java b/framework/db/src/com/cloud/utils/db/Filter.java
index b2482fd..fdcad9c 100755
--- a/framework/db/src/com/cloud/utils/db/Filter.java
+++ b/framework/db/src/com/cloud/utils/db/Filter.java
@@ -79,7 +79,7 @@ public class Filter {
String name = column != null ? column.name() : field;
StringBuilder order = new StringBuilder();
- if (column.table() == null || column.table().length() == 0) {
+ if (column == null || column.table() == null || column.table().length() == 0) {
order.append(DbUtil.getTableName(clazz));
} else {
order.append(column.table());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a6ad11f/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
index f282428..d929e00 100755
--- a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
+++ b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
@@ -396,10 +396,10 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
final List<T> result = new ArrayList<T>();
try {
pstmt = txn.prepareAutoCloseStatement(sql);
- int i = 0;
+ int i = 1;
if (clause != null) {
for (final Pair<Attribute, Object> value : sc.getValues()) {
- prepareAttribute(++i, pstmt, value.first(), value.second());
+ prepareAttribute(i++, pstmt, value.first(), value.second());
}
}
@@ -431,10 +431,13 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
@Override
@SuppressWarnings("unchecked")
public <M> List<M> customSearchIncludingRemoved(SearchCriteria<M> sc, final Filter filter) {
+ if (sc == null) {
+ throw new CloudRuntimeException("Call to customSearchIncludingRemoved with null search Criteria");
+ }
if (sc.isSelectAll()) {
return (List<M>)searchIncludingRemoved((SearchCriteria<T>)sc, filter, null, false);
}
- String clause = sc != null ? sc.getWhereClause() : null;
+ String clause = sc.getWhereClause();
if (clause != null && clause.length() == 0) {
clause = null;
}
@@ -445,11 +448,9 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
}
Collection<JoinBuilder<SearchCriteria<?>>> joins = null;
- if (sc != null) {
- joins = sc.getJoins();
- if (joins != null) {
- addJoins(str, joins);
- }
+ joins = sc.getJoins();
+ if (joins != null) {
+ addJoins(str, joins);
}
List<Object> groupByValues = addGroupBy(str, sc);
@@ -461,10 +462,10 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
PreparedStatement pstmt = null;
try {
pstmt = txn.prepareAutoCloseStatement(sql);
- int i = 0;
+ int i = 1;
if (clause != null) {
for (final Pair<Attribute, Object> value : sc.getValues()) {
- prepareAttribute(++i, pstmt, value.first(), value.second());
+ prepareAttribute(i++, pstmt, value.first(), value.second());
}
}
@@ -1070,6 +1071,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
@DB()
protected List<Object> addGroupBy(final StringBuilder sql, SearchCriteria<?> sc) {
+ if (sc == null)
+ return null;
Pair<GroupBy<?, ?, ?>, List<Object>> groupBys = sc.getGroupBy();
if (groupBys != null) {
groupBys.first().toSql(sql);
@@ -1179,6 +1182,10 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
// FIXME: Does not work for joins.
@Override
public int expunge(final SearchCriteria<T> sc) {
+ if (sc == null) {
+ throw new CloudRuntimeException("Call to throw new expunge with null search Criteria");
+ }
+
final StringBuilder str = new StringBuilder("DELETE FROM ");
str.append(_table);
str.append(" WHERE ");
[13/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Remove SetupGuestNetworkAnswer
It's unnecessary and not different from Answer itself.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6bde675f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6bde675f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6bde675f
Branch: refs/heads/ui-restyle
Commit: 6bde675f87111e13ce7d2e036fdf4c67177929c6
Parents: 161e7d9
Author: Sheng Yang <sh...@citrix.com>
Authored: Fri Feb 14 17:28:55 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Fri Feb 14 18:10:05 2014 -0800
----------------------------------------------------------------------
.../agent/api/SetupGuestNetworkAnswer.java | 26 ---------------
.../virtualnetwork/VirtualRoutingResource.java | 12 +++----
.../cloud/agent/manager/MockNetworkManager.java | 3 +-
.../agent/manager/MockNetworkManagerImpl.java | 9 +++---
.../VpcVirtualNetworkApplianceManagerImpl.java | 33 +++++++++-----------
5 files changed, 25 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bde675f/core/src/com/cloud/agent/api/SetupGuestNetworkAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/SetupGuestNetworkAnswer.java b/core/src/com/cloud/agent/api/SetupGuestNetworkAnswer.java
deleted file mode 100644
index 16eb771..0000000
--- a/core/src/com/cloud/agent/api/SetupGuestNetworkAnswer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with 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.
-package com.cloud.agent.api;
-
-public class SetupGuestNetworkAnswer extends Answer {
- public SetupGuestNetworkAnswer() {
- }
-
- public SetupGuestNetworkAnswer(SetupGuestNetworkCommand cmd, boolean success, String result) {
- super(cmd, success, result);
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bde675f/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 0b90cc9..a287ada 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -25,7 +25,6 @@ import com.cloud.agent.api.CheckS2SVpnConnectionsCommand;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.GetDomRVersionAnswer;
import com.cloud.agent.api.GetDomRVersionCmd;
-import com.cloud.agent.api.SetupGuestNetworkAnswer;
import com.cloud.agent.api.SetupGuestNetworkCommand;
import com.cloud.agent.api.routing.CreateIpAliasCommand;
import com.cloud.agent.api.routing.DeleteIpAliasCommand;
@@ -47,7 +46,6 @@ import com.cloud.agent.api.routing.SetNetworkACLCommand;
import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
import com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand;
-import com.cloud.agent.api.routing.SetSourceNatAnswer;
import com.cloud.agent.api.routing.SetSourceNatCommand;
import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
@@ -631,7 +629,7 @@ public class VirtualRoutingResource {
return new Answer(cmd);
}
- protected SetupGuestNetworkAnswer execute(SetupGuestNetworkCommand cmd) {
+ protected Answer execute(SetupGuestNetworkCommand cmd) {
NicTO nic = cmd.getNic();
String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
String routerGIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
@@ -668,9 +666,9 @@ public class VirtualRoutingResource {
ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_guestnw.sh", args);
if (!result.isSuccess()) {
- return new SetupGuestNetworkAnswer(cmd, false, "Creating guest network failed due to " + result.getDetails());
+ return new Answer(cmd, false, "Creating guest network failed due to " + result.getDetails());
}
- return new SetupGuestNetworkAnswer(cmd, true, "success");
+ return new Answer(cmd, true, "success");
}
private SetNetworkACLAnswer execute(SetNetworkACLCommand cmd) {
@@ -720,7 +718,7 @@ public class VirtualRoutingResource {
}
}
- protected SetSourceNatAnswer execute(SetSourceNatCommand cmd) {
+ protected Answer execute(SetSourceNatCommand cmd) {
String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
IpAddressTO pubIP = cmd.getIpAddress();
String dev = "eth" + pubIP.getNicDevId();
@@ -730,7 +728,7 @@ public class VirtualRoutingResource {
args += " -c ";
args += dev;
ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_snat.sh", args);
- return new SetSourceNatAnswer(cmd, result.isSuccess(), result.getDetails());
+ return new Answer(cmd, result.isSuccess(), result.getDetails());
}
private SetPortForwardingRulesAnswer execute(SetPortForwardingRulesVpcCommand cmd) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bde675f/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManager.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManager.java
index 554af68..e7a7a95 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManager.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManager.java
@@ -25,7 +25,6 @@ import com.cloud.agent.api.NetworkUsageCommand;
import com.cloud.agent.api.PlugNicAnswer;
import com.cloud.agent.api.PlugNicCommand;
import com.cloud.agent.api.PvlanSetupCommand;
-import com.cloud.agent.api.SetupGuestNetworkAnswer;
import com.cloud.agent.api.SetupGuestNetworkCommand;
import com.cloud.agent.api.UnPlugNicAnswer;
import com.cloud.agent.api.UnPlugNicCommand;
@@ -79,7 +78,7 @@ public interface MockNetworkManager extends Manager {
SetPortForwardingRulesAnswer setVpcPortForwards(SetPortForwardingRulesVpcCommand cmd);
- SetupGuestNetworkAnswer setUpGuestNetwork(SetupGuestNetworkCommand cmd);
+ Answer setUpGuestNetwork(SetupGuestNetworkCommand cmd);
SetStaticNatRulesAnswer setVPCStaticNatRules(SetStaticNatRulesCommand cmd);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bde675f/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManagerImpl.java
index a4ffd95..c76ef4d 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockNetworkManagerImpl.java
@@ -30,7 +30,6 @@ import com.cloud.agent.api.NetworkUsageCommand;
import com.cloud.agent.api.PlugNicAnswer;
import com.cloud.agent.api.PlugNicCommand;
import com.cloud.agent.api.PvlanSetupCommand;
-import com.cloud.agent.api.SetupGuestNetworkAnswer;
import com.cloud.agent.api.SetupGuestNetworkCommand;
import com.cloud.agent.api.UnPlugNicAnswer;
import com.cloud.agent.api.UnPlugNicCommand;
@@ -203,18 +202,18 @@ public class MockNetworkManagerImpl extends ManagerBase implements MockNetworkMa
}
@Override
- public SetupGuestNetworkAnswer setUpGuestNetwork(SetupGuestNetworkCommand cmd) {
+ public Answer setUpGuestNetwork(SetupGuestNetworkCommand cmd) {
String domrName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
try {
MockVMVO vms = _mockVmDao.findByVmName(domrName);
if (vms == null) {
- return new SetupGuestNetworkAnswer(cmd, false, "Can not find VM " + domrName);
+ return new Answer(cmd, false, "Can not find VM " + domrName);
}
- return new SetupGuestNetworkAnswer(cmd, true, "success");
+ return new Answer(cmd, true, "success");
} catch (Exception e) {
String msg = "Creating guest network failed due to " + e.toString();
s_logger.warn(msg, e);
- return new SetupGuestNetworkAnswer(cmd, false, msg);
+ return new Answer(cmd, false, msg);
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6bde675f/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index 6e4b771..2b798bf 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -16,27 +16,10 @@
// under the License.
package com.cloud.network.router;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeSet;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.NetworkUsageCommand;
import com.cloud.agent.api.PlugNicCommand;
-import com.cloud.agent.api.SetupGuestNetworkAnswer;
import com.cloud.agent.api.SetupGuestNetworkCommand;
import com.cloud.agent.api.routing.IpAssocVpcCommand;
import com.cloud.agent.api.routing.NetworkElementCommand;
@@ -126,6 +109,20 @@ import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.VirtualMachineProfile.Param;
import com.cloud.vm.dao.VMInstanceDao;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeSet;
@Component
@Local(value = {VpcVirtualNetworkApplianceManager.class, VpcVirtualNetworkApplianceService.class})
@@ -339,7 +336,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
cmds.addCommand("setupguestnetwork", setupCmd);
sendCommandsToRouter(router, cmds);
- SetupGuestNetworkAnswer setupAnswer = cmds.getAnswer(SetupGuestNetworkAnswer.class);
+ Answer setupAnswer = cmds.getAnswer("setupguestnetwork");
String setup = add ? "set" : "destroy";
if (!(setupAnswer != null && setupAnswer.getResult())) {
s_logger.warn("Unable to " + setup + " guest network on router " + router);
[40/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Separate VR command generation and execution
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8fccb8c0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8fccb8c0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8fccb8c0
Branch: refs/heads/ui-restyle
Commit: 8fccb8c077c7f228521628edb40313ae0c160af8
Parents: 5332f67
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 19:12:06 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 19:46:55 2014 -0800
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 686 ++++++++++++-------
1 file changed, 449 insertions(+), 237 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8fccb8c0/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 2ac6f4f..d51e8bb 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -74,6 +74,7 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -200,7 +201,43 @@ public class VirtualRoutingResource {
}
}
- private Answer execute(VpnUsersCfgCommand cmd) {
+ protected class ConfigItem {
+ private String script;
+ private String args;
+ private String info;
+
+ public ConfigItem(String script, String args) {
+ this.script = script;
+ this.args = args;
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public void setScript(String script) {
+ this.script = script;
+ }
+
+ public String getArgs() {
+ return args;
+ }
+
+ public void setArgs(String args) {
+ this.args = args;
+ }
+
+ public String getInfo() {
+ return info;
+ }
+
+ public void setInfo(String info) {
+ this.info = info;
+ }
+ }
+
+ private List<ConfigItem> generateConfig(VpnUsersCfgCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
for (VpnUsersCfgCommand.UsernamePassword userpwd : cmd.getUserpwds()) {
String args = "";
if (!userpwd.isAdd()) {
@@ -210,15 +247,24 @@ public class VirtualRoutingResource {
args += "-u ";
args += userpwd.getUsernamePassword();
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPN_L2TP, args);
+ cfg.add(new ConfigItem(VRScripts.VPN_L2TP, args));
+ }
+ return cfg;
+ }
+
+ private Answer execute(VpnUsersCfgCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ for (ConfigItem c : cfg) {
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
if (!result.isSuccess()) {
- return new Answer(cmd, false, "Configure VPN user failed for user " + userpwd.getUsername() + ":" + result.getDetails());
+ return new Answer(cmd, false, "Configure VPN user failed: " + result.getDetails());
}
}
return new Answer(cmd);
}
- private Answer execute(RemoteAccessVpnCfgCommand cmd) {
+ private List<ConfigItem> generateConfig(RemoteAccessVpnCfgCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
String args = "";
if (cmd.isCreate()) {
args += "-r ";
@@ -237,18 +283,21 @@ public class VirtualRoutingResource {
}
args += " -C " + cmd.getLocalCidr();
args += " -i " + cmd.getPublicInterface();
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPN_L2TP, args);
+ cfg.add(new ConfigItem(VRScripts.VPN_L2TP, args));
+ return cfg;
+ }
+
+ private Answer execute(RemoteAccessVpnCfgCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- private Answer execute(SetFirewallRulesCommand cmd) {
- String[] results = new String[cmd.getRules().length];
- String routerAccessIp = cmd.getRouterAccessIp();
- String egressDefault = cmd.getAccessDetail(NetworkElementCommand.FIREWALL_EGRESS_DEFAULT);
+ private List<ConfigItem> generateConfig(SetFirewallRulesCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
- if (routerAccessIp == null) {
- return new SetFirewallRulesAnswer(cmd, false, results);
- }
+ String egressDefault = cmd.getAccessDetail(NetworkElementCommand.FIREWALL_EGRESS_DEFAULT);
FirewallRuleTO[] allrules = cmd.getRules();
FirewallRule.TrafficType trafficType = allrules[0].getTrafficType();
@@ -276,14 +325,27 @@ public class VirtualRoutingResource {
args += " -a " + sb.toString();
}
- ExecutionResult result;
-
if (trafficType == FirewallRule.TrafficType.Egress) {
- result = _vrDeployer.executeInVR(routerAccessIp, VRScripts.FIREWALL_EGRESS, args);
+ cfg.add(new ConfigItem(VRScripts.FIREWALL_EGRESS, args));
} else {
- result = _vrDeployer.executeInVR(routerAccessIp, VRScripts.FIREWALL_INGRESS, args);
+ cfg.add(new ConfigItem(VRScripts.FIREWALL_INGRESS, args));
}
+ return cfg;
+ }
+
+ private Answer execute(SetFirewallRulesCommand cmd) {
+ String[] results = new String[cmd.getRules().length];
+ String routerAccessIp = cmd.getRouterAccessIp();
+
+ if (routerAccessIp == null) {
+ return new SetFirewallRulesAnswer(cmd, false, results);
+ }
+
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ ExecutionResult result = _vrDeployer.executeInVR(routerAccessIp, c.getScript(), c.getArgs());
+
if (!result.isSuccess()) {
//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++) {
@@ -295,10 +357,9 @@ public class VirtualRoutingResource {
}
- private Answer execute(SetPortForwardingRulesCommand cmd) {
- String[] results = new String[cmd.getRules().length];
- int i = 0;
- boolean endResult = true;
+ private List<ConfigItem> generateConfig(SetPortForwardingRulesCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
for (PortForwardingRuleTO rule : cmd.getRules()) {
StringBuilder args = new StringBuilder();
args.append(rule.revoked() ? " -D " : " -A ");
@@ -307,8 +368,20 @@ public class VirtualRoutingResource {
args.append(" -p ").append(rule.getStringSrcPortRange());
args.append(" -r ").append(rule.getDstIp());
args.append(" -d ").append(rule.getStringDstPortRange());
+ cfg.add(new ConfigItem(VRScripts.FIREWALL_NAT, args.toString()));
+ }
+
+ return cfg;
+ }
+
+ private Answer execute(SetPortForwardingRulesCommand cmd) {
+ String[] results = new String[cmd.getRules().length];
+ int i = 0;
+ boolean endResult = true;
+ List<ConfigItem> cfg = generateConfig(cmd);
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.FIREWALL_NAT, args.toString());
+ for (ConfigItem c : cfg) {
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
if (!result.isSuccess()) {
results[i++] = "Failed";
@@ -321,51 +394,45 @@ public class VirtualRoutingResource {
return new SetPortForwardingRulesAnswer(cmd, results, endResult);
}
- protected SetStaticNatRulesAnswer SetVPCStaticNatRules(SetStaticNatRulesCommand cmd) {
- String[] results = new String[cmd.getRules().length];
- int i = 0;
- boolean endResult = true;
+ private List<ConfigItem> generateConfig(SetStaticNatRulesCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+ if (cmd.getVpcId() != null) {
+ for (StaticNatRuleTO rule : cmd.getRules()) {
+ String args = rule.revoked() ? " -D" : " -A";
+ args += " -l " + rule.getSrcIp();
+ args += " -r " + rule.getDstIp();
- for (StaticNatRuleTO rule : cmd.getRules()) {
- String args = rule.revoked() ? " -D" : " -A";
- args += " -l " + rule.getSrcIp();
- args += " -r " + rule.getDstIp();
+ cfg.add(new ConfigItem(VRScripts.VPC_STATIC_NAT, args));
+ }
+ } else {
+ for (StaticNatRuleTO rule : cmd.getRules()) {
+ //1:1 NAT needs instanceip;publicip;domrip;op
+ StringBuilder args = new StringBuilder();
+ args.append(rule.revoked() ? " -D " : " -A ");
+ args.append(" -l ").append(rule.getSrcIp());
+ args.append(" -r ").append(rule.getDstIp());
+
+ if (rule.getProtocol() != null) {
+ args.append(" -P ").append(rule.getProtocol().toLowerCase());
+ }
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_STATIC_NAT, args);
+ args.append(" -d ").append(rule.getStringSrcPortRange());
+ args.append(" -G ");
- if (!result.isSuccess()) {
- results[i++] = null;
- } else {
- results[i++] = "Failed";
- endResult = false;
+ cfg.add(new ConfigItem(VRScripts.FIREWALL_NAT, args.toString()));
}
}
- return new SetStaticNatRulesAnswer(cmd, results, endResult);
-
+ return cfg;
}
private SetStaticNatRulesAnswer execute(SetStaticNatRulesCommand cmd) {
- if (cmd.getVpcId() != null) {
- return SetVPCStaticNatRules(cmd);
- }
String[] results = new String[cmd.getRules().length];
int i = 0;
boolean endResult = true;
- for (StaticNatRuleTO rule : cmd.getRules()) {
- //1:1 NAT needs instanceip;publicip;domrip;op
- StringBuilder args = new StringBuilder();
- args.append(rule.revoked() ? " -D " : " -A ");
- args.append(" -l ").append(rule.getSrcIp());
- args.append(" -r ").append(rule.getDstIp());
-
- if (rule.getProtocol() != null) {
- args.append(" -P ").append(rule.getProtocol().toLowerCase());
- }
- args.append(" -d ").append(rule.getStringSrcPortRange());
- args.append(" -G ");
-
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.FIREWALL_NAT, args.toString());
+ List<ConfigItem> cfg = generateConfig(cmd);
+ for (ConfigItem c : cfg) {
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
if (!result.isSuccess()) {
results[i++] = "Failed";
@@ -378,29 +445,11 @@ public class VirtualRoutingResource {
return new SetStaticNatRulesAnswer(cmd, results, endResult);
}
- private Answer execute(LoadBalancerConfigCommand cmd) {
- String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
-
- if (routerIp == null) {
- return new Answer(cmd);
- }
+ private List<ConfigItem> generateConfig(LoadBalancerConfigCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+ String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
LoadBalancerConfigurator cfgtr = new HAProxyConfigurator();
- String[] config = cfgtr.generateConfiguration(cmd);
- String tmpCfgFileContents = "";
- for (int i = 0; i < config.length; i++) {
- tmpCfgFileContents += config[i];
- tmpCfgFileContents += "\n";
- }
-
- String tmpCfgFilePath = "/etc/haproxy/";
- String tmpCfgFileName = "haproxy.cfg.new";
- ExecutionResult result = _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents);
-
- if (!result.isSuccess()) {
- return new Answer(cmd, false, "Fail to copy LB config file to VR");
- }
-
String[][] rules = cfgtr.generateFwRules(cmd);
String[] addRules = rules[LoadBalancerConfigurator.ADD];
@@ -436,17 +485,48 @@ public class VirtualRoutingResource {
if (cmd.getVpcId() == null) {
args = " -i " + routerIp + args;
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.LB, args);
+ cfg.add(new ConfigItem(VRScripts.LB, args));
} else {
args = " -i " + cmd.getNic().getIp() + args;
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_LB, args);
+ cfg.add(new ConfigItem(VRScripts.VPC_LB, args));
}
+ return cfg;
+ }
+
+ private Answer execute(LoadBalancerConfigCommand cmd) {
+ String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+
+ if (routerIp == null) {
+ return new Answer(cmd);
+ }
+
+ LoadBalancerConfigurator cfgtr = new HAProxyConfigurator();
+ String[] config = cfgtr.generateConfiguration(cmd);
+ String tmpCfgFileContents = "";
+ for (int i = 0; i < config.length; i++) {
+ tmpCfgFileContents += config[i];
+ tmpCfgFileContents += "\n";
+ }
+
+ String tmpCfgFilePath = "/etc/haproxy/";
+ String tmpCfgFileName = "haproxy.cfg.new";
+ ExecutionResult result = _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents);
+
+ if (!result.isSuccess()) {
+ return new Answer(cmd, false, "Fail to copy LB config file to VR");
+ }
+
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- protected Answer execute(VmDataCommand cmd) {
+ private List<ConfigItem> generateConfig(VmDataCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
Map<String, List<String[]>> data = new HashMap<String, List<String[]>>();
data.put(cmd.getVmIpAddress(), cmd.getVmData());
@@ -457,22 +537,40 @@ public class VirtualRoutingResource {
String args = "-d " + json;
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VMDATA, args);
+ cfg.add(new ConfigItem(VRScripts.VMDATA, args));
+ return cfg;
+ }
+
+ protected Answer execute(VmDataCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- protected Answer execute(final SavePasswordCommand cmd) {
+ private List<ConfigItem> generateConfig(SavePasswordCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
final String password = cmd.getPassword();
final String vmIpAddress = cmd.getVmIpAddress();
String args = "-v " + vmIpAddress;
args += " -p " + password;
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.PASSWORD, args);
+ cfg.add(new ConfigItem(VRScripts.PASSWORD, args));
+ return cfg;
+ }
+
+ protected Answer execute(final SavePasswordCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- protected Answer execute(final DhcpEntryCommand cmd) {
+ private List<ConfigItem> generateConfig(DhcpEntryCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
String args = " -m " + cmd.getVmMac();
if (cmd.getVmIpAddress() != null) {
args += " -4 " + cmd.getVmIpAddress();
@@ -499,22 +597,41 @@ public class VirtualRoutingResource {
if (!cmd.isDefault()) {
args += " -N";
}
+ cfg.add(new ConfigItem(VRScripts.DHCP, args));
+
+ return cfg;
+ }
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.DHCP, args);
+ protected Answer execute(final DhcpEntryCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- protected Answer execute(final CreateIpAliasCommand cmd) {
+ private List<ConfigItem> generateConfig(CreateIpAliasCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
String args = "";
for (IpAliasTO ipaliasto : ipAliasTOs) {
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
}
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.IPALIAS_CREATE, args);
+
+ cfg.add(new ConfigItem(VRScripts.IPALIAS_CREATE, args));
+ return cfg;
+ }
+
+ protected Answer execute(final CreateIpAliasCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- protected Answer execute(final DeleteIpAliasCommand cmd) {
+ private List<ConfigItem> generateConfig(DeleteIpAliasCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
String args = "";
List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
@@ -526,17 +643,35 @@ public class VirtualRoutingResource {
for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
}
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.IPALIAS_DELETE, args);
+
+ cfg.add(new ConfigItem(VRScripts.IPALIAS_DELETE, args));
+ return cfg;
+ }
+
+ protected Answer execute(final DeleteIpAliasCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- protected Answer execute(final DnsMasqConfigCommand cmd) {
+ private List<ConfigItem> generateConfig(DnsMasqConfigCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
List<DhcpTO> dhcpTos = cmd.getIps();
String args = "";
for (DhcpTO dhcpTo : dhcpTos) {
args = args + dhcpTo.getRouterIp() + ":" + dhcpTo.getGateway() + ":" + dhcpTo.getNetmask() + ":" + dhcpTo.getStartIpOfSubnet() + "-";
}
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.DNSMASQ_CONFIG, args);
+
+ cfg.add(new ConfigItem(VRScripts.DNSMASQ_CONFIG, args));
+ return cfg;
+ }
+
+ protected Answer execute(final DnsMasqConfigCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -558,8 +693,16 @@ public class VirtualRoutingResource {
return new CheckRouterAnswer(cmd, result.getDetails(), true);
}
+ private List<ConfigItem> generateConfig(BumpUpPriorityCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+ cfg.add(new ConfigItem(VRScripts.RVR_BUMPUP_PRI, null));
+ return cfg;
+ }
+
protected Answer execute(BumpUpPriorityCommand cmd) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.RVR_BUMPUP_PRI, null);
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -575,7 +718,9 @@ public class VirtualRoutingResource {
return new GetDomRVersionAnswer(cmd, result.getDetails(), lines[0], lines[1]);
}
- protected Answer execute(Site2SiteVpnCfgCommand cmd) {
+ private List<ConfigItem> generateConfig(Site2SiteVpnCfgCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
String args = "";
if (cmd.isCreate()) {
args += "-A";
@@ -617,32 +762,43 @@ public class VirtualRoutingResource {
args += " -N ";
args += cmd.getPeerGuestCidrList();
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.S2SVPN_IPSEC, args);
- if (!result.isSuccess()) {
- return new Answer(cmd, false, "Configure site to site VPN failed due to " + result.getDetails());
- }
- return new Answer(cmd);
+
+ cfg.add(new ConfigItem(VRScripts.S2SVPN_IPSEC, args));
+ return cfg;
}
- protected Answer execute(SetMonitorServiceCommand cmd) {
+ protected Answer execute(Site2SiteVpnCfgCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+ return new Answer(cmd, result.isSuccess(), result.getDetails());
+ }
+
+ protected List<ConfigItem> generateConfig(SetMonitorServiceCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
String config = cmd.getConfiguration();
String disableMonitoring = cmd.getAccessDetail(NetworkElementCommand.ROUTER_MONITORING_ENABLE);
-
String args = " -c " + config;
if (disableMonitoring != null) {
args = args + " -d";
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.MONITOR_SERVICE, args);
+ cfg.add(new ConfigItem(VRScripts.MONITOR_SERVICE, args));
+ return cfg;
+ }
- if (!result.isSuccess()) {
- return new Answer(cmd, false, result.getDetails());
- }
- return new Answer(cmd);
+ protected Answer execute(SetMonitorServiceCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+ return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- protected Answer execute(SetupGuestNetworkCommand cmd) {
+ protected List<ConfigItem> generateConfig(SetupGuestNetworkCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
NicTO nic = cmd.getNic();
String routerGIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
String gateway = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
@@ -675,62 +831,72 @@ public class VirtualRoutingResource {
if (domainName != null && !domainName.isEmpty()) {
args += " -e " + domainName;
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_GUEST_NETWORK, args);
- if (!result.isSuccess()) {
- return new Answer(cmd, false, "Creating guest network failed due to " + result.getDetails());
- }
- return new Answer(cmd, true, "success");
+ cfg.add(new ConfigItem(VRScripts.VPC_GUEST_NETWORK, args));
+ return cfg;
}
- private SetNetworkACLAnswer execute(SetNetworkACLCommand cmd) {
- String[] results = new String[cmd.getRules().length];
+ protected Answer execute(SetupGuestNetworkCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+ return new Answer(cmd, result.isSuccess(), result.getDetails());
+ }
+
+ protected List<ConfigItem> generateConfig(SetNetworkACLCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
String privateGw = cmd.getAccessDetail(NetworkElementCommand.VPC_PRIVATE_GATEWAY);
- try {
- String[][] rules = cmd.generateFwRules();
- String[] aclRules = rules[0];
- NicTO nic = cmd.getNic();
- String dev = "eth" + nic.getDeviceId();
- String netmask = Long.toString(NetUtils.getCidrSize(nic.getNetmask()));
- StringBuilder sb = new StringBuilder();
-
- for (int i = 0; i < aclRules.length; i++) {
- sb.append(aclRules[i]).append(',');
- }
+ String[][] rules = cmd.generateFwRules();
+ String[] aclRules = rules[0];
+ NicTO nic = cmd.getNic();
+ String dev = "eth" + nic.getDeviceId();
+ String netmask = Long.toString(NetUtils.getCidrSize(nic.getNetmask()));
+ StringBuilder sb = new StringBuilder();
- String rule = sb.toString();
- ExecutionResult result;
+ for (int i = 0; i < aclRules.length; i++) {
+ sb.append(aclRules[i]).append(',');
+ }
- String args = " -d " + dev;
- args += " -M " + nic.getMac();
- if (privateGw != null) {
- args += " -a " + rule;
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_PRIVATEGW_ACL, args);
- } else {
- args += " -i " + nic.getIp();
- args += " -m " + netmask;
- args += " -a " + rule;
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_ACL, args);
- }
+ String rule = sb.toString();
- if (!result.isSuccess()) {
- for (int i = 0; i < results.length; i++) {
- results[i] = "Failed";
- }
- return new SetNetworkACLAnswer(cmd, false, results);
- }
+ String args = " -d " + dev;
+ args += " -M " + nic.getMac();
+ if (privateGw != null) {
+ args += " -a " + rule;
+
+ cfg.add(new ConfigItem(VRScripts.VPC_PRIVATEGW_ACL, args));
+ } else {
+ args += " -i " + nic.getIp();
+ args += " -m " + netmask;
+ args += " -a " + rule;
+ cfg.add(new ConfigItem(VRScripts.VPC_ACL, args));
+ }
+
+ return cfg;
+ }
- return new SetNetworkACLAnswer(cmd, true, results);
- } catch (Exception e) {
- String msg = "SetNetworkACL failed due to " + e.toString();
- s_logger.error(msg, e);
+ private SetNetworkACLAnswer execute(SetNetworkACLCommand cmd) {
+ String[] results = new String[cmd.getRules().length];
+
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+
+ if (!result.isSuccess()) {
+ for (int i = 0; i < results.length; i++) {
+ results[i] = "Failed";
+ }
return new SetNetworkACLAnswer(cmd, false, results);
}
+
+ return new SetNetworkACLAnswer(cmd, true, results);
}
- protected Answer execute(SetSourceNatCommand cmd) {
+ protected List<ConfigItem> generateConfig(SetSourceNatCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
IpAddressTO pubIP = cmd.getIpAddress();
String dev = "eth" + pubIP.getNicDevId();
String args = " -A ";
@@ -738,15 +904,21 @@ public class VirtualRoutingResource {
args += pubIP.getPublicIp();
args += " -c ";
args += dev;
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_SOURCE_NAT, args);
+
+ cfg.add(new ConfigItem(VRScripts.VPC_SOURCE_NAT, args));
+ return cfg;
+ }
+
+ protected Answer execute(SetSourceNatCommand cmd) {
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
- private SetPortForwardingRulesAnswer execute(SetPortForwardingRulesVpcCommand cmd) {
- String[] results = new String[cmd.getRules().length];
- int i = 0;
+ protected List<ConfigItem> generateConfig(SetPortForwardingRulesVpcCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
- boolean endResult = true;
for (PortForwardingRuleTO rule : cmd.getRules()) {
String args = rule.revoked() ? " -D" : " -A";
args += " -P " + rule.getProtocol().toLowerCase();
@@ -755,7 +927,20 @@ public class VirtualRoutingResource {
args += " -r " + rule.getDstIp();
args += " -d " + rule.getStringDstPortRange().replace(":", "-");
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_PORTFORWARDING, args);
+ cfg.add(new ConfigItem(VRScripts.VPC_PORTFORWARDING, args));
+ }
+
+ return cfg;
+ }
+
+ private SetPortForwardingRulesAnswer execute(SetPortForwardingRulesVpcCommand cmd) {
+ String[] results = new String[cmd.getRules().length];
+ int i = 0;
+
+ boolean endResult = true;
+ List<ConfigItem> cfg = generateConfig(cmd);
+ for (ConfigItem c : cfg) {
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
if (!result.isSuccess()) {
results[i++] = "Failed";
@@ -769,82 +954,135 @@ public class VirtualRoutingResource {
public IpAssocAnswer execute(IpAssocVpcCommand cmd) {
String[] results = new String[cmd.getIpAddresses().length];
- String args = "";
- String snatArgs = "";
for (int i = 0; i < cmd.getIpAddresses().length; i ++) {
results[i] = "Failed";
}
int i = 0;
- for (IpAddressTO ip : cmd.getIpAddresses()) {
- if (ip.isAdd()) {
- args += " -A ";
- snatArgs += " -A ";
- } else {
- args += " -D ";
- snatArgs += " -D ";
- }
-
- args += " -l ";
- args += ip.getPublicIp();
- String nicName = "eth" + ip.getNicDevId();
- args += " -c ";
- args += nicName;
- args += " -g ";
- args += ip.getVlanGateway();
- args += " -m ";
- args += Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
- args += " -n ";
- args += NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
-
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_IPASSOC, args);
+ List<ConfigItem> cfg = generateConfig(cmd);
+ for (ConfigItem c : cfg) {
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
if (!result.isSuccess()) {
- results[i++] = ip.getPublicIp() + " - vpc_ipassoc failed:" + result.getDetails();
+ results[i++] = c.getInfo() + " failed: " + result.getDetails();
break;
}
- if (ip.isSourceNat()) {
- snatArgs += " -l " + ip.getPublicIp();
- snatArgs += " -c " + nicName;
-
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_PRIVATEGW, snatArgs);
- if (result != null) {
- results[i++] = ip.getPublicIp() + " - vpc_privateGateway failed:" + result.getDetails();
- break;
- }
- }
- results[i++] = ip.getPublicIp() + " - success ";
+ results[i++] = c.getInfo() + " - success ";
}
return new IpAssocAnswer(cmd, results);
}
+ protected List<ConfigItem> generateConfig(SetStaticRouteCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+
+ 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 = " -a " + sb.toString();
+
+ cfg.add(new ConfigItem(VRScripts.VPC_STATIC_ROUTE, args));
+ return cfg;
+ }
+
private SetStaticRouteAnswer execute(SetStaticRouteCommand cmd) {
- try {
- String[] results = new String[cmd.getStaticRoutes().length];
- String[][] rules = cmd.generateSRouteRules();
- StringBuilder sb = new StringBuilder();
- String[] srRules = rules[0];
+ String[] results = new String[cmd.getStaticRoutes().length];
+
+ List<ConfigItem> cfg = generateConfig(cmd);
+ ConfigItem c = cfg.get(0);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- for (int i = 0; i < srRules.length; i++) {
- sb.append(srRules[i]).append(',');
+ if (!result.isSuccess()) {
+ for (int i = 0; i < results.length; i++) {
+ results[i] = "Failed";
}
+ return new SetStaticRouteAnswer(cmd, false, results);
+ }
- String args = " -a " + sb.toString();
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_STATIC_ROUTE, args);
+ return new SetStaticRouteAnswer(cmd, true, results);
+ }
- if (!result.isSuccess()) {
- for (int i = 0; i < results.length; i++) {
- results[i] = "Failed";
+ protected List<ConfigItem> generateConfig(IpAssocCommand cmd) {
+ LinkedList<ConfigItem> cfg = new LinkedList<>();
+ ConfigItem c;
+
+ if (cmd instanceof IpAssocVpcCommand) {
+ for (IpAddressTO ip : cmd.getIpAddresses()) {
+ String args = "";
+ String snatArgs = "";
+
+ if (ip.isAdd()) {
+ args += " -A ";
+ snatArgs += " -A ";
+ } else {
+ args += " -D ";
+ snatArgs += " -D ";
+ }
+
+ args += " -l ";
+ args += ip.getPublicIp();
+ String nicName = "eth" + ip.getNicDevId();
+ args += " -c ";
+ args += nicName;
+ args += " -g ";
+ args += ip.getVlanGateway();
+ args += " -m ";
+ args += Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
+ args += " -n ";
+ args += NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
+
+ c = new ConfigItem(VRScripts.VPC_IPASSOC, args);
+ c.setInfo(ip.getPublicIp() + " - vpc_ipassoc");
+ cfg.add(c);
+
+ if (ip.isSourceNat()) {
+ snatArgs += " -l " + ip.getPublicIp();
+ snatArgs += " -c " + nicName;
+
+ c = new ConfigItem(VRScripts.VPC_PRIVATEGW, snatArgs);
+ c.setInfo(ip.getPublicIp() + " - vpc_privategateway");
+ cfg.add(c);
}
- return new SetStaticRouteAnswer(cmd, false, results);
}
+ } else {
+ for (IpAddressTO ip: cmd.getIpAddresses()) {
+ String args = "";
+ if (ip.isAdd()) {
+ args += "-A";
+ } else {
+ args += "-D";
+ }
+ String cidrSize = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
+ if (ip.isSourceNat()) {
+ args += " -s";
+ }
+ if (ip.isFirstIP()) {
+ args += " -f";
+ }
+ args += " -l ";
+ args += ip.getPublicIp() + "/" + cidrSize;
- return new SetStaticRouteAnswer(cmd, true, results);
- } catch (Exception e) {
- String msg = "SetStaticRoute failed due to " + e.toString();
- s_logger.error(msg, e);
- return new SetStaticRouteAnswer(cmd, false, null);
+ String publicNic = "eth" + ip.getNicDevId();
+ args += " -c ";
+ args += publicNic;
+
+ args += " -g ";
+ args += ip.getVlanGateway();
+
+ if (ip.isNewNic()) {
+ args += " -n";
+ }
+
+ c = new ConfigItem(VRScripts.IPASSOC, args);
+ c.setInfo(ip.getPublicIp());
+ cfg.add(c);
+ }
}
+ return cfg;
}
public Answer execute(IpAssocCommand cmd) {
@@ -854,39 +1092,13 @@ public class VirtualRoutingResource {
}
int i = 0;
- for (IpAddressTO ip: cmd.getIpAddresses()) {
- String args = "";
- if (ip.isAdd()) {
- args += "-A";
- } else {
- args += "-D";
- }
- String cidrSize = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));
- if (ip.isSourceNat()) {
- args += " -s";
- }
- if (ip.isFirstIP()) {
- args += " -f";
- }
- args += " -l ";
- args += ip.getPublicIp() + "/" + cidrSize;
-
- String publicNic = "eth" + ip.getNicDevId();
- args += " -c ";
- args += publicNic;
-
- args += " -g ";
- args += ip.getVlanGateway();
-
- if (ip.isNewNic()) {
- args += " -n";
- }
-
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.IPASSOC, args);
+ List<ConfigItem> cfg = generateConfig(cmd);
+ for (ConfigItem c : cfg) {
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
if (result.isSuccess()) {
- results[i++] = ip.getPublicIp() + " - success";
+ results[i++] = c.getInfo() + " - success";
} else {
- results[i++] = ip.getPublicIp() + " - failed:" + result.getDetails();
+ results[i++] = c.getInfo() + " - failed:" + result.getDetails();
break;
}
}
[42/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Introduce GroupedAnswer
In some cases, Network Element need multiple answer in one, then introduced e.g.
IpAssocAnswer, SetFirewallAnswer, etc. But in fact they are basically the same.
So introduce GroupedAnswer for them.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/43b41441
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/43b41441
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/43b41441
Branch: refs/heads/ui-restyle
Commit: 43b414416c7d25945079d0c105343d83455146f3
Parents: ebf7ee4
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 19:12:07 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 19:47:04 2014 -0800
----------------------------------------------------------------------
.../cloud/agent/api/routing/GroupAnswer.java | 40 +++++++++++++
.../virtualnetwork/VirtualRoutingResource.java | 59 ++++++++++----------
2 files changed, 71 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43b41441/core/src/com/cloud/agent/api/routing/GroupAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/GroupAnswer.java b/core/src/com/cloud/agent/api/routing/GroupAnswer.java
new file mode 100644
index 0000000..0917a7b
--- /dev/null
+++ b/core/src/com/cloud/agent/api/routing/GroupAnswer.java
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+
+package com.cloud.agent.api.routing;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+
+public class GroupAnswer extends Answer {
+ String[] results;
+
+ protected GroupAnswer() {
+ super();
+ }
+
+ public GroupAnswer(Command cmd, boolean success, int rulesCount, String[] results) {
+ super(cmd, success, null);
+
+ assert (rulesCount == results.length) : "Results' count should match requests' count!";
+ this.results = results;
+ }
+
+ String[] getResults() {
+ return results;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43b41441/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index faa826a..f66b030 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -29,26 +29,21 @@ import com.cloud.agent.api.routing.CreateIpAliasCommand;
import com.cloud.agent.api.routing.DeleteIpAliasCommand;
import com.cloud.agent.api.routing.DhcpEntryCommand;
import com.cloud.agent.api.routing.DnsMasqConfigCommand;
+import com.cloud.agent.api.routing.GroupAnswer;
import com.cloud.agent.api.routing.IpAliasTO;
-import com.cloud.agent.api.routing.IpAssocAnswer;
import com.cloud.agent.api.routing.IpAssocCommand;
import com.cloud.agent.api.routing.IpAssocVpcCommand;
import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
import com.cloud.agent.api.routing.NetworkElementCommand;
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
import com.cloud.agent.api.routing.SavePasswordCommand;
-import com.cloud.agent.api.routing.SetFirewallRulesAnswer;
import com.cloud.agent.api.routing.SetFirewallRulesCommand;
import com.cloud.agent.api.routing.SetMonitorServiceCommand;
-import com.cloud.agent.api.routing.SetNetworkACLAnswer;
import com.cloud.agent.api.routing.SetNetworkACLCommand;
-import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
import com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand;
import com.cloud.agent.api.routing.SetSourceNatCommand;
-import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
-import com.cloud.agent.api.routing.SetStaticRouteAnswer;
import com.cloud.agent.api.routing.SetStaticRouteCommand;
import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
import com.cloud.agent.api.routing.VmDataCommand;
@@ -337,11 +332,12 @@ public class VirtualRoutingResource {
}
private Answer execute(SetFirewallRulesCommand cmd) {
- String[] results = new String[cmd.getRules().length];
+ int rulesCount = cmd.getRules().length;
+ String[] results = new String[rulesCount];
String routerAccessIp = cmd.getRouterAccessIp();
if (routerAccessIp == null) {
- return new SetFirewallRulesAnswer(cmd, false, results);
+ return new GroupAnswer(cmd, false, rulesCount, results);
}
List<ConfigItem> cfg = generateConfig(cmd);
@@ -353,9 +349,9 @@ public class VirtualRoutingResource {
for (int i = 0; i < results.length; i++) {
results[i] = "Failed: " + result.getDetails();
}
- return new SetFirewallRulesAnswer(cmd, false, results);
+ return new GroupAnswer(cmd, false, rulesCount, results);
}
- return new SetFirewallRulesAnswer(cmd, true, results);
+ return new GroupAnswer(cmd, true, rulesCount, results);
}
@@ -377,7 +373,8 @@ public class VirtualRoutingResource {
}
private Answer execute(SetPortForwardingRulesCommand cmd) {
- String[] results = new String[cmd.getRules().length];
+ int rulesCount = cmd.getRules().length;
+ String[] results = new String[rulesCount];
int i = 0;
boolean endResult = true;
List<ConfigItem> cfg = generateConfig(cmd);
@@ -393,7 +390,7 @@ public class VirtualRoutingResource {
}
}
- return new SetPortForwardingRulesAnswer(cmd, results, endResult);
+ return new GroupAnswer(cmd, endResult, rulesCount, results);
}
private List<ConfigItem> generateConfig(SetStaticNatRulesCommand cmd) {
@@ -427,7 +424,7 @@ public class VirtualRoutingResource {
return cfg;
}
- private SetStaticNatRulesAnswer execute(SetStaticNatRulesCommand cmd) {
+ private GroupAnswer execute(SetStaticNatRulesCommand cmd) {
String[] results = new String[cmd.getRules().length];
int i = 0;
boolean endResult = true;
@@ -444,7 +441,7 @@ public class VirtualRoutingResource {
}
}
- return new SetStaticNatRulesAnswer(cmd, results, endResult);
+ return new GroupAnswer(cmd, endResult, cmd.getRules().length, results);
}
private List<ConfigItem> generateConfig(LoadBalancerConfigCommand cmd) {
@@ -859,8 +856,9 @@ public class VirtualRoutingResource {
return cfg;
}
- private SetNetworkACLAnswer execute(SetNetworkACLCommand cmd) {
- String[] results = new String[cmd.getRules().length];
+ private GroupAnswer execute(SetNetworkACLCommand cmd) {
+ int rulesCount = cmd.getRules().length;
+ String[] results = new String[rulesCount];
List<ConfigItem> cfg = generateConfig(cmd);
ConfigItem c = cfg.get(0);
@@ -870,10 +868,10 @@ public class VirtualRoutingResource {
for (int i = 0; i < results.length; i++) {
results[i] = "Failed";
}
- return new SetNetworkACLAnswer(cmd, false, results);
+ return new GroupAnswer(cmd, false, rulesCount, results);
}
- return new SetNetworkACLAnswer(cmd, true, results);
+ return new GroupAnswer(cmd, true, rulesCount, results);
}
protected List<ConfigItem> generateConfig(SetSourceNatCommand cmd) {
@@ -913,7 +911,7 @@ public class VirtualRoutingResource {
return cfg;
}
- private SetPortForwardingRulesAnswer execute(SetPortForwardingRulesVpcCommand cmd) {
+ private GroupAnswer execute(SetPortForwardingRulesVpcCommand cmd) {
String[] results = new String[cmd.getRules().length];
int i = 0;
@@ -929,10 +927,11 @@ public class VirtualRoutingResource {
results[i++] = null;
}
}
- return new SetPortForwardingRulesAnswer(cmd, results, endResult);
+ return new GroupAnswer(cmd, endResult, cmd.getRules().length, results);
}
- public IpAssocAnswer execute(IpAssocVpcCommand cmd) {
+ public GroupAnswer execute(IpAssocVpcCommand cmd) {
+ boolean finalResult = true;
String[] results = new String[cmd.getIpAddresses().length];
for (int i = 0; i < cmd.getIpAddresses().length; i ++) {
results[i] = "Failed";
@@ -944,12 +943,13 @@ public class VirtualRoutingResource {
ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
if (!result.isSuccess()) {
results[i++] = c.getInfo() + " failed: " + result.getDetails();
+ finalResult = false;
break;
}
results[i++] = c.getInfo() + " - success ";
}
- return new IpAssocAnswer(cmd, results);
+ return new GroupAnswer(cmd, finalResult, cmd.getIpAddresses().length, results);
}
protected List<ConfigItem> generateConfig(SetStaticRouteCommand cmd) {
@@ -969,8 +969,9 @@ public class VirtualRoutingResource {
return cfg;
}
- private SetStaticRouteAnswer execute(SetStaticRouteCommand cmd) {
- String[] results = new String[cmd.getStaticRoutes().length];
+ private GroupAnswer execute(SetStaticRouteCommand cmd) {
+ int rulesCount = cmd.getStaticRoutes().length;
+ String[] results = new String[rulesCount];
List<ConfigItem> cfg = generateConfig(cmd);
ConfigItem c = cfg.get(0);
@@ -980,10 +981,10 @@ public class VirtualRoutingResource {
for (int i = 0; i < results.length; i++) {
results[i] = "Failed";
}
- return new SetStaticRouteAnswer(cmd, false, results);
+ return new GroupAnswer(cmd, false, rulesCount, results);
}
- return new SetStaticRouteAnswer(cmd, true, results);
+ return new GroupAnswer(cmd, true, rulesCount, results);
}
protected List<ConfigItem> generateConfig(IpAssocCommand cmd) {
@@ -1066,9 +1067,10 @@ public class VirtualRoutingResource {
}
public Answer execute(IpAssocCommand cmd) {
+ boolean finalResult = true;
String[] results = new String[cmd.getIpAddresses().length];
for (int i = 0; i < results.length; i++) {
- results[i] = IpAssocAnswer.errorResult;
+ results[i] = "Failed";
}
int i = 0;
@@ -1079,10 +1081,11 @@ public class VirtualRoutingResource {
results[i++] = c.getInfo() + " - success";
} else {
results[i++] = c.getInfo() + " - failed:" + result.getDetails();
+ finalResult = false;
break;
}
}
- return new IpAssocAnswer(cmd, results);
+ return new GroupAnswer(cmd, finalResult, cmd.getIpAddresses().length, results);
}
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
[18/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6129: removing hard-coded script names
Replacing whatami with $0 which is how UNIX shell scripts should get the
script's name.
BUG-ID: CLOUDSTACK-6129
Bugfix-for:
Reviewed-by:
Reported-by:
Signed-off-by: John Kinsella <jl...@stratosec.co> 1392660036 -0800
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9dd57c22
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9dd57c22
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9dd57c22
Branch: refs/heads/ui-restyle
Commit: 9dd57c22b02afcddb1d6c8ddc3e1b578961454e3
Parents: 9f72443
Author: John Kinsella <jl...@stratosec.co>
Authored: Mon Feb 17 10:00:36 2014 -0800
Committer: John Kinsella <jl...@stratosec.co>
Committed: Mon Feb 17 10:00:36 2014 -0800
----------------------------------------------------------------------
agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in | 8 +++-----
agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in | 8 +++-----
agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in | 8 +++-----
agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in | 8 +++-----
agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in | 8 +++-----
packaging/centos63/cloud-agent.rc | 8 +++-----
packaging/centos63/cloud-ipallocator.rc | 8 +++-----
.../centos/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in | 8 +++-----
.../fedora/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in | 8 +++-----
.../distro/opensuse/SYSCONFDIR/init.d/cloud-ipallocator.in | 8 +++-----
.../distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in | 8 +++-----
python/distro/sles/SYSCONFDIR/init.d/cloud-ipallocator.in | 8 +++-----
python/distro/ubuntu/SYSCONFDIR/init.d/cloud-ipallocator.in | 8 +++-----
.../centos/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in | 8 +++-----
.../fedora/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in | 8 +++-----
.../rhel/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in | 8 +++-----
.../distro/ubuntu/SYSCONFDIR/init.d/cloud-console-proxy.in | 8 +++-----
17 files changed, 51 insertions(+), 85 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in
index fb82ebf..60e1e04 100755
--- a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in
+++ b/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in
@@ -24,12 +24,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-agent
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -114,7 +112,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in
index fb82ebf..60e1e04 100755
--- a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in
+++ b/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in
@@ -24,12 +24,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-agent
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -114,7 +112,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in
index ea1c605..2422268 100644
--- a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in
+++ b/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in
@@ -31,12 +31,10 @@
. /lib/lsb/init-functions
. /etc/rc.status
-whatami=cloud-agent
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -166,7 +164,7 @@ case "$1" in
start
;;
*)
- echo $"Usage: $whatami {start|stop|restart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
index fb82ebf..60e1e04 100644
--- a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
+++ b/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in
@@ -24,12 +24,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-agent
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -114,7 +112,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in
----------------------------------------------------------------------
diff --git a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in
index ea1c605..2422268 100644
--- a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in
+++ b/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in
@@ -31,12 +31,10 @@
. /lib/lsb/init-functions
. /etc/rc.status
-whatami=cloud-agent
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -166,7 +164,7 @@ case "$1" in
start
;;
*)
- echo $"Usage: $whatami {start|stop|restart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/packaging/centos63/cloud-agent.rc
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud-agent.rc b/packaging/centos63/cloud-agent.rc
index ab49524..40c358e 100755
--- a/packaging/centos63/cloud-agent.rc
+++ b/packaging/centos63/cloud-agent.rc
@@ -24,12 +24,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloudstack-agent
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=/var/run/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=/var/run/"$SHORTNAME".pid
LOCKFILE=/var/lock/subsys/"$SHORTNAME"
LOGDIR=/var/log/cloudstack/agent
LOGFILE=${LOGDIR}/agent.log
@@ -112,7 +110,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/packaging/centos63/cloud-ipallocator.rc
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud-ipallocator.rc b/packaging/centos63/cloud-ipallocator.rc
index 08cf9c8..9a24d8d 100755
--- a/packaging/centos63/cloud-ipallocator.rc
+++ b/packaging/centos63/cloud-ipallocator.rc
@@ -23,12 +23,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-external-ipallocator
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=/var/run/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=/var/run/"$SHORTNAME".pid
LOCKFILE=/var/lock/subsys/"$SHORTNAME"
LOGFILE=/var/log/cloudstack/ipallocator/ipallocator.log
PROGNAME="External IPAllocator"
@@ -90,7 +88,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/python/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
----------------------------------------------------------------------
diff --git a/python/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in b/python/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
index 6d929c0..b6720f5 100755
--- a/python/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
+++ b/python/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
@@ -23,12 +23,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-external-ipallocator
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@IPALOCATORLOG@
PROGNAME="External IPAllocator"
@@ -90,7 +88,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/python/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
----------------------------------------------------------------------
diff --git a/python/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in b/python/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
index a21070d..aa7e8cf 100755
--- a/python/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
+++ b/python/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
@@ -23,12 +23,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-external-ipallocator
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -90,7 +88,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/python/distro/opensuse/SYSCONFDIR/init.d/cloud-ipallocator.in
----------------------------------------------------------------------
diff --git a/python/distro/opensuse/SYSCONFDIR/init.d/cloud-ipallocator.in b/python/distro/opensuse/SYSCONFDIR/init.d/cloud-ipallocator.in
index b12e16b..7aa456d 100755
--- a/python/distro/opensuse/SYSCONFDIR/init.d/cloud-ipallocator.in
+++ b/python/distro/opensuse/SYSCONFDIR/init.d/cloud-ipallocator.in
@@ -30,12 +30,10 @@
. /lib/lsb/init-functions
. /etc/rc.status
-whatami=cloud-external-ipallocator
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -110,7 +108,7 @@ case "$1" in
start
;;
*)
- echo $"Usage: $whatami {start|stop|restart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/python/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
----------------------------------------------------------------------
diff --git a/python/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in b/python/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
index a21070d..aa7e8cf 100644
--- a/python/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
+++ b/python/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in
@@ -23,12 +23,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-external-ipallocator
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -90,7 +88,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/python/distro/sles/SYSCONFDIR/init.d/cloud-ipallocator.in
----------------------------------------------------------------------
diff --git a/python/distro/sles/SYSCONFDIR/init.d/cloud-ipallocator.in b/python/distro/sles/SYSCONFDIR/init.d/cloud-ipallocator.in
index b12e16b..7aa456d 100755
--- a/python/distro/sles/SYSCONFDIR/init.d/cloud-ipallocator.in
+++ b/python/distro/sles/SYSCONFDIR/init.d/cloud-ipallocator.in
@@ -30,12 +30,10 @@
. /lib/lsb/init-functions
. /etc/rc.status
-whatami=cloud-external-ipallocator
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -110,7 +108,7 @@ case "$1" in
start
;;
*)
- echo $"Usage: $whatami {start|stop|restart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/python/distro/ubuntu/SYSCONFDIR/init.d/cloud-ipallocator.in
----------------------------------------------------------------------
diff --git a/python/distro/ubuntu/SYSCONFDIR/init.d/cloud-ipallocator.in b/python/distro/ubuntu/SYSCONFDIR/init.d/cloud-ipallocator.in
index 3dcc471..ec84962 100755
--- a/python/distro/ubuntu/SYSCONFDIR/init.d/cloud-ipallocator.in
+++ b/python/distro/ubuntu/SYSCONFDIR/init.d/cloud-ipallocator.in
@@ -24,12 +24,10 @@
. /lib/lsb/init-functions
. /etc/default/rcS
-whatami=cloud-external-ipallocator
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@AGENTLOG@
PROGNAME="Cloud Agent"
@@ -104,7 +102,7 @@ case "$1" in
start
;;
*)
- echo $"Usage: $whatami {start|stop|restart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/systemvm/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
----------------------------------------------------------------------
diff --git a/systemvm/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in b/systemvm/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
index 47fdaef..76ee681 100644
--- a/systemvm/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
+++ b/systemvm/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
@@ -24,12 +24,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-console-proxy
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@CPLOG@
PROGNAME="Cloud Console Proxy"
@@ -90,7 +88,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/systemvm/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
----------------------------------------------------------------------
diff --git a/systemvm/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in b/systemvm/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
index 47fdaef..76ee681 100644
--- a/systemvm/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
+++ b/systemvm/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
@@ -24,12 +24,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-console-proxy
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@CPLOG@
PROGNAME="Cloud Console Proxy"
@@ -90,7 +88,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/systemvm/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
----------------------------------------------------------------------
diff --git a/systemvm/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in b/systemvm/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
index 47fdaef..76ee681 100644
--- a/systemvm/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
+++ b/systemvm/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-console-proxy.in
@@ -24,12 +24,10 @@
. /etc/rc.d/init.d/functions
-whatami=cloud-console-proxy
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@CPLOG@
PROGNAME="Cloud Console Proxy"
@@ -90,7 +88,7 @@ case "$1" in
fi
;;
*)
- echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
RETVAL=3
esac
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9dd57c22/systemvm/distro/ubuntu/SYSCONFDIR/init.d/cloud-console-proxy.in
----------------------------------------------------------------------
diff --git a/systemvm/distro/ubuntu/SYSCONFDIR/init.d/cloud-console-proxy.in b/systemvm/distro/ubuntu/SYSCONFDIR/init.d/cloud-console-proxy.in
index 550f2fb..c83f00a 100755
--- a/systemvm/distro/ubuntu/SYSCONFDIR/init.d/cloud-console-proxy.in
+++ b/systemvm/distro/ubuntu/SYSCONFDIR/init.d/cloud-console-proxy.in
@@ -25,12 +25,10 @@
. /lib/lsb/init-functions
. /etc/default/rcS
-whatami=cloud-console-proxy
-
# set environment variables
-SHORTNAME="$whatami"
-PIDFILE=@PIDDIR@/"$whatami".pid
+SHORTNAME="$0"
+PIDFILE=@PIDDIR@/"$SHORTNAME".pid
LOCKFILE=@LOCKDIR@/"$SHORTNAME"
LOGFILE=@CPLOG@
PROGNAME="Cloud Console Proxy"
@@ -104,7 +102,7 @@ case "$1" in
start
;;
*)
- echo $"Usage: $whatami {start|stop|restart|status|help}"
+ echo $"Usage: $SHORTNAME {start|stop|restart|status|help}"
RETVAL=3
esac
[20/50] [abbrv] Nvp and rest refactoring and more tests
Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
new file mode 100644
index 0000000..d406f94
--- /dev/null
+++ b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
@@ -0,0 +1,373 @@
+package com.cloud.utils.rest;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.Collections;
+//import java.util.List;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.http.HttpStatus;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RESTServiceConnectorTest {
+ protected static final String UUID = "aaaa";
+ protected static final String UUID2 = "bbbb";
+ protected static final String SCHEMA = "myTestSchema";
+ protected static final String SCHEMA2 = "myTestSchema2";
+ protected static final String HREF = "myTestHref";
+ protected static final String HREF2 = "myTestHref2";
+ protected static final String DISPLAY_NAME = "myTestName";
+ protected static final String UUID_JSON_RESPONSE = "{\"uuid\" : \"aaaa\"}";
+ protected static final String SEC_PROFILE_JSON_RESPONSE =
+ "{\"uuid\" : \"aaaa\","
+ + "\"display_name\" : \"myTestName\","
+ + "\"href\" : \"myTestHref\","
+ + "\"schema\" : \"myTestSchema\"}";
+
+ protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
+ + "\"display_name\" : \"myTestName\","
+ + "\"href\" : \"myTestHref\","
+ + "\"schema\" : \"myTestSchema\"},"
+ + "{ \"uuid\" : \"bbbb\","
+ + "\"display_name\" : \"myTestName2\","
+ + "\"href\" : \"myTestHref2\","
+ + "\"schema\" : \"myTestSchema2\"}],"
+ + "\"result_count\": 2}";
+
+ RESTServiceConnector connector;
+ HttpClient client = mock(HttpClient.class);
+ HttpMethod method;
+ String type;
+ String uri;
+
+ @Before
+ public void setUp() {
+ final HttpClientParams hmp = mock(HttpClientParams.class);
+ when(client.getParams()).thenReturn(hmp);
+ connector = new RESTServiceConnector(null) {
+ @Override
+ public HttpClient createHttpClient() {
+ return client;
+ }
+
+ @Override
+ public HttpMethod createMethod(final String newType, final String newUri) {
+ type = newType;
+ uri = newUri;
+ return method;
+ }
+ };
+
+ connector.validation = new RESTValidationStrategy();
+ connector.setAdminCredentials("admin", "adminpass");
+ connector.setControllerAddress("localhost");
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteLoginWithoutHostname() throws CloudstackRESTException {
+ connector.setControllerAddress(null);
+ connector.validation.login(RESTServiceConnector.protocol, client);
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteLoginWithoutCredentials() throws CloudstackRESTException {
+ method = mock(PutMethod.class);
+ connector.setAdminCredentials(null, null);
+ connector.validation.login(RESTServiceConnector.protocol, client);
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteUpdateObjectWithoutHostname() throws CloudstackRESTException {
+ method = mock(PutMethod.class);
+ connector.setControllerAddress(null);
+ connector.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteUpdateObjectWithoutCredentials() throws CloudstackRESTException {
+ method = mock(PutMethod.class);
+ connector.setAdminCredentials(null, null);
+ connector.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteCreateObjectWithoutHostname() throws CloudstackRESTException {
+ method = mock(PostMethod.class);
+ connector.setControllerAddress(null);
+ connector.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteCreateObjectWithoutCredentials() throws CloudstackRESTException {
+ method = mock(PostMethod.class);
+ connector.setAdminCredentials(null, null);
+ connector.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteDeleteObjectWithoutHostname() throws CloudstackRESTException {
+ method = mock(DeleteMethod.class);
+ connector.setControllerAddress(null);
+ connector.executeDeleteObject("/");
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteDeleteObjectWithoutCredentials() throws CloudstackRESTException {
+ method = mock(DeleteMethod.class);
+ connector.setAdminCredentials(null, null);
+ connector.executeDeleteObject("/");
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteRetrieveObjectWithoutHostname() throws CloudstackRESTException {
+ method = mock(GetMethod.class);
+ connector.setControllerAddress(null);
+ connector.executeRetrieveObject(String.class, "/", Collections.<String, String> emptyMap());
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteRetrieveObjectWithoutCredentials() throws CloudstackRESTException {
+ method = mock(GetMethod.class);
+ connector.setAdminCredentials(null, null);
+ connector.executeRetrieveObject(String.class, "/", Collections.<String, String> emptyMap());
+ }
+
+ @Test
+ public void testExecuteMethod() throws CloudstackRESTException {
+ final GetMethod gm = mock(GetMethod.class);
+
+ when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+ connector.executeMethod(gm);
+ verify(gm, times(1)).getStatusCode();
+ }
+
+ /* Bit of a roundabout way to ensure that login is called after an un authorized result
+ * It not possible to properly mock login()
+ */
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteMethodWithLogin() throws CloudstackRESTException, HttpException, IOException {
+ final GetMethod gm = mock(GetMethod.class);
+ when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
+ when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
+ connector.executeMethod(gm);
+ verify(gm, times(1)).getStatusCode();
+ }
+
+ @Test
+ public void testExecuteCreateObject() throws CloudstackRESTException, IOException {
+ JsonEntity ls = new JsonEntity();
+ method = mock(PostMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
+ when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
+ ls = connector.executeCreateObject(ls, JsonEntity.class, "/", Collections.<String, String> emptyMap());
+ assertTrue(UUID.equals(ls.getUuid()));
+ verify(method, times(1)).releaseConnection();
+
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteCreateObjectFailure() throws CloudstackRESTException, IOException {
+ JsonEntity ls = new JsonEntity();
+ method = mock(PostMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ final Header header = mock(Header.class);
+ when(header.getValue()).thenReturn("text/html");
+ when(method.getResponseHeader("Content-Type")).thenReturn(header);
+ when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+ when(method.isRequestSent()).thenReturn(true);
+ try {
+ ls = connector.executeCreateObject(ls, JsonEntity.class, "/", Collections.<String, String> emptyMap());
+ } finally {
+ verify(method, times(1)).releaseConnection();
+ }
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteCreateObjectException() throws CloudstackRESTException, IOException {
+ JsonEntity ls = new JsonEntity();
+ when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
+ method = mock(PostMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ final Header header = mock(Header.class);
+ when(header.getValue()).thenReturn("text/html");
+ when(method.getResponseHeader("Content-Type")).thenReturn(header);
+ when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+ try {
+ ls = connector.executeCreateObject(ls, JsonEntity.class, "/", Collections.<String, String> emptyMap());
+ } finally {
+ verify(method, times(1)).releaseConnection();
+ }
+ }
+
+ @Test
+ public void testExecuteUpdateObject() throws CloudstackRESTException, IOException {
+ final JsonEntity ls = new JsonEntity();
+ method = mock(PutMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+ connector.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+ verify(method, times(1)).releaseConnection();
+ verify(client, times(1)).executeMethod(method);
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteUpdateObjectFailure() throws CloudstackRESTException, IOException {
+ final JsonEntity ls = new JsonEntity();
+ method = mock(PutMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ final Header header = mock(Header.class);
+ when(header.getValue()).thenReturn("text/html");
+ when(method.getResponseHeader("Content-Type")).thenReturn(header);
+ when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+ when(method.isRequestSent()).thenReturn(true);
+ try {
+ connector.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+ } finally {
+ verify(method, times(1)).releaseConnection();
+ }
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteUpdateObjectException() throws CloudstackRESTException, IOException {
+ final JsonEntity ls = new JsonEntity();
+ method = mock(PutMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+ when(client.executeMethod((HttpMethod)any())).thenThrow(new IOException());
+ try {
+ connector.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+ } finally {
+ verify(method, times(1)).releaseConnection();
+ }
+ }
+
+ @Test
+ public void testExecuteDeleteObject() throws CloudstackRESTException, IOException {
+ method = mock(DeleteMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+ connector.executeDeleteObject("/");
+ verify(method, times(1)).releaseConnection();
+ verify(client, times(1)).executeMethod(method);
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteDeleteObjectFailure() throws CloudstackRESTException, IOException {
+ method = mock(DeleteMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ final Header header = mock(Header.class);
+ when(header.getValue()).thenReturn("text/html");
+ when(method.getResponseHeader("Content-Type")).thenReturn(header);
+ when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+ when(method.isRequestSent()).thenReturn(true);
+ try {
+ connector.executeDeleteObject("/");
+ } finally {
+ verify(method, times(1)).releaseConnection();
+ }
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteDeleteObjectException() throws CloudstackRESTException, IOException {
+ method = mock(DeleteMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+ when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
+ try {
+ connector.executeDeleteObject("/");
+ } finally {
+ verify(method, times(1)).releaseConnection();
+ }
+ }
+
+ @Test
+ public void testExecuteRetrieveObject() throws CloudstackRESTException, IOException {
+ method = mock(GetMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+ when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
+ connector.executeRetrieveObject(JsonEntity.class, "/", Collections.<String, String> emptyMap());
+ verify(method, times(1)).releaseConnection();
+ verify(client, times(1)).executeMethod(method);
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteRetrieveObjectFailure() throws CloudstackRESTException, IOException {
+ method = mock(GetMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+ when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
+ final Header header = mock(Header.class);
+ when(header.getValue()).thenReturn("text/html");
+ when(method.getResponseHeader("Content-Type")).thenReturn(header);
+ when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+ when(method.isRequestSent()).thenReturn(true);
+ try {
+ connector.executeRetrieveObject(JsonEntity.class, "/", Collections.<String, String> emptyMap());
+ } finally {
+ verify(method, times(1)).releaseConnection();
+ }
+ }
+
+ @Test(expected = CloudstackRESTException.class)
+ public void testExecuteRetrieveObjectException() throws CloudstackRESTException, IOException {
+ method = mock(GetMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+ when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
+ when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
+ try {
+ connector.executeRetrieveObject(JsonEntity.class, "/", Collections.<String, String> emptyMap());
+ } finally {
+ verify(method, times(1)).releaseConnection();
+ }
+ }
+
+}
+
+class JsonEntity {
+ private String displayName;
+ private String uuid;
+ private String href;
+ private String schema;
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(final String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(final String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(final String href) {
+ this.href = href;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public void setSchema(final String schema) {
+ this.schema = schema;
+ }
+}
\ No newline at end of file
[07/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fix checkstyle and license issues
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/97bad4f9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/97bad4f9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/97bad4f9
Branch: refs/heads/ui-restyle
Commit: 97bad4f9b39702a780d8f1ab757817f23b0cf0b8
Parents: 15fa2ef
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Fri Feb 14 16:54:36 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:47 2014 +0100
----------------------------------------------------------------------
.../com/cloud/vm/VirtualMachineManagerImpl.java | 7 ++---
.../db/test/com/cloud/utils/db/GroupByTest.java | 21 ++++++++++++++-
.../xen/resource/CitrixResourceBase.java | 28 +++++++++-----------
.../xen/resource/CitrixResourceBaseTest.java | 26 +++++++++---------
.../cloud/template/TemplateManagerImplTest.java | 18 +++++++++++++
.../src/test/java/streamer/ByteBufferTest.java | 2 ++
.../consoleproxy/ConsoleProxyRdpClientTest.java | 17 ++++++++++++
utils/test/com/cloud/utils/UuidUtilsTest.java | 17 ++++++++++++
8 files changed, 102 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97bad4f9/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 9513bd7..888c750 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -40,6 +40,8 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+import org.apache.log4j.Logger;
+
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@@ -67,7 +69,6 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.to.VolumeObjectTO;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
-import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
@@ -938,8 +939,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
//storing the value of overcommit in the vm_details table for doing a capacity check in case the cluster overcommit ratio is changed.
if (_uservmDetailsDao.findDetail(vm.getId(), "cpuOvercommitRatio") == null &&
((Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f))) {
- _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue());
- _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue());
+ _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue(), true);
+ _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue(), true);
} else if (_uservmDetailsDao.findDetail(vm.getId(), "cpuOvercommitRatio") != null) {
_uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue(), true);
_uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue(), true);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97bad4f9/framework/db/test/com/cloud/utils/db/GroupByTest.java
----------------------------------------------------------------------
diff --git a/framework/db/test/com/cloud/utils/db/GroupByTest.java b/framework/db/test/com/cloud/utils/db/GroupByTest.java
index e0087ea..d394c73 100644
--- a/framework/db/test/com/cloud/utils/db/GroupByTest.java
+++ b/framework/db/test/com/cloud/utils/db/GroupByTest.java
@@ -1,9 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.db;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import org.junit.Test;
-import static org.junit.Assert.assertTrue;
import com.cloud.utils.Pair;
import com.cloud.utils.db.SearchCriteria.Func;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97bad4f9/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 788e70d..2cabc58 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
@@ -1956,7 +1956,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
protected ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) {
Connection conn = getConnection();
- int i = 0;
String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
@@ -2029,8 +2028,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
protected ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) {
Connection conn = getConnection();
- String[] results = new String[cmd.getIpAddresses().length];
- int i = 0;
String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
try {
@@ -7307,19 +7304,18 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
return new ExecutionResult(true, null);
}
- protected void setNicDevIdIfCorrectVifIsNotNull(Connection conn,
- IpAddressTO ip, VIF correctVif) throws InternalErrorException,
- BadServerResponse, XenAPIException, XmlRpcException {
- if (correctVif == null) {
- if (ip.isAdd()) {
- throw new InternalErrorException("Failed to find DomR VIF to associate IP with.");
- } else {
- s_logger.debug("VIF to deassociate IP with does not exist, return success");
- }
- } else {
- ip.setNicDevId(Integer.valueOf(correctVif.getDevice(conn)));
- }
- }
+ protected void setNicDevIdIfCorrectVifIsNotNull(Connection conn, IpAddressTO ip, VIF correctVif) throws InternalErrorException, BadServerResponse, XenAPIException,
+ XmlRpcException {
+ if (correctVif == null) {
+ if (ip.isAdd()) {
+ throw new InternalErrorException("Failed to find DomR VIF to associate IP with.");
+ } else {
+ s_logger.debug("VIF to deassociate IP with does not exist, return success");
+ }
+ } else {
+ ip.setNicDevId(Integer.valueOf(correctVif.getDevice(conn)));
+ }
+ }
protected ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) {
Connection conn = getConnection();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97bad4f9/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
index b54a21c..0920c7f 100644
--- a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
+++ b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.Matchers.any;
import java.util.HashMap;
import java.util.Iterator;
@@ -46,6 +45,7 @@ import com.xensource.xenapi.Types;
import com.xensource.xenapi.VIF;
import com.xensource.xenapi.VM;
import com.xensource.xenapi.XenAPIObject;
+
import com.cloud.agent.api.ScaleVmAnswer;
import com.cloud.agent.api.ScaleVmCommand;
import com.cloud.agent.api.to.IpAddressTO;
@@ -176,17 +176,15 @@ public class CitrixResourceBaseTest {
}
- @Test
- public void testSetNicDevIdIfCorrectVifIsNotNull() throws Exception {
- IpAddressTO ip = mock (IpAddressTO.class);
- when (ip.isAdd()).thenReturn(false);
- VIF correctVif = null;
- try {
- _resource.setNicDevIdIfCorrectVifIsNotNull(conn, ip, correctVif);
- }
- catch (NullPointerException e)
- {
- fail("this test is meant to show that null pointer is not thrown");
- }
- }
+ @Test
+ public void testSetNicDevIdIfCorrectVifIsNotNull() throws Exception {
+ IpAddressTO ip = mock(IpAddressTO.class);
+ when(ip.isAdd()).thenReturn(false);
+ VIF correctVif = null;
+ try {
+ _resource.setNicDevIdIfCorrectVifIsNotNull(conn, ip, correctVif);
+ } catch (NullPointerException e) {
+ fail("this test is meant to show that null pointer is not thrown");
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97bad4f9/server/test/com/cloud/template/TemplateManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/template/TemplateManagerImplTest.java b/server/test/com/cloud/template/TemplateManagerImplTest.java
index 3788393..bcbc323 100644
--- a/server/test/com/cloud/template/TemplateManagerImplTest.java
+++ b/server/test/com/cloud/template/TemplateManagerImplTest.java
@@ -1,3 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.template;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97bad4f9/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java b/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java
index 8dbeba2..6bcfed9 100644
--- a/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java
+++ b/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java
@@ -17,6 +17,8 @@
package streamer;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.Collection;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97bad4f9/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java b/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java
index 038f438..80bf5bc 100644
--- a/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java
+++ b/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
package com.cloud.consoleproxy;
import junit.framework.Assert;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/97bad4f9/utils/test/com/cloud/utils/UuidUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/UuidUtilsTest.java b/utils/test/com/cloud/utils/UuidUtilsTest.java
index 299e247..a39eae7 100644
--- a/utils/test/com/cloud/utils/UuidUtilsTest.java
+++ b/utils/test/com/cloud/utils/UuidUtilsTest.java
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
package com.cloud.utils;
import static org.junit.Assert.assertFalse;
[34/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Dynamically detect the current branch and remove the build date from the systemvm name. This makes it easier to push them to the download location automagically.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fefddc06
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fefddc06
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fefddc06
Branch: refs/heads/ui-restyle
Commit: fefddc062486ed0c997309b719fd4b2f89b9b62c
Parents: 808c6df6
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Wed Feb 19 09:36:03 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Wed Feb 19 09:36:03 2014 +0100
----------------------------------------------------------------------
tools/appliance/build.sh | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fefddc06/tools/appliance/build.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh
index 2e8bc88..658aa8d 100644
--- a/tools/appliance/build.sh
+++ b/tools/appliance/build.sh
@@ -26,7 +26,10 @@ else
fi
build_date=`date +%Y-%m-%d`
-branch="master"
+branch=`git status | grep '# On branch' | awk '{print $4}'`
+if [ -z "$branch" ] ; then
+ branch=unknown
+fi
rootdir=$PWD
# Initialize veewee and dependencies
@@ -69,10 +72,10 @@ if [ $? == 0 ]; then
set -e
vboxmanage internalcommands converttoraw -format vdi "$hdd_path" img.raw
faketime '2010-01-01' vhd-util convert -s 0 -t 1 -i img.raw -o stagefixed.vhd
- faketime '2010-01-01' vhd-util convert -s 1 -t 2 -i stagefixed.vhd -o $appliance-$build_date-$branch-xen.vhd
+ faketime '2010-01-01' vhd-util convert -s 1 -t 2 -i stagefixed.vhd -o $appliance-$branch-xen.vhd
rm *.bak
- bzip2 $appliance-$build_date-$branch-xen.vhd
- echo "$appliance exported for Xen: dist/$appliance-$build_date-$branch-xen.vhd.bz2"
+ bzip2 $appliance-$branch-xen.vhd
+ echo "$appliance exported for Xen: dist/$appliance-$branch-xen.vhd.bz2"
else
echo "** Skipping $appliance export for Xen: faketime or vhd-util command is missing. **"
echo "** faketime source code is available from https://github.com/wolfcw/libfaketime **"
@@ -83,27 +86,27 @@ set -e
# Export for KVM
vboxmanage internalcommands converttoraw -format vdi "$hdd_path" raw.img
-qemu-img convert -f raw -c -O qcow2 raw.img $appliance-$build_date-$branch-kvm.qcow2
+qemu-img convert -f raw -c -O qcow2 raw.img $appliance-$branch-kvm.qcow2
rm raw.img
-bzip2 $appliance-$build_date-$branch-kvm.qcow2
-echo "$appliance exported for KVM: dist/$appliance-$build_date-$branch-kvm.qcow2.bz2"
+bzip2 $appliance-$branch-kvm.qcow2
+echo "$appliance exported for KVM: dist/$appliance-$branch-kvm.qcow2.bz2"
# Export both ova and vmdk for VMWare
-vboxmanage clonehd $hdd_uuid $appliance-$build_date-$branch-vmware.vmdk --format VMDK
-bzip2 $appliance-$build_date-$branch-vmware.vmdk
-echo "$appliance exported for VMWare: dist/$appliance-$build_date-$branch-vmware.vmdk.bz2"
-vboxmanage export $machine_uuid --output $appliance-$build_date-$branch-vmware.ovf
-mv $appliance-$build_date-$branch-vmware.ovf $appliance-$build_date-$branch-vmware.ovf-orig
-java -cp convert Convert convert_ovf_vbox_to_esx.xslt $appliance-$build_date-$branch-vmware.ovf-orig $appliance-$build_date-$branch-vmware.ovf
-tar -cf $appliance-$build_date-$branch-vmware.ova $appliance-$build_date-$branch-vmware.ovf $appliance-$build_date-$branch-vmware-disk1.vmdk
-rm -f $appliance-$build_date-$branch-vmware.ovf $appliance-$build_date-$branch-vmware.ovf-orig $appliance-$build_date-$branch-vmware-disk1.vmdk
-echo "$appliance exported for VMWare: dist/$appliance-$build_date-$branch-vmware.ova"
+vboxmanage clonehd $hdd_uuid $appliance-$branch-vmware.vmdk --format VMDK
+bzip2 $appliance-$branch-vmware.vmdk
+echo "$appliance exported for VMWare: dist/$appliance-$branch-vmware.vmdk.bz2"
+vboxmanage export $machine_uuid --output $appliance-$branch-vmware.ovf
+mv $appliance-$branch-vmware.ovf $appliance-$branch-vmware.ovf-orig
+java -cp convert Convert convert_ovf_vbox_to_esx.xslt $appliance-$branch-vmware.ovf-orig $appliance-$branch-vmware.ovf
+tar -cf $appliance-$branch-vmware.ova $appliance-$branch-vmware.ovf $appliance-$branch-vmware-disk1.vmdk
+rm -f $appliance-$branch-vmware.ovf $appliance-$branch-vmware.ovf-orig $appliance-$branch-vmware-disk1.vmdk
+echo "$appliance exported for VMWare: dist/$appliance-$branch-vmware.ova"
# Export for HyperV
-vboxmanage clonehd $hdd_uuid $appliance-$build_date-$branch-hyperv.vhd --format VHD
+vboxmanage clonehd $hdd_uuid $appliance-$branch-hyperv.vhd --format VHD
# HyperV doesn't support import a zipped image from S3, but we create a zipped version to save space on the jenkins box
-zip $appliance-$build_date-$branch-hyperv.vhd.zip $appliance-$build_date-$branch-hyperv.vhd
-echo "$appliance exported for HyperV: dist/$appliance-$build_date-$branch-hyperv.vhd"
+zip $appliance-$branch-hyperv.vhd.zip $appliance-$branch-hyperv.vhd
+echo "$appliance exported for HyperV: dist/$appliance-$branch-hyperv.vhd"
mv *-hyperv.vhd *-hyperv.vhd.zip *.bz2 *.ova dist/
[10/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
error message containing array content instead of array
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0d7a9652
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0d7a9652
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0d7a9652
Branch: refs/heads/ui-restyle
Commit: 0d7a96526cd025d03d7483a232b25b1dc002ba9d
Parents: 3199de6
Author: Daan Hoogland <da...@onecht.net>
Authored: Tue Feb 11 16:03:50 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:47 2014 +0100
----------------------------------------------------------------------
server/src/com/cloud/network/IpAddressManagerImpl.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d7a9652/server/src/com/cloud/network/IpAddressManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java b/server/src/com/cloud/network/IpAddressManagerImpl.java
index 6596074..d88755d 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -17,6 +17,7 @@
package com.cloud.network;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -684,7 +685,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
if (dedicatedVlanDbIds != null && !dedicatedVlanDbIds.isEmpty()) {
fetchFromDedicatedRange = true;
sc.setParameters("vlanId", dedicatedVlanDbIds.toArray());
- errorMessage.append(", vlanId id=" + dedicatedVlanDbIds.toArray());
+ errorMessage.append(", vlanId id=" + Arrays.toString(dedicatedVlanDbIds.toArray()));
} else if (nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty()) {
sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
errorMessage.append(", vlanId id=" + nonDedicatedVlanDbIds.toArray());
[21/50] [abbrv] Nvp and rest refactoring and more tests
Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
index 2717c31..23fe82a 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
@@ -76,7 +76,7 @@ import com.cloud.host.Host;
import com.cloud.network.nicira.Attachment;
import com.cloud.network.nicira.ControlClusterStatus;
import com.cloud.network.nicira.DestinationNatRule;
-import com.cloud.network.nicira.LogicalRouterConfig;
+import com.cloud.network.nicira.LogicalRouter;
import com.cloud.network.nicira.LogicalRouterPort;
import com.cloud.network.nicira.LogicalSwitch;
import com.cloud.network.nicira.LogicalSwitchPort;
@@ -132,7 +132,7 @@ public class NiciraNvpResourceTest {
public void testInitialization() throws ConfigurationException {
resource.configure("NiciraNvpResource", parameters);
- StartupCommand[] sc = resource.initialize();
+ final StartupCommand[] sc = resource.initialize();
assertTrue(sc.length == 1);
assertTrue("Incorrect startup command GUID", "aaaaa-bbbbb-ccccc".equals(sc[0].getGuid()));
assertTrue("Incorrect NVP device name", "nvptestdevice".equals(sc[0].getName()));
@@ -143,11 +143,11 @@ public class NiciraNvpResourceTest {
public void testPingCommandStatusOk() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+ final ControlClusterStatus ccs = mock(ControlClusterStatus.class);
when(ccs.getClusterStatus()).thenReturn("stable");
when(nvpApi.getControlClusterStatus()).thenReturn(ccs);
- PingCommand ping = resource.getCurrentStatus(42);
+ final PingCommand ping = resource.getCurrentStatus(42);
assertTrue(ping != null);
assertTrue(ping.getHostId() == 42);
assertTrue(ping.getHostType() == Host.Type.L2Networking);
@@ -157,11 +157,11 @@ public class NiciraNvpResourceTest {
public void testPingCommandStatusFail() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+ final ControlClusterStatus ccs = mock(ControlClusterStatus.class);
when(ccs.getClusterStatus()).thenReturn("unstable");
when(nvpApi.getControlClusterStatus()).thenReturn(ccs);
- PingCommand ping = resource.getCurrentStatus(42);
+ final PingCommand ping = resource.getCurrentStatus(42);
assertTrue(ping == null);
}
@@ -169,11 +169,11 @@ public class NiciraNvpResourceTest {
public void testPingCommandStatusApiException() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+ final ControlClusterStatus ccs = mock(ControlClusterStatus.class);
when(ccs.getClusterStatus()).thenReturn("unstable");
when(nvpApi.getControlClusterStatus()).thenThrow(new NiciraNvpApiException());
- PingCommand ping = resource.getCurrentStatus(42);
+ final PingCommand ping = resource.getCurrentStatus(42);
assertTrue(ping == null);
}
@@ -181,12 +181,12 @@ public class NiciraNvpResourceTest {
public void testRetries() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalSwitch ls = mock(LogicalSwitch.class);
+ final LogicalSwitch ls = mock(LogicalSwitch.class);
when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
when(nvpApi.createLogicalSwitch((LogicalSwitch)any())).thenThrow(new NiciraNvpApiException()).thenThrow(new NiciraNvpApiException()).thenReturn(ls);
- CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)parameters.get("guid"), "stt", "loigicalswitch", "owner");
- CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer)resource.executeRequest(clsc);
+ final CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)parameters.get("guid"), "stt", "loigicalswitch", "owner");
+ final CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer)resource.executeRequest(clsc);
assertTrue(clsa.getResult());
}
@@ -194,12 +194,12 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalSwitch ls = mock(LogicalSwitch.class);
+ final LogicalSwitch ls = mock(LogicalSwitch.class);
when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
when(nvpApi.createLogicalSwitch((LogicalSwitch)any())).thenReturn(ls);
- CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)parameters.get("guid"), "stt", "loigicalswitch", "owner");
- CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer)resource.executeRequest(clsc);
+ final CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)parameters.get("guid"), "stt", "loigicalswitch", "owner");
+ final CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer)resource.executeRequest(clsc);
assertTrue(clsa.getResult());
assertTrue("cccc".equals(clsa.getLogicalSwitchUuid()));
}
@@ -208,12 +208,12 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalSwitch ls = mock(LogicalSwitch.class);
+ final LogicalSwitch ls = mock(LogicalSwitch.class);
when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
when(nvpApi.createLogicalSwitch((LogicalSwitch)any())).thenThrow(new NiciraNvpApiException());
- CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)parameters.get("guid"), "stt", "loigicalswitch", "owner");
- CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer)resource.executeRequest(clsc);
+ final CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)parameters.get("guid"), "stt", "loigicalswitch", "owner");
+ final CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer)resource.executeRequest(clsc);
assertFalse(clsa.getResult());
}
@@ -221,8 +221,8 @@ public class NiciraNvpResourceTest {
public void testDeleteLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
- DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer)resource.executeRequest(dlsc);
+ final DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
+ final DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer)resource.executeRequest(dlsc);
assertTrue(dlsa.getResult());
}
@@ -232,8 +232,8 @@ public class NiciraNvpResourceTest {
doThrow(new NiciraNvpApiException()).when(nvpApi).deleteLogicalSwitch((String)any());
- DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
- DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer)resource.executeRequest(dlsc);
+ final DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
+ final DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer)resource.executeRequest(dlsc);
assertFalse(dlsa.getResult());
}
@@ -241,12 +241,12 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+ final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
when(lsp.getUuid()).thenReturn("eeee");
when(nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort)any())).thenReturn(lsp);
- CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
- CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer)resource.executeRequest(clspc);
+ final CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+ final CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer)resource.executeRequest(clspc);
assertTrue(clspa.getResult());
assertTrue("eeee".equals(clspa.getLogicalSwitchPortUuid()));
@@ -256,12 +256,12 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalSwitchPortApiExceptionInCreate() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+ final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
when(lsp.getUuid()).thenReturn("eeee");
when(nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort)any())).thenThrow(new NiciraNvpApiException());
- CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
- CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer)resource.executeRequest(clspc);
+ final CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+ final CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer)resource.executeRequest(clspc);
assertFalse(clspa.getResult());
}
@@ -269,13 +269,13 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalSwitchPortApiExceptionInModify() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+ final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
when(lsp.getUuid()).thenReturn("eeee");
when(nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort)any())).thenReturn(lsp);
- doThrow(new NiciraNvpApiException()).when(nvpApi).modifyLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any());
+ doThrow(new NiciraNvpApiException()).when(nvpApi).updateLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any());
- CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
- CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer)resource.executeRequest(clspc);
+ final CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+ final CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer)resource.executeRequest(clspc);
assertFalse(clspa.getResult());
verify(nvpApi, atLeastOnce()).deleteLogicalSwitchPort((String)any(), (String)any());
}
@@ -285,7 +285,7 @@ public class NiciraNvpResourceTest {
resource.configure("NiciraNvpResource", parameters);
doThrow(new NiciraNvpApiException()).when(nvpApi).deleteLogicalSwitchPort((String)any(), (String)any());
- DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer)resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa", "bbbb"));
+ final DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer)resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa", "bbbb"));
assertFalse(dlspa.getResult());
}
@@ -293,8 +293,8 @@ public class NiciraNvpResourceTest {
public void testUpdateLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- doThrow(new NiciraNvpApiException()).when(nvpApi).modifyLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any());
- UpdateLogicalSwitchPortAnswer dlspa =
+ doThrow(new NiciraNvpApiException()).when(nvpApi).updateLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any());
+ final UpdateLogicalSwitchPortAnswer dlspa =
(UpdateLogicalSwitchPortAnswer)resource.executeRequest(new UpdateLogicalSwitchPortCommand("aaaa", "bbbb", "cccc", "owner", "nicname"));
assertFalse(dlspa.getResult());
}
@@ -304,11 +304,12 @@ public class NiciraNvpResourceTest {
resource.configure("NiciraNvpResource", parameters);
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<LogicalSwitchPort> lspl = mock(NiciraNvpList.class);
when(lspl.getResultCount()).thenReturn(1);
when(nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
- FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer)resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+ final FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer)resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
assertTrue(flspa.getResult());
}
@@ -317,11 +318,12 @@ public class NiciraNvpResourceTest {
resource.configure("NiciraNvpResource", parameters);
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<LogicalSwitchPort> lspl = mock(NiciraNvpList.class);
when(lspl.getResultCount()).thenReturn(0);
when(nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
- FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer)resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+ final FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer)resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
assertFalse(flspa.getResult());
}
@@ -331,7 +333,7 @@ public class NiciraNvpResourceTest {
when(nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenThrow(new NiciraNvpApiException());
- FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer)resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+ final FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer)resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
assertFalse(flspa.getResult());
}
@@ -339,17 +341,17 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
- LogicalRouterPort lrp = mock(LogicalRouterPort.class);
- LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+ final LogicalRouter lrc = mock(LogicalRouter.class);
+ final LogicalRouterPort lrp = mock(LogicalRouterPort.class);
+ final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
when(lrc.getUuid()).thenReturn("ccccc");
when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
when(lsp.getUuid()).thenReturn("fffff");
- when(nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+ when(nvpApi.createLogicalRouter((LogicalRouter)any())).thenReturn(lrc);
when(nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
when(nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
- CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
- CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer)resource.executeRequest(clrc);
+ final CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+ final CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer)resource.executeRequest(clrc);
assertTrue(clra.getResult());
assertTrue("ccccc".equals(clra.getLogicalRouterUuid()));
@@ -360,9 +362,9 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- when(nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenThrow(new NiciraNvpApiException());
- CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
- CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer)resource.executeRequest(clrc);
+ when(nvpApi.createLogicalRouter((LogicalRouter)any())).thenThrow(new NiciraNvpApiException());
+ final CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+ final CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer)resource.executeRequest(clrc);
assertFalse(clra.getResult());
}
@@ -371,12 +373,12 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalRouterApiExceptionRollbackRouter() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
+ final LogicalRouter lrc = mock(LogicalRouter.class);
when(lrc.getUuid()).thenReturn("ccccc");
- when(nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+ when(nvpApi.createLogicalRouter((LogicalRouter)any())).thenReturn(lrc);
when(nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenThrow(new NiciraNvpApiException());
- CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
- CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer)resource.executeRequest(clrc);
+ final CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+ final CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer)resource.executeRequest(clrc);
assertFalse(clra.getResult());
verify(nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
@@ -386,18 +388,18 @@ public class NiciraNvpResourceTest {
public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
- LogicalRouterPort lrp = mock(LogicalRouterPort.class);
- LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+ final LogicalRouter lrc = mock(LogicalRouter.class);
+ final LogicalRouterPort lrp = mock(LogicalRouterPort.class);
+ final LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
when(lrc.getUuid()).thenReturn("ccccc");
when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
when(lsp.getUuid()).thenReturn("fffff");
- when(nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+ when(nvpApi.createLogicalRouter((LogicalRouter)any())).thenReturn(lrc);
when(nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
when(nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
when(nvpApi.createLogicalRouterNatRule((String)any(), (NatRule)any())).thenThrow(new NiciraNvpApiException());
- CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
- CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer)resource.executeRequest(clrc);
+ final CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+ final CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer)resource.executeRequest(clrc);
assertFalse(clra.getResult());
verify(nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
@@ -409,7 +411,7 @@ public class NiciraNvpResourceTest {
resource.configure("NiciraNvpResource", parameters);
doThrow(new NiciraNvpApiException()).when(nvpApi).deleteLogicalRouter(eq("aaaaa"));
- DeleteLogicalRouterAnswer dlspa = (DeleteLogicalRouterAnswer)resource.executeRequest(new DeleteLogicalRouterCommand("aaaaa"));
+ final DeleteLogicalRouterAnswer dlspa = (DeleteLogicalRouterAnswer)resource.executeRequest(new DeleteLogicalRouterCommand("aaaaa"));
assertFalse(dlspa.getResult());
}
@@ -417,16 +419,17 @@ public class NiciraNvpResourceTest {
public void testConfigurePublicIpsOnLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
resource.configure("NiciraNvpResource", parameters);
- ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class);
+ final ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class);
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<LogicalRouterPort> list = mock(NiciraNvpList.class);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
- doThrow(new NiciraNvpApiException()).when(nvpApi).modifyLogicalRouterPort((String)any(), (LogicalRouterPort)any());
+ doThrow(new NiciraNvpApiException()).when(nvpApi).updateLogicalRouterPort((String)any(), (LogicalRouterPort)any());
when(nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa", "bbbbb")).thenReturn(list);
- ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertFalse(answer.getResult());
}
@@ -440,31 +443,32 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
- StaticNatRuleTO rule = new StaticNatRuleTO(1, "11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
- List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+ final ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+ final StaticNatRuleTO rule = new StaticNatRuleTO(1, "11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+ final List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
// Mock the api create calls
- NatRule[] rulepair = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+ final NatRule[] rulepair = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
rulepair[0].setUuid(UUID.randomUUID());
rulepair[1].setUuid(UUID.randomUUID());
when(nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
- ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertTrue(a.getResult());
verify(nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
@Override
- public boolean matches(Object argument) {
- NatRule rule = (NatRule)argument;
+ public boolean matches(final Object argument) {
+ final NatRule rule = (NatRule)argument;
if (rule.getType().equals("DestinationNatRule") && ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
return true;
}
@@ -485,33 +489,34 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
- StaticNatRuleTO rule = new StaticNatRuleTO(1, "11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
- List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+ final ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+ final StaticNatRuleTO rule = new StaticNatRuleTO(1, "11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+ final List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api create calls
- NatRule[] rulepair = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+ final NatRule[] rulepair = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
rulepair[0].setUuid(UUID.randomUUID());
rulepair[1].setUuid(UUID.randomUUID());
when(nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(storedRules.getResultCount()).thenReturn(2);
when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
- ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertTrue(a.getResult());
verify(nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
@Override
- public boolean matches(Object argument) {
- NatRule rule = (NatRule)argument;
+ public boolean matches(final Object argument) {
+ final NatRule rule = (NatRule)argument;
if (rule.getType().equals("DestinationNatRule") && ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
return true;
}
@@ -532,15 +537,15 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
- StaticNatRuleTO rule = new StaticNatRuleTO(1, "11.11.11.11", null, null, "10.10.10.10", null, null, null, true, false);
- List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+ final ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+ final StaticNatRuleTO rule = new StaticNatRuleTO(1, "11.11.11.11", null, null, "10.10.10.10", null, null, null, true, false);
+ final List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api create calls
- NatRule[] rulepair = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+ final NatRule[] rulepair = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
final UUID rule0Uuid = UUID.randomUUID();
final UUID rule1Uuid = UUID.randomUUID();
rulepair[0].setUuid(rule0Uuid);
@@ -549,18 +554,19 @@ public class NiciraNvpResourceTest {
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(storedRules.getResultCount()).thenReturn(2);
when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
- ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertTrue(a.getResult());
verify(nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
@Override
- public boolean matches(Object argument) {
- UUID uuid = (UUID)argument;
+ public boolean matches(final Object argument) {
+ final UUID uuid = (UUID)argument;
if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
return true;
}
@@ -578,26 +584,27 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
- StaticNatRuleTO rule = new StaticNatRuleTO(1, "11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
- List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+ final ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+ final StaticNatRuleTO rule = new StaticNatRuleTO(1, "11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+ final List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api create calls
- NatRule[] rulepair = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+ final NatRule[] rulepair = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
rulepair[0].setUuid(UUID.randomUUID());
rulepair[1].setUuid(UUID.randomUUID());
when(nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(storedRules.getResultCount()).thenReturn(0);
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
- ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertFalse(a.getResult());
verify(nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
@@ -612,31 +619,32 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
- PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
- List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+ final ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+ final PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
+ final List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
// Mock the api create calls
- NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
+ final NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
rulepair[0].setUuid(UUID.randomUUID());
rulepair[1].setUuid(UUID.randomUUID());
when(nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
- ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertTrue(a.getResult());
verify(nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
@Override
- public boolean matches(Object argument) {
- NatRule rule = (NatRule)argument;
+ public boolean matches(final Object argument) {
+ final NatRule rule = (NatRule)argument;
if (rule.getType().equals("DestinationNatRule") && ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
return true;
}
@@ -657,33 +665,34 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
- PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, true);
- List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+ final ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+ final PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, true);
+ final List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api create calls
- NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
+ final NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
rulepair[0].setUuid(UUID.randomUUID());
rulepair[1].setUuid(UUID.randomUUID());
when(nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(storedRules.getResultCount()).thenReturn(2);
when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
- ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertTrue(a.getResult());
verify(nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
@Override
- public boolean matches(Object argument) {
- NatRule rule = (NatRule)argument;
+ public boolean matches(final Object argument) {
+ final NatRule rule = (NatRule)argument;
if (rule.getType().equals("DestinationNatRule") && ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
return true;
}
@@ -704,15 +713,15 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
- PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", true, true);
- List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+ final ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+ final PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", true, true);
+ final List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api create calls
- NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
+ final NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
final UUID rule0Uuid = UUID.randomUUID();
final UUID rule1Uuid = UUID.randomUUID();
rulepair[0].setUuid(rule0Uuid);
@@ -721,18 +730,19 @@ public class NiciraNvpResourceTest {
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(storedRules.getResultCount()).thenReturn(2);
when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
- ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertTrue(a.getResult());
verify(nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
@Override
- public boolean matches(Object argument) {
- UUID uuid = (UUID)argument;
+ public boolean matches(final Object argument) {
+ final UUID uuid = (UUID)argument;
if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
return true;
}
@@ -750,26 +760,27 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
- PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
- List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+ final ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+ final PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
+ final List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api create calls
- NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
+ final NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
rulepair[0].setUuid(UUID.randomUUID());
rulepair[1].setUuid(UUID.randomUUID());
when(nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(storedRules.getResultCount()).thenReturn(0);
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
- ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
assertFalse(a.getResult());
verify(nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
@@ -784,25 +795,26 @@ public class NiciraNvpResourceTest {
*/
// Mock the command
- ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
- PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 85, "10.10.10.10", 80, 85, "tcp", false, false);
- List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+ final ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+ final PortForwardingRuleTO rule = new PortForwardingRuleTO(1, "11.11.11.11", 80, 85, "10.10.10.10", 80, 85, "tcp", false, false);
+ final List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
rules.add(rule);
when(cmd.getRules()).thenReturn(rules);
when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
// Mock the api find call
@SuppressWarnings("unchecked")
+ final
NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
when(nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
// Mock the api create calls
- NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {80, 85}, "11.11.11.11", new int[] {80, 85}, "tcp");
+ final NatRule[] rulepair = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {80, 85}, "11.11.11.11", new int[] {80, 85}, "tcp");
rulepair[0].setUuid(UUID.randomUUID());
rulepair[1].setUuid(UUID.randomUUID());
when(nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
- ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
+ final ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer)resource.executeRequest(cmd);
// The expected result is false, Nicira does not support port ranges in DNAT
assertFalse(a.getResult());
@@ -811,16 +823,16 @@ public class NiciraNvpResourceTest {
@Test
public void testGenerateStaticNatRulePair() {
- NatRule[] rules = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+ final NatRule[] rules = resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
assertTrue("DestinationNatRule".equals(rules[0].getType()));
assertTrue("SourceNatRule".equals(rules[1].getType()));
- DestinationNatRule dnr = (DestinationNatRule)rules[0];
+ final DestinationNatRule dnr = (DestinationNatRule)rules[0];
assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
assertTrue(dnr.getToDestinationPort() == null);
assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));
- SourceNatRule snr = (SourceNatRule)rules[1];
+ final SourceNatRule snr = (SourceNatRule)rules[1];
assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
assertTrue(snr.getToSourcePort() == null);
assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
@@ -828,18 +840,18 @@ public class NiciraNvpResourceTest {
@Test
public void testGeneratePortForwardingRulePair() {
- NatRule[] rules = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
+ final NatRule[] rules = resource.generatePortForwardingRulePair("10.10.10.10", new int[] {8080, 8080}, "11.11.11.11", new int[] {80, 80}, "tcp");
assertTrue("DestinationNatRule".equals(rules[0].getType()));
assertTrue("SourceNatRule".equals(rules[1].getType()));
- DestinationNatRule dnr = (DestinationNatRule)rules[0];
+ final DestinationNatRule dnr = (DestinationNatRule)rules[0];
assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
assertTrue(dnr.getToDestinationPort() == 8080);
assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));
assertTrue(dnr.getMatch().getDestinationPort() == 80);
assertTrue(dnr.getMatch().getEthertype().equals("IPv4") && dnr.getMatch().getProtocol() == 6);
- SourceNatRule snr = (SourceNatRule)rules[1];
+ final SourceNatRule snr = (SourceNatRule)rules[1];
assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
assertTrue(snr.getToSourcePort() == 80);
assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index cf6e960..d9bd2de 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,7 @@
<properties>
<cs.jdk.version>1.7</cs.jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<cs.log4j.version>1.2.16</cs.log4j.version>
<cs.log4j.extras.version>1.1</cs.log4j.extras.version>
@@ -501,6 +502,11 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.3</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${cs.checkstyle.version}</version>
<dependencies>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/utils/pom.xml
----------------------------------------------------------------------
diff --git a/utils/pom.xml b/utils/pom.xml
index f63d7c4..f3b8f5f 100755
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -141,6 +141,10 @@
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -173,4 +177,27 @@
</resource>
</resources>
</build>
+
+ <profiles>
+ <profile>
+ <id>integration</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java b/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
new file mode 100644
index 0000000..e522852
--- /dev/null
+++ b/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
@@ -0,0 +1,47 @@
+package com.cloud.utils.rest;
+
+import java.io.IOException;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethodBase;
+
+/**
+ * Base 64 encoded authorization strategy. This implementation as opposed to
+ * {@link RESTValidationStrategy} doesn't do a login after auth error, but instead
+ * includes the encoded credentials in each request, instead of a cookie.
+ */
+public class BasicEncodedRESTValidationStrategy extends RESTValidationStrategy {
+
+ public BasicEncodedRESTValidationStrategy(final String host, final String adminuser, final String adminpass) {
+ super();
+ this.host = host;
+ user = adminuser;
+ password = adminpass;
+ }
+
+ public BasicEncodedRESTValidationStrategy() {
+ }
+
+ @Override
+ public void executeMethod(final HttpMethodBase method, final HttpClient client,
+ final String protocol)
+ throws CloudstackRESTException, HttpException, IOException {
+ if (host == null || host.isEmpty() || user == null || user.isEmpty() || password == null || password.isEmpty()) {
+ throw new CloudstackRESTException("Hostname/credentials are null or empty");
+ }
+
+ final String encodedCredentials = encodeCredentials();
+ method.setRequestHeader("Authorization", "Basic " + encodedCredentials);
+ client.executeMethod(method);
+ }
+
+ private String encodeCredentials() {
+ final String authString = user + ":" + password;
+ final byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
+ final String authStringEnc = new String(authEncBytes);
+ return authStringEnc;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/utils/src/com/cloud/utils/rest/CloudstackRESTException.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/CloudstackRESTException.java b/utils/src/com/cloud/utils/rest/CloudstackRESTException.java
new file mode 100644
index 0000000..8d74598
--- /dev/null
+++ b/utils/src/com/cloud/utils/rest/CloudstackRESTException.java
@@ -0,0 +1,36 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package com.cloud.utils.rest;
+
+public class CloudstackRESTException extends Exception {
+
+ public CloudstackRESTException() {
+ }
+
+ public CloudstackRESTException(final String message) {
+ super(message);
+ }
+
+ public CloudstackRESTException(final Throwable cause) {
+ super(cause);
+ }
+
+ public CloudstackRESTException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/utils/src/com/cloud/utils/rest/RESTServiceConnector.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/RESTServiceConnector.java b/utils/src/com/cloud/utils/rest/RESTServiceConnector.java
new file mode 100644
index 0000000..7cc2e89
--- /dev/null
+++ b/utils/src/com/cloud/utils/rest/RESTServiceConnector.java
@@ -0,0 +1,377 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
+package com.cloud.utils.rest;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Type;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.commons.httpclient.ConnectTimeoutException;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.httpclient.params.HttpConnectionParams;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
+import org.apache.log4j.Logger;
+
+import com.google.gson.FieldNamingPolicy;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.reflect.TypeToken;
+
+/**
+ * This abstraction encapsulates client side code for REST service communication. It encapsulates
+ * access in a delegate validation strategy. There may different implementations extending
+ * {@link RESTValidationStrategy}, and any of them should mention the needed data to work.
+ *
+ * This connector allows the use of {@link JsonDeserializer} for specific classes. You can provide
+ * in the constructor a list of classes and a list of deserializers for these classes. These should
+ * be a correlated so that Nth deserializer is correctly mapped to Nth class.
+ */
+public class RESTServiceConnector {
+ private static final String HTTPS = "https";
+ protected static final String GET_METHOD_TYPE = "get";
+ protected static final String DELETE_METHOD_TYPE = "delete";
+ protected static final String PUT_METHOD_TYPE = "put";
+ protected static final String POST_METHOD_TYPE = "post";
+ private static final String TEXT_HTML_CONTENT_TYPE = "text/html";
+ private static final String JSON_CONTENT_TYPE = "application/json";
+ private static final String CONTENT_TYPE = "Content-Type";
+ private static final int BODY_RESP_MAX_LEN = 1024;
+ private static final int HTTPS_PORT = 443;
+
+ private static final Logger s_logger = Logger.getLogger(RESTServiceConnector.class);
+
+ protected final static String protocol = HTTPS;
+
+ private final static MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
+
+ protected RESTValidationStrategy validation;
+
+ private final HttpClient client;
+
+ private final Gson gson;
+
+
+ /**
+ * Getter that may be needed only for test purpose
+ *
+ * @return
+ */
+ public Gson getGson() {
+ return gson;
+ }
+
+ public RESTServiceConnector(final RESTValidationStrategy validationStrategy) {
+ this(validationStrategy, null, null);
+ }
+
+ public RESTServiceConnector(final RESTValidationStrategy validationStrategy, final List<Class<?>> classList, final List<JsonDeserializer<?>> deserializerList) {
+ validation = validationStrategy;
+ client = createHttpClient();
+ client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+
+ try {
+ // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
+ Protocol.registerProtocol(HTTPS, new Protocol(HTTPS, (ProtocolSocketFactory)new TrustingProtocolSocketFactory(), HTTPS_PORT));
+ } catch (final IOException e) {
+ s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e);
+ }
+
+ final GsonBuilder gsonBuilder = new GsonBuilder();
+ if(classList != null && deserializerList != null) {
+ for(int i = 0; i < classList.size() && i < deserializerList.size(); i++) {
+ gsonBuilder.registerTypeAdapter(classList.get(i), deserializerList.get(i));
+ }
+ }
+ gson = gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
+ }
+
+ public HttpClient createHttpClient() {
+ return new HttpClient(s_httpClientManager);
+ }
+
+ public HttpMethod createMethod(final String type, final String uri) throws CloudstackRESTException {
+ String url;
+ try {
+ url = new URL(protocol, validation.getHost(), uri).toString();
+ } catch (final MalformedURLException e) {
+ s_logger.error("Unable to build REST Service URL", e);
+ throw new CloudstackRESTException("Unable to build Nicira API URL", e);
+ }
+
+ if (POST_METHOD_TYPE.equalsIgnoreCase(type)) {
+ return new PostMethod(url);
+ } else if (GET_METHOD_TYPE.equalsIgnoreCase(type)) {
+ return new GetMethod(url);
+ } else if (DELETE_METHOD_TYPE.equalsIgnoreCase(type)) {
+ return new DeleteMethod(url);
+ } else if (PUT_METHOD_TYPE.equalsIgnoreCase(type)) {
+ return new PutMethod(url);
+ } else {
+ throw new CloudstackRESTException("Requesting unknown method type");
+ }
+ }
+
+ public void setControllerAddress(final String address) {
+ validation.setHost(address);
+ }
+
+ public void setAdminCredentials(final String username, final String password) {
+ validation.setUser(username);
+ validation.setPassword(password);
+ }
+
+ public <T> void executeUpdateObject(final T newObject, final String uri, final Map<String, String> parameters) throws CloudstackRESTException {
+
+ final PutMethod pm = (PutMethod)createMethod(PUT_METHOD_TYPE, uri);
+ pm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
+ try {
+ pm.setRequestEntity(new StringRequestEntity(gson.toJson(newObject), JSON_CONTENT_TYPE, null));
+ } catch (final UnsupportedEncodingException e) {
+ throw new CloudstackRESTException("Failed to encode json request body", e);
+ }
+
+ executeMethod(pm);
+
+ if (pm.getStatusCode() != HttpStatus.SC_OK) {
+ final String errorMessage = responseToErrorMessage(pm);
+ pm.releaseConnection();
+ s_logger.error("Failed to update object : " + errorMessage);
+ throw new CloudstackRESTException("Failed to update object : " + errorMessage);
+ }
+ pm.releaseConnection();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T executeCreateObject(final T newObject, final Type returnObjectType, final String uri, final Map<String, String> parameters)
+ throws CloudstackRESTException {
+
+ final PostMethod pm = (PostMethod)createMethod(POST_METHOD_TYPE, uri);
+ pm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
+ try {
+ pm.setRequestEntity(new StringRequestEntity(gson.toJson(newObject), JSON_CONTENT_TYPE, null));
+ } catch (final UnsupportedEncodingException e) {
+ throw new CloudstackRESTException("Failed to encode json request body", e);
+ }
+
+ executeMethod(pm);
+
+ if (pm.getStatusCode() != HttpStatus.SC_CREATED) {
+ final String errorMessage = responseToErrorMessage(pm);
+ pm.releaseConnection();
+ s_logger.error("Failed to create object : " + errorMessage);
+ throw new CloudstackRESTException("Failed to create object : " + errorMessage);
+ }
+
+ T result;
+ try {
+ result = (T)gson.fromJson(pm.getResponseBodyAsString(), TypeToken.get(newObject.getClass()).getType());
+ } catch (final IOException e) {
+ throw new CloudstackRESTException("Failed to decode json response body", e);
+ } finally {
+ pm.releaseConnection();
+ }
+
+ return result;
+ }
+
+ public void executeDeleteObject(final String uri) throws CloudstackRESTException {
+ final DeleteMethod dm = (DeleteMethod)createMethod(DELETE_METHOD_TYPE, uri);
+ dm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
+
+ executeMethod(dm);
+
+ if (dm.getStatusCode() != HttpStatus.SC_NO_CONTENT) {
+ final String errorMessage = responseToErrorMessage(dm);
+ dm.releaseConnection();
+ s_logger.error("Failed to delete object : " + errorMessage);
+ throw new CloudstackRESTException("Failed to delete object : " + errorMessage);
+ }
+ dm.releaseConnection();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T executeRetrieveObject(final Type returnObjectType, final String uri, final Map<String, String> parameters) throws CloudstackRESTException {
+ final GetMethod gm = (GetMethod)createMethod(GET_METHOD_TYPE, uri);
+ gm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
+ if (parameters != null && !parameters.isEmpty()) {
+ final List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
+ for (final Entry<String, String> e : parameters.entrySet()) {
+ nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
+ }
+ gm.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
+ }
+
+ executeMethod(gm);
+
+ if (gm.getStatusCode() != HttpStatus.SC_OK) {
+ final String errorMessage = responseToErrorMessage(gm);
+ gm.releaseConnection();
+ s_logger.error("Failed to retrieve object : " + errorMessage);
+ throw new CloudstackRESTException("Failed to retrieve object : " + errorMessage);
+ }
+
+ T returnValue;
+ try {
+ returnValue = (T)gson.fromJson(gm.getResponseBodyAsString(), returnObjectType);
+ } catch (final IOException e) {
+ s_logger.error("IOException while retrieving response body", e);
+ throw new CloudstackRESTException(e);
+ } finally {
+ gm.releaseConnection();
+ }
+ return returnValue;
+ }
+
+ public void executeMethod(final HttpMethodBase method) throws CloudstackRESTException {
+ try {
+ validation.executeMethod(method, client, protocol);
+ } catch (final HttpException e) {
+ s_logger.error("HttpException caught while trying to connect to the REST Service", e);
+ method.releaseConnection();
+ throw new CloudstackRESTException("API call to REST Service Failed", e);
+ } catch (final IOException e) {
+ s_logger.error("IOException caught while trying to connect to the REST Service", e);
+ method.releaseConnection();
+ throw new CloudstackRESTException("API call to Nicira REST Service Failed", e);
+ }
+ }
+
+ private String responseToErrorMessage(final HttpMethodBase method) {
+ assert method.isRequestSent() : "no use getting an error message unless the request is sent";
+
+ if (TEXT_HTML_CONTENT_TYPE.equals(method.getResponseHeader(CONTENT_TYPE).getValue())) {
+ // The error message is the response content
+ // Safety margin of 1024 characters, anything longer is probably useless
+ // and will clutter the logs
+ try {
+ return method.getResponseBodyAsString(BODY_RESP_MAX_LEN);
+ } catch (final IOException e) {
+ s_logger.debug("Error while loading response body", e);
+ }
+ }
+
+ // The default
+ return method.getStatusText();
+ }
+
+ /* Some controllers use a self-signed certificate. The
+ * TrustingProtocolSocketFactory will accept any provided
+ * certificate when making an SSL connection to the SDN
+ * Manager
+ */
+ private class TrustingProtocolSocketFactory implements SecureProtocolSocketFactory {
+
+ private SSLSocketFactory ssf;
+
+ public TrustingProtocolSocketFactory() throws IOException {
+ // Create a trust manager that does not validate certificate chains
+ final TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ @Override
+ public void checkClientTrusted(final X509Certificate[] certs, final String authType) {
+ // Trust always
+ }
+
+ @Override
+ public void checkServerTrusted(final X509Certificate[] certs, final String authType) {
+ // Trust always
+ }
+ }};
+
+ try {
+ // Install the all-trusting trust manager
+ final SSLContext sc = SSLContext.getInstance("SSL");
+ sc.init(null, trustAllCerts, new java.security.SecureRandom());
+ ssf = sc.getSocketFactory();
+ } catch (final KeyManagementException e) {
+ throw new IOException(e);
+ } catch (final NoSuchAlgorithmException e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public Socket createSocket(final String host, final int port) throws IOException {
+ return ssf.createSocket(host, port);
+ }
+
+ @Override
+ public Socket createSocket(final String address, final int port, final InetAddress localAddress, final int localPort) throws IOException, UnknownHostException {
+ return ssf.createSocket(address, port, localAddress, localPort);
+ }
+
+ @Override
+ public Socket createSocket(final Socket socket, final String host, final int port, final boolean autoClose) throws IOException, UnknownHostException {
+ return ssf.createSocket(socket, host, port, autoClose);
+ }
+
+ @Override
+ public Socket createSocket(final String host, final int port, final InetAddress localAddress, final int localPort, final HttpConnectionParams params)
+ throws IOException, UnknownHostException, ConnectTimeoutException {
+ final int timeout = params.getConnectionTimeout();
+ if (timeout == 0) {
+ return createSocket(host, port, localAddress, localPort);
+ } else {
+ final Socket s = ssf.createSocket();
+ s.bind(new InetSocketAddress(localAddress, localPort));
+ s.connect(new InetSocketAddress(host, port), timeout);
+ return s;
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java b/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
new file mode 100644
index 0000000..cb25614
--- /dev/null
+++ b/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
@@ -0,0 +1,146 @@
+package com.cloud.utils.rest;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.log4j.Logger;
+
+/**
+ * Basic authentication strategy. This strategy needs user and password for authentication.
+ *
+ * A login URL is needed which will be used for login and getting the cookie to be
+ * used in next requests. If an executeMethod request fails due to authorization it will try
+ * to login, get the cookie and repeat the attempt to execute the method.
+ */
+public class RESTValidationStrategy {
+
+ private static final Logger s_logger = Logger.getLogger(RESTValidationStrategy.class);
+
+ protected String host;
+ protected String user;
+ protected String password;
+ protected String serverVersion;
+ protected String loginUrl;
+
+ public RESTValidationStrategy(final String host, final String user, final String password,
+ final String serverVersion, final String loginUrl) {
+ super();
+ this.host = host;
+ this.user = user;
+ this.password = password;
+ this.serverVersion = serverVersion;
+ this.loginUrl = loginUrl;
+ }
+
+ public RESTValidationStrategy(final String loginUrl) {
+ this.loginUrl = loginUrl;
+ }
+
+ public RESTValidationStrategy() {
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(final String user) {
+ this.user = user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(final String password) {
+ this.password = password;
+ }
+
+ public String getLoginUrl() {
+ return loginUrl;
+ }
+
+ public void setLoginUrl(final String loginUrl) {
+ this.loginUrl = loginUrl;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(final String host) {
+ this.host = host;
+ }
+
+ public void executeMethod(final HttpMethodBase method, final HttpClient client,
+ final String protocol)
+ throws CloudstackRESTException, HttpException, IOException {
+ if (host == null || host.isEmpty() || user == null || user.isEmpty() || password == null || password.isEmpty()) {
+ throw new CloudstackRESTException("Hostname/credentials are null or empty");
+ }
+
+ client.executeMethod(method);
+ if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
+ method.releaseConnection();
+ // login and try again
+ login(protocol, client);
+ client.executeMethod(method);
+ }
+ }
+
+ /**
+ * Logs against the REST server. The cookie is stored in the <code>_authcookie<code> variable.
+ * <p>
+ * The method returns false if the login failed or the connection could not be made.
+ *
+ */
+ protected void login(final String protocol,
+ final HttpClient client)
+ throws CloudstackRESTException {
+ String url;
+
+ if (host == null || host.isEmpty() || user == null || user.isEmpty() || password == null || password.isEmpty()) {
+ throw new CloudstackRESTException("Hostname/credentials are null or empty");
+ }
+
+ try {
+ url = new URL(protocol, host, loginUrl).toString();
+ } catch (final MalformedURLException e) {
+ s_logger.error("Unable to build Nicira API URL", e);
+ throw new CloudstackRESTException("Unable to build Nicira API URL", e);
+ }
+
+ final PostMethod pm = new PostMethod(url);
+ pm.addParameter("username", user);
+ pm.addParameter("password", password);
+
+ try {
+ client.executeMethod(pm);
+ } catch (final HttpException e) {
+ throw new CloudstackRESTException("REST Service API login failed ", e);
+ } catch (final IOException e) {
+ throw new CloudstackRESTException("REST Service API login failed ", e);
+ } finally {
+ pm.releaseConnection();
+ }
+
+ if (pm.getStatusCode() != HttpStatus.SC_OK) {
+ s_logger.error("REST Service API login failed : " + pm.getStatusText());
+ throw new CloudstackRESTException("REST Service API login failed " + pm.getStatusText());
+ }
+
+ // Extract the version for later use
+ if (pm.getResponseHeader("Server") != null) {
+ serverVersion = pm.getResponseHeader("Server").getValue();
+ s_logger.debug("Server reports version " + serverVersion);
+ }
+
+ // Success; the cookie required for login is kept in _client
+ }
+
+}
[45/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Introduce VR resource unit test
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3bbbda88
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3bbbda88
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3bbbda88
Branch: refs/heads/ui-restyle
Commit: 3bbbda887f182443c266a43e21cf2b6918acf08f
Parents: 711b308
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 19:12:07 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 19:47:20 2014 -0800
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 8 +-
.../VirtualRoutingResourceTest.java | 783 +++++++++++++++++++
2 files changed, 788 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3bbbda88/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 7845da0..48ff421 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -133,6 +133,8 @@ public class VirtualRoutingResource {
return new Answer(cmd, false, rc.getDetails());
}
+ assert cmd.getRouterAccessIp() != null : "Why there is no access IP for VR?";
+
if (cmd.isQuery()) {
return executeQueryCommand(cmd);
}
@@ -421,7 +423,7 @@ public class VirtualRoutingResource {
for (PortForwardingRuleTO rule : cmd.getRules()) {
StringBuilder args = new StringBuilder();
- args.append(rule.revoked() ? " -D " : " -A ");
+ args.append(rule.revoked() ? "-D" : "-A");
args.append(" -P ").append(rule.getProtocol().toLowerCase());
args.append(" -l ").append(rule.getSrcIp());
args.append(" -p ").append(rule.getStringSrcPortRange());
@@ -812,7 +814,7 @@ public class VirtualRoutingResource {
IpAddressTO pubIP = cmd.getIpAddress();
String dev = "eth" + pubIP.getNicDevId();
- String args = " -A ";
+ String args = "-A";
args += " -l ";
args += pubIP.getPublicIp();
args += " -c ";
@@ -826,7 +828,7 @@ public class VirtualRoutingResource {
LinkedList<ConfigItem> cfg = new LinkedList<>();
for (PortForwardingRuleTO rule : cmd.getRules()) {
- String args = rule.revoked() ? " -D" : " -A";
+ String args = rule.revoked() ? "-D" : "-A";
args += " -P " + rule.getProtocol().toLowerCase();
args += " -l " + rule.getSrcIp();
args += " -p " + rule.getStringSrcPortRange();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3bbbda88/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
----------------------------------------------------------------------
diff --git a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
new file mode 100644
index 0000000..f961530
--- /dev/null
+++ b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
@@ -0,0 +1,783 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package com.cloud.agent.resource.virtualnetwork;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.BumpUpPriorityCommand;
+import com.cloud.agent.api.SetupGuestNetworkCommand;
+import com.cloud.agent.api.routing.CreateIpAliasCommand;
+import com.cloud.agent.api.routing.DeleteIpAliasCommand;
+import com.cloud.agent.api.routing.DhcpEntryCommand;
+import com.cloud.agent.api.routing.DnsMasqConfigCommand;
+import com.cloud.agent.api.routing.GroupAnswer;
+import com.cloud.agent.api.routing.IpAliasTO;
+import com.cloud.agent.api.routing.IpAssocCommand;
+import com.cloud.agent.api.routing.IpAssocVpcCommand;
+import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
+import com.cloud.agent.api.routing.NetworkElementCommand;
+import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
+import com.cloud.agent.api.routing.SavePasswordCommand;
+import com.cloud.agent.api.routing.SetFirewallRulesCommand;
+import com.cloud.agent.api.routing.SetMonitorServiceCommand;
+import com.cloud.agent.api.routing.SetNetworkACLCommand;
+import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
+import com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand;
+import com.cloud.agent.api.routing.SetSourceNatCommand;
+import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
+import com.cloud.agent.api.routing.SetStaticRouteCommand;
+import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
+import com.cloud.agent.api.routing.VmDataCommand;
+import com.cloud.agent.api.routing.VpnUsersCfgCommand;
+import com.cloud.agent.api.to.DhcpTO;
+import com.cloud.agent.api.to.FirewallRuleTO;
+import com.cloud.agent.api.to.IpAddressTO;
+import com.cloud.agent.api.to.LoadBalancerTO;
+import com.cloud.agent.api.to.MonitorServiceTO;
+import com.cloud.agent.api.to.NetworkACLTO;
+import com.cloud.agent.api.to.NicTO;
+import com.cloud.agent.api.to.PortForwardingRuleTO;
+import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource.VRScripts;
+import com.cloud.network.lb.LoadBalancingRule.LbDestination;
+import com.cloud.network.rules.FirewallRule.Purpose;
+import com.cloud.network.vpc.NetworkACLItem.TrafficType;
+import com.cloud.network.vpc.VpcGateway;
+import com.cloud.utils.ExecutionResult;
+import com.cloud.utils.net.NetUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
+public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
+ VirtualRoutingResource _resource;
+ NetworkElementCommand _currentCmd;
+ int _count;
+
+ String ROUTERIP = "10.2.3.4";
+
+ @Override
+ public ExecutionResult executeInVR(String routerIp, String script, String args) {
+ assertEquals(routerIp, ROUTERIP);
+ verifyCommand(_currentCmd, script, args);
+ return new ExecutionResult(true, null);
+ }
+
+ @Override
+ public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
+ assertEquals(routerIp, ROUTERIP);
+ verifyFile(_currentCmd, path, filename, content);
+ return new ExecutionResult(true, null);
+ }
+
+ @Override
+ public ExecutionResult prepareCommand(NetworkElementCommand cmd) {
+ cmd.setRouterAccessIp(ROUTERIP);
+ _currentCmd = cmd;
+ if (cmd instanceof IpAssocVpcCommand) {
+ return prepareNetworkElementCommand((IpAssocVpcCommand)cmd);
+ } else if (cmd instanceof IpAssocCommand) {
+ return prepareNetworkElementCommand((IpAssocCommand)cmd);
+ } else if (cmd instanceof SetupGuestNetworkCommand) {
+ return prepareNetworkElementCommand((SetupGuestNetworkCommand)cmd);
+ } else if (cmd instanceof SetSourceNatCommand) {
+ return prepareNetworkElementCommand((SetSourceNatCommand)cmd);
+ } else if (cmd instanceof SetNetworkACLCommand) {
+ return prepareNetworkElementCommand((SetNetworkACLCommand)cmd);
+ }
+ return new ExecutionResult(true, null);
+ }
+
+ @Override
+ public ExecutionResult cleanupCommand(NetworkElementCommand cmd) {
+ return new ExecutionResult(true, null);
+ }
+
+ @Before
+ public void setup() {
+ _resource = new VirtualRoutingResource(this);
+ }
+
+ protected void verifyCommand(NetworkElementCommand cmd, String script, String args) {
+ if (cmd instanceof SetPortForwardingRulesVpcCommand) {
+ verifyArgs((SetPortForwardingRulesVpcCommand) cmd, script, args);
+ } else if (cmd instanceof SetPortForwardingRulesCommand) {
+ verifyArgs((SetPortForwardingRulesCommand) cmd, script, args);
+ } else if (cmd instanceof SetStaticRouteCommand) {
+ verifyArgs((SetStaticRouteCommand) cmd, script, args);
+ } else if (cmd instanceof SetStaticNatRulesCommand) {
+ verifyArgs((SetStaticNatRulesCommand) cmd, script, args);
+ } else if (cmd instanceof LoadBalancerConfigCommand) {
+ verifyArgs((LoadBalancerConfigCommand) cmd, script, args);
+ } else if (cmd instanceof SavePasswordCommand) {
+ verifyArgs((SavePasswordCommand)cmd, script, args);
+ } else if (cmd instanceof DhcpEntryCommand) {
+ verifyArgs((DhcpEntryCommand)cmd, script, args);
+ } else if (cmd instanceof CreateIpAliasCommand) {
+ verifyArgs((CreateIpAliasCommand)cmd, script, args);
+ } else if (cmd instanceof DnsMasqConfigCommand) {
+ verifyArgs((DnsMasqConfigCommand)cmd, script, args);
+ } else if (cmd instanceof DeleteIpAliasCommand) {
+ verifyArgs((DeleteIpAliasCommand)cmd, script, args);
+ } else if (cmd instanceof VmDataCommand) {
+ verifyArgs((VmDataCommand)cmd, script, args);
+ } else if (cmd instanceof SetFirewallRulesCommand) {
+ verifyArgs((SetFirewallRulesCommand)cmd, script, args);
+ } else if (cmd instanceof BumpUpPriorityCommand) {
+ verifyArgs((BumpUpPriorityCommand)cmd, script, args);
+ } else if (cmd instanceof RemoteAccessVpnCfgCommand) {
+ verifyArgs((RemoteAccessVpnCfgCommand)cmd, script, args);
+ } else if (cmd instanceof VpnUsersCfgCommand) {
+ verifyArgs((VpnUsersCfgCommand)cmd, script, args);
+ } else if (cmd instanceof Site2SiteVpnCfgCommand) {
+ verifyArgs((Site2SiteVpnCfgCommand)cmd, script, args);
+ } else if (cmd instanceof SetMonitorServiceCommand) {
+ verifyArgs((SetMonitorServiceCommand)cmd, script, args);
+ } else if (cmd instanceof SetupGuestNetworkCommand) {
+ verifyArgs((SetupGuestNetworkCommand)cmd, script, args);
+ } else if (cmd instanceof SetNetworkACLCommand) {
+ verifyArgs((SetNetworkACLCommand)cmd, script, args);
+ } else if (cmd instanceof SetSourceNatCommand) {
+ verifyArgs((SetSourceNatCommand)cmd, script, args);
+ } else if (cmd instanceof IpAssocCommand) {
+ verifyArgs((IpAssocCommand)cmd, script, args);
+ }
+ }
+
+ private void verifyArgs(VpnUsersCfgCommand cmd, String script, String args) {
+ //To change body of created methods use File | Settings | File Templates.
+ }
+
+ private void verifyArgs(SetStaticRouteCommand cmd, String script, String args) {
+ //To change body of created methods use File | Settings | File Templates.
+ }
+
+ private void verifyArgs(SetStaticNatRulesCommand cmd, String script, String args) {
+ //To change body of created methods use File | Settings | File Templates.
+ }
+
+ @Test
+ public void testBumpUpCommand() {
+ BumpUpPriorityCommand cmd = new BumpUpPriorityCommand();
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(BumpUpPriorityCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.RVR_BUMPUP_PRI);
+ assertEquals(args, null);
+ }
+
+ @Test
+ public void testSetPortForwardingRulesVpcCommand() {
+ List<PortForwardingRuleTO> pfRules = new ArrayList<>();
+ pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false));
+ pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false));
+ SetPortForwardingRulesVpcCommand cmd = new SetPortForwardingRulesVpcCommand(pfRules);
+ assertEquals(cmd.getAnswersCount(), 2);
+
+ // Reset rule check count
+ _count = 0;
+
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer instanceof GroupAnswer);
+ assertEquals(((GroupAnswer) answer).getResults().length, 2);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(SetPortForwardingRulesVpcCommand cmd, String script, String args) {
+ assertTrue(script.equals(VRScripts.VPC_PORTFORWARDING));
+ _count ++;
+ switch (_count) {
+ case 1:
+ assertEquals(args, "-A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22-80");
+ break;
+ case 2:
+ assertEquals(args, "-D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080-8080");
+ break;
+ default:
+ fail("Failed to recongize the match!");
+ }
+ }
+
+ @Test
+ public void testSetPortForwardingRulesCommand() {
+ List<PortForwardingRuleTO> pfRules = new ArrayList<>();
+ pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false));
+ pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false));
+ SetPortForwardingRulesCommand cmd = new SetPortForwardingRulesCommand(pfRules);
+ assertEquals(cmd.getAnswersCount(), 2);
+
+ // Reset rule check count
+ _count = 0;
+
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer instanceof GroupAnswer);
+ assertEquals(((GroupAnswer) answer).getResults().length, 2);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(SetPortForwardingRulesCommand cmd, String script, String args) {
+ assertTrue(script.equals(VRScripts.FIREWALL_NAT));
+ _count ++;
+ switch (_count) {
+ case 1:
+ assertEquals(args, "-A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22:80");
+ break;
+ case 2:
+ assertEquals(args, "-D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080:8080");
+ break;
+ default:
+ fail("Failed to recongize the match!");
+ }
+ }
+
+ @Test
+ public void testIpAssocCommand() {
+ List<IpAddressTO> ips = new ArrayList<IpAddressTO>();
+ ips.add(new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
+ ips.add(new IpAddressTO(2, "64.1.1.11", false, false, false, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
+ ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false));
+ IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]);
+ IpAssocCommand cmd = new IpAssocCommand(ipArray);
+ assertEquals(cmd.getAnswersCount(), 3);
+
+ _count = 0;
+
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer instanceof GroupAnswer);
+ assertEquals(((GroupAnswer) answer).getResults().length, 3);
+ assertTrue(answer.getResult());
+
+ }
+
+ private ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) {
+ IpAddressTO[] ips = cmd.getIpAddresses();
+ for (IpAddressTO ip : ips) {
+ ip.setNicDevId(2);
+ }
+ return new ExecutionResult(true, null);
+ }
+
+ @Test
+ public void testIpAssocVpcCommand() {
+ List<IpAddressTO> ips = new ArrayList<IpAddressTO>();
+ ips.add(new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
+ ips.add(new IpAddressTO(2, "64.1.1.11", false, false, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false));
+ ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false));
+ IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]);
+ IpAssocVpcCommand cmd = new IpAssocVpcCommand(ipArray);
+ assertEquals(cmd.getAnswersCount(), 6);
+
+ _count = 0;
+
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer instanceof GroupAnswer);
+ assertEquals(((GroupAnswer) answer).getResults().length, 6);
+ assertTrue(answer.getResult());
+
+ }
+
+ private ExecutionResult prepareNetworkElementCommand(IpAssocVpcCommand cmd) {
+ IpAddressTO[] ips = cmd.getIpAddresses();
+ for (IpAddressTO ip : ips) {
+ ip.setNicDevId(2);
+ }
+ return new ExecutionResult(true, null);
+ }
+
+ private void verifyArgs(IpAssocCommand cmd, String script, String args) {
+ if (cmd instanceof IpAssocVpcCommand) {
+ _count ++;
+ switch (_count) {
+ case 1:
+ assertEquals(script, VRScripts.VPC_IPASSOC);
+ assertEquals(args, " -A -l 64.1.1.10 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0");
+ break;
+ case 2:
+ assertEquals(script, VRScripts.VPC_PRIVATEGW);
+ assertEquals(args, " -A -l 64.1.1.10 -c eth2");
+ break;
+ case 3:
+ assertEquals(script, VRScripts.VPC_IPASSOC);
+ assertEquals(args, " -D -l 64.1.1.11 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0");
+ break;
+ case 4:
+ assertEquals(script, VRScripts.VPC_PRIVATEGW);
+ assertEquals(args, " -D -l 64.1.1.11 -c eth2");
+ break;
+ case 5:
+ assertEquals(script, VRScripts.VPC_IPASSOC);
+ assertEquals(args, " -A -l 65.1.1.11 -c eth2 -g 65.1.1.1 -m 24 -n 65.1.1.0");
+ break;
+ default:
+ fail("Failed to recongize the match!");
+ }
+ } else {
+ assertEquals(script, VRScripts.IPASSOC);
+ _count ++;
+ switch (_count) {
+ case 1:
+ assertEquals(args, "-A -s -f -l 64.1.1.10/24 -c eth2 -g 64.1.1.1");
+ break;
+ case 2:
+ assertEquals(args, "-D -l 64.1.1.11/24 -c eth2 -g 64.1.1.1");
+ break;
+ case 3:
+ assertEquals(args, "-A -l 65.1.1.11/24 -c eth2 -g 65.1.1.1");
+ break;
+ default:
+ fail("Failed to recongize the match!");
+ }
+ }
+ }
+
+ @Test
+ public void testSourceNatCommand() {
+ IpAddressTO ip = new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false);
+ SetSourceNatCommand cmd = new SetSourceNatCommand(ip, true);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) {
+ IpAddressTO ip = cmd.getIpAddress();
+ ip.setNicDevId(1);
+ return new ExecutionResult(true, null);
+ }
+
+ private void verifyArgs(SetSourceNatCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.VPC_SOURCE_NAT);
+ assertEquals(args, "-A -l 64.1.1.10 -c eth1");
+ }
+
+ @Test
+ public void testNetworkACLCommand() {
+ List<NetworkACLTO> acls = new ArrayList<>();
+ List<String> cidrs = new ArrayList<>();
+ cidrs.add("192.168.0.1/24");
+ cidrs.add("192.168.0.2/24");
+ acls.add(new NetworkACLTO(1, "64", "TCP", 20, 80, false, false, cidrs, 0, 0, TrafficType.Ingress, true, 1));
+ acls.add(new NetworkACLTO(2, "64", "ICMP", 0, 0, false, false, cidrs, -1, -1, TrafficType.Ingress, false, 2));
+ acls.add(new NetworkACLTO(3, "65", "ALL", 0, 0, false, false, cidrs, -1, -1, TrafficType.Egress, true, 3));
+ NicTO nic = new NicTO();
+ nic.setMac("01:23:45:67:89:AB");
+ nic.setIp("192.168.1.1");
+ nic.setNetmask("255.255.255.0");
+
+ _count = 0;
+
+ SetNetworkACLCommand cmd = new SetNetworkACLCommand(acls, nic);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ cmd.setAccessDetail(NetworkElementCommand.VPC_PRIVATE_GATEWAY, String.valueOf(VpcGateway.Type.Private));
+ answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(SetNetworkACLCommand cmd, String script, String args) {
+ _count ++;
+ switch (_count) {
+ case 1:
+ assertEquals(script, VRScripts.VPC_ACL);
+ assertEquals(args, " -d eth3 -M 01:23:45:67:89:AB -i 192.168.1.1 -m 24 -a Egress:ALL:0:0:192.168.0.1/24-192.168.0.2/24:ACCEPT:," +
+ "Ingress:ICMP:0:0:192.168.0.1/24-192.168.0.2/24:DROP:,Ingress:TCP:20:80:192.168.0.1/24-192.168.0.2/24:ACCEPT:,");
+ break;
+ case 2:
+ assertEquals(script, VRScripts.VPC_PRIVATEGW_ACL);
+ assertEquals(args, " -d eth3 -M 01:23:45:67:89:AB -a Egress:ALL:0:0:192.168.0.1/24-192.168.0.2/24:ACCEPT:," +
+ "Ingress:ICMP:0:0:192.168.0.1/24-192.168.0.2/24:DROP:,Ingress:TCP:20:80:192.168.0.1/24-192.168.0.2/24:ACCEPT:,");
+ break;
+ default:
+ fail();
+ }
+ }
+
+ private ExecutionResult prepareNetworkElementCommand(SetNetworkACLCommand cmd) {
+ NicTO nic = cmd.getNic();
+ nic.setDeviceId(3);
+ return new ExecutionResult(true, null);
+ }
+
+ @Test
+ public void testSetupGuestNetworkCommand() {
+ NicTO nic = new NicTO();
+ nic.setMac("01:23:45:67:89:AB");
+ nic.setIp("10.1.1.1");
+ nic.setNetmask("255.255.255.0");
+
+ SetupGuestNetworkCommand cmd = new SetupGuestNetworkCommand("10.1.1.10-10.1.1.20", "cloud.test", false, 0, "8.8.8.8", "8.8.4.4", true, nic);
+ cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, "10.1.1.2");
+ cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "10.1.1.1");
+
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ }
+
+ private ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cmd) {
+ NicTO nic = cmd.getNic();
+ nic.setDeviceId(4);
+ return new ExecutionResult(true, null);
+ }
+
+ private void verifyArgs(SetupGuestNetworkCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.VPC_GUEST_NETWORK);
+ assertEquals(args, " -C -M 01:23:45:67:89:AB -d eth4 -i 10.1.1.2 -g 10.1.1.1 -m 24 -n 10.1.1.0 -s 8.8.8.8,8.8.4.4 -e cloud.test");
+ }
+
+ @Test
+ public void testSetMonitorServiceCommand() {
+ List<MonitorServiceTO> services = new ArrayList<>();
+ services.add(new MonitorServiceTO("service", "process", "name", "path", "file", true));
+ services.add(new MonitorServiceTO("service_2", "process_2", "name_2", "path_2", "file_2", false));
+
+ SetMonitorServiceCommand cmd = new SetMonitorServiceCommand(services);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(SetMonitorServiceCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.MONITOR_SERVICE);
+ assertEquals(args, " -c [service]:processname=process:servicename=name:pidfile=file:,[service_2]:processname=process_2:servicename=name_2:pidfile=file_2:,");
+ }
+
+ @Test
+ public void testSite2SiteVpnCfgCommand() {
+ _count = 0;
+
+ Site2SiteVpnCfgCommand cmd = new Site2SiteVpnCfgCommand(true, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), true, false);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ cmd = new Site2SiteVpnCfgCommand(true, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), false, true);
+ answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ cmd = new Site2SiteVpnCfgCommand(false, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), false, true);
+ answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(Site2SiteVpnCfgCommand cmd, String script, String args) {
+ _count ++;
+
+ assertEquals(script, VRScripts.S2SVPN_IPSEC);
+ switch (_count) {
+ case 1:
+ assertEquals(args, "-A -l 64.10.1.10 -n 192.168.1.1/16 -g 64.10.1.1 -r 124.10.1.10 -N 192.168.100.1/24 -e \"3des-sha1,aes128-md5\" -i \"3des-sha1,aes128-sha1;modp1536\" -t 1800 -T 1800 -s \"psk\" -d 1");
+ break;
+ case 2:
+ assertEquals(args, "-A -l 64.10.1.10 -n 192.168.1.1/16 -g 64.10.1.1 -r 124.10.1.10 -N 192.168.100.1/24 -e \"3des-sha1,aes128-md5\" -i \"3des-sha1,aes128-sha1;modp1536\" -t 1800 -T 1800 -s \"psk\" -d 0 -p ");
+ break;
+ case 3:
+ assertEquals(args, "-D -r 124.10.1.10 -n 192.168.1.1/16 -N 192.168.100.1/24");
+ break;
+ default:
+ fail();
+ }
+ }
+
+ @Test
+ public void testRemoteAccessVpnCfgCommand() {
+ _count = 0;
+
+ RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
+ cmd.setLocalCidr("10.1.1.1/24");
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ cmd = new RemoteAccessVpnCfgCommand(false, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false);
+ cmd.setLocalCidr("10.1.1.1/24");
+ answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", true);
+ cmd.setLocalCidr("10.1.1.1/24");
+ answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(RemoteAccessVpnCfgCommand cmd, String script, String args) {
+ _count ++;
+
+ assertEquals(script, VRScripts.VPN_L2TP);
+ switch (_count) {
+ case 1:
+ assertEquals(args, "-r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c -C 10.1.1.1/24 -i eth2");
+ break;
+ case 2:
+ assertEquals(args, "-d -s 124.10.10.10 -C 10.1.1.1/24 -i eth2");
+ break;
+ case 3:
+ assertEquals(args, "-r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c -C 10.1.1.1/24 -i eth1");
+ break;
+ default:
+ fail();
+
+ }
+ }
+
+ @Test
+ public void testFirewallRulesCommand() {
+ _count = 0;
+
+ List<FirewallRuleTO> rules = new ArrayList<>();
+ List<String> sourceCidrs = new ArrayList<>();
+ sourceCidrs.add("10.10.1.1/24");
+ sourceCidrs.add("10.10.1.2/24");
+ rules.add(new FirewallRuleTO(1, "64.10.10.10", "TCP", 22, 80, false, false, Purpose.Firewall, sourceCidrs, 0, 0));
+ rules.add(new FirewallRuleTO(2, "64.10.10.10", "ICMP", 0, 0, false, false, Purpose.Firewall, sourceCidrs, -1, -1));
+ rules.add(new FirewallRuleTO(3, "64.10.10.10", "ICMP", 0, 0, true, true, Purpose.Firewall, sourceCidrs, -1, -1));
+ SetFirewallRulesCommand cmd = new SetFirewallRulesCommand(rules);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ assertTrue(answer instanceof GroupAnswer);
+ assertEquals(((GroupAnswer) answer).getResults().length, 3);
+
+ //TODO Didn't test egress rule because not able to generate FirewallRuleVO object
+ }
+
+ private void verifyArgs(SetFirewallRulesCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.FIREWALL_INGRESS);
+ assertEquals(args, " -F -a 64.10.10.10:ICMP:0:0:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:TCP:22:80:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:reverted:0:0:0:,");
+ }
+
+ @Test
+ public void testVmDataCommand() {
+ VmDataCommand cmd = new VmDataCommand("10.1.10.4", "i-4-VM", true);
+ cmd.addVmData("userdata", "user-data", "user-data");
+ cmd.addVmData("metadata", "service-offering", "serviceOffering");
+ cmd.addVmData("metadata", "availability-zone", "zoneName");
+ cmd.addVmData("metadata", "local-ipv4", "10.1.10.4");
+ cmd.addVmData("metadata", "local-hostname", "test-vm");
+ cmd.addVmData("metadata", "public-ipv4", "110.1.10.4");
+ cmd.addVmData("metadata", "public-hostname", "hostname");
+ cmd.addVmData("metadata", "instance-id", "i-4-VM");
+ cmd.addVmData("metadata", "vm-id", "4");
+ cmd.addVmData("metadata", "public-keys", "publickey");
+ cmd.addVmData("metadata", "cloud-identifier", "CloudStack-{test}");
+
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(VmDataCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.VMDATA);
+ assertEquals(args, "-d eyIxMC4xLjEwLjQiOltbInVzZXJkYXRhIiwidXNlci1kYXRhIiwidXNlci1kYXRhIl0sWyJtZXRhZGF0YSIsInN" +
+ "lcnZpY2Utb2ZmZXJpbmciLCJzZXJ2aWNlT2ZmZXJpbmciXSxbIm1ldGFkYXRhIiwiYXZhaWxhYmlsaXR5LXpvbmUiLCJ6b25lTmFt" +
+ "ZSJdLFsibWV0YWRhdGEiLCJsb2NhbC1pcHY0IiwiMTAuMS4xMC40Il0sWyJtZXRhZGF0YSIsImxvY2FsLWhvc3RuYW1lIiwidGVzd" +
+ "C12bSJdLFsibWV0YWRhdGEiLCJwdWJsaWMtaXB2NCIsIjExMC4xLjEwLjQiXSxbIm1ldGFkYXRhIiwicHVibGljLWhvc3RuYW1lIi" +
+ "wiaG9zdG5hbWUiXSxbIm1ldGFkYXRhIiwiaW5zdGFuY2UtaWQiLCJpLTQtVk0iXSxbIm1ldGFkYXRhIiwidm0taWQiLCI0Il0sWyJ" +
+ "tZXRhZGF0YSIsInB1YmxpYy1rZXlzIiwicHVibGlja2V5Il0sWyJtZXRhZGF0YSIsImNsb3VkLWlkZW50aWZpZXIiLCJDbG91ZFN0YWNrLXt0ZXN0fSJdXX0=");
+ }
+
+ @Test
+ public void testSavePasswordCommand() {
+ SavePasswordCommand cmd = new SavePasswordCommand("123pass", "10.1.10.4", "i-4-VM", true);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(SavePasswordCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.PASSWORD);
+ assertEquals(args, "-v 10.1.10.4 -p 123pass");
+ }
+
+ @Test
+ public void testDhcpEntryCommand() {
+ _count = 0;
+ DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", null, true);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ cmd = new DhcpEntryCommand("12:34:56:78:90:AB", null, "vm1", "2001:db8:0:0:0:ff00:42:8329", true);
+ cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac()));
+ answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", "2001:db8:0:0:0:ff00:42:8329", true);
+ cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac()));
+ answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(DhcpEntryCommand cmd, String script, String args) {
+ _count ++;
+ assertEquals(script, VRScripts.DHCP);
+ switch (_count) {
+ case 1:
+ assertEquals(args, " -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1");
+ break;
+ case 2:
+ assertEquals(args, " -m 12:34:56:78:90:AB -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB");
+ break;
+ case 3:
+ assertEquals(args, " -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB");
+ break;
+ default:
+ fail();
+ }
+ }
+
+ @Test
+ public void testCreateIpAliasCommand() {
+ List<IpAliasTO> aliases = new ArrayList<>();
+ aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1"));
+ aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
+ aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
+ CreateIpAliasCommand cmd = new CreateIpAliasCommand("169.254.3.10", aliases);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(CreateIpAliasCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.IPALIAS_CREATE);
+ assertEquals(args, "1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-");
+ }
+
+ @Test
+ public void testDeleteIpAliasCommand() {
+ List<IpAliasTO> aliases = new ArrayList<>();
+ aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1"));
+ aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2"));
+ aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3"));
+ DeleteIpAliasCommand cmd = new DeleteIpAliasCommand("169.254.10.1", aliases, aliases);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(DeleteIpAliasCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.IPALIAS_DELETE);
+ assertEquals(args, "1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-- 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-");
+ }
+
+ @Test
+ public void testDnsMasqConfigCommand() {
+ List<DhcpTO> dhcps = new ArrayList<DhcpTO>();
+ dhcps.add(new DhcpTO("10.1.20.2", "10.1.20.1", "255.255.255.0", "10.1.20.5"));
+ dhcps.add(new DhcpTO("10.1.21.2", "10.1.21.1", "255.255.255.0", "10.1.21.5"));
+ DnsMasqConfigCommand cmd = new DnsMasqConfigCommand(dhcps);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyArgs(DnsMasqConfigCommand cmd, String script, String args) {
+ assertEquals(script, VRScripts.DNSMASQ_CONFIG);
+ assertEquals(args, "10.1.20.2:10.1.20.1:255.255.255.0:10.1.20.5-10.1.21.2:10.1.21.1:255.255.255.0:10.1.21.5-");
+ }
+
+ @Test
+ public void testLoadBalancerConfigCommand() {
+ _count = 0;
+
+ List<LoadBalancerTO> lbs = new ArrayList<>();
+ List<LbDestination> dests = new ArrayList<>();
+ dests.add(new LbDestination(22, 80, "10.1.10.2", false));
+ dests.add(new LbDestination(22, 80, "10.1.10.2", true));
+ lbs.add(new LoadBalancerTO(UUID.randomUUID().toString(), "64.10.1.10", 80, "tcp", "algo", false, false, false, dests));
+ LoadBalancerTO[] arrayLbs = new LoadBalancerTO[lbs.size()];
+ lbs.toArray(arrayLbs);
+ NicTO nic = new NicTO();
+ LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, null, "1000", true);
+ Answer answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+
+ cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, Long.valueOf(1), "1000", true);
+ answer = _resource.executeRequest(cmd);
+ assertTrue(answer.getResult());
+ }
+
+ private void verifyFile(NetworkElementCommand cmd, String path, String filename, String content) {
+ if (!(cmd instanceof LoadBalancerConfigCommand)) {
+ fail("Only LB command would call this!");
+ }
+ _count ++;
+ switch (_count) {
+ case 1:
+ case 3:
+ assertEquals(path, "/etc/haproxy/");
+ assertEquals(filename, "haproxy.cfg.new");
+ assertEquals(content, "global\n" +
+ "\tlog 127.0.0.1:3914 local0 warning\n" +
+ "\tmaxconn 1000\n" +
+ "\tmaxpipes 250\n" +
+ "\tchroot /var/lib/haproxy\n" +
+ "\tuser haproxy\n" +
+ "\tgroup haproxy\n" +
+ "\tdaemon\n" +
+ "\t \n" +
+ "defaults\n" +
+ "\tlog global\n" +
+ "\tmode tcp\n" +
+ "\toption dontlognull\n" +
+ "\tretries 3\n" +
+ "\toption redispatch\n" +
+ "\t#no option set here :<\n" +
+ "\tno option forceclose\n" +
+ "\ttimeout connect 5000\n" +
+ "\ttimeout client 50000\n" +
+ "\ttimeout server 50000\n" +
+ "\n" +
+ "listen stats_on_guest 10.1.10.2:8081\n" +
+ "\tstats enable\n" +
+ "\tstats uri /admin?stats\n" +
+ "\tstats realm Haproxy\\ Statistics\n" +
+ "\tstats auth admin1:AdMiN123\n" +
+ "\n" +
+ "\t \n" +
+ "listen 64_10_1_10-80 64.10.1.10:80\n" +
+ "\tbalance algo\n" +
+ "\tserver 64_10_1_10-80_0 10.1.10.2:22 check\n" +
+ "\t \n" +
+ "\t \n");
+ break;
+ default:
+ fail();
+ }
+ }
+
+ private void verifyArgs(LoadBalancerConfigCommand cmd, String script, String args) {
+ _count ++;
+ switch (_count) {
+ case 2:
+ assertEquals(script, VRScripts.LB);
+ assertEquals(args, " -i null -a 64.10.1.10:80:, -s 10.1.10.2:8081:0/0:,,");
+ break;
+ case 4:
+ assertEquals(script, VRScripts.VPC_LB);
+ assertEquals(args, " -i null -a 64.10.1.10:80:, -s 10.1.10.2:8081:0/0:,,");
+ break;
+ default:
+ fail();
+ }
+ }
+
+}
+
[23/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Nvp and rest refactoring and more tests
Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/510972ab
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/510972ab
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/510972ab
Branch: refs/heads/ui-restyle
Commit: 510972abde3b5435ed2a4d02fc4f59a1f6dabefe
Parents: dda47db
Author: Antonio Fornie <af...@schubergphilis.com>
Authored: Wed Feb 5 10:01:06 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Feb 18 09:51:54 2014 +0100
----------------------------------------------------------------------
.../network/nicira/AccessConfiguration.java | 90 +--
.../src/com/cloud/network/nicira/Acl.java | 1 -
.../cloud/network/nicira/BaseNiciraEntity.java | 85 +++
.../network/nicira/BaseNiciraNamedEntity.java | 44 ++
.../com/cloud/network/nicira/LogicalRouter.java | 71 ++
.../network/nicira/LogicalRouterConfig.java | 65 --
.../cloud/network/nicira/LogicalRouterPort.java | 41 +-
.../com/cloud/network/nicira/LogicalSwitch.java | 68 +-
.../cloud/network/nicira/LogicalSwitchPort.java | 50 +-
.../com/cloud/network/nicira/NiciraNvpApi.java | 745 +++++++------------
...SingleDefaultRouteImplicitRoutingConfig.java | 40 +
.../SingleDefaultRouteImplictRoutingConfig.java | 40 -
.../com/cloud/network/nicira/VifAttachment.java | 35 +-
.../network/resource/NiciraNvpResource.java | 20 +-
.../network/element/NiciraNvpElementTest.java | 42 +-
.../guru/NiciraNvpGuestNetworkGuruTest.java | 154 ++--
.../com/cloud/network/nicira/NatRuleTest.java | 12 +-
.../cloud/network/nicira/NiciraNvpApiIT.java | 200 ++++-
.../cloud/network/nicira/NiciraNvpApiTest.java | 650 ++++++----------
.../com/cloud/network/nicira/NiciraTagTest.java | 8 +-
.../network/resource/NiciraNvpResourceTest.java | 258 ++++---
pom.xml | 6 +
utils/pom.xml | 27 +
.../BasicEncodedRESTValidationStrategy.java | 47 ++
.../utils/rest/CloudstackRESTException.java | 36 +
.../cloud/utils/rest/RESTServiceConnector.java | 377 ++++++++++
.../utils/rest/RESTValidationStrategy.java | 146 ++++
.../utils/rest/RESTServiceConnectorTest.java | 373 ++++++++++
28 files changed, 2277 insertions(+), 1454 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java
index 487f14b..b5291dc 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessConfiguration.java
@@ -19,32 +19,12 @@
package com.cloud.network.nicira;
-import java.io.Serializable;
import java.util.List;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
+public abstract class AccessConfiguration<T extends AccessRule> extends BaseNiciraNamedEntity {
-@SuppressWarnings("serial")
-public abstract class AccessConfiguration<T extends AccessRule> implements Serializable {
-
- protected String displayName;
protected List<T> logicalPortEgressRules;
protected List<T> logicalPortIngressRules;
- protected List<NiciraNvpTag> tags;
- protected String uuid;
- protected String href;
- protected String schema;
-
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(final String displayName) {
- this.displayName = displayName;
- }
public List<T> getLogicalPortEgressRules() {
return logicalPortEgressRules;
@@ -61,72 +41,4 @@ public abstract class AccessConfiguration<T extends AccessRule> implements Seria
public void setLogicalPortIngressRules(final List<T> logicalPortIngressRules) {
this.logicalPortIngressRules = logicalPortIngressRules;
}
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(final String uuid) {
- this.uuid = uuid;
- }
-
- public String getHref() {
- return href;
- }
-
- public void setHref(final String href) {
- this.href = href;
- }
-
- public String getSchema() {
- return schema;
- }
-
- public void setSchema(final String schema) {
- this.schema = schema;
- }
-
- public List<NiciraNvpTag> getTags() {
- return tags;
- }
-
- public void setTags(final List<NiciraNvpTag> tags) {
- this.tags = tags;
- }
-
- @Override
- public String toString() {
- return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false);
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 31)
- .append(displayName).append(logicalPortEgressRules)
- .append(logicalPortIngressRules).append(tags)
- .append(uuid).append(href).append(schema)
- .toHashCode();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (!(this.getClass().isInstance(obj))) {
- return false;
- }
- final AccessConfiguration<? extends AccessRule> another =
- (AccessConfiguration<? extends AccessRule>) obj;
- return new EqualsBuilder()
- .append(displayName, another.displayName)
- .append(uuid, another.uuid)
- .append(href, another.href)
- .append(schema, another.schema)
- .isEquals();
- }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java
index 976177f..870124e 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java
@@ -19,6 +19,5 @@
package com.cloud.network.nicira;
-@SuppressWarnings("serial")
public class Acl extends AccessConfiguration<AclRule> {
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraEntity.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraEntity.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraEntity.java
new file mode 100644
index 0000000..afcd233
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraEntity.java
@@ -0,0 +1,85 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
+package com.cloud.network.nicira;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+public abstract class BaseNiciraEntity implements Serializable {
+ protected String href;
+ protected String schema;
+ protected String uuid;
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(final String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(final String href) {
+ this.href = href;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public void setSchema(final String schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false);
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 31)
+ .append(this.getClass())
+ .append(uuid)
+ .toHashCode();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ if (!(this.getClass().isInstance(obj))) {
+ return false;
+ }
+ final BaseNiciraEntity another = (BaseNiciraEntity) obj;
+ return new EqualsBuilder().append(uuid, another.uuid).isEquals();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraNamedEntity.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraNamedEntity.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraNamedEntity.java
new file mode 100644
index 0000000..0e21ddb
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/BaseNiciraNamedEntity.java
@@ -0,0 +1,44 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
+package com.cloud.network.nicira;
+
+import java.util.List;
+
+public abstract class BaseNiciraNamedEntity extends BaseNiciraEntity {
+
+ protected String displayName;
+ protected List<NiciraNvpTag> tags;
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(final String displayName) {
+ this.displayName = displayName;
+ }
+
+ public List<NiciraNvpTag> getTags() {
+ return tags;
+ }
+
+ public void setTags(final List<NiciraNvpTag> tags) {
+ this.tags = tags;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouter.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouter.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouter.java
new file mode 100644
index 0000000..edc9351
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouter.java
@@ -0,0 +1,71 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
+package com.cloud.network.nicira;
+
+
+/**
+ *
+ */
+public class LogicalRouter extends BaseNiciraNamedEntity {
+ public static final String REPLICATION_MODE_SERVICE = "service";
+ public static final String REPLICATION_MODE_SOURCE = "source";
+
+ private final String type = "LogicalRouterConfig";
+ private RoutingConfig routingConfig;
+ private boolean distributed;
+ private boolean natSynchronizationEnabled;
+ private String replicationMode;
+
+ public String getType() {
+ return type;
+ }
+
+ public RoutingConfig getRoutingConfig() {
+ return routingConfig;
+ }
+
+ public void setRoutingConfig(final RoutingConfig routingConfig) {
+ this.routingConfig = routingConfig;
+ }
+
+ public boolean isDistributed() {
+ return distributed;
+ }
+
+ public void setDistributed(final boolean distributed) {
+ this.distributed = distributed;
+ }
+
+ public boolean isNatSynchronizationEnabled() {
+ return natSynchronizationEnabled;
+ }
+
+ public void setNatSynchronizationEnabled(final boolean natSynchronizationEnabled) {
+ this.natSynchronizationEnabled = natSynchronizationEnabled;
+ }
+
+ public String getReplicationMode() {
+ return replicationMode;
+ }
+
+ public void setReplicationMode(final String replicationMode) {
+ this.replicationMode = replicationMode;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
deleted file mode 100644
index b6eaa8f..0000000
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with 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.
-//
-
-package com.cloud.network.nicira;
-
-import java.util.List;
-
-/**
- *
- */
-public class LogicalRouterConfig {
- private String displayName;
- private RoutingConfig routingConfig;
- private final String type = "LogicalRouterConfig";
- private String uuid;
- private List<NiciraNvpTag> tags;
-
- public RoutingConfig getRoutingConfig() {
- return routingConfig;
- }
-
- public void setRoutingConfig(RoutingConfig routingConfig) {
- this.routingConfig = routingConfig;
- }
-
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public List<NiciraNvpTag> getTags() {
- return tags;
- }
-
- public void setTags(List<NiciraNvpTag> tags) {
- this.tags = tags;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
index 8ffe054..d9ee09a 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
@@ -21,24 +21,18 @@ package com.cloud.network.nicira;
import java.util.List;
-/**
- *
- */
-public class LogicalRouterPort {
- private String displayName;
- private List<NiciraNvpTag> tags;
+public class LogicalRouterPort extends BaseNiciraNamedEntity {
private Integer portno;
private boolean adminStatusEnabled;
private List<String> ipAddresses;
private String macAddress;
private final String type = "LogicalRouterPortConfig";
- private String uuid;
public int getPortno() {
return portno;
}
- public void setPortno(int portno) {
+ public void setPortno(final int portno) {
this.portno = portno;
}
@@ -46,7 +40,7 @@ public class LogicalRouterPort {
return adminStatusEnabled;
}
- public void setAdminStatusEnabled(boolean adminStatusEnabled) {
+ public void setAdminStatusEnabled(final boolean adminStatusEnabled) {
this.adminStatusEnabled = adminStatusEnabled;
}
@@ -54,7 +48,7 @@ public class LogicalRouterPort {
return ipAddresses;
}
- public void setIpAddresses(List<String> ipAddresses) {
+ public void setIpAddresses(final List<String> ipAddresses) {
this.ipAddresses = ipAddresses;
}
@@ -62,32 +56,7 @@ public class LogicalRouterPort {
return macAddress;
}
- public void setMacAddress(String macAddress) {
+ public void setMacAddress(final String macAddress) {
this.macAddress = macAddress;
}
-
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- public List<NiciraNvpTag> getTags() {
- return tags;
- }
-
- public void setTags(List<NiciraNvpTag> tags) {
- this.tags = tags;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
index 2379354..b527d94 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
@@ -21,29 +21,20 @@ package com.cloud.network.nicira;
import java.util.List;
-public class LogicalSwitch {
- private String displayName;
+public class LogicalSwitch extends BaseNiciraNamedEntity {
+ public static final String REPLICATION_MODE_SERVICE = "service";
+ public static final String REPLICATION_MODE_SOURCE = "source";
+
+ private final String type = "LogicalSwitchConfig";
private boolean portIsolationEnabled;
- private List<NiciraNvpTag> tags;
private List<TransportZoneBinding> transportZones;
- private String type;
- private String uuid;
- private String href;
- private String schema;
-
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
+ private String replicationMode;
public boolean isPortIsolationEnabled() {
return portIsolationEnabled;
}
- public void setPortIsolationEnabled(boolean portIsolationEnabled) {
+ public void setPortIsolationEnabled(final boolean portIsolationEnabled) {
this.portIsolationEnabled = portIsolationEnabled;
}
@@ -51,48 +42,19 @@ public class LogicalSwitch {
return type;
}
- public void setType(String type) {
- this.type = type;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
- public String getHref() {
- return href;
- }
-
- public void setHref(String href) {
- this.href = href;
- }
-
- public String getSchema() {
- return schema;
- }
-
- public void setSchema(String schema) {
- this.schema = schema;
- }
-
- public List<NiciraNvpTag> getTags() {
- return tags;
- }
-
- public void setTags(List<NiciraNvpTag> tags) {
- this.tags = tags;
- }
-
public List<TransportZoneBinding> getTransportZones() {
return transportZones;
}
- public void setTransportZones(List<TransportZoneBinding> transportZones) {
+ public void setTransportZones(final List<TransportZoneBinding> transportZones) {
this.transportZones = transportZones;
}
+ public String getReplicationMode() {
+ return replicationMode;
+ }
+
+ public void setReplicationMode(final String replicationMode) {
+ this.replicationMode = replicationMode;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
index 3565fbe..5e07423 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
@@ -21,16 +21,13 @@ package com.cloud.network.nicira;
import java.util.List;
-public class LogicalSwitchPort {
- private String displayName;
- private List<NiciraNvpTag> tags;
+public class LogicalSwitchPort extends BaseNiciraNamedEntity {
private Integer portno;
private boolean adminStatusEnabled;
private String queueUuid;
private List<String> securityProfiles;
private List<String> mirrorTargets;
- private String type;
- private String uuid;
+ private final String type = "LogicalSwitchPortConfig";
public LogicalSwitchPort() {
super();
@@ -43,27 +40,11 @@ public class LogicalSwitchPort {
this.adminStatusEnabled = adminStatusEnabled;
}
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
- public List<NiciraNvpTag> getTags() {
- return tags;
- }
-
- public void setTags(List<NiciraNvpTag> tags) {
- this.tags = tags;
- }
-
public Integer getPortno() {
return portno;
}
- public void setPortno(Integer portno) {
+ public void setPortno(final Integer portno) {
this.portno = portno;
}
@@ -71,7 +52,7 @@ public class LogicalSwitchPort {
return adminStatusEnabled;
}
- public void setAdminStatusEnabled(boolean adminStatusEnabled) {
+ public void setAdminStatusEnabled(final boolean adminStatusEnabled) {
this.adminStatusEnabled = adminStatusEnabled;
}
@@ -79,7 +60,7 @@ public class LogicalSwitchPort {
return queueUuid;
}
- public void setQueueUuid(String queueUuid) {
+ public void setQueueUuid(final String queueUuid) {
this.queueUuid = queueUuid;
}
@@ -87,7 +68,7 @@ public class LogicalSwitchPort {
return securityProfiles;
}
- public void setSecurityProfiles(List<String> securityProfiles) {
+ public void setSecurityProfiles(final List<String> securityProfiles) {
this.securityProfiles = securityProfiles;
}
@@ -95,24 +76,7 @@ public class LogicalSwitchPort {
return mirrorTargets;
}
- public void setMirrorTargets(List<String> mirrorTargets) {
+ public void setMirrorTargets(final List<String> mirrorTargets) {
this.mirrorTargets = mirrorTargets;
}
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
index 83d0075..3861d63 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
@@ -18,55 +18,14 @@
//
package com.cloud.network.nicira;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
-import java.net.Socket;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.UUID;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.commons.httpclient.ConnectTimeoutException;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.apache.commons.httpclient.params.HttpConnectionParams;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
-import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
-import org.apache.log4j.Logger;
-
-import com.google.gson.FieldNamingPolicy;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
@@ -74,33 +33,24 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
+import com.cloud.utils.rest.CloudstackRESTException;
+import com.cloud.utils.rest.RESTServiceConnector;
+import com.cloud.utils.rest.RESTValidationStrategy;
+
@SuppressWarnings("rawtypes")
public class NiciraNvpApi {
protected static final String GET_METHOD_TYPE = "get";
protected static final String DELETE_METHOD_TYPE = "delete";
protected static final String PUT_METHOD_TYPE = "put";
protected static final String POST_METHOD_TYPE = "post";
- private static final String TEXT_HTML_CONTENT_TYPE = "text/html";
- private static final String JSON_CONTENT_TYPE = "application/json";
- private static final String CONTENT_TYPE = "Content-Type";
- private static final int BODY_RESP_MAX_LEN = 1024;
+
protected static final String SEC_PROFILE_URI_PREFIX = "/ws.v1/security-profile";
protected static final String ACL_URI_PREFIX = "/ws.v1/acl";
private static final String SWITCH_URI_PREFIX = "/ws.v1/lswitch";
private static final String ROUTER_URI_PREFIX = "/ws.v1/lrouter";
- private static final int HTTPS_PORT = 443;
- private static final Logger s_logger = Logger.getLogger(NiciraNvpApi.class);
- private final static String protocol = "https";
- private final static MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
-
- private String host;
- private String adminuser;
- private String adminpass;
-
- private final HttpClient client;
- private String nvpVersion;
+ private static final String LOGIN_URL = "/ws.v1/login";
- private final Gson gson;
+ protected RESTServiceConnector restConnector;
protected final static Map<Class, String> prefixMap;
@@ -112,115 +62,174 @@ public class NiciraNvpApi {
prefixMap = new HashMap<Class, String>();
prefixMap.put(SecurityProfile.class, SEC_PROFILE_URI_PREFIX);
prefixMap.put(Acl.class, ACL_URI_PREFIX);
+ prefixMap.put(LogicalSwitch.class, SWITCH_URI_PREFIX);
+ prefixMap.put(LogicalRouter.class, ROUTER_URI_PREFIX);
listTypeMap = new HashMap<Class, Type>();
listTypeMap.put(SecurityProfile.class, new TypeToken<NiciraNvpList<SecurityProfile>>() {
}.getType());
listTypeMap.put(Acl.class, new TypeToken<NiciraNvpList<Acl>>() {
}.getType());
+ listTypeMap.put(LogicalSwitch.class, new TypeToken<NiciraNvpList<LogicalSwitch>>() {
+ }.getType());
+ listTypeMap.put(LogicalRouter.class, new TypeToken<NiciraNvpList<LogicalRouter>>() {
+ }.getType());
defaultListParams = new HashMap<String, String>();
defaultListParams.put("fields", "*");
}
- /* This factory method is protected so we can extend this
- * in the unittests.
- */
- protected HttpClient createHttpClient() {
- return new HttpClient(s_httpClientManager);
+ public NiciraNvpApi() {
+ final List<Class<?>> classList = new ArrayList<Class<?>>();
+ classList.add(NatRule.class);
+ classList.add(RoutingConfig.class);
+ final List<JsonDeserializer<?>> deserializerList = new ArrayList<JsonDeserializer<?>>();
+ deserializerList.add(new NatRuleAdapter());
+ deserializerList.add(new RoutingConfigAdapter());
+
+ restConnector = new RESTServiceConnector(new RESTValidationStrategy(LOGIN_URL), classList, deserializerList);
}
- protected HttpMethod createMethod(final String type, final String uri) throws NiciraNvpApiException {
- String url;
- try {
- url = new URL(protocol, host, uri).toString();
- } catch (final MalformedURLException e) {
- s_logger.error("Unable to build Nicira API URL", e);
- throw new NiciraNvpApiException("Unable to build Nicira API URL", e);
- }
+ public NiciraNvpApi(final String address, final String username, final String password) {
+ this();
+ restConnector.setControllerAddress(address);
+ restConnector.setAdminCredentials(username, password);
+ }
- if (POST_METHOD_TYPE.equalsIgnoreCase(type)) {
- return new PostMethod(url);
- } else if (GET_METHOD_TYPE.equalsIgnoreCase(type)) {
- return new GetMethod(url);
- } else if (DELETE_METHOD_TYPE.equalsIgnoreCase(type)) {
- return new DeleteMethod(url);
- } else if (PUT_METHOD_TYPE.equalsIgnoreCase(type)) {
- return new PutMethod(url);
- } else {
- throw new NiciraNvpApiException("Requesting unknown method type");
- }
+ public void setControllerAddress(final String address) {
+ restConnector.setControllerAddress(address);
}
- public NiciraNvpApi() {
- client = createHttpClient();
- client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+ public void setAdminCredentials(final String username, final String password) {
+ restConnector.setAdminCredentials(username, password);
+ }
+
+ /**
+ * POST
+ *
+ * @param entity
+ * @return
+ * @throws NiciraNvpApiException
+ */
+ protected <T> T create(final T entity) throws NiciraNvpApiException {
+ final String uri = prefixMap.get(entity.getClass());
+ return createWithUri(entity, uri);
+ }
+ /**
+ * POST
+ *
+ * @param entity
+ * @return
+ * @throws NiciraNvpApiException
+ */
+ protected <T> T createWithUri(final T entity, final String uri) throws NiciraNvpApiException {
+ T createdEntity;
try {
- // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
- Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory)new TrustingProtocolSocketFactory(), HTTPS_PORT));
- } catch (final IOException e) {
- s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e);
+ createdEntity = restConnector.executeCreateObject(entity, new TypeToken<T>() {
+ }.getType(), uri, Collections.<String, String> emptyMap());
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
}
- gson = new GsonBuilder().registerTypeAdapter(NatRule.class, new NatRuleAdapter()).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
- }
-
- public void setControllerAddress(final String address) {
- host = address;
+ return createdEntity;
}
- public void setAdminCredentials(final String username, final String password) {
- adminuser = username;
- adminpass = password;
+ /**
+ * GET list of items
+ *
+ * @return
+ * @throws NiciraNvpApiException
+ */
+ protected <T> NiciraNvpList<T> find(final Class<T> clazz) throws NiciraNvpApiException {
+ return find(null, clazz);
}
/**
- * Logs into the Nicira API. The cookie is stored in the <code>_authcookie<code> variable.
- * <p>
- * The method returns false if the login failed or the connection could not be made.
+ * GET list of items
*
+ * @param uuid
+ * @return
+ * @throws NiciraNvpApiException
*/
- protected void login() throws NiciraNvpApiException {
- String url;
-
- if (host == null || host.isEmpty() || adminuser == null || adminuser.isEmpty() || adminpass == null || adminpass.isEmpty()) {
- throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+ public <T> NiciraNvpList<T> find(final String uuid, final Class<T> clazz) throws NiciraNvpApiException {
+ final String uri = prefixMap.get(clazz);
+ Map<String, String> params = defaultListParams;
+ if (uuid != null) {
+ params = new HashMap<String, String>(defaultListParams);
+ params.put("uuid", uuid);
}
+ NiciraNvpList<T> entities;
try {
- url = new URL(protocol, host, "/ws.v1/login").toString();
- } catch (final MalformedURLException e) {
- s_logger.error("Unable to build Nicira API URL", e);
- throw new NiciraNvpApiException("Unable to build Nicira API URL", e);
+ entities = restConnector.executeRetrieveObject(listTypeMap.get(clazz), uri, params);
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
}
- final PostMethod pm = new PostMethod(url);
- pm.addParameter("username", adminuser);
- pm.addParameter("password", adminpass);
+ if (entities == null) {
+ throw new NiciraNvpApiException("Unexpected response from API");
+ }
+ return entities;
+ }
+
+ /**
+ * PUT item given a UUID as key and an item object
+ * with the new data
+ *
+ * @param item
+ * @param uuid
+ * @throws NiciraNvpApiException
+ */
+ public <T> void update(final T item, final String uuid)
+ throws NiciraNvpApiException {
+ final String uri = prefixMap.get(item.getClass()) + "/" + uuid;
+ updateWithUri(item, uri);
+ }
+
+ /**
+ * PUT item given a UUID as key and an item object
+ * with the new data
+ *
+ * @param item
+ * @param uuid
+ * @throws NiciraNvpApiException
+ */
+ public <T> void updateWithUri(final T item, final String uri)
+ throws NiciraNvpApiException {
try {
- client.executeMethod(pm);
- } catch (final HttpException e) {
- throw new NiciraNvpApiException("Nicira NVP API login failed ", e);
- } catch (final IOException e) {
- throw new NiciraNvpApiException("Nicira NVP API login failed ", e);
- } finally {
- pm.releaseConnection();
+ restConnector.executeUpdateObject(item, uri, Collections.<String, String> emptyMap());
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
}
+ }
- if (pm.getStatusCode() != HttpStatus.SC_OK) {
- s_logger.error("Nicira NVP API login failed : " + pm.getStatusText());
- throw new NiciraNvpApiException("Nicira NVP API login failed " + pm.getStatusText());
- }
+ /**
+ * DELETE Security Profile given a UUID as key
+ *
+ * @param securityProfileUuid
+ * @throws NiciraNvpApiException
+ */
+ public <T> void delete(final String uuid, final Class<T> clazz)
+ throws NiciraNvpApiException {
+ final String uri = prefixMap.get(clazz) + "/" + uuid;
+ deleteWithUri(uri);
+ }
- // Extract the version for later use
- if (pm.getResponseHeader("Server") != null) {
- nvpVersion = pm.getResponseHeader("Server").getValue();
- s_logger.debug("NVP Controller reports version " + nvpVersion);
+ /**
+ * DELETE Security Profile given a UUID as key
+ *
+ * @param securityProfileUuid
+ * @throws NiciraNvpApiException
+ */
+ public <T> void deleteWithUri(final String uri)
+ throws NiciraNvpApiException {
+ try {
+ restConnector.executeDeleteObject(uri);
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
}
-
- // Success; the cookie required for login is kept in _client
}
/**
@@ -341,111 +350,68 @@ public class NiciraNvpApi {
delete(aclUuid, Acl.class);
}
- /**
- * POST
- *
- * @param entity
- * @return
- * @throws NiciraNvpApiException
- */
- protected <T> T create(final T entity) throws NiciraNvpApiException {
- final String uri = prefixMap.get(entity.getClass());
- final T createdEntity = executeCreateObject(entity, new TypeToken<T>() {
- }.getType(), uri, Collections.<String, String> emptyMap());
-
- return createdEntity;
+ public LogicalSwitch createLogicalSwitch(final LogicalSwitch logicalSwitch) throws NiciraNvpApiException {
+ return create(logicalSwitch);
}
/**
- * GET list of items
+ * GET list of {@link LogicalSwitch}
*
* @return
* @throws NiciraNvpApiException
*/
- protected <T> NiciraNvpList<T> find(final Class<T> clazz) throws NiciraNvpApiException {
- return find(null, clazz);
+ public NiciraNvpList<LogicalSwitch> findLogicalSwitch() throws NiciraNvpApiException {
+ return findLogicalSwitch(null);
}
/**
- * GET list of items
+ * GET list of {@link LogicalSwitch} filtered by UUID
*
* @param uuid
* @return
* @throws NiciraNvpApiException
*/
- public <T> NiciraNvpList<T> find(final String uuid, final Class<T> clazz) throws NiciraNvpApiException {
- final String uri = prefixMap.get(clazz);
- Map<String, String> params = defaultListParams;
- if (uuid != null) {
- params = new HashMap<String, String>(defaultListParams);
- params.put("uuid", uuid);
- }
-
- final NiciraNvpList<T> entities = executeRetrieveObject(listTypeMap.get(clazz), uri, params);
-
- if (entities == null) {
- throw new NiciraNvpApiException("Unexpected response from API");
- }
-
- return entities;
+ public NiciraNvpList<LogicalSwitch> findLogicalSwitch(final String uuid) throws NiciraNvpApiException {
+ return find(uuid, LogicalSwitch.class);
}
/**
- * PUT item given a UUID as key and an item object
+ * PUT {@link LogicalSwitch} given a UUID as key and a {@link LogicalSwitch}
* with the new data
*
- * @param item
- * @param uuid
+ * @param logicalSwitch
+ * @param logicalSwitchUuid
* @throws NiciraNvpApiException
*/
- public <T> void update(final T item,
- final String uuid)
+ public void updateLogicalSwitch(final LogicalSwitch logicalSwitch,
+ final String logicalSwitchUuid)
throws NiciraNvpApiException {
- final String uri = prefixMap.get(item.getClass()) + "/" + uuid;
- executeUpdateObject(item, uri, Collections.<String, String> emptyMap());
- }
-
- /**
- * DELETE Security Profile given a UUID as key
- *
- * @param securityProfileUuid
- * @throws NiciraNvpApiException
- */
- public <T> void delete(final String uuid, final Class<T> clazz)
- throws NiciraNvpApiException {
- final String uri = prefixMap.get(clazz) + "/" + uuid;
- executeDeleteObject(uri);
- }
-
- public LogicalSwitch createLogicalSwitch(final LogicalSwitch logicalSwitch) throws NiciraNvpApiException {
- final String uri = SWITCH_URI_PREFIX;
- final LogicalSwitch createdLogicalSwitch = executeCreateObject(logicalSwitch, new TypeToken<LogicalSwitch>() {
- }.getType(), uri, Collections.<String, String> emptyMap());
-
- return createdLogicalSwitch;
+ update(logicalSwitch, logicalSwitchUuid);
}
public void deleteLogicalSwitch(final String uuid) throws NiciraNvpApiException {
- final String uri = SWITCH_URI_PREFIX + "/" + uuid;
- executeDeleteObject(uri);
+ delete(uuid, LogicalSwitch.class);
}
public LogicalSwitchPort createLogicalSwitchPort(final String logicalSwitchUuid, final LogicalSwitchPort logicalSwitchPort) throws NiciraNvpApiException {
final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport";
- final LogicalSwitchPort createdLogicalSwitchPort = executeCreateObject(logicalSwitchPort, new TypeToken<LogicalSwitchPort>() {
- }.getType(), uri, Collections.<String, String> emptyMap());
+ return createWithUri(logicalSwitchPort, uri);
+ }
- return createdLogicalSwitchPort;
+ public void updateLogicalSwitchPort(final String logicalSwitchUuid, final LogicalSwitchPort logicalSwitchPort) throws NiciraNvpApiException {
+ final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPort.getUuid();
+ updateWithUri(logicalSwitchPort, uri);
}
- public void modifyLogicalSwitchPortAttachment(final String logicalSwitchUuid, final String logicalSwitchPortUuid, final Attachment attachment) throws NiciraNvpApiException {
+ public void updateLogicalSwitchPortAttachment(final String logicalSwitchUuid, final String logicalSwitchPortUuid,
+ final Attachment attachment) throws NiciraNvpApiException {
final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid + "/attachment";
- executeUpdateObject(attachment, uri, Collections.<String, String> emptyMap());
+ updateWithUri(attachment, uri);
}
public void deleteLogicalSwitchPort(final String logicalSwitchUuid, final String logicalSwitchPortUuid) throws NiciraNvpApiException {
final String uri = SWITCH_URI_PREFIX + "/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid;
- executeDeleteObject(uri);
+ deleteWithUri(uri);
}
public String findLogicalSwitchPortUuidByVifAttachmentUuid(final String logicalSwitchUuid, final String vifAttachmentUuid) throws NiciraNvpApiException {
@@ -454,8 +420,13 @@ public class NiciraNvpApi {
params.put("attachment_vif_uuid", vifAttachmentUuid);
params.put("fields", "uuid");
- final NiciraNvpList<LogicalSwitchPort> lspl = executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>() {
- }.getType(), uri, params);
+ NiciraNvpList<LogicalSwitchPort> lspl;
+ try {
+ lspl = restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>() {
+ }.getType(), uri, params);
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
+ }
if (lspl == null || lspl.getResultCount() != 1) {
throw new NiciraNvpApiException("Unexpected response from API");
@@ -467,8 +438,13 @@ public class NiciraNvpApi {
public ControlClusterStatus getControlClusterStatus() throws NiciraNvpApiException {
final String uri = "/ws.v1/control-cluster/status";
- final ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>() {
- }.getType(), uri, null);
+ ControlClusterStatus ccs;
+ try {
+ ccs = restConnector.executeRetrieveObject(new TypeToken<ControlClusterStatus>() {
+ }.getType(), uri, null);
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
+ }
return ccs;
}
@@ -479,8 +455,13 @@ public class NiciraNvpApi {
params.put("uuid", logicalSwitchPortUuid);
params.put("fields", "uuid");
- final NiciraNvpList<LogicalSwitchPort> lspl = executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>() {
- }.getType(), uri, params);
+ NiciraNvpList<LogicalSwitchPort> lspl;
+ try {
+ lspl = restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>() {
+ }.getType(), uri, params);
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
+ }
if (lspl == null) {
throw new NiciraNvpApiException("Unexpected response from API");
@@ -489,64 +470,101 @@ public class NiciraNvpApi {
return lspl;
}
- public LogicalRouterConfig createLogicalRouter(final LogicalRouterConfig logicalRouterConfig) throws NiciraNvpApiException {
- final String uri = ROUTER_URI_PREFIX;
+ public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortsByUuid(final String logicalRouterUuid, final String logicalRouterPortUuid) throws NiciraNvpApiException {
+ final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport";
+ final Map<String, String> params = new HashMap<String, String>();
+ params.put("uuid", logicalRouterPortUuid);
+ params.put("fields", "uuid");
+
+ NiciraNvpList<LogicalRouterPort> lrpl;
+ try {
+ lrpl = restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
+ }.getType(), uri, params);
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
+ }
+
+ if (lrpl == null) {
+ throw new NiciraNvpApiException("Unexpected response from API");
+ }
+
+ return lrpl;
+ }
+
+ public LogicalRouter createLogicalRouter(final LogicalRouter logicalRouter) throws NiciraNvpApiException {
+ return create(logicalRouter);
+ }
+
+ /**
+ * GET list of {@link LogicalRouter}
+ *
+ * @return
+ * @throws NiciraNvpApiException
+ */
+ public NiciraNvpList<LogicalRouter> findLogicalRouter() throws NiciraNvpApiException {
+ return findLogicalRouter(null);
+ }
+
+ /**
+ * GET list of {@link LogicalRouter} filtered by UUID
+ *
+ * @param uuid
+ * @return
+ * @throws NiciraNvpApiException
+ */
+ public NiciraNvpList<LogicalRouter> findLogicalRouter(final String uuid) throws NiciraNvpApiException {
+ return find(uuid, LogicalRouter.class);
+ }
- final LogicalRouterConfig lrc = executeCreateObject(logicalRouterConfig, new TypeToken<LogicalRouterConfig>() {
- }.getType(), uri, Collections.<String, String> emptyMap());
+ public LogicalRouter findOneLogicalRouterByUuid(final String logicalRouterUuid) throws NiciraNvpApiException {
+ return findLogicalRouter(logicalRouterUuid).getResults().get(0);
+ }
- return lrc;
+ public void updateLogicalRouter(final LogicalRouter logicalRouter,
+ final String logicalRouterUuid)
+ throws NiciraNvpApiException {
+ update(logicalRouter, logicalRouterUuid);
}
public void deleteLogicalRouter(final String logicalRouterUuid) throws NiciraNvpApiException {
final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid;
-
- executeDeleteObject(uri);
+ deleteWithUri(uri);
}
public LogicalRouterPort createLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport";
-
- final LogicalRouterPort lrp = executeCreateObject(logicalRouterPort, new TypeToken<LogicalRouterPort>() {
- }.getType(), uri, Collections.<String, String> emptyMap());
- return lrp;
+ return createWithUri(logicalRouterPort, uri);
}
public void deleteLogicalRouterPort(final String logicalRouterUuid, final String logicalRouterPortUuid) throws NiciraNvpApiException {
final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPortUuid;
-
- executeDeleteObject(uri);
+ deleteWithUri(uri);
}
- public void modifyLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
+ public void updateLogicalRouterPort(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPort.getUuid();
-
- executeUpdateObject(logicalRouterPort, uri, Collections.<String, String> emptyMap());
+ updateWithUri(logicalRouterPort, uri);
}
- public void modifyLogicalRouterPortAttachment(final String logicalRouterUuid, final String logicalRouterPortUuid, final Attachment attachment)
+ public void updateLogicalRouterPortAttachment(final String logicalRouterUuid, final String logicalRouterPortUuid, final Attachment attachment)
throws NiciraNvpApiException {
final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport/" + logicalRouterPortUuid + "/attachment";
- executeUpdateObject(attachment, uri, Collections.<String, String> emptyMap());
+ updateWithUri(attachment, uri);
}
public NatRule createLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException {
final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat";
-
- return executeCreateObject(natRule, new TypeToken<NatRule>() {
- }.getType(), uri, Collections.<String, String> emptyMap());
+ return createWithUri(natRule, uri);
}
- public void modifyLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException {
+ public void updateLogicalRouterNatRule(final String logicalRouterUuid, final NatRule natRule) throws NiciraNvpApiException {
final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat/" + natRule.getUuid();
-
- executeUpdateObject(natRule, uri, Collections.<String, String> emptyMap());
+ updateWithUri(natRule, uri);
}
public void deleteLogicalRouterNatRule(final String logicalRouterUuid, final UUID natRuleUuid) throws NiciraNvpApiException {
final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/nat/" + natRuleUuid.toString();
-
- executeDeleteObject(uri);
+ deleteWithUri(uri);
}
public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceAndVlanId(final String logicalRouterUuid, final String gatewayServiceUuid,
@@ -557,21 +575,12 @@ public class NiciraNvpApi {
params.put("attachment_vlan", "0");
params.put("fields", "*");
- return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
- }.getType(), uri, params);
- }
-
- public LogicalRouterConfig findOneLogicalRouterByUuid(final String logicalRouterUuid) throws NiciraNvpApiException {
- final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid;
-
- return executeRetrieveObject(new TypeToken<LogicalRouterConfig>() {
- }.getType(), uri, Collections.<String, String> emptyMap());
- }
-
- public void updateLogicalRouterPortConfig(final String logicalRouterUuid, final LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
- final String uri = ROUTER_URI_PREFIX + "/" + logicalRouterUuid + "/lport" + logicalRouterPort.getUuid();
-
- executeUpdateObject(logicalRouterPort, uri, Collections.<String, String> emptyMap());
+ try {
+ return restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
+ }.getType(), uri, params);
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
+ }
}
public NiciraNvpList<NatRule> findNatRulesByLogicalRouterUuid(final String logicalRouterUuid) throws NiciraNvpApiException {
@@ -579,8 +588,12 @@ public class NiciraNvpApi {
final Map<String, String> params = new HashMap<String, String>();
params.put("fields", "*");
- return executeRetrieveObject(new TypeToken<NiciraNvpList<NatRule>>() {
- }.getType(), uri, params);
+ try {
+ return restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<NatRule>>() {
+ }.getType(), uri, params);
+ } catch (final CloudstackRESTException e) {
+ throw new NiciraNvpApiException(e);
+ }
}
public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceUuid(final String logicalRouterUuid, final String l3GatewayServiceUuid)
@@ -590,231 +603,11 @@ public class NiciraNvpApi {
params.put("fields", "*");
params.put("attachment_gwsvc_uuid", l3GatewayServiceUuid);
- return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
- }.getType(), uri, params);
- }
-
- protected <T> void executeUpdateObject(final T newObject, final String uri, final Map<String, String> parameters) throws NiciraNvpApiException {
- if (host == null || host.isEmpty() || adminuser == null || adminuser.isEmpty() || adminpass == null || adminpass.isEmpty()) {
- throw new NiciraNvpApiException("Hostname/credentials are null or empty");
- }
-
- final PutMethod pm = (PutMethod)createMethod(PUT_METHOD_TYPE, uri);
- pm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
try {
- pm.setRequestEntity(new StringRequestEntity(gson.toJson(newObject), JSON_CONTENT_TYPE, null));
- } catch (final UnsupportedEncodingException e) {
- throw new NiciraNvpApiException("Failed to encode json request body", e);
- }
-
- executeMethod(pm);
-
- if (pm.getStatusCode() != HttpStatus.SC_OK) {
- final String errorMessage = responseToErrorMessage(pm);
- pm.releaseConnection();
- s_logger.error("Failed to update object : " + errorMessage);
- throw new NiciraNvpApiException("Failed to update object : " + errorMessage);
- }
- pm.releaseConnection();
- }
-
- @SuppressWarnings("unchecked")
- protected <T> T executeCreateObject(final T newObject, final Type returnObjectType, final String uri, final Map<String, String> parameters)
- throws NiciraNvpApiException {
- if (host == null || host.isEmpty() || adminuser == null || adminuser.isEmpty() || adminpass == null || adminpass.isEmpty()) {
- throw new NiciraNvpApiException("Hostname/credentials are null or empty");
- }
-
- final PostMethod pm = (PostMethod)createMethod(POST_METHOD_TYPE, uri);
- pm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
- try {
- pm.setRequestEntity(new StringRequestEntity(gson.toJson(newObject), JSON_CONTENT_TYPE, null));
- } catch (final UnsupportedEncodingException e) {
- throw new NiciraNvpApiException("Failed to encode json request body", e);
- }
-
- executeMethod(pm);
-
- if (pm.getStatusCode() != HttpStatus.SC_CREATED) {
- final String errorMessage = responseToErrorMessage(pm);
- pm.releaseConnection();
- s_logger.error("Failed to create object : " + errorMessage);
- throw new NiciraNvpApiException("Failed to create object : " + errorMessage);
- }
-
- T result;
- try {
- result = (T)gson.fromJson(pm.getResponseBodyAsString(), TypeToken.get(newObject.getClass()).getType());
- } catch (final IOException e) {
- throw new NiciraNvpApiException("Failed to decode json response body", e);
- } finally {
- pm.releaseConnection();
- }
-
- return result;
- }
-
- protected void executeDeleteObject(final String uri) throws NiciraNvpApiException {
- if (host == null || host.isEmpty() || adminuser == null || adminuser.isEmpty() || adminpass == null || adminpass.isEmpty()) {
- throw new NiciraNvpApiException("Hostname/credentials are null or empty");
- }
-
- final DeleteMethod dm = (DeleteMethod)createMethod(DELETE_METHOD_TYPE, uri);
- dm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
-
- executeMethod(dm);
-
- if (dm.getStatusCode() != HttpStatus.SC_NO_CONTENT) {
- final String errorMessage = responseToErrorMessage(dm);
- dm.releaseConnection();
- s_logger.error("Failed to delete object : " + errorMessage);
- throw new NiciraNvpApiException("Failed to delete object : " + errorMessage);
- }
- dm.releaseConnection();
- }
-
- @SuppressWarnings("unchecked")
- protected <T> T executeRetrieveObject(final Type returnObjectType, final String uri, final Map<String, String> parameters) throws NiciraNvpApiException {
- if (host == null || host.isEmpty() || adminuser == null || adminuser.isEmpty() || adminpass == null || adminpass.isEmpty()) {
- throw new NiciraNvpApiException("Hostname/credentials are null or empty");
- }
-
- final GetMethod gm = (GetMethod)createMethod(GET_METHOD_TYPE, uri);
- gm.setRequestHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
- if (parameters != null && !parameters.isEmpty()) {
- final List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
- for (final Entry<String, String> e : parameters.entrySet()) {
- nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
- }
- gm.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
- }
-
- executeMethod(gm);
-
- if (gm.getStatusCode() != HttpStatus.SC_OK) {
- final String errorMessage = responseToErrorMessage(gm);
- gm.releaseConnection();
- s_logger.error("Failed to retrieve object : " + errorMessage);
- throw new NiciraNvpApiException("Failed to retrieve object : " + errorMessage);
- }
-
- T returnValue;
- try {
- returnValue = (T)gson.fromJson(gm.getResponseBodyAsString(), returnObjectType);
- } catch (final IOException e) {
- s_logger.error("IOException while retrieving response body", e);
+ return restConnector.executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>() {
+ }.getType(), uri, params);
+ } catch (final CloudstackRESTException e) {
throw new NiciraNvpApiException(e);
- } finally {
- gm.releaseConnection();
- }
- return returnValue;
- }
-
- protected void executeMethod(final HttpMethodBase method) throws NiciraNvpApiException {
- try {
- client.executeMethod(method);
- if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
- method.releaseConnection();
- // login and try again
- login();
- client.executeMethod(method);
- }
- } catch (final HttpException e) {
- s_logger.error("HttpException caught while trying to connect to the Nicira NVP Controller", e);
- method.releaseConnection();
- throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e);
- } catch (final IOException e) {
- s_logger.error("IOException caught while trying to connect to the Nicira NVP Controller", e);
- method.releaseConnection();
- throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e);
- }
- }
-
- private String responseToErrorMessage(final HttpMethodBase method) {
- assert method.isRequestSent() : "no use getting an error message unless the request is sent";
-
- if (TEXT_HTML_CONTENT_TYPE.equals(method.getResponseHeader(CONTENT_TYPE).getValue())) {
- // The error message is the response content
- // Safety margin of 1024 characters, anything longer is probably useless
- // and will clutter the logs
- try {
- return method.getResponseBodyAsString(BODY_RESP_MAX_LEN);
- } catch (final IOException e) {
- s_logger.debug("Error while loading response body", e);
- }
- }
-
- // The default
- return method.getStatusText();
- }
-
- /* The Nicira controller uses a self-signed certificate. The
- * TrustingProtocolSocketFactory will accept any provided
- * certificate when making an SSL connection to the SDN
- * Manager
- */
- private class TrustingProtocolSocketFactory implements SecureProtocolSocketFactory {
-
- private SSLSocketFactory ssf;
-
- public TrustingProtocolSocketFactory() throws IOException {
- // Create a trust manager that does not validate certificate chains
- final TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
-
- @Override
- public void checkClientTrusted(final X509Certificate[] certs, final String authType) {
- // Trust always
- }
-
- @Override
- public void checkServerTrusted(final X509Certificate[] certs, final String authType) {
- // Trust always
- }
- }};
-
- try {
- // Install the all-trusting trust manager
- final SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, trustAllCerts, new java.security.SecureRandom());
- ssf = sc.getSocketFactory();
- } catch (final KeyManagementException e) {
- throw new IOException(e);
- } catch (final NoSuchAlgorithmException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public Socket createSocket(final String host, final int port) throws IOException {
- return ssf.createSocket(host, port);
- }
-
- @Override
- public Socket createSocket(final String address, final int port, final InetAddress localAddress, final int localPort) throws IOException, UnknownHostException {
- return ssf.createSocket(address, port, localAddress, localPort);
- }
-
- @Override
- public Socket createSocket(final Socket socket, final String host, final int port, final boolean autoClose) throws IOException, UnknownHostException {
- return ssf.createSocket(socket, host, port, autoClose);
- }
-
- @Override
- public Socket createSocket(final String host, final int port, final InetAddress localAddress, final int localPort, final HttpConnectionParams params)
- throws IOException, UnknownHostException, ConnectTimeoutException {
- final int timeout = params.getConnectionTimeout();
- if (timeout == 0) {
- return createSocket(host, port, localAddress, localPort);
- } else {
- final Socket s = ssf.createSocket();
- s.bind(new InetSocketAddress(localAddress, localPort));
- s.connect(new InetSocketAddress(host, port), timeout);
- return s;
- }
}
}
@@ -837,6 +630,24 @@ public class NiciraNvpApi {
throw new JsonParseException("Failed to deserialize type \"" + natRuleType + "\"");
}
+ }
+
+ public static class RoutingConfigAdapter implements JsonDeserializer<RoutingConfig> {
+ @Override
+ public RoutingConfig deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context) throws JsonParseException {
+ final JsonObject jsonObject = jsonElement.getAsJsonObject();
+
+ if (!jsonObject.has("type")) {
+ throw new JsonParseException("Deserializing as a RoutingConfig, but no type present in the json object");
+ }
+
+ final String routingConfigType = jsonObject.get("type").getAsString();
+ if ("SingleDefaultRouteImplicitRoutingConfig".equals(routingConfigType)) {
+ return context.deserialize(jsonElement, SingleDefaultRouteImplicitRoutingConfig.class);
+ }
+
+ throw new JsonParseException("Failed to deserialize type \"" + routingConfigType + "\"");
+ }
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java
new file mode 100644
index 0000000..ea5df2c
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java
@@ -0,0 +1,40 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
+package com.cloud.network.nicira;
+
+/**
+ *
+ */
+public class SingleDefaultRouteImplicitRoutingConfig extends RoutingConfig {
+ public RouterNextHop defaultRouteNextHop;
+ public final String type = "SingleDefaultRouteImplicitRoutingConfig";
+
+ public SingleDefaultRouteImplicitRoutingConfig(final RouterNextHop routerNextHop) {
+ defaultRouteNextHop = routerNextHop;
+ }
+
+ public RouterNextHop getDefaultRouteNextHop() {
+ return defaultRouteNextHop;
+ }
+
+ public void setDefaultRouteNextHop(final RouterNextHop defaultRouteNextHop) {
+ this.defaultRouteNextHop = defaultRouteNextHop;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
deleted file mode 100644
index 0533579..0000000
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with 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.
-//
-
-package com.cloud.network.nicira;
-
-/**
- *
- */
-public class SingleDefaultRouteImplictRoutingConfig extends RoutingConfig {
- public RouterNextHop defaultRouteNextHop;
- public final String type = "SingleDefaultRouteImplicitRoutingConfig";
-
- public SingleDefaultRouteImplictRoutingConfig(RouterNextHop routerNextHop) {
- defaultRouteNextHop = routerNextHop;
- }
-
- public RouterNextHop getDefaultRouteNextHop() {
- return defaultRouteNextHop;
- }
-
- public void setDefaultRouteNextHop(RouterNextHop defaultRouteNextHop) {
- this.defaultRouteNextHop = defaultRouteNextHop;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
index 87765be..fe7d93a 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
@@ -19,6 +19,11 @@
package com.cloud.network.nicira;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
public class VifAttachment extends Attachment {
private final String type = "VifAttachment";
private String vifUuid;
@@ -34,7 +39,7 @@ public class VifAttachment extends Attachment {
return vifUuid;
}
- public void setVifUuid(String vifUuid) {
+ public void setVifUuid(final String vifUuid) {
this.vifUuid = vifUuid;
}
@@ -42,4 +47,32 @@ public class VifAttachment extends Attachment {
return type;
}
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false);
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 31)
+ .append(this.getClass())
+ .append(vifUuid)
+ .toHashCode();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ if (!(this.getClass().isInstance(obj))) {
+ return false;
+ }
+ final VifAttachment another = (VifAttachment) obj;
+ return new EqualsBuilder().append(vifUuid, another.vifUuid).isEquals();
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
index c228b08..ec95ea5 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
@@ -66,7 +66,7 @@ import com.cloud.host.Host.Type;
import com.cloud.network.nicira.ControlClusterStatus;
import com.cloud.network.nicira.DestinationNatRule;
import com.cloud.network.nicira.L3GatewayAttachment;
-import com.cloud.network.nicira.LogicalRouterConfig;
+import com.cloud.network.nicira.LogicalRouter;
import com.cloud.network.nicira.LogicalRouterPort;
import com.cloud.network.nicira.LogicalSwitch;
import com.cloud.network.nicira.LogicalSwitchPort;
@@ -78,7 +78,7 @@ import com.cloud.network.nicira.NiciraNvpList;
import com.cloud.network.nicira.NiciraNvpTag;
import com.cloud.network.nicira.PatchAttachment;
import com.cloud.network.nicira.RouterNextHop;
-import com.cloud.network.nicira.SingleDefaultRouteImplictRoutingConfig;
+import com.cloud.network.nicira.SingleDefaultRouteImplicitRoutingConfig;
import com.cloud.network.nicira.SourceNatRule;
import com.cloud.network.nicira.TransportZoneBinding;
import com.cloud.network.nicira.VifAttachment;
@@ -294,7 +294,7 @@ public class NiciraNvpResource implements ServerResource {
LogicalSwitchPort logicalSwitchPort = new LogicalSwitchPort(attachmentUuid, tags, true);
LogicalSwitchPort newPort = niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, logicalSwitchPort);
try {
- niciraNvpApi.modifyLogicalSwitchPortAttachment(cmd.getLogicalSwitchUuid(), newPort.getUuid(), new VifAttachment(attachmentUuid));
+ niciraNvpApi.updateLogicalSwitchPortAttachment(cmd.getLogicalSwitchUuid(), newPort.getUuid(), new VifAttachment(attachmentUuid));
} catch (NiciraNvpApiException ex) {
s_logger.warn("modifyLogicalSwitchPort failed after switchport was created, removing switchport");
niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), newPort.getUuid());
@@ -334,7 +334,7 @@ public class NiciraNvpResource implements ServerResource {
List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
tags.add(new NiciraNvpTag("cs_account", cmd.getOwnerName()));
- niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, new VifAttachment(attachmentUuid));
+ niciraNvpApi.updateLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, new VifAttachment(attachmentUuid));
return new UpdateLogicalSwitchPortAnswer(cmd, true, "Attachment for " + logicalSwitchPortUuid + " updated", logicalSwitchPortUuid);
} catch (NiciraNvpApiException e) {
if (numRetries > 0) {
@@ -383,10 +383,10 @@ public class NiciraNvpResource implements ServerResource {
try {
// Create the Router
- LogicalRouterConfig lrc = new LogicalRouterConfig();
+ LogicalRouter lrc = new LogicalRouter();
lrc.setDisplayName(truncate(routerName, NAME_MAX_LEN));
lrc.setTags(tags);
- lrc.setRoutingConfig(new SingleDefaultRouteImplictRoutingConfig(new RouterNextHop(publicNetworkNextHopIp)));
+ lrc.setRoutingConfig(new SingleDefaultRouteImplicitRoutingConfig(new RouterNextHop(publicNetworkNextHopIp)));
lrc = niciraNvpApi.createLogicalRouter(lrc);
// store the switchport for rollback
@@ -408,7 +408,7 @@ public class NiciraNvpResource implements ServerResource {
if (cmd.getVlanId() != 0) {
attachment.setVlanId(cmd.getVlanId());
}
- niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
+ niciraNvpApi.updateLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
// Create the inside port for the router
LogicalRouterPort lrpi = new LogicalRouterPort();
@@ -425,10 +425,10 @@ public class NiciraNvpResource implements ServerResource {
lsp = niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);
// Attach the inside router port to the lswitch port with a PatchAttachment
- niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpi.getUuid(), new PatchAttachment(lsp.getUuid()));
+ niciraNvpApi.updateLogicalRouterPortAttachment(lrc.getUuid(), lrpi.getUuid(), new PatchAttachment(lsp.getUuid()));
// Attach the inside lswitch port to the router with a PatchAttachment
- niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(), new PatchAttachment(lrpi.getUuid()));
+ niciraNvpApi.updateLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(), new PatchAttachment(lrpi.getUuid()));
// Setup the source nat rule
SourceNatRule snr = new SourceNatRule();
@@ -484,7 +484,7 @@ public class NiciraNvpResource implements ServerResource {
}
LogicalRouterPort lrp = ports.getResults().get(0);
lrp.setIpAddresses(cmd.getPublicCidrs());
- niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
+ niciraNvpApi.updateLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() + " ip addresses on logical router uuid " +
cmd.getLogicalRouterUuid());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
index 822c8c7..bf8ce18 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
@@ -104,7 +104,7 @@ public class NiciraNvpElementTest {
@Test
public void canHandleTest() {
- Network net = mock(Network.class);
+ final Network net = mock(Network.class);
when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
when(net.getId()).thenReturn(NETWORK_ID);
@@ -134,43 +134,43 @@ public class NiciraNvpElementTest {
@Test
public void implementTest() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
- Network network = mock(Network.class);
+ final Network network = mock(Network.class);
when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
when(network.getId()).thenReturn(NETWORK_ID);
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
mock(DeployDestination.class);
- Domain dom = mock(Domain.class);
+ final Domain dom = mock(Domain.class);
when(dom.getName()).thenReturn("domain");
- Account acc = mock(Account.class);
+ final Account acc = mock(Account.class);
when(acc.getAccountName()).thenReturn("accountname");
- ReservationContext context = mock(ReservationContext.class);
+ final ReservationContext context = mock(ReservationContext.class);
when(context.getDomain()).thenReturn(dom);
when(context.getAccount()).thenReturn(acc);
}
@Test
public void applyIpTest() throws ResourceUnavailableException {
- Network network = mock(Network.class);
+ final Network network = mock(Network.class);
when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
when(network.getId()).thenReturn(NETWORK_ID);
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
- List<PublicIpAddress> ipAddresses = new ArrayList<PublicIpAddress>();
- PublicIpAddress pipReleased = mock(PublicIpAddress.class);
- PublicIpAddress pipAllocated = mock(PublicIpAddress.class);
- Ip ipReleased = new Ip("42.10.10.10");
- Ip ipAllocated = new Ip("10.10.10.10");
+ final List<PublicIpAddress> ipAddresses = new ArrayList<PublicIpAddress>();
+ final PublicIpAddress pipReleased = mock(PublicIpAddress.class);
+ final PublicIpAddress pipAllocated = mock(PublicIpAddress.class);
+ final Ip ipReleased = new Ip("42.10.10.10");
+ final Ip ipAllocated = new Ip("10.10.10.10");
when(pipAllocated.getState()).thenReturn(IpAddress.State.Allocated);
when(pipAllocated.getAddress()).thenReturn(ipAllocated);
when(pipAllocated.getNetmask()).thenReturn("255.255.255.0");
@@ -180,25 +180,25 @@ public class NiciraNvpElementTest {
ipAddresses.add(pipAllocated);
ipAddresses.add(pipReleased);
- Set<Service> services = new HashSet<Service>();
+ final Set<Service> services = new HashSet<Service>();
services.add(Service.SourceNat);
services.add(Service.StaticNat);
services.add(Service.PortForwarding);
- List<NiciraNvpDeviceVO> deviceList = new ArrayList<NiciraNvpDeviceVO>();
- NiciraNvpDeviceVO nndVO = mock(NiciraNvpDeviceVO.class);
- NiciraNvpRouterMappingVO nnrmVO = mock(NiciraNvpRouterMappingVO.class);
+ final List<NiciraNvpDeviceVO> deviceList = new ArrayList<NiciraNvpDeviceVO>();
+ final NiciraNvpDeviceVO nndVO = mock(NiciraNvpDeviceVO.class);
+ final NiciraNvpRouterMappingVO nnrmVO = mock(NiciraNvpRouterMappingVO.class);
when(niciraNvpRouterMappingDao.findByNetworkId(NETWORK_ID)).thenReturn(nnrmVO);
when(nnrmVO.getLogicalRouterUuid()).thenReturn("abcde");
when(nndVO.getHostId()).thenReturn(NETWORK_ID);
- HostVO hvo = mock(HostVO.class);
+ final HostVO hvo = mock(HostVO.class);
when(hvo.getId()).thenReturn(NETWORK_ID);
when(hvo.getDetail("l3gatewayserviceuuid")).thenReturn("abcde");
when(hostDao.findById(NETWORK_ID)).thenReturn(hvo);
deviceList.add(nndVO);
when(niciraNvpDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(deviceList);
- ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
+ final ConfigurePublicIpsOnLogicalRouterAnswer answer = mock(ConfigurePublicIpsOnLogicalRouterAnswer.class);
when(answer.getResult()).thenReturn(true);
when(agentManager.easySend(eq(NETWORK_ID), any(ConfigurePublicIpsOnLogicalRouterCommand.class))).thenReturn(answer);
@@ -206,8 +206,8 @@ public class NiciraNvpElementTest {
verify(agentManager, atLeast(1)).easySend(eq(NETWORK_ID), argThat(new ArgumentMatcher<ConfigurePublicIpsOnLogicalRouterCommand>() {
@Override
- public boolean matches(Object argument) {
- ConfigurePublicIpsOnLogicalRouterCommand command = (ConfigurePublicIpsOnLogicalRouterCommand)argument;
+ public boolean matches(final Object argument) {
+ final ConfigurePublicIpsOnLogicalRouterCommand command = (ConfigurePublicIpsOnLogicalRouterCommand)argument;
if (command.getPublicCidrs().size() == 1)
return true;
return false;
[24/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fix license headers
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a369647b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a369647b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a369647b
Branch: refs/heads/ui-restyle
Commit: a369647bcab858d1f5a7d7bb74811b3500d8e6de
Parents: 510972a
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Tue Feb 18 10:16:31 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Feb 18 10:16:31 2014 +0100
----------------------------------------------------------------------
.../BasicEncodedRESTValidationStrategy.java | 17 +++++++++++++++
.../utils/rest/RESTValidationStrategy.java | 19 +++++++++++++++-
.../utils/rest/RESTServiceConnectorTest.java | 23 +++++++++++++++++---
3 files changed, 55 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a369647b/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java b/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
index e522852..d6bbd66 100644
--- a/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
+++ b/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
package com.cloud.utils.rest;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a369647b/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java b/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
index cb25614..15b8be1 100644
--- a/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
+++ b/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
package com.cloud.utils.rest;
import java.io.IOException;
@@ -101,7 +118,7 @@ public class RESTValidationStrategy {
*/
protected void login(final String protocol,
final HttpClient client)
- throws CloudstackRESTException {
+ throws CloudstackRESTException {
String url;
if (host == null || host.isEmpty() || user == null || user.isEmpty() || password == null || password.isEmpty()) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a369647b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
index d406f94..ac535ce 100644
--- a/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
+++ b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
@@ -1,3 +1,20 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
package com.cloud.utils.rest;
import static org.junit.Assert.assertTrue;
@@ -35,9 +52,9 @@ public class RESTServiceConnectorTest {
protected static final String UUID_JSON_RESPONSE = "{\"uuid\" : \"aaaa\"}";
protected static final String SEC_PROFILE_JSON_RESPONSE =
"{\"uuid\" : \"aaaa\","
- + "\"display_name\" : \"myTestName\","
- + "\"href\" : \"myTestHref\","
- + "\"schema\" : \"myTestSchema\"}";
+ + "\"display_name\" : \"myTestName\","
+ + "\"href\" : \"myTestHref\","
+ + "\"schema\" : \"myTestSchema\"}";
protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
+ "\"display_name\" : \"myTestName\","
[31/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6134:
If volume already exists for the vm - register the vm in the inventory and start it.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c969aa25
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c969aa25
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c969aa25
Branch: refs/heads/ui-restyle
Commit: c969aa25956a823acac2b5829c4db1528edd8965
Parents: 24309f6
Author: Nitin Mehta <ni...@citrix.com>
Authored: Tue Feb 18 18:24:33 2014 -0800
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Tue Feb 18 18:24:33 2014 -0800
----------------------------------------------------------------------
.../vmware/resource/VmwareResource.java | 51 +++++++++++--
.../hypervisor/vmware/mo/VirtualMachineMO.java | 76 +++++++++++++++++---
2 files changed, 112 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c969aa25/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 182fe9f..c74a278 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -247,6 +247,7 @@ import com.cloud.hypervisor.vmware.mo.HostMO;
import com.cloud.hypervisor.vmware.mo.HostStorageSystemMO;
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
import com.cloud.hypervisor.vmware.mo.NetworkDetails;
+import com.cloud.hypervisor.vmware.mo.TaskMO;
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
import com.cloud.hypervisor.vmware.mo.VirtualMachineDiskInfo;
import com.cloud.hypervisor.vmware.mo.VirtualMachineDiskInfoBuilder;
@@ -538,6 +539,33 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
return answer;
}
+ /**
+ * Registers the vm to the inventory given the vmx file.
+ */
+ private void registerVm(String vmName, DatastoreMO dsMo) throws Exception{
+
+ //1st param
+ VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
+ ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
+ DatacenterMO dataCenterMo = new DatacenterMO(getServiceContext(), dcMor);
+ ManagedObjectReference vmFolderMor = dataCenterMo.getVmFolder();
+
+ //2nd param
+ String vmxFilePath = dsMo.searchFileInSubFolders(vmName + ".vmx", false);
+
+ // 5th param
+ ManagedObjectReference morPool = hyperHost.getHyperHostOwnerResourcePool();
+
+ ManagedObjectReference morTask = getServiceContext().getService().registerVMTask(vmFolderMor, vmxFilePath, vmName, false, morPool, hyperHost.getMor());
+ boolean result = getServiceContext().getVimClient().waitForTask(morTask);
+ if (!result) {
+ throw new Exception("Unable to register vm due to " + TaskMO.getTaskFailureInfo(getServiceContext(), morTask));
+ } else {
+ getServiceContext().waitForTaskProgressDone(morTask);
+ }
+
+ }
+
private Answer execute(ResizeVolumeCommand cmd) {
String path = cmd.getPath();
String vmName = cmd.getInstanceName();
@@ -1450,12 +1478,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
assert (vmSpec.getMinSpeed() != null) && (rootDiskDataStoreDetails != null);
if (rootDiskDataStoreDetails.second().folderExists(String.format("[%s]", rootDiskDataStoreDetails.second().getName()), vmNameOnVcenter)) {
- s_logger.warn("WARN!!! Folder already exists on datastore for new VM " + vmNameOnVcenter + ", erase it");
- rootDiskDataStoreDetails.second().deleteFile(String.format("[%s] %s/", rootDiskDataStoreDetails.second().getName(), vmNameOnVcenter),
- dcMo.getMor(), false);
- }
-
- if (!hyperHost.createBlankVm(vmNameOnVcenter, vmInternalCSName, vmSpec.getCpus(), vmSpec.getMaxSpeed().intValue(),
+ registerVm(vmNameOnVcenter, dsRootVolumeIsOn);
+ vmMo = hyperHost.findVmOnHyperHost(vmInternalCSName);
+ tearDownVm(vmMo);
+ }else if (!hyperHost.createBlankVm(vmNameOnVcenter, vmInternalCSName, vmSpec.getCpus(), vmSpec.getMaxSpeed().intValue(),
getReservedCpuMHZ(vmSpec), vmSpec.getLimitCpuUse(), (int)(vmSpec.getMaxRam() / (1024 * 1024)), getReservedMemoryMb(vmSpec),
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(), rootDiskDataStoreDetails.first(), false)) {
throw new Exception("Failed to create VM. vmName: " + vmInternalCSName);
@@ -1767,6 +1793,19 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
}
+ private void tearDownVm(VirtualMachineMO vmMo) throws Exception{
+
+ if(vmMo == null) return;
+
+ boolean hasSnapshot = false;
+ hasSnapshot = vmMo.hasSnapshot();
+ if (!hasSnapshot)
+ vmMo.tearDownDevices(new Class<?>[] {VirtualDisk.class, VirtualEthernetCard.class});
+ else
+ vmMo.tearDownDevices(new Class<?>[] {VirtualEthernetCard.class});
+ vmMo.ensureScsiDeviceController();
+ }
+
@Override
public ManagedObjectReference prepareManagedStorage(VmwareHypervisorHost hyperHost, String iScsiName,
String storageHost, int storagePort, String chapInitiatorUsername, String chapInitiatorSecret,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c969aa25/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 99a7425..7fc8836 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -190,17 +190,75 @@ public class VirtualMachineMO extends BaseMO {
}
public boolean powerOn() throws Exception {
- if (getResetSafePowerState() == VirtualMachinePowerState.POWERED_ON)
- return true;
+ if(getResetSafePowerState() == VirtualMachinePowerState.POWERED_ON)
+ return true;
- ManagedObjectReference morTask = _context.getService().powerOnVMTask(_mor, null);
+ ManagedObjectReference morTask = _context.getService().powerOnVMTask(_mor, null);
+ // Monitor VM questions
+ final Boolean[] flags = {false};
+ final VirtualMachineMO vmMo = this;
+ Future<?> future = MonitorServiceExecutor.submit(new Runnable() {
+ @Override
+ public void run() {
+ s_logger.info("VM Question monitor started...");
- boolean result = _context.getVimClient().waitForTask(morTask);
- if (result) {
- _context.waitForTaskProgressDone(morTask);
- return true;
- } else {
- s_logger.error("VMware powerOnVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
+ while (!flags[0]) {
+ try {
+ VirtualMachineRuntimeInfo runtimeInfo = vmMo.getRuntimeInfo();
+ VirtualMachineQuestionInfo question = runtimeInfo.getQuestion();
+ if (question != null) {
+ s_logger.info("Question id: " + question.getId());
+ s_logger.info("Question text: " + question.getText());
+ if (question.getMessage() != null) {
+ for (VirtualMachineMessage msg : question.getMessage()) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("msg id: " + msg.getId());
+ s_logger.info("msg text: " + msg.getText());
+ }
+ if ("msg.uuid.altered".equalsIgnoreCase(msg.getId())) {
+ s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId()
+ + ", we will automatically answer as 'moved it' to address out of band HA for the VM");
+ vmMo.answerVM(question.getId(), "1");
+ break;
+ }
+ }
+ }
+
+ if (s_logger.isTraceEnabled())
+ s_logger.trace("These are the choices we can have just in case");
+ ChoiceOption choice = question.getChoice();
+ if (choice != null) {
+ for (ElementDescription info : choice.getChoiceInfo()) {
+ if (s_logger.isTraceEnabled()) {
+ s_logger.trace("Choice option key: " + info.getKey());
+ s_logger.trace("Choice option label: " + info.getLabel());
+ }
+ }
+ }
+ }
+ } catch (Throwable e) {
+ s_logger.error("Unexpected exception: ", e);
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
+ s_logger.info("VM Question monitor stopped");
+ }
+ });
+
+ try {
+ boolean result = _context.getVimClient().waitForTask(morTask);
+ if (result) {
+ _context.waitForTaskProgressDone(morTask);
+ return true;
+ } else {
+ s_logger.error("VMware powerOnVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
+ }
+ } finally {
+ // make sure to let VM question monitor exit
+ flags[0] = true;
}
return false;
[29/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Slight optimization, don't run checkstyle on container or non-java projects.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f1139848
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f1139848
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f1139848
Branch: refs/heads/ui-restyle
Commit: f1139848e50870078ea7fd2f732bcf59accf0753
Parents: 594b51c
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Tue Feb 18 12:24:11 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Feb 18 12:24:11 2014 +0100
----------------------------------------------------------------------
client/pom.xml | 11 +++++++++++
engine/pom.xml | 13 +++++++++++++
framework/pom.xml | 13 +++++++++++++
plugins/pom.xml | 13 +++++++++++++
services/pom.xml | 13 +++++++++++++
5 files changed, 63 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1139848/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index f59e1a0..03a141d 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -571,6 +571,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>cloudstack-checkstyle</id>
+ <phase>none</phase>
+ <inherited>false</inherited>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<profiles>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1139848/engine/pom.xml
----------------------------------------------------------------------
diff --git a/engine/pom.xml b/engine/pom.xml
index f95007c..5f1b95b 100644
--- a/engine/pom.xml
+++ b/engine/pom.xml
@@ -29,6 +29,19 @@
</parent>
<build>
<defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>cloudstack-checkstyle</id>
+ <phase>none</phase>
+ <inherited>false</inherited>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
<modules>
<module>api</module>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1139848/framework/pom.xml
----------------------------------------------------------------------
diff --git a/framework/pom.xml b/framework/pom.xml
index 505c49e..a1f4321 100644
--- a/framework/pom.xml
+++ b/framework/pom.xml
@@ -28,6 +28,19 @@
</parent>
<build>
<defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>cloudstack-checkstyle</id>
+ <phase>none</phase>
+ <inherited>false</inherited>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
<modules>
<module>ipc</module>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1139848/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index b1bafee..a9cf617 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -22,6 +22,19 @@
<build>
<defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>cloudstack-checkstyle</id>
+ <phase>none</phase>
+ <inherited>false</inherited>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
<modules>
<module>api/rate-limit</module>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1139848/services/pom.xml
----------------------------------------------------------------------
diff --git a/services/pom.xml b/services/pom.xml
index 0e61a61..def3027 100644
--- a/services/pom.xml
+++ b/services/pom.xml
@@ -29,6 +29,19 @@
</parent>
<build>
<defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>cloudstack-checkstyle</id>
+ <phase>none</phase>
+ <inherited>false</inherited>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
<modules>
<module>console-proxy</module>
[06/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fix functional issue introduced by some findbug changes.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/443acac9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/443acac9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/443acac9
Branch: refs/heads/ui-restyle
Commit: 443acac92792cbffff2654c3414df276efac404f
Parents: 97bad4f
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Fri Feb 14 18:36:18 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:47 2014 +0100
----------------------------------------------------------------------
.../src/com/cloud/utils/db/GenericDaoBase.java | 28 ++++++++++----------
1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/443acac9/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
index d929e00..9f18c34 100755
--- a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
+++ b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
@@ -554,7 +554,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
final Enum<?>[] enums = (Enum<?>[])field.getType().getEnumConstants();
for (final Enum<?> e : enums) {
if ((enumType == EnumType.STRING && e.name().equalsIgnoreCase(rs.getString(index))) ||
- (enumType == EnumType.ORDINAL && e.ordinal() == rs.getInt(index))) {
+ (enumType == EnumType.ORDINAL && e.ordinal() == rs.getInt(index))) {
field.set(entity, e);
return;
}
@@ -768,7 +768,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
protected int addJoinAttributes(int count, PreparedStatement pstmt, Collection<JoinBuilder<SearchCriteria<?>>> joins) throws SQLException {
for (JoinBuilder<SearchCriteria<?>> join : joins) {
for (final Pair<Attribute, Object> value : join.getT().getValues()) {
- prepareAttribute(++count, pstmt, value.first(), value.second());
+ prepareAttribute(count++, pstmt, value.first(), value.second());
}
}
@@ -1255,18 +1255,18 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
for (JoinBuilder<SearchCriteria<?>> join : joins) {
StringBuilder onClause = new StringBuilder();
onClause.append(" ")
- .append(join.getType().getName())
- .append(" ")
- .append(join.getSecondAttribute().table)
- .append(" ON ")
- .append(join.getFirstAttribute().table)
- .append(".")
- .append(join.getFirstAttribute().columnName)
- .append("=")
- .append(join.getSecondAttribute().table)
- .append(".")
- .append(join.getSecondAttribute().columnName)
- .append(" ");
+ .append(join.getType().getName())
+ .append(" ")
+ .append(join.getSecondAttribute().table)
+ .append(" ON ")
+ .append(join.getFirstAttribute().table)
+ .append(".")
+ .append(join.getFirstAttribute().columnName)
+ .append("=")
+ .append(join.getSecondAttribute().table)
+ .append(".")
+ .append(join.getSecondAttribute().columnName)
+ .append(" ");
str.insert(fromIndex, onClause);
String whereClause = join.getT().getWhereClause();
if ((whereClause != null) && !"".equals(whereClause)) {
[36/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
listView: Fix 'addRow' event being triggered under wrong scope
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b01720d9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b01720d9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b01720d9
Branch: refs/heads/ui-restyle
Commit: b01720d9366dadad6510bba5b1017a58aa42b55b
Parents: 5e717cb
Author: Brian Federle <br...@citrix.com>
Authored: Wed Feb 19 14:36:23 2014 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Wed Feb 19 14:36:23 2014 -0800
----------------------------------------------------------------------
ui/scripts/ui/widgets/listView.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b01720d9/ui/scripts/ui/widgets/listView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js
index daf86ff..9e399e1 100644
--- a/ui/scripts/ui/widgets/listView.js
+++ b/ui/scripts/ui/widgets/listView.js
@@ -1275,13 +1275,13 @@
allowedActions: allowedActions
}
);
-
- $listView.trigger('cloudStack.listView.addRow', {
- $tr: $tr
- });
}
- // Add sub-select
+ $tr.closest('.list-view').trigger('cloudStack.listView.addRow', {
+ $tr: $tr
+ });
+
+ // Add sub-select
if (subselect) {
var $td = $tr.find('td.first');
var $select = $('<div></div>').addClass('subselect').append(
[43/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Add generic wrapper for group answer needed commands
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8b341b06
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8b341b06
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8b341b06
Branch: refs/heads/ui-restyle
Commit: 8b341b0639b1947a71df29d409948eb96e238499
Parents: 43b4144
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 19:12:07 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 19:47:09 2014 -0800
----------------------------------------------------------------------
.../cloud/agent/api/routing/GroupAnswer.java | 2 +-
.../cloud/agent/api/routing/IpAssocCommand.java | 4 +
.../agent/api/routing/IpAssocVpcCommand.java | 6 +
.../api/routing/NetworkElementCommand.java | 4 +
.../api/routing/SetFirewallRulesCommand.java | 9 +-
.../agent/api/routing/SetNetworkACLCommand.java | 11 +-
.../routing/SetPortForwardingRulesCommand.java | 10 +-
.../SetPortForwardingRulesVpcCommand.java | 4 +-
.../api/routing/SetStaticNatRulesCommand.java | 9 +-
.../api/routing/SetStaticRouteCommand.java | 13 +-
.../virtualnetwork/VirtualRoutingResource.java | 216 ++++++-------------
11 files changed, 117 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/GroupAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/GroupAnswer.java b/core/src/com/cloud/agent/api/routing/GroupAnswer.java
index 0917a7b..293934b 100644
--- a/core/src/com/cloud/agent/api/routing/GroupAnswer.java
+++ b/core/src/com/cloud/agent/api/routing/GroupAnswer.java
@@ -34,7 +34,7 @@ public class GroupAnswer extends Answer {
this.results = results;
}
- String[] getResults() {
+ public String[] getResults() {
return results;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/IpAssocCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/IpAssocCommand.java b/core/src/com/cloud/agent/api/routing/IpAssocCommand.java
index df5d54a..fe6ab6f 100644
--- a/core/src/com/cloud/agent/api/routing/IpAssocCommand.java
+++ b/core/src/com/cloud/agent/api/routing/IpAssocCommand.java
@@ -38,4 +38,8 @@ public class IpAssocCommand extends NetworkElementCommand {
return ipAddresses;
}
+ @Override
+ public int getAnswersCount() {
+ return ipAddresses.length;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java b/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java
index 3e5566a..d4996a5 100644
--- a/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java
+++ b/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java
@@ -26,4 +26,10 @@ public class IpAssocVpcCommand extends IpAssocCommand {
public IpAssocVpcCommand(IpAddressTO[] ips) {
super(ips);
}
+
+ @Override
+ public int getAnswersCount() {
+ //Count private gateway to maximum value
+ return ipAddresses.length * 2;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
index 205784b..f13037c 100644
--- a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
+++ b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
@@ -62,4 +62,8 @@ public abstract class NetworkElementCommand extends Command {
public void setRouterAccessIp(String routerAccessIp) {
this.routerAccessIp = routerAccessIp;
}
+
+ public int getAnswersCount() {
+ return 1;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
index f7ac052..36771b9 100644
--- a/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
@@ -16,12 +16,12 @@
// under the License.
package com.cloud.agent.api.routing;
+import com.cloud.agent.api.to.FirewallRuleTO;
+
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import com.cloud.agent.api.to.FirewallRuleTO;
-
/**
*
* AccessDetails allow different components to put in information about
@@ -92,4 +92,9 @@ public class SetFirewallRulesCommand extends NetworkElementCommand {
return result;
}
+
+ @Override
+ public int getAnswersCount() {
+ return rules.length;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
index 7edcdf3..0b9fec5 100644
--- a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
@@ -17,14 +17,14 @@
package com.cloud.agent.api.routing;
+import com.cloud.agent.api.to.NetworkACLTO;
+import com.cloud.agent.api.to.NicTO;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import com.cloud.agent.api.to.NetworkACLTO;
-import com.cloud.agent.api.to.NicTO;
-
public class SetNetworkACLCommand extends NetworkElementCommand {
NetworkACLTO[] rules;
NicTO nic;
@@ -97,4 +97,9 @@ public class SetNetworkACLCommand extends NetworkElementCommand {
public NicTO getNic() {
return nic;
}
+
+ @Override
+ public int getAnswersCount() {
+ return rules.length;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java b/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java
index a7bf37f..d93ccaf 100644
--- a/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java
@@ -16,10 +16,10 @@
// under the License.
package com.cloud.agent.api.routing;
-import java.util.List;
-
import com.cloud.agent.api.to.PortForwardingRuleTO;
+import java.util.List;
+
public class SetPortForwardingRulesCommand extends NetworkElementCommand {
PortForwardingRuleTO[] rules;
@@ -37,4 +37,10 @@ public class SetPortForwardingRulesCommand extends NetworkElementCommand {
public PortForwardingRuleTO[] getRules() {
return rules;
}
+
+ @Override
+ public int getAnswersCount() {
+ return rules.length;
+ }
}
+
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java b/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java
index 613ae5d..1bce50d 100644
--- a/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java
@@ -16,10 +16,10 @@
// under the License.
package com.cloud.agent.api.routing;
-import java.util.List;
-
import com.cloud.agent.api.to.PortForwardingRuleTO;
+import java.util.List;
+
public class SetPortForwardingRulesVpcCommand extends SetPortForwardingRulesCommand {
protected SetPortForwardingRulesVpcCommand() {
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java b/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java
index a38bf5f..64c7660 100644
--- a/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java
@@ -16,10 +16,10 @@
// under the License.
package com.cloud.agent.api.routing;
-import java.util.List;
-
import com.cloud.agent.api.to.StaticNatRuleTO;
+import java.util.List;
+
public class SetStaticNatRulesCommand extends NetworkElementCommand {
StaticNatRuleTO[] rules;
@@ -44,4 +44,9 @@ public class SetStaticNatRulesCommand extends NetworkElementCommand {
public Long getVpcId() {
return vpcId;
}
+
+ @Override
+ public int getAnswersCount() {
+ return rules.length;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java b/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java
index 26800a1..1e4f0c8 100644
--- a/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java
@@ -17,14 +17,14 @@
package com.cloud.agent.api.routing;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import com.cloud.network.vpc.StaticRoute;
import com.cloud.network.vpc.StaticRouteProfile;
import com.cloud.utils.net.NetUtils;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
public class SetStaticRouteCommand extends NetworkElementCommand {
StaticRouteProfile[] staticRoutes;
@@ -59,4 +59,9 @@ public class SetStaticRouteCommand extends NetworkElementCommand {
result[0] = toAdd.toArray(new String[toAdd.size()]);
return result;
}
+
+ @Override
+ public int getAnswersCount() {
+ return staticRoutes.length;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b341b06/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index f66b030..49a5c0a 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -231,14 +231,44 @@ public class VirtualRoutingResource {
}
}
- private Answer applyConfigSingle(NetworkElementCommand cmd, List<ConfigItem> cfg) {
- for (ConfigItem c : cfg) {
+ private Answer applyConfig(NetworkElementCommand cmd, List<ConfigItem> cfg) {
+ int answersCount = cmd.getAnswersCount();
+ assert (cfg.size() <= answersCount) : "Why there are more commands than answers?";
+
+ if (cfg.size() == 1 && answersCount == 1) {
+ ConfigItem c = cfg.get(0);
ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- if (!result.isSuccess()) {
- return new Answer(cmd, false, result.getDetails());
+ return new Answer(cmd, result.isSuccess(), result.getDetails());
+ }
+
+ ExecutionResult[] results = new ExecutionResult[answersCount];
+ String[] resultsString = new String[answersCount];
+ boolean finalResult = true;
+ int i = 0, j;
+ for (ConfigItem c : cfg) {
+ results[i] = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+ if (c.getInfo() != null) {
+ if (results[i].isSuccess()) {
+ results[i].setDetails(c.getInfo() + " - success: " + results[i].getDetails());
+ } else {
+ results[i].setDetails(c.getInfo() + " - failed: " + results[i].getDetails());
+ }
}
+ i ++;
}
- return new Answer(cmd);
+ i = 0; j = 0;
+ while (j < answersCount) {
+ resultsString[j] = results[i].getDetails();
+ if (!results[i].isSuccess()) {
+ finalResult = false;
+ }
+ // Fill the resultsString with the last result of execution, mostly in 1:n
+ if (i < cfg.size() - 1) {
+ i ++;
+ }
+ j ++;
+ }
+ return new GroupAnswer(cmd, finalResult, answersCount, resultsString);
}
private List<ConfigItem> generateConfig(VpnUsersCfgCommand cmd) {
@@ -259,7 +289,7 @@ public class VirtualRoutingResource {
private Answer execute(VpnUsersCfgCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(RemoteAccessVpnCfgCommand cmd) {
@@ -288,7 +318,7 @@ public class VirtualRoutingResource {
private Answer execute(RemoteAccessVpnCfgCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(SetFirewallRulesCommand cmd) {
@@ -332,27 +362,8 @@ public class VirtualRoutingResource {
}
private Answer execute(SetFirewallRulesCommand cmd) {
- int rulesCount = cmd.getRules().length;
- String[] results = new String[rulesCount];
- String routerAccessIp = cmd.getRouterAccessIp();
-
- if (routerAccessIp == null) {
- return new GroupAnswer(cmd, false, rulesCount, results);
- }
-
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- ExecutionResult result = _vrDeployer.executeInVR(routerAccessIp, c.getScript(), c.getArgs());
-
- if (!result.isSuccess()) {
- //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: " + result.getDetails();
- }
- return new GroupAnswer(cmd, false, rulesCount, results);
- }
- return new GroupAnswer(cmd, true, rulesCount, results);
-
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(SetPortForwardingRulesCommand cmd) {
@@ -373,24 +384,8 @@ public class VirtualRoutingResource {
}
private Answer execute(SetPortForwardingRulesCommand cmd) {
- int rulesCount = cmd.getRules().length;
- String[] results = new String[rulesCount];
- int i = 0;
- boolean endResult = true;
List<ConfigItem> cfg = generateConfig(cmd);
-
- for (ConfigItem c : cfg) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
-
- if (!result.isSuccess()) {
- results[i++] = "Failed";
- endResult = false;
- } else {
- results[i++] = null;
- }
- }
-
- return new GroupAnswer(cmd, endResult, rulesCount, results);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(SetStaticNatRulesCommand cmd) {
@@ -424,24 +419,9 @@ public class VirtualRoutingResource {
return cfg;
}
- private GroupAnswer execute(SetStaticNatRulesCommand cmd) {
- String[] results = new String[cmd.getRules().length];
- int i = 0;
- boolean endResult = true;
-
+ private Answer execute(SetStaticNatRulesCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- for (ConfigItem c : cfg) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
-
- if (!result.isSuccess()) {
- results[i++] = "Failed";
- endResult = false;
- } else {
- results[i++] = null;
- }
- }
-
- return new GroupAnswer(cmd, endResult, cmd.getRules().length, results);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(LoadBalancerConfigCommand cmd) {
@@ -542,7 +522,7 @@ public class VirtualRoutingResource {
protected Answer execute(VmDataCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(SavePasswordCommand cmd) {
@@ -560,7 +540,7 @@ public class VirtualRoutingResource {
protected Answer execute(final SavePasswordCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(DhcpEntryCommand cmd) {
@@ -599,7 +579,7 @@ public class VirtualRoutingResource {
protected Answer execute(final DhcpEntryCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(CreateIpAliasCommand cmd) {
@@ -617,7 +597,7 @@ public class VirtualRoutingResource {
protected Answer execute(final CreateIpAliasCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(DeleteIpAliasCommand cmd) {
@@ -641,7 +621,7 @@ public class VirtualRoutingResource {
protected Answer execute(final DeleteIpAliasCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
private List<ConfigItem> generateConfig(DnsMasqConfigCommand cmd) {
@@ -659,7 +639,7 @@ public class VirtualRoutingResource {
protected Answer execute(final DnsMasqConfigCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) {
@@ -688,7 +668,7 @@ public class VirtualRoutingResource {
protected Answer execute(BumpUpPriorityCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
protected Answer execute(GetDomRVersionCmd cmd) {
@@ -754,7 +734,7 @@ public class VirtualRoutingResource {
protected Answer execute(Site2SiteVpnCfgCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetMonitorServiceCommand cmd) {
@@ -774,7 +754,7 @@ public class VirtualRoutingResource {
protected Answer execute(SetMonitorServiceCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetupGuestNetworkCommand cmd) {
@@ -819,7 +799,7 @@ public class VirtualRoutingResource {
protected Answer execute(SetupGuestNetworkCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetNetworkACLCommand cmd) {
@@ -856,22 +836,9 @@ public class VirtualRoutingResource {
return cfg;
}
- private GroupAnswer execute(SetNetworkACLCommand cmd) {
- int rulesCount = cmd.getRules().length;
- String[] results = new String[rulesCount];
-
+ private Answer execute(SetNetworkACLCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
-
- if (!result.isSuccess()) {
- for (int i = 0; i < results.length; i++) {
- results[i] = "Failed";
- }
- return new GroupAnswer(cmd, false, rulesCount, results);
- }
-
- return new GroupAnswer(cmd, true, rulesCount, results);
+ return applyConfig(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetSourceNatCommand cmd) {
@@ -891,7 +858,7 @@ public class VirtualRoutingResource {
protected Answer execute(SetSourceNatCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfigSingle(cmd, cfg);
+ return applyConfig(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetPortForwardingRulesVpcCommand cmd) {
@@ -911,45 +878,14 @@ public class VirtualRoutingResource {
return cfg;
}
- private GroupAnswer execute(SetPortForwardingRulesVpcCommand cmd) {
- String[] results = new String[cmd.getRules().length];
- int i = 0;
-
- boolean endResult = true;
+ private Answer execute(SetPortForwardingRulesVpcCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- for (ConfigItem c : cfg) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
-
- if (!result.isSuccess()) {
- results[i++] = "Failed";
- endResult = false;
- } else {
- results[i++] = null;
- }
- }
- return new GroupAnswer(cmd, endResult, cmd.getRules().length, results);
+ return applyConfig(cmd, cfg);
}
- public GroupAnswer execute(IpAssocVpcCommand cmd) {
- boolean finalResult = true;
- String[] results = new String[cmd.getIpAddresses().length];
- for (int i = 0; i < cmd.getIpAddresses().length; i ++) {
- results[i] = "Failed";
- }
-
- int i = 0;
+ public Answer execute(IpAssocVpcCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- for (ConfigItem c : cfg) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- if (!result.isSuccess()) {
- results[i++] = c.getInfo() + " failed: " + result.getDetails();
- finalResult = false;
- break;
- }
-
- results[i++] = c.getInfo() + " - success ";
- }
- return new GroupAnswer(cmd, finalResult, cmd.getIpAddresses().length, results);
+ return applyConfig(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetStaticRouteCommand cmd) {
@@ -969,22 +905,9 @@ public class VirtualRoutingResource {
return cfg;
}
- private GroupAnswer execute(SetStaticRouteCommand cmd) {
- int rulesCount = cmd.getStaticRoutes().length;
- String[] results = new String[rulesCount];
-
+ private Answer execute(SetStaticRouteCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
-
- if (!result.isSuccess()) {
- for (int i = 0; i < results.length; i++) {
- results[i] = "Failed";
- }
- return new GroupAnswer(cmd, false, rulesCount, results);
- }
-
- return new GroupAnswer(cmd, true, rulesCount, results);
+ return applyConfig(cmd, cfg);
}
protected List<ConfigItem> generateConfig(IpAssocCommand cmd) {
@@ -1067,25 +990,8 @@ public class VirtualRoutingResource {
}
public Answer execute(IpAssocCommand cmd) {
- boolean finalResult = true;
- String[] results = new String[cmd.getIpAddresses().length];
- for (int i = 0; i < results.length; i++) {
- results[i] = "Failed";
- }
-
- int i = 0;
List<ConfigItem> cfg = generateConfig(cmd);
- for (ConfigItem c : cfg) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- if (result.isSuccess()) {
- results[i++] = c.getInfo() + " - success";
- } else {
- results[i++] = c.getInfo() + " - failed:" + result.getDetails();
- finalResult = false;
- break;
- }
- }
- return new GroupAnswer(cmd, finalResult, cmd.getIpAddresses().length, results);
+ return applyConfig(cmd, cfg);
}
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
[05/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fix findbugs findings in cloudstack-service-console-proxy-rdpclient
Findings:
- 32 int shifted by an amount not in range -31..31:
The shifts by 32 bits don't actually have any effect on the value
(as shown by the tests)
- possible null pointer dereference
- repeated conditional test
- field only ever set to null
All other uses of the field were to check if it was null,
which it was, so it was removed
Other actions:
- Upgrade jUnit to version 4
- Add PowerMock dependency
Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1237bf32
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1237bf32
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1237bf32
Branch: refs/heads/ui-restyle
Commit: 1237bf32229c3f734110ef26139f18fea27163b4
Parents: ef2ced7
Author: miguelaferreira <mf...@shubergphilis.com>
Authored: Tue Feb 11 18:56:05 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:46 2014 +0100
----------------------------------------------------------------------
pom.xml | 12 ++
services/console-proxy-rdp/rdpconsole/pom.xml | 2 +-
.../rdpconsole/src/main/java/common/Client.java | 92 ++++++------
.../src/main/java/streamer/ByteBuffer.java | 122 ++++++++-------
.../src/test/java/common/ClientTest.java | 43 ++++++
.../src/test/java/rdpclient/MockServerTest.java | 5 +
.../src/test/java/streamer/ByteBufferTest.java | 150 +++++++++++++++++++
7 files changed, 331 insertions(+), 95 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1237bf32/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9dbd72b..cf6e960 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,6 +75,7 @@
<cs.vmware.api.version>5.1</cs.vmware.api.version>
<org.springframework.version>3.2.4.RELEASE</org.springframework.version>
<cs.mockito.version>1.9.5</cs.mockito.version>
+ <cs.powermock.version>1.5.3</cs.powermock.version>
<cs.aws.sdk.version>1.3.22</cs.aws.sdk.version>
<cs.lang.version>2.6</cs.lang.version>
<cs.commons-io.version>1.4</cs.commons-io.version>
@@ -418,6 +419,17 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>${cs.powermock.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${cs.powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1237bf32/services/console-proxy-rdp/rdpconsole/pom.xml
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/pom.xml b/services/console-proxy-rdp/rdpconsole/pom.xml
index 05585a1..efcf780 100755
--- a/services/console-proxy-rdp/rdpconsole/pom.xml
+++ b/services/console-proxy-rdp/rdpconsole/pom.xml
@@ -58,7 +58,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>${cs.junit.version}</version>
<scope>test</scope>
</dependency>
<!-- Apache Portable Runtime implementation of SSL protocol, which is compatible with broken MS RDP SSL suport.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1237bf32/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java b/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java
index 688693b..f21d7e3 100755
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/common/Client.java
@@ -34,6 +34,7 @@ import streamer.apr.AprSocketWrapperImpl;
import streamer.bco.BcoSocketWrapperImpl;
import streamer.ssl.SSLState;
import vncclient.VncClient;
+
import common.opt.IntOption;
import common.opt.Option;
import common.opt.OptionParser;
@@ -47,28 +48,28 @@ public class Client {
}
// Common options
- private Option help = new Option() {
+ private final Option help = new Option() {
{
name = "--help";
alias = "-h";
description = "Show this help text.";
}
};
- private Option debugLink = new Option() {
+ private final Option debugLink = new Option() {
{
name = "--debug-link";
alias = "-DL";
description = "Print debugging messages when packets are trasnferred via links.";
}
};
- private Option debugElement = new Option() {
+ private final Option debugElement = new Option() {
{
name = "--debug-element";
alias = "-DE";
description = "Print debugging messages when packets are received or sended by elements.";
}
};
- private Option debugPipeline = new Option() {
+ private final Option debugPipeline = new Option() {
{
name = "--debug-pipeline";
alias = "-DP";
@@ -76,7 +77,7 @@ public class Client {
}
};
- private StringOption hostName = new StringOption() {
+ private final StringOption hostName = new StringOption() {
{
name = "--host";
alias = "-n";
@@ -85,7 +86,7 @@ public class Client {
description = "Name or IP address of host to connect to.";
}
};
- private IntOption canvasWidth = new IntOption() {
+ private final IntOption canvasWidth = new IntOption() {
{
name = "--width";
alias = "-W";
@@ -94,7 +95,7 @@ public class Client {
}
};
- private IntOption canvasHeight = new IntOption() {
+ private final IntOption canvasHeight = new IntOption() {
{
name = "--height";
alias = "-H";
@@ -105,7 +106,7 @@ public class Client {
// Protocol specific options
- private IntOption vncPort = new IntOption() {
+ private final IntOption vncPort = new IntOption() {
{
name = "--port";
alias = "-p";
@@ -114,7 +115,7 @@ public class Client {
}
};
- private IntOption rdpPort = new IntOption() {
+ private final IntOption rdpPort = new IntOption() {
{
name = "--port";
alias = "-p";
@@ -123,7 +124,7 @@ public class Client {
}
};
- private IntOption hyperVPort = new IntOption() {
+ private final IntOption hyperVPort = new IntOption() {
{
name = "--port";
alias = "-p";
@@ -132,7 +133,7 @@ public class Client {
}
};
- private StringOption password = new StringOption() {
+ private final StringOption password = new StringOption() {
{
name = "--password";
alias = "-P";
@@ -141,7 +142,7 @@ public class Client {
}
};
- private StringOption rdpPassword = new StringOption() {
+ private final StringOption rdpPassword = new StringOption() {
{
name = "--password";
alias = "-P";
@@ -150,7 +151,7 @@ public class Client {
}
};
- private StringOption userName = new StringOption() {
+ private final StringOption userName = new StringOption() {
{
name = "--user";
alias = "-U";
@@ -159,7 +160,7 @@ public class Client {
}
};
- private StringOption domain = new StringOption() {
+ private final StringOption domain = new StringOption() {
{
name = "--domain";
alias = "-D";
@@ -168,7 +169,7 @@ public class Client {
}
};
- private StringOption hyperVInstanceId = new StringOption() {
+ private final StringOption hyperVInstanceId = new StringOption() {
{
name = "--instance";
alias = "-i";
@@ -176,7 +177,7 @@ public class Client {
description = "HyperV instance ID to use.";
}
};
- private StringEnumerationOption sslImplementation = new StringEnumerationOption() {
+ private final StringEnumerationOption sslImplementation = new StringEnumerationOption() {
{
name = "--ssl-implementation";
alias = "-j";
@@ -196,6 +197,7 @@ public class Client {
private static ScrollPane scroller;
private static ScreenDescription screen;
private static BufferedImageCanvas canvas;
+ private InetSocketAddress address;
private void help() {
System.out.println("Usage: \n java common.Client vnc|rdp|hyperv OPTIONS\n");
@@ -243,32 +245,7 @@ public class Client {
}
});
- // Assemble pipeline
- InetSocketAddress address;
- Element main;
- switch (protocol) {
- case VNC:
- address = new InetSocketAddress(hostName.value, vncPort.value);
- main = new VncClient("client", password.value, screen, canvas);
- break;
- case RDP:
- address = new InetSocketAddress(hostName.value, rdpPort.value);
- main = new RdpClient("client", hostName.value, domain.value, userName.value, rdpPassword.value, null, screen, canvas, sslState);
- break;
- case HYPERV:
- address = new InetSocketAddress(hostName.value, hyperVPort.value);
- main = new RdpClient("client", hostName.value, domain.value, userName.value, password.value, hyperVInstanceId.value, screen, canvas, sslState);
- break;
- default:
- address = null;
- main = null;
- }
-
- Pipeline pipeline = new PipelineImpl("Client");
- pipeline.add(socket, main);
- pipeline.link("socket", main.getId(), "socket");
-
- pipeline.validate();
+ assemblePipeline(setMainElementAndAddressBasedOnProtocol(protocol, sslState));
frame = createVncClientMainWindow(canvas, protocol.toString() + " " + hostName.value, new WindowAdapter() {
@Override
@@ -289,6 +266,37 @@ public class Client {
}
}
+ protected static void assemblePipeline(Element main) {
+ Pipeline pipeline = new PipelineImpl("Client");
+ pipeline.add(socket, main);
+ pipeline.link("socket", main.getId(), "socket");
+
+ pipeline.validate();
+ }
+
+ private Element setMainElementAndAddressBasedOnProtocol(Protocol protocol, SSLState sslState) {
+ Element main;
+ switch (protocol) {
+ case VNC:
+ address = new InetSocketAddress(hostName.value, vncPort.value);
+ main = new VncClient("client", password.value, screen, canvas);
+ break;
+ case RDP:
+ address = new InetSocketAddress(hostName.value, rdpPort.value);
+ main = new RdpClient("client", hostName.value, domain.value, userName.value, rdpPassword.value, null, screen, canvas, sslState);
+ break;
+ case HYPERV:
+ address = new InetSocketAddress(hostName.value, hyperVPort.value);
+ main = new RdpClient("client", hostName.value, domain.value, userName.value, password.value, hyperVInstanceId.value, screen, canvas, sslState);
+ break;
+ default:
+ address = null;
+ main = null;
+ }
+
+ return main;
+ }
+
private Protocol parseOptions(String[] args) {
String protocolName = (args.length > 0) ? args[0] : "";
Protocol protocol = Protocol.NONE;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1237bf32/services/console-proxy-rdp/rdpconsole/src/main/java/streamer/ByteBuffer.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/main/java/streamer/ByteBuffer.java b/services/console-proxy-rdp/rdpconsole/src/main/java/streamer/ByteBuffer.java
index 3a718ba..e307342 100755
--- a/services/console-proxy-rdp/rdpconsole/src/main/java/streamer/ByteBuffer.java
+++ b/services/console-proxy-rdp/rdpconsole/src/main/java/streamer/ByteBuffer.java
@@ -36,7 +36,6 @@ public class ByteBuffer {
public int cursor = 0;
private int refCount = 1;
- private ByteBuffer parentByteBuffer = null;
private Order order;
@@ -159,8 +158,23 @@ public class ByteBuffer {
*/
public String dump() {
StringBuilder builder = new StringBuilder(length * 4);
+ int i = addBytesToBuilder(builder);
+ int end = i - 1;
+ if (end % 16 != 15) {
+ int begin = end & ~0xf;
+ for (int j = 0; j < (15 - (end % 16)); j++) {
+ builder.append(" ");
+ }
+ builder.append(' ');
+ builder.append(toASCIIString(begin, end));
+ builder.append('\n');
+ }
+ return builder.toString();
+ }
+
+ protected int addBytesToBuilder(StringBuilder builder) {
int i = 0;
- for (; i < length && i < length; i++) {
+ for (; i < length; i++) {
if (i % 16 == 0) {
builder.append(String.format("%04x", i));
}
@@ -175,17 +189,7 @@ public class ByteBuffer {
builder.append('\n');
}
}
- int end = i - 1;
- if (end % 16 != 15) {
- int begin = end & ~0xf;
- for (int j = 0; j < (15 - (end % 16)); j++) {
- builder.append(" ");
- }
- builder.append(' ');
- builder.append(toASCIIString(begin, end));
- builder.append('\n');
- }
- return builder.toString();
+ return i;
}
private String toASCIIString(int start, int finish) {
@@ -222,14 +226,8 @@ public class ByteBuffer {
refCount--;
if (refCount == 0) {
-
- if (parentByteBuffer != null) {
- parentByteBuffer.unref();
- parentByteBuffer = null;
- } else {
- // Return buffer to buffer pool
- BufferPool.recycleBuffer(data);
- }
+ // Return buffer to buffer pool
+ BufferPool.recycleBuffer(data);
data = null;
}
@@ -237,7 +235,7 @@ public class ByteBuffer {
}
public boolean isSoleOwner() {
- return refCount == 1 && (parentByteBuffer == null);
+ return refCount == 1;
}
/**
@@ -247,8 +245,8 @@ public class ByteBuffer {
ref();
if (this.length < (offset + length))
- throw new RuntimeException("Length of region is larger that length of this buffer. Buffer length: " + this.length + ", offset: " + offset
- + ", new region length: " + length + ".");
+ throw new RuntimeException("Length of region is larger that length of this buffer. Buffer length: " + this.length + ", offset: " + offset + ", new region length: "
+ + length + ".");
ByteBuffer slice = new ByteBuffer(data, this.offset + offset, length);
@@ -308,8 +306,8 @@ public class ByteBuffer {
public short[] toShortArray() {
if (length % 2 != 0)
- throw new ArrayIndexOutOfBoundsException("Length of byte array must be dividable by 2 without remainder. Array length: " + length + ", remainder: "
- + (length % 2) + ".");
+ throw new ArrayIndexOutOfBoundsException("Length of byte array must be dividable by 2 without remainder. Array length: " + length + ", remainder: " + (length % 2)
+ + ".");
short[] buf = new short[length / 2];
@@ -324,8 +322,8 @@ public class ByteBuffer {
*/
public int[] toIntLEArray() {
if (length % 4 != 0)
- throw new ArrayIndexOutOfBoundsException("Length of byte array must be dividable by 4 without remainder. Array length: " + length + ", remainder: "
- + (length % 4) + ".");
+ throw new ArrayIndexOutOfBoundsException("Length of byte array must be dividable by 4 without remainder. Array length: " + length + ", remainder: " + (length % 4)
+ + ".");
int[] buf = new int[length / 4];
@@ -341,8 +339,8 @@ public class ByteBuffer {
*/
public int[] toInt3LEArray() {
if (length % 3 != 0)
- throw new ArrayIndexOutOfBoundsException("Length of byte array must be dividable by 3 without remainder. Array length: " + length + ", remainder: "
- + (length % 3) + ".");
+ throw new ArrayIndexOutOfBoundsException("Length of byte array must be dividable by 3 without remainder. Array length: " + length + ", remainder: " + (length % 3)
+ + ".");
int[] buf = new int[length / 3];
@@ -373,8 +371,7 @@ public class ByteBuffer {
if (cursor + 4 > length)
throw new ArrayIndexOutOfBoundsException("Cannot read 4 bytes from this buffer: " + this + ".");
- int result = (((data[offset + cursor] & 0xff) << 24) + ((data[offset + cursor + 1] & 0xff) << 16) + ((data[offset + cursor + 2] & 0xff) << 8) + (data[offset
- + cursor + 3] & 0xff));
+ int result = (((data[offset + cursor] & 0xff) << 24) + ((data[offset + cursor + 1] & 0xff) << 16) + ((data[offset + cursor + 2] & 0xff) << 8) + (data[offset + cursor + 3] & 0xff));
cursor += 4;
return result;
}
@@ -386,8 +383,7 @@ public class ByteBuffer {
if (cursor + 4 > length)
throw new ArrayIndexOutOfBoundsException("Cannot read 4 bytes from this buffer: " + this + ".");
- int result = (((data[offset + cursor + 3] & 0xff) << 24) + ((data[offset + cursor + 2] & 0xff) << 16) + ((data[offset + cursor + 1] & 0xff) << 8) + (data[offset
- + cursor] & 0xff));
+ int result = (((data[offset + cursor + 3] & 0xff) << 24) + ((data[offset + cursor + 2] & 0xff) << 16) + ((data[offset + cursor + 1] & 0xff) << 8) + (data[offset + cursor] & 0xff));
cursor += 4;
return result;
}
@@ -399,8 +395,8 @@ public class ByteBuffer {
if (cursor + 4 > length)
throw new ArrayIndexOutOfBoundsException("Cannot read 4 bytes from this buffer: " + this + ".");
- long result = (((long)(data[offset + cursor + 3] & 0xff) << 24) + ((long)(data[offset + cursor + 2] & 0xff) << 16)
- + ((long)(data[offset + cursor + 1] & 0xff) << 8) + (data[offset + cursor + 0] & 0xff));
+ long result = (((long)(data[offset + cursor + 3] & 0xff) << 24) + ((long)(data[offset + cursor + 2] & 0xff) << 16) + ((long)(data[offset + cursor + 1] & 0xff) << 8) + (data[offset
+ + cursor + 0] & 0xff));
cursor += 4;
return result;
}
@@ -412,12 +408,19 @@ public class ByteBuffer {
if (cursor + 4 > length)
throw new ArrayIndexOutOfBoundsException("Cannot read 4 bytes from this buffer: " + this + ".");
- long result = (((long)(data[offset + cursor + 0] & 0xff) << 24) + ((long)(data[offset + cursor + 1] & 0xff) << 16)
- + ((long)(data[offset + cursor + 2] & 0xff) << 8) + (data[offset + cursor + 3] & 0xff));
+ byte value1 = data[offset + cursor + 0];
+ byte value2 = data[offset + cursor + 1];
+ byte value3 = data[offset + cursor + 2];
+ byte value4 = data[offset + cursor + 3];
+ long result = calculateUnsignedInt(value1, value2, value3, value4);
cursor += 4;
return result;
}
+ protected static long calculateUnsignedInt(byte value1, byte value2, byte value3, byte value4) {
+ return (calculateUnsignedByte(value1) << 24) + (calculateUnsignedByte(value2) << 16) + (calculateUnsignedByte(value3) << 8) + calculateUnsignedByte(value4);
+ }
+
/**
* Read signed int in variable length format. Top most bit of each byte
* indicates that next byte contains additional bits. Cursor is advanced by
@@ -474,11 +477,16 @@ public class ByteBuffer {
if (cursor + 1 > length)
throw new ArrayIndexOutOfBoundsException("Cannot read 1 byte from this buffer: " + this + ".");
- int b = data[offset + cursor] & 0xff;
+ byte value = data[offset + cursor];
+ int b = calculateUnsignedByte(value);
cursor += 1;
return b;
}
+ protected static int calculateUnsignedByte(byte value) {
+ return value & 0xff;
+ }
+
/**
* Read signed byte. Cursor is advanced by 1.
*/
@@ -498,11 +506,17 @@ public class ByteBuffer {
if (cursor + 2 > length)
throw new ArrayIndexOutOfBoundsException("Cannot read 2 bytes from this buffer: " + this + ".");
- int result = (((data[offset + cursor] & 0xff) << 8) | (data[offset + cursor + 1] & 0xff));
+ byte value1 = data[offset + cursor];
+ byte value2 = data[offset + cursor + 1];
+ int result = calculateUnsignedShort(value1, value2);
cursor += 2;
return result;
}
+ protected static int calculateUnsignedShort(byte value1, byte value2) {
+ return (calculateUnsignedByte(value1) << 8) | calculateUnsignedByte(value2);
+ }
+
/**
* Read signed short in little endian order. Cursor is advanced by 2.
*/
@@ -522,11 +536,17 @@ public class ByteBuffer {
if (cursor + 2 > length)
throw new ArrayIndexOutOfBoundsException("Cannot read 2 bytes from this buffer: " + this + ".");
- short result = (short)(((data[offset + cursor + 0] & 0xff) << 8) | (data[offset + cursor + 1] & 0xff));
+ byte value1 = data[offset + cursor + 0];
+ byte value2 = data[offset + cursor + 1];
+ short result = calculateSignedShort(value1, value2);
cursor += 2;
return result;
}
+ protected static short calculateSignedShort(byte value1, byte value2) {
+ return (short)calculateUnsignedShort(value1, value2);
+ }
+
/**
* Read unsigned short in network order in variable length format. Cursor is
* advanced by 1 or 2 bytes.
@@ -653,13 +673,13 @@ public class ByteBuffer {
value = readSignedInt();
break;
case 5:
- value = (readSignedByte() << 32) | readUnsignedInt();
+ value = readSignedByte() | readUnsignedInt();
break;
case 6:
- value = (readSignedShort() << 32) | readUnsignedInt();
+ value = readSignedShort() | readUnsignedInt();
break;
case 7:
- value = (readSignedByte() << 32 + 24) | (readUnsignedShort() << 32) | readUnsignedInt();
+ value = (readSignedByte() << 24) | readUnsignedShort() | readUnsignedInt();
break;
case 8:
value = readSignedLong();
@@ -694,20 +714,19 @@ public class ByteBuffer {
value = readUnsignedInt();
break;
case 5:
- value = (readUnsignedByte() << 32) | readUnsignedInt();
+ value = readUnsignedByte() | readUnsignedInt();
break;
case 6:
- value = (readUnsignedShort() << 32) | readUnsignedInt();
+ value = readUnsignedShort() | readUnsignedInt();
break;
case 7:
- value = (readUnsignedByte() << 32 + 16) | (readUnsignedShort() << 32) | readUnsignedInt();
+ value = (readUnsignedByte() << 16) | readUnsignedShort() | readUnsignedInt();
break;
case 8:
value = readSignedLong();
if (value < 0)
- throw new RuntimeException(
- "Cannot read 64 bit integers which are larger than 0x7FffFFffFFffFFff, because of lack of unsinged long type in Java. Value: " + value + ". Data: "
- + this + ".");
+ throw new RuntimeException("Cannot read 64 bit integers which are larger than 0x7FffFFffFFffFFff, because of lack of unsinged long type in Java. Value: " + value
+ + ". Data: " + this + ".");
break;
default:
throw new RuntimeException("Cannot read integers which are more than 8 bytes long. Length: " + len + ". Data: " + this + ".");
@@ -971,8 +990,7 @@ public class ByteBuffer {
*/
public void prepend(byte[] data, int offset, int length) {
if (!isSoleOwner()) {
- throw new RuntimeException("Create full copy of this byte buffer data for modification. refCount: " + refCount + ", parentByteBuffer: "
- + parentByteBuffer + ".");
+ throw new RuntimeException("Create full copy of this byte buffer data for modification. refCount: " + refCount + ".");
}
// If there is no enough space for header to prepend
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1237bf32/services/console-proxy-rdp/rdpconsole/src/test/java/common/ClientTest.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/test/java/common/ClientTest.java b/services/console-proxy-rdp/rdpconsole/src/test/java/common/ClientTest.java
new file mode 100644
index 0000000..3f5aa90
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/test/java/common/ClientTest.java
@@ -0,0 +1,43 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package common;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.reflect.Whitebox;
+
+import streamer.Element;
+import streamer.SocketWrapper;
+
+@RunWith(PowerMockRunner.class)
+public class ClientTest {
+
+ @Test(expected = NullPointerException.class)
+ public void testAssemblePipelineWhenMainElementIsNull() throws Exception {
+ SocketWrapper socketMock = mock(SocketWrapper.class);
+ when(socketMock.getId()).thenReturn("socket");
+ Whitebox.setInternalState(Client.class, "socket", socketMock);
+ Element main = null;
+
+ Client.assemblePipeline(main);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1237bf32/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java b/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java
index 17bc4bd..34e37c9 100755
--- a/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java
+++ b/services/console-proxy-rdp/rdpconsole/src/test/java/rdpclient/MockServerTest.java
@@ -30,11 +30,15 @@ import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import junit.framework.TestCase;
+
+import org.junit.Test;
+
import streamer.debug.MockServer;
import streamer.debug.MockServer.Packet;
public class MockServerTest extends TestCase {
+ @Test
public void testIsMockServerCanRespond() throws Exception {
final byte[] mockClientData = new byte[] {0x01, 0x02, 0x03};
@@ -87,6 +91,7 @@ public class MockServerTest extends TestCase {
}
}
+ @Test
public void testIsMockServerCanUpgradeConnectionToSsl() throws Exception {
final byte[] mockClientData1 = new byte[] {0x01, 0x02, 0x03};
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1237bf32/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java
----------------------------------------------------------------------
diff --git a/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java b/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java
new file mode 100644
index 0000000..8dbeba2
--- /dev/null
+++ b/services/console-proxy-rdp/rdpconsole/src/test/java/streamer/ByteBufferTest.java
@@ -0,0 +1,150 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+package streamer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Random;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(value = Parameterized.class)
+public class ByteBufferTest {
+
+ private static final Random random = new Random(System.currentTimeMillis());
+
+ private final byte[] data;
+
+ public ByteBufferTest(byte[] data) {
+ this.data = data;
+ }
+
+ private static byte[] getRandomByteArray() {
+ return new byte[] {(byte)random.nextInt(), (byte)random.nextInt(), (byte)random.nextInt(), (byte)random.nextInt(), (byte)random.nextInt(), (byte)random.nextInt(),
+ (byte)random.nextInt()};
+ }
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ int parameterCount = 50;
+ List<Object[]> parameters = new ArrayList<Object[]>(parameterCount);
+
+ for (int i = 0; i < parameterCount; i++) {
+ parameters.add(new Object[] {getRandomByteArray()});
+ }
+
+ return parameters;
+ }
+
+ // This findbugs finding is meant to show that the shift by 32 does nothing
+ // and was used to remove these cases from the production code.
+ // Don't try to fix it
+ @Test
+ public void testShiftByteBy32BitsDoesNothing() throws Exception {
+ for (byte b : data) {
+ assertEquals(b, b << 32);
+ }
+ }
+
+ @Test
+ public void testReadSignedVarIntWhenLenIs5() throws Exception {
+ int len = 5;
+ ByteBuffer byteBuffer = new ByteBuffer(data);
+
+ long expected = data[0] | ByteBuffer.calculateUnsignedInt(data[1], data[2], data[3], data[4]);
+ long actual = byteBuffer.readSignedVarInt(len);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testReadSignedVarIntWhenLenIs6() throws Exception {
+ int len = 6;
+ ByteBuffer byteBuffer = new ByteBuffer(data);
+
+ long expected = ByteBuffer.calculateSignedShort(data[0], data[1]) | ByteBuffer.calculateUnsignedInt(data[2], data[3], data[4], data[5]);
+ long actual = byteBuffer.readSignedVarInt(len);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testReadSignedVarIntWhenLenIs7() throws Exception {
+ int len = 7;
+ ByteBuffer byteBuffer = new ByteBuffer(data);
+
+ long expected = data[0] << 24 | ByteBuffer.calculateUnsignedShort(data[1], data[2]) | ByteBuffer.calculateUnsignedInt(data[3], data[4], data[5], data[6]);
+ long actual = byteBuffer.readSignedVarInt(len);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testReadUnsignedVarIntWhenLenIs5() throws Exception {
+ int len = 5;
+ ByteBuffer byteBuffer = new ByteBuffer(data);
+
+ long expected = ByteBuffer.calculateUnsignedByte(data[0]) | ByteBuffer.calculateUnsignedInt(data[1], data[2], data[3], data[4]);
+ long actual = byteBuffer.readUnsignedVarInt(len);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testReadUnsignedVarIntWhenLenIs6() throws Exception {
+ int len = 6;
+ ByteBuffer byteBuffer = new ByteBuffer(data);
+
+ long expected = ByteBuffer.calculateUnsignedShort(data[0], data[1]) | ByteBuffer.calculateUnsignedInt(data[2], data[3], data[4], data[5]);
+ long actual = byteBuffer.readUnsignedVarInt(len);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testReadUnsignedVarIntWhenLenIs7() throws Exception {
+ int len = 7;
+ ByteBuffer byteBuffer = new ByteBuffer(data);
+
+ long expected = (ByteBuffer.calculateUnsignedByte(data[0]) << 16) | ByteBuffer.calculateUnsignedShort(data[1], data[2])
+ | ByteBuffer.calculateUnsignedInt(data[3], data[4], data[5], data[6]);
+ long actual = byteBuffer.readUnsignedVarInt(len);
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testAddBytesToBuilder() throws Exception {
+ StringBuilder builder = new StringBuilder();
+ byte[] data = new byte[] {(byte)1, (byte)2};
+ ByteBuffer byteBuffer = new ByteBuffer(data);
+
+ int expected = 2;
+ int actual = byteBuffer.addBytesToBuilder(builder);
+
+ assertNotNull(builder);
+ assertFalse(builder.toString().isEmpty());
+ assertEquals(expected, actual);
+ }
+
+}
[38/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-4744: Enhance root admin API updateVolume with chaininfo parameter as a part of "Better control over first party objects" feature.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c171e2c3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c171e2c3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c171e2c3
Branch: refs/heads/ui-restyle
Commit: c171e2c3e430a8ddb27b54eabf1156f987ddc180
Parents: c93b096
Author: Nitin Mehta <ni...@citrix.com>
Authored: Wed Feb 19 18:01:18 2014 -0800
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Wed Feb 19 18:01:18 2014 -0800
----------------------------------------------------------------------
api/src/com/cloud/storage/VolumeApiService.java | 2 +-
api/src/org/apache/cloudstack/api/ApiConstants.java | 1 +
.../api/command/user/volume/UpdateVolumeCmd.java | 11 +++++++++--
.../cloudstack/api/response/VolumeResponse.java | 14 +++++++++++++-
.../com/cloud/api/query/dao/VolumeJoinDaoImpl.java | 1 +
server/src/com/cloud/api/query/vo/VolumeJoinVO.java | 6 ++++++
.../src/com/cloud/storage/VolumeApiServiceImpl.java | 6 +++++-
setup/db/db/schema-430to440.sql | 5 +++--
8 files changed, 39 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c171e2c3/api/src/com/cloud/storage/VolumeApiService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/VolumeApiService.java b/api/src/com/cloud/storage/VolumeApiService.java
index 09ac3ee..310f69e 100644
--- a/api/src/com/cloud/storage/VolumeApiService.java
+++ b/api/src/com/cloud/storage/VolumeApiService.java
@@ -82,7 +82,7 @@ public interface VolumeApiService {
Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException;
- Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume, String customId, long owner);
+ Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume, String customId, long owner, String chainInfo);
/**
* Extracts the volume to a particular location.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c171e2c3/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 3b9b19c..3699102 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -41,6 +41,7 @@ public class ApiConstants {
public static final String PRIVATE_KEY = "privatekey";
public static final String DOMAIN_SUFFIX = "domainsuffix";
public static final String DNS_SEARCH_ORDER = "dnssearchorder";
+ public static final String CHAIN_INFO = "chaininfo";
public static final String CIDR = "cidr";
public static final String IP6_CIDR = "ip6cidr";
public static final String CIDR_LIST = "cidrlist";
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c171e2c3/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
index 65d2849..78d402b 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
@@ -47,6 +47,9 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd {
@Parameter(name = ApiConstants.PATH, type = CommandType.STRING, description = "The path of the volume")
private String path;
+ @Parameter(name = ApiConstants.CHAIN_INFO, type = CommandType.STRING, description = "The chain info of the volume")
+ private String chainInfo;
+
@Parameter(name = ApiConstants.STORAGE_ID,
type = CommandType.UUID,
entityType = StoragePoolResponse.class,
@@ -86,7 +89,10 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd {
return displayVolume;
}
-/////////////////////////////////////////////////////
+ public String getChainInfo() {
+ return chainInfo;
+ }
+ /////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@@ -139,7 +145,8 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd {
@Override
public void execute() {
CallContext.current().setEventDetails("Volume Id: " + getId());
- Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume(), getCustomId(), getEntityOwnerId());
+ Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume(),
+ getCustomId(), getEntityOwnerId(), getChainInfo());
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName(getCommandName());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c171e2c3/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
index daf5350..4cba2a1 100644
--- a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
@@ -193,13 +193,17 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
private Boolean displayVolume;
@SerializedName(ApiConstants.PATH)
- @Param(description = "The path of the volume")
+ @Param(description = "the path of the volume")
private String path;
@SerializedName(ApiConstants.STORAGE_ID)
@Param(description = "id of the primary storage hosting the disk volume; returned to admin user only", since = "4.3")
private String storagePoolId;
+ @SerializedName(ApiConstants.CHAIN_INFO)
+ @Param(description = "the chain info of the volume", since = "4.4")
+ String chainInfo;
+
public String getPath() {
return path;
}
@@ -417,4 +421,12 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
public void setStoragePoolId(String storagePoolId) {
this.storagePoolId = storagePoolId;
}
+
+ public String getChainInfo() {
+ return chainInfo;
+ }
+
+ public void setChainInfo(String chainInfo) {
+ this.chainInfo = chainInfo;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c171e2c3/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
index 5fa27dc..0c56935 100644
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
@@ -209,6 +209,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
volResponse.setExtractable(isExtractable);
volResponse.setDisplayVolume(volume.isDisplayVolume());
+ volResponse.setChainInfo(volume.getChainInfo());
// set async job
if (volume.getJobId() != null) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c171e2c3/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
index f288c2f..1d1b37d 100644
--- a/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/VolumeJoinVO.java
@@ -264,6 +264,9 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
@Column(name = "path")
protected String path;
+ @Column(name = "chain_info", length = 65535)
+ String chainInfo;
+
public VolumeJoinVO() {
}
@@ -567,4 +570,7 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
return path;
}
+ public String getChainInfo() {
+ return chainInfo;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c171e2c3/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 252d925..614834e 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1205,7 +1205,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
@Override
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true)
- public Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume, String customId, long entityOwnerId) {
+ public Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume, String customId, long entityOwnerId, String chainInfo) {
VolumeVO volume = _volumeDao.findById(volumeId);
@@ -1217,6 +1217,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
volume.setDisplayVolume(displayVolume);
}
+ if(chainInfo != null){
+ volume.setChainInfo(chainInfo);
+ }
+
if (state != null) {
try {
Volume.State volumeState = Volume.State.valueOf(state);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c171e2c3/setup/db/db/schema-430to440.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-430to440.sql b/setup/db/db/schema-430to440.sql
index d1d0d06..a98df26 100644
--- a/setup/db/db/schema-430to440.sql
+++ b/setup/db/db/schema-430to440.sql
@@ -122,9 +122,10 @@ CREATE VIEW `cloud`.`volume_view` AS
volumes.attached,
volumes.removed,
volumes.pod_id,
- volumes.display_volume,
+ volumes.display_volume,
volumes.format,
- volumes.path,
+ volumes.path,
+ volumes.chain_info,
account.id account_id,
account.uuid account_uuid,
account.account_name account_name,
[08/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fixes on Contrail and Mon InMemory plugins; adding comments about the changes.
Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3199de69
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3199de69
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3199de69
Branch: refs/heads/ui-restyle
Commit: 3199de69fe6511cbb424940b7c7d00b52f2ec631
Parents: cbea6d2
Author: wrodrigues <wr...@schubergphilis.com>
Authored: Tue Feb 11 11:15:55 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:47 2014 +0100
----------------------------------------------------------------------
.../mom/inmemory/InMemoryEventBus.java | 53 +++---
.../mom/inmemory/InMemoryEventBusTest.java | 162 ++++++++++++++++++
.../management/ContrailManagerImpl.java | 68 ++++----
.../network/contrail/model/ModelObject.java | 10 +-
.../contrail/model/ServiceInstanceModel.java | 21 ++-
.../contrail/model/VirtualMachineModel.java | 78 +++++----
.../contrail/model/VirtualNetworkModel.java | 171 ++++++++++---------
.../contrail/model/VirtualMachineModelTest.java | 9 +-
.../contrail/model/VirtualNetworkModelTest.java | 143 +++++++++++++++-
utils/src/com/cloud/utils/UuidUtils.java | 10 +-
utils/test/com/cloud/utils/UuidUtilsTest.java | 23 +++
11 files changed, 567 insertions(+), 181 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java
----------------------------------------------------------------------
diff --git a/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java b/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java
index 99d0a12..9a57ff0 100644
--- a/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java
+++ b/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java
@@ -26,33 +26,36 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
-import com.cloud.utils.Pair;
-import org.apache.log4j.Logger;
-
import org.apache.cloudstack.framework.events.Event;
import org.apache.cloudstack.framework.events.EventBus;
import org.apache.cloudstack.framework.events.EventBusException;
import org.apache.cloudstack.framework.events.EventSubscriber;
import org.apache.cloudstack.framework.events.EventTopic;
+import org.apache.log4j.Logger;
+import com.cloud.utils.Pair;
import com.cloud.utils.component.ManagerBase;
@Local(value = EventBus.class)
public class InMemoryEventBus extends ManagerBase implements EventBus {
- private String name;
private static final Logger s_logger = Logger.getLogger(InMemoryEventBus.class);
- private static ConcurrentHashMap<UUID, Pair<EventTopic, EventSubscriber>> s_subscribers;
+
+ private final static ConcurrentHashMap<UUID, Pair<EventTopic, EventSubscriber>> subscribers;
+
+ static {
+ subscribers = new ConcurrentHashMap<UUID, Pair<EventTopic, EventSubscriber>>();
+ }
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- s_subscribers = new ConcurrentHashMap<UUID, Pair<EventTopic, EventSubscriber>>();
+ _name = name;
return true;
}
@Override
public void setName(String name) {
- this.name = name;
+ _name = name;
}
@Override
@@ -62,29 +65,35 @@ public class InMemoryEventBus extends ManagerBase implements EventBus {
}
UUID subscriberId = UUID.randomUUID();
- s_subscribers.put(subscriberId, new Pair(topic, subscriber));
+ subscribers.put(subscriberId, new Pair<EventTopic, EventSubscriber>(topic, subscriber));
return subscriberId;
}
@Override
public void unsubscribe(UUID subscriberId, EventSubscriber subscriber) throws EventBusException {
- if (s_subscribers != null && s_subscribers.isEmpty()) {
+ if (subscriberId == null) {
+ throw new EventBusException("Cannot unregister a null subscriberId.");
+ }
+
+ if (subscribers.isEmpty()) {
throw new EventBusException("There are no registered subscribers to unregister.");
}
- if (s_subscribers.get(subscriberId) == null) {
+
+ if (!subscribers.containsKey(subscriberId)) {
throw new EventBusException("No subscriber found with subscriber id " + subscriberId);
+ } else {
+ subscribers.remove(subscriberId);
}
- s_subscribers.remove(subscriberId);
}
@Override
public void publish(Event event) throws EventBusException {
- if (s_subscribers == null || s_subscribers.isEmpty()) {
+ if (subscribers == null || subscribers.isEmpty()) {
return; // no subscriber to publish to, so just return
}
- for (UUID subscriberId : s_subscribers.keySet()) {
- Pair<EventTopic, EventSubscriber> subscriberDetails = s_subscribers.get(subscriberId);
+ for (UUID subscriberId : subscribers.keySet()) {
+ Pair<EventTopic, EventSubscriber> subscriberDetails = subscribers.get(subscriberId);
// if the event matches subscribers interested event topic then call back the subscriber with the event
if (isEventMatchesTopic(event, subscriberDetails.first())) {
EventSubscriber subscriber = subscriberDetails.second();
@@ -108,6 +117,10 @@ public class InMemoryEventBus extends ManagerBase implements EventBus {
return true;
}
+ public int totalSubscribers() {
+ return subscribers.size();
+ }
+
private String replaceNullWithWildcard(String key) {
if (key == null || key.isEmpty()) {
return "*";
@@ -122,7 +135,7 @@ public class InMemoryEventBus extends ManagerBase implements EventBus {
eventTopicSource = eventTopicSource.replace(".", "-");
String eventSource = replaceNullWithWildcard(event.getEventSource());
eventSource = eventSource.replace(".", "-");
- if (eventTopicSource != "*" && eventSource != "*" && !eventTopicSource.equalsIgnoreCase(eventSource)) {
+ if (!eventTopicSource.equals("*") && !eventSource.equals("*") && !eventTopicSource.equalsIgnoreCase(eventSource)) {
return false;
}
@@ -130,7 +143,7 @@ public class InMemoryEventBus extends ManagerBase implements EventBus {
eventTopicCategory = eventTopicCategory.replace(".", "-");
String eventCategory = replaceNullWithWildcard(event.getEventCategory());
eventCategory = eventCategory.replace(".", "-");
- if (eventTopicCategory != "*" && eventCategory != "*" && !eventTopicCategory.equalsIgnoreCase(eventCategory)) {
+ if (!eventTopicCategory.equals("*") && !eventCategory.equals("*") && !eventTopicCategory.equalsIgnoreCase(eventCategory)) {
return false;
}
@@ -138,7 +151,7 @@ public class InMemoryEventBus extends ManagerBase implements EventBus {
eventTopicType = eventTopicType.replace(".", "-");
String eventType = replaceNullWithWildcard(event.getEventType());
eventType = eventType.replace(".", "-");
- if (eventTopicType != "*" && eventType != "*" && !eventTopicType.equalsIgnoreCase(eventType)) {
+ if (!eventTopicType.equals("*") && !eventType.equals("*") && !eventTopicType.equalsIgnoreCase(eventType)) {
return false;
}
@@ -146,7 +159,7 @@ public class InMemoryEventBus extends ManagerBase implements EventBus {
eventTopicResourceType = eventTopicResourceType.replace(".", "-");
String resourceType = replaceNullWithWildcard(event.getResourceType());
resourceType = resourceType.replace(".", "-");
- if (eventTopicResourceType != "*" && resourceType != "*" && !eventTopicResourceType.equalsIgnoreCase(resourceType)) {
+ if (!eventTopicResourceType.equals("*") && !resourceType.equals("*") && !eventTopicResourceType.equalsIgnoreCase(resourceType)) {
return false;
}
@@ -154,10 +167,10 @@ public class InMemoryEventBus extends ManagerBase implements EventBus {
resourceUuid = resourceUuid.replace(".", "-");
String eventTopicresourceUuid = replaceNullWithWildcard(topic.getResourceUUID());
eventTopicresourceUuid = eventTopicresourceUuid.replace(".", "-");
- if (resourceUuid != "*" && eventTopicresourceUuid != "*" && !resourceUuid.equalsIgnoreCase(eventTopicresourceUuid)) {
+ if (!resourceUuid.equals("*") && !eventTopicresourceUuid.equals("*") && !resourceUuid.equalsIgnoreCase(eventTopicresourceUuid)) {
return false;
}
return true;
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/event-bus/inmemory/test/org/apache/cloudstack/mom/inmemory/InMemoryEventBusTest.java
----------------------------------------------------------------------
diff --git a/plugins/event-bus/inmemory/test/org/apache/cloudstack/mom/inmemory/InMemoryEventBusTest.java b/plugins/event-bus/inmemory/test/org/apache/cloudstack/mom/inmemory/InMemoryEventBusTest.java
new file mode 100644
index 0000000..a967f89
--- /dev/null
+++ b/plugins/event-bus/inmemory/test/org/apache/cloudstack/mom/inmemory/InMemoryEventBusTest.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with 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.
+ */
+
+package org.apache.cloudstack.mom.inmemory;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.UUID;
+
+import org.apache.cloudstack.framework.events.Event;
+import org.apache.cloudstack.framework.events.EventBusException;
+import org.apache.cloudstack.framework.events.EventSubscriber;
+import org.apache.cloudstack.framework.events.EventTopic;
+import org.junit.Test;
+
+import com.cloud.utils.UuidUtils;
+
+public class InMemoryEventBusTest {
+
+ @Test
+ public void testConfigure() throws Exception {
+ String name = "test001";
+
+ InMemoryEventBus bus = new InMemoryEventBus();
+ boolean success = bus.configure(name, null);
+
+ assertTrue(success);
+ assertTrue(name.equals(bus.getName()));
+ }
+
+ @Test
+ public void testSubscribe() throws Exception {
+ EventTopic topic = mock(EventTopic.class);
+ EventSubscriber subscriber = mock(EventSubscriber.class);
+
+ InMemoryEventBus bus = new InMemoryEventBus();
+
+ UUID uuid = bus.subscribe(topic, subscriber);
+ assertNotNull(uuid);
+
+ String uuidStr = uuid.toString();
+ assertTrue(UuidUtils.validateUUID(uuidStr));
+ assertTrue(bus.totalSubscribers() == 1);
+
+ bus.unsubscribe(uuid, subscriber);
+ assertTrue(bus.totalSubscribers() == 0);
+ }
+
+ @Test(expected = EventBusException.class)
+ public void testSubscribeFailTopic() throws Exception {
+ EventSubscriber subscriber = mock(EventSubscriber.class);
+
+ InMemoryEventBus bus = new InMemoryEventBus();
+
+ bus.subscribe(null, subscriber);
+ }
+
+ @Test(expected = EventBusException.class)
+ public void testSubscribeFailSubscriber() throws Exception {
+ EventTopic topic = mock(EventTopic.class);
+
+ InMemoryEventBus bus = new InMemoryEventBus();
+
+ bus.subscribe(topic, null);
+ }
+
+ @Test
+ public void testUnsubscribe() throws Exception {
+ EventTopic topic = mock(EventTopic.class);
+ EventSubscriber subscriber = mock(EventSubscriber.class);
+
+ InMemoryEventBus bus = new InMemoryEventBus();
+
+ UUID uuid = bus.subscribe(topic, subscriber);
+ assertNotNull(uuid);
+
+ String uuidStr = uuid.toString();
+
+ assertTrue(UuidUtils.validateUUID(uuidStr));
+ assertTrue(bus.totalSubscribers() == 1);
+ //
+ bus.unsubscribe(uuid, subscriber);
+ assertTrue(bus.totalSubscribers() == 0);
+ }
+
+ @Test(expected = EventBusException.class)
+ public void testUnsubscribeFailEmpty() throws Exception {
+ UUID uuid = UUID.randomUUID();
+
+ InMemoryEventBus bus = new InMemoryEventBus();
+ bus.unsubscribe(uuid, null);
+ }
+
+ @Test(expected = EventBusException.class)
+ public void testUnsubscribeFailNull() throws Exception {
+ InMemoryEventBus bus = new InMemoryEventBus();
+ bus.unsubscribe(null, null);
+ }
+
+ @Test(expected = EventBusException.class)
+ public void testUnsubscribeFailWrongUUID() throws Exception {
+ EventSubscriber subscriber = mock(EventSubscriber.class);
+ InMemoryEventBus bus = new InMemoryEventBus();
+ UUID uuid = UUID.randomUUID();
+
+ bus.unsubscribe(uuid, subscriber);
+ }
+
+ @Test
+ public void testPublish() throws Exception {
+ EventTopic topic = mock(EventTopic.class);
+ EventSubscriber subscriber = mock(EventSubscriber.class);
+ Event event = mock(Event.class);
+
+ InMemoryEventBus bus = new InMemoryEventBus();
+
+ UUID uuid = bus.subscribe(topic, subscriber);
+ assertNotNull(uuid);
+
+ String uuidStr = uuid.toString();
+ assertTrue(UuidUtils.validateUUID(uuidStr));
+ assertTrue(bus.totalSubscribers() == 1);
+
+ bus.publish(event);
+
+ verify(subscriber, times(1)).onEvent(event);
+
+ bus.unsubscribe(uuid, subscriber);
+ assertTrue(bus.totalSubscribers() == 0);
+ }
+
+ @Test
+ public void testPublishEmpty() throws Exception {
+ EventSubscriber subscriber = mock(EventSubscriber.class);
+ Event event = mock(Event.class);
+
+ InMemoryEventBus bus = new InMemoryEventBus();
+ bus.publish(event);
+
+ verify(subscriber, times(0)).onEvent(event);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
index b25de48..01be7db 100644
--- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
+++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/management/ContrailManagerImpl.java
@@ -31,9 +31,9 @@ import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
+import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
-import javax.ejb.Local;
import net.juniper.contrail.api.ApiConnector;
import net.juniper.contrail.api.ApiConnectorFactory;
@@ -44,19 +44,16 @@ import net.juniper.contrail.api.types.FloatingIpPool;
import net.juniper.contrail.api.types.NetworkPolicy;
import net.juniper.contrail.api.types.VirtualNetwork;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-
-import com.google.common.collect.ImmutableList;
-
import org.apache.cloudstack.network.contrail.model.FloatingIpModel;
import org.apache.cloudstack.network.contrail.model.FloatingIpPoolModel;
import org.apache.cloudstack.network.contrail.model.ModelController;
import org.apache.cloudstack.network.contrail.model.VirtualNetworkModel;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.ConfigurationService;
-import com.cloud.server.ConfigurationServer;
import com.cloud.dc.DataCenter;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.VlanDao;
@@ -75,20 +72,21 @@ import com.cloud.network.dao.NetworkVO;
import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
import com.cloud.network.dao.PhysicalNetworkVO;
-import com.cloud.offering.NetworkOffering.Availability;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.offerings.NetworkOfferingVO;
-import com.cloud.offerings.dao.NetworkOfferingDao;
-import com.cloud.projects.ProjectVO;
-import com.cloud.network.vpc.dao.NetworkACLDao;
-import com.cloud.network.vpc.dao.VpcDao;
-import com.cloud.network.vpc.dao.VpcOfferingDao;
+import com.cloud.network.vpc.NetworkACLVO;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.network.vpc.VpcOfferingVO;
import com.cloud.network.vpc.VpcProvisioningService;
import com.cloud.network.vpc.VpcVO;
-import com.cloud.network.vpc.NetworkACLVO;
+import com.cloud.network.vpc.dao.NetworkACLDao;
+import com.cloud.network.vpc.dao.VpcDao;
+import com.cloud.network.vpc.dao.VpcOfferingDao;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Availability;
+import com.cloud.offerings.NetworkOfferingVO;
+import com.cloud.offerings.dao.NetworkOfferingDao;
+import com.cloud.projects.ProjectVO;
import com.cloud.projects.dao.ProjectDao;
+import com.cloud.server.ConfigurationServer;
import com.cloud.user.Account;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.PropertiesUtil;
@@ -100,6 +98,7 @@ import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
+import com.google.common.collect.ImmutableList;
@Local(value = { ContrailManager.class})
public class ContrailManagerImpl extends ManagerBase implements ContrailManager {
@@ -159,7 +158,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
private Timer _dbSyncTimer;
private int _dbSyncInterval = DB_SYNC_INTERVAL_DEFAULT;
private final String configuration = "contrail.properties";
- private ModelDatabase _database;
+ private final ModelDatabase _database;
private ModelController _controller;
ContrailManagerImpl() {
@@ -194,7 +193,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
}
private NetworkOffering locatePublicNetworkOffering(String offeringName,
- String offeringDisplayText, Provider provider) {
+ String offeringDisplayText, Provider provider) {
List<? extends NetworkOffering> offerList = _configService.listNetworkOfferings(TrafficType.Public, false);
for (NetworkOffering offer: offerList) {
if (offer.getName().equals(offeringName)) {
@@ -229,7 +228,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
}
private NetworkOffering locateNetworkOffering(String offeringName,
- String offeringDisplayText, Provider provider) {
+ String offeringDisplayText, Provider provider) {
List<? extends NetworkOffering> offerList = _configService.listNetworkOfferings(TrafficType.Guest, false);
for (NetworkOffering offer : offerList) {
if (offer.getName().equals(offeringName)) {
@@ -248,8 +247,8 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
}
ConfigurationManager configMgr = (ConfigurationManager)_configService;
NetworkOfferingVO voffer =
- configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Guest, null, false, Availability.Optional, null, serviceProviderMap, true,
- Network.GuestType.Isolated, false, null, false, null, false, true, null, true, null, false);
+ configMgr.createNetworkOffering(offeringName, offeringDisplayText, TrafficType.Guest, null, false, Availability.Optional, null, serviceProviderMap, true,
+ Network.GuestType.Isolated, false, null, false, null, false, true, null, true, null, false);
voffer.setState(NetworkOffering.State.Enabled);
long id = voffer.getId();
@@ -300,6 +299,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
File configFile = PropertiesUtil.findConfigFile(configuration);
+ FileInputStream fileStream = null;
try {
String hostname = null;
int port = 0;
@@ -307,10 +307,12 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
return false;
} else {
final Properties configProps = new Properties();
- configProps.load(new FileInputStream(configFile));
+ fileStream = new FileInputStream(configFile);
+ configProps.load(fileStream);
+
String value = configProps.getProperty("management.db_sync_interval");
if (value != null) {
- _dbSyncInterval = Integer.valueOf(value);
+ _dbSyncInterval = Integer.parseInt(value);
}
hostname = configProps.getProperty("api.hostname");
String portStr = configProps.getProperty("api.port");
@@ -326,16 +328,18 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
s_logger.debug("Exception in configure: " + ex);
ex.printStackTrace();
throw new ConfigurationException();
+ } finally {
+ IOUtils.closeQuietly(fileStream);
}
_controller = new ModelController(this, _api, _vmDao, _networksDao, _nicDao, _vlanDao, _ipAddressDao);
_routerOffering = locateNetworkOffering(routerOfferingName, routerOfferingDisplayText,
- Provider.JuniperContrailRouter);
+ Provider.JuniperContrailRouter);
_routerPublicOffering = locatePublicNetworkOffering(routerPublicOfferingName, routerPublicOfferingDisplayText,
- Provider.JuniperContrailRouter);
+ Provider.JuniperContrailRouter);
_vpcRouterOffering = locateNetworkOffering(vpcRouterOfferingName, vpcRouterOfferingDisplayText,
- Provider.JuniperContrailVpcRouter);
+ Provider.JuniperContrailVpcRouter);
_vpcOffering = locateVpcOffering();
_eventHandler.subscribe();
@@ -448,7 +452,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
DomainVO domain = _domainDao.findById(domainId);
if (domain.getId() != Domain.ROOT_DOMAIN) {
net.juniper.contrail.api.types.Domain vncDomain =
- (net.juniper.contrail.api.types.Domain)_api.findById(net.juniper.contrail.api.types.Domain.class, domain.getUuid());
+ (net.juniper.contrail.api.types.Domain)_api.findById(net.juniper.contrail.api.types.Domain.class, domain.getUuid());
return _api.findByName(net.juniper.contrail.api.types.Project.class, vncDomain, VNC_DEFAULT_PROJECT);
}
return null;
@@ -481,8 +485,8 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
@Override
public void findInfrastructureNetworks(PhysicalNetworkVO phys, List<NetworkVO> dbList) {
final TrafficType[] ttypes = {TrafficType.Control, // maps to __link_local__
- TrafficType.Management, // maps to ip-fabric
- TrafficType.Public, TrafficType.Storage // maps to ip-fabric
+ TrafficType.Management, // maps to ip-fabric
+ TrafficType.Public, TrafficType.Storage // maps to ip-fabric
};
for (int i = 0; i < ttypes.length; i++) {
@@ -528,7 +532,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
List<PhysicalNetworkVO> net_list = _physicalNetworkDao.listByZone(network.getDataCenterId());
for (PhysicalNetworkVO phys : net_list) {
if(_physProviderDao.findByServiceProvider(phys.getId(), Provider.JuniperContrailRouter.getName()) != null ||
- _physProviderDao.findByServiceProvider(phys.getId(), Provider.JuniperContrailVpcRouter.getName()) != null) {
+ _physProviderDao.findByServiceProvider(phys.getId(), Provider.JuniperContrailVpcRouter.getName()) != null) {
return true;
}
}
@@ -653,7 +657,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
for (Iterator<PhysicalNetworkVO> iter = phys_list.iterator(); iter.hasNext();) {
PhysicalNetworkVO phys = iter.next();
if (_physProviderDao.findByServiceProvider(phys.getId(), provider) != null ||
- _physProviderDao.findByServiceProvider(phys.getId(), vpcProvider) != null) {
+ _physProviderDao.findByServiceProvider(phys.getId(), vpcProvider) != null) {
List<NetworkVO> infraNets = new ArrayList<NetworkVO>();
findInfrastructureNetworks(phys, infraNets);
for (NetworkVO net : infraNets) {
@@ -886,7 +890,7 @@ public class ContrailManagerImpl extends ManagerBase implements ContrailManager
VirtualNetworkModel vnModel = getDatabase().lookupVirtualNetwork(net.getUuid(), getCanonicalName(net), TrafficType.Public);
if (vnModel == null) {
vnModel = new VirtualNetworkModel(net, net.getUuid(),
- getCanonicalName(net), net.getTrafficType());
+ getCanonicalName(net), net.getTrafficType());
vnModel.setProperties(getModelController(), net);
}
try {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ModelObject.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ModelObject.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ModelObject.java
index 1b048ed..c751d75 100644
--- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ModelObject.java
+++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ModelObject.java
@@ -39,8 +39,16 @@ import com.cloud.exception.InternalErrorException;
* The update method pushes updates to the contrail API server.
*/
public interface ModelObject {
+
public static class ModelReference implements Comparable<ModelReference>, Serializable {
- WeakReference<ModelObject> reference;
+
+ private static final long serialVersionUID = -2019113974956703526L;
+
+ /*
+ * WeakReference class is not serializable by definition. So, we cannot enforce its serialization unless we write the implementation of
+ * methods writeObject() and readObject(). Since the code was already not serializing it, it's been marked as transient.
+ */
+ transient WeakReference<ModelObject> reference;
ModelReference(ModelObject obj) {
reference = new WeakReference<ModelObject>(obj);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ServiceInstanceModel.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ServiceInstanceModel.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ServiceInstanceModel.java
index 0ce22ad..e79053c 100644
--- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ServiceInstanceModel.java
+++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/ServiceInstanceModel.java
@@ -30,11 +30,10 @@ import net.juniper.contrail.api.types.ServiceInstanceType;
import net.juniper.contrail.api.types.ServiceTemplate;
import net.juniper.contrail.api.types.ServiceTemplateType;
+import org.apache.cloudstack.network.contrail.management.ContrailManager;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.apache.cloudstack.network.contrail.management.ContrailManager;
-
import com.cloud.offering.ServiceOffering;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.utils.exception.CloudRuntimeException;
@@ -72,8 +71,14 @@ public class ServiceInstanceModel extends ModelObjectBase {
String parent_name;
if (project != null) {
parent_name = StringUtils.join(project.getQualifiedName(), ':');
+
+ _projectId = project.getUuid();
} else {
parent_name = ContrailManager.VNC_ROOT_DOMAIN + ":" + ContrailManager.VNC_DEFAULT_PROJECT;
+
+ //In the original code, if the projectId is null, it will simply throw NPE on the last line (nr. 90) of the method where the projectId.getUuid() is called.
+ //This was added as a way to avoid NPE. Should we perhaps throw a CloudRuntimeException if the project object is null?
+ _projectId = UUID.randomUUID().toString();
}
_fqName = parent_name + ":" + name;
@@ -86,8 +91,6 @@ public class ServiceInstanceModel extends ModelObjectBase {
_templateName = template.getName();
_templateId = template.getUuid();
_templateUrl = template.getUrl();
-
- _projectId = project.getUuid();
}
/**
@@ -170,16 +173,16 @@ public class ServiceInstanceModel extends ModelObjectBase {
}
private void clearServicePolicy(ModelController controller) {
- _left.addToNetworkPolicy(null);
- _right.addToNetworkPolicy(null);
- try {
+ _left.addToNetworkPolicy(null);
+ _right.addToNetworkPolicy(null);
+ try {
controller.getManager().getDatabase().getNetworkPolicys().remove(_policy);
_policy.delete(controller.getManager().getModelController());
_policy = null;
} catch (Exception e) {
s_logger.error(e);
}
- try {
+ try {
_left.update(controller.getManager().getModelController());
_right.update(controller.getManager().getModelController());
} catch (Exception ex) {
@@ -194,7 +197,7 @@ public class ServiceInstanceModel extends ModelObjectBase {
_right.addToNetworkPolicy(policyModel);
List<String> siList = new ArrayList<String>();
siList.add(StringUtils.join(_serviceInstance.getQualifiedName(), ':'));
- try {
+ try {
policyModel.build(controller.getManager().getModelController(), _leftName, _rightName, "in-network", siList, "pass");
} catch (Exception e) {
s_logger.error(e);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualMachineModel.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualMachineModel.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualMachineModel.java
index 4d0218c..4b64c80 100644
--- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualMachineModel.java
+++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualMachineModel.java
@@ -18,6 +18,7 @@
package org.apache.cloudstack.network.contrail.model;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
@@ -28,13 +29,14 @@ import net.juniper.contrail.api.types.ServiceInstance;
import net.juniper.contrail.api.types.VirtualMachine;
import org.apache.cloudstack.network.contrail.management.ContrailManager;
-import org.apache.log4j.Logger;
import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
import com.cloud.exception.InternalErrorException;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkVO;
import com.cloud.uservm.UserVm;
+import com.cloud.utils.UuidUtils;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.NicVO;
import com.cloud.vm.VMInstanceVO;
@@ -83,10 +85,26 @@ public class VirtualMachineModel extends ModelObjectBase {
final Gson json = new Gson();
Map<String, String> kvmap = json.fromJson(userVm.getUserData(), new TypeToken<Map<String, String>>() {
}.getType());
- String data = kvmap.get("service-instance");
- if (data != null) {
- /* link the object with the service instance */
- buildServiceInstance(controller, data);
+ //Renamed "data" to "serviceUuid" because it's clearer.
+ String serviceUuid = kvmap.get("service-instance");
+ if (serviceUuid != null) {
+ /*
+ * UUID.fromString() does not validate an UUID properly. I tried, for example, informing less digits in the UUID, where 12 were expected,
+ * and the UUID.fromstring() did not thrown the exception as expected. However, if you try UUID.fromString("aaa") it breaks, but if you try
+ * UUID.fromString("3dd4fa6e-2899-4429-b818-d34fe8df5") it doesn't (the last portion should have 12, instead of 9 digits).
+ *
+ * In other fix I added the validate UUID method to the UuidUtil classes.
+ */
+ if (UuidUtils.validateUUID(serviceUuid)) {
+ /* link the object with the service instance */
+ buildServiceInstance(controller, serviceUuid);
+ } else {
+ // Throw a CloudRuntimeException in case the UUID is not valid.
+ String message = "Invalid UUID ({0}) given for the service-instance for VM {1}.";
+ message = MessageFormat.format(message, instance.getId(), serviceUuid);
+ s_logger.warn(message);
+ throw new CloudRuntimeException(message);
+ }
}
}
}
@@ -109,22 +127,20 @@ public class VirtualMachineModel extends ModelObjectBase {
s_logger.warn("service-instance read", ex);
throw new CloudRuntimeException("Unable to read service-instance object", ex);
}
+
ServiceInstanceModel siModel;
- if (siObj == null) {
+ String fqn = StringUtils.join(siObj.getQualifiedName(), ':');
+ siModel = manager.getDatabase().lookupServiceInstance(fqn);
+ if (siModel == null) {
siModel = new ServiceInstanceModel(serviceUuid);
siModel.build(controller, siObj);
manager.getDatabase().getServiceInstances().add(siModel);
- } else {
- String fqn = StringUtils.join(siObj.getQualifiedName(), ':');
- siModel = manager.getDatabase().lookupServiceInstance(fqn);
- if (siModel == null) {
- if (siObj == null) {
- siModel = new ServiceInstanceModel(serviceUuid);
- siModel.build(controller, siObj);
- manager.getDatabase().getServiceInstances().add(siModel);
- }
- }
}
+ /*
+ * The code that was under the ELSE was never executed and due to that has been removed.
+ * Also, in the case siObj was null, it was going pass it as parameter to the build() method in the
+ * siModel object.
+ */
_serviceModel = siModel;
}
@@ -344,26 +360,26 @@ public class VirtualMachineModel extends ModelObjectBase {
@Override
public boolean verify(ModelController controller) {
assert _initialized : "initialized is false";
- assert _uuid != null : "uuid is not set";
+ assert _uuid != null : "uuid is not set";
- ApiConnector api = controller.getApiAccessor();
+ ApiConnector api = controller.getApiAccessor();
- try {
- _vm = (VirtualMachine) api.findById(VirtualMachine.class, _uuid);
- } catch (IOException e) {
- s_logger.error("virtual-machine verify", e);
- }
+ try {
+ _vm = (VirtualMachine) api.findById(VirtualMachine.class, _uuid);
+ } catch (IOException e) {
+ s_logger.error("virtual-machine verify", e);
+ }
- if (_vm == null) {
- return false;
- }
+ if (_vm == null) {
+ return false;
+ }
- for (ModelObject successor: successors()) {
- if (!successor.verify(controller)) {
- return false;
- }
+ for (ModelObject successor: successors()) {
+ if (!successor.verify(controller)) {
+ return false;
}
- return true;
+ }
+ return true;
}
@Override
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualNetworkModel.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualNetworkModel.java b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualNetworkModel.java
index b0505b1..7563714 100644
--- a/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualNetworkModel.java
+++ b/plugins/network-elements/juniper-contrail/src/org/apache/cloudstack/network/contrail/model/VirtualNetworkModel.java
@@ -32,9 +32,8 @@ import net.juniper.contrail.api.types.VirtualNetwork;
import net.juniper.contrail.api.types.VirtualNetworkPolicyType;
import net.juniper.contrail.api.types.VnSubnetsType;
-import org.apache.log4j.Logger;
-
import org.apache.cloudstack.network.contrail.management.ContrailManager;
+import org.apache.log4j.Logger;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.VlanDao;
@@ -49,7 +48,7 @@ public class VirtualNetworkModel extends ModelObjectBase {
private String _uuid;
private long _id;
- private TrafficType _trafficType;
+ private final TrafficType _trafficType;
/*
* current state for object properties
@@ -362,92 +361,92 @@ public class VirtualNetworkModel extends ModelObjectBase {
@Override
public boolean verify(ModelController controller) {
assert _initialized : "initialized is false";
- assert _uuid != null : "uuid is not set";
+ assert _uuid != null : "uuid is not set";
- ApiConnector api = controller.getApiAccessor();
- VlanDao vlanDao = controller.getVlanDao();
+ ApiConnector api = controller.getApiAccessor();
+ VlanDao vlanDao = controller.getVlanDao();
- try {
- _vn = (VirtualNetwork)api.findById(VirtualNetwork.class, _uuid);
- } catch (IOException e) {
- e.printStackTrace();
- }
+ try {
+ _vn = (VirtualNetwork)api.findById(VirtualNetwork.class, _uuid);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
- if (_vn == null) {
- return false;
- }
+ if (_vn == null) {
+ return false;
+ }
- if (!isDynamicNetwork()) {
- return true;
- }
+ if (!isDynamicNetwork()) {
+ return true;
+ }
- List<String> dbSubnets = new ArrayList<String>();
- if (_trafficType == TrafficType.Public) {
- List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id);
- for (VlanVO vlan : vlan_list) {
- String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask());
- dbSubnets.add(vlan.getVlanGateway() + cidr);
- }
- } else {
- dbSubnets.add(this._gateway + this._prefix);
+ List<String> dbSubnets = new ArrayList<String>();
+ if (_trafficType == TrafficType.Public) {
+ List<VlanVO> vlan_list = vlanDao.listVlansByNetworkId(_id);
+ for (VlanVO vlan : vlan_list) {
+ String cidr = NetUtils.ipAndNetMaskToCidr(vlan.getVlanGateway(), vlan.getVlanNetmask());
+ dbSubnets.add(vlan.getVlanGateway() + cidr);
}
+ } else {
+ dbSubnets.add(_gateway + _prefix);
+ }
- List<ObjectReference<VnSubnetsType>> ipamRefs = _vn.getNetworkIpam();
- List<String> vncSubnets = new ArrayList<String>();
+ List<ObjectReference<VnSubnetsType>> ipamRefs = _vn.getNetworkIpam();
+ List<String> vncSubnets = new ArrayList<String>();
- if (ipamRefs == null && !dbSubnets.isEmpty()) {
- return false;
- }
+ if (ipamRefs == null && !dbSubnets.isEmpty()) {
+ return false;
+ }
- if (ipamRefs != null) {
- for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
- VnSubnetsType vnSubnetType = ref.getAttr();
- if (vnSubnetType != null) {
- List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetType.getIpamSubnets();
- if (subnets != null && !subnets.isEmpty()) {
- VnSubnetsType.IpamSubnetType ipamSubnet = subnets.get(0);
- vncSubnets.add(ipamSubnet.getDefaultGateway() + ipamSubnet.getSubnet().getIpPrefix() + "/" + ipamSubnet.getSubnet().getIpPrefixLen());
- }
+ if (ipamRefs != null) {
+ for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
+ VnSubnetsType vnSubnetType = ref.getAttr();
+ if (vnSubnetType != null) {
+ List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetType.getIpamSubnets();
+ if (subnets != null && !subnets.isEmpty()) {
+ VnSubnetsType.IpamSubnetType ipamSubnet = subnets.get(0);
+ vncSubnets.add(ipamSubnet.getDefaultGateway() + ipamSubnet.getSubnet().getIpPrefix() + "/" + ipamSubnet.getSubnet().getIpPrefixLen());
}
}
}
- // unordered, no duplicates hence perform negation operation as set
- Set<String> diff = new HashSet<String>(dbSubnets);
- diff.removeAll(vncSubnets);
+ }
+ // unordered, no duplicates hence perform negation operation as set
+ Set<String> diff = new HashSet<String>(dbSubnets);
+ diff.removeAll(vncSubnets);
- if (!diff.isEmpty()) {
- s_logger.debug("Subnets changed, network: " + this._name + "; db: " + dbSubnets + ", vnc: " + vncSubnets + ", diff: " + diff);
- return false;
- }
+ if (!diff.isEmpty()) {
+ s_logger.debug("Subnets changed, network: " + _name + "; db: " + dbSubnets + ", vnc: " + vncSubnets + ", diff: " + diff);
+ return false;
+ }
- List<ObjectReference<VirtualNetworkPolicyType>> policyRefs = _vn.getNetworkPolicy();
- if ((policyRefs == null || policyRefs.isEmpty()) && _policyModel != null) {
- return false;
- }
+ List<ObjectReference<VirtualNetworkPolicyType>> policyRefs = _vn.getNetworkPolicy();
+ if ((policyRefs == null || policyRefs.isEmpty()) && _policyModel != null) {
+ return false;
+ }
- if ((policyRefs != null && !policyRefs.isEmpty()) && _policyModel == null) {
- return false;
- }
+ if ((policyRefs != null && !policyRefs.isEmpty()) && _policyModel == null) {
+ return false;
+ }
- if (policyRefs != null && !policyRefs.isEmpty() && _policyModel != null) {
- ObjectReference<VirtualNetworkPolicyType> ref = policyRefs.get(0);
- if (!ref.getUuid().equals(_policyModel.getUuid())) {
- return false;
- }
+ if (policyRefs != null && !policyRefs.isEmpty() && _policyModel != null) {
+ ObjectReference<VirtualNetworkPolicyType> ref = policyRefs.get(0);
+ if (!ref.getUuid().equals(_policyModel.getUuid())) {
+ return false;
}
+ }
- for (ModelObject successor : successors()) {
- if (!successor.verify(controller)) {
- return false;
- }
+ for (ModelObject successor : successors()) {
+ if (!successor.verify(controller)) {
+ return false;
}
- return true;
+ }
+ return true;
}
@Override
public boolean compare(ModelController controller, ModelObject o) {
VirtualNetworkModel latest;
- assert this._vn != null : "vnc virtual network current is not initialized";
+ assert _vn != null : "vnc virtual network current is not initialized";
try {
latest = (VirtualNetworkModel)o;
@@ -464,7 +463,7 @@ public class VirtualNetworkModel extends ModelObjectBase {
}
assert latest._vn != null : "vnc virtual network new is not initialized";
- List<ObjectReference<VnSubnetsType>> currentIpamRefs = this._vn.getNetworkIpam();
+ List<ObjectReference<VnSubnetsType>> currentIpamRefs = _vn.getNetworkIpam();
List<ObjectReference<VnSubnetsType>> newIpamRefs = latest._vn.getNetworkIpam();
List<String> currentSubnets = new ArrayList<String>();
List<String> newSubnets = new ArrayList<String>();
@@ -503,42 +502,60 @@ public class VirtualNetworkModel extends ModelObjectBase {
diff.removeAll(newSubnets);
if (!diff.isEmpty()) {
- s_logger.debug("Subnets differ, network: " + this._name + "; db: " + currentSubnets + ", vnc: " + newSubnets + ", diff: " + diff);
+ s_logger.debug("Subnets differ, network: " + _name + "; db: " + currentSubnets + ", vnc: " + newSubnets + ", diff: " + diff);
return false;
}
- List<ObjectReference<VirtualNetworkPolicyType>> currentPolicyRefs = this._vn.getNetworkPolicy();
+ List<ObjectReference<VirtualNetworkPolicyType>> currentPolicyRefs = _vn.getNetworkPolicy();
List<ObjectReference<VirtualNetworkPolicyType>> latestPolicyRefs = latest._vn.getNetworkPolicy();
if (currentPolicyRefs == null && latestPolicyRefs == null) {
return true;
}
- if ((currentPolicyRefs == null && latestPolicyRefs != null) ||
- (currentPolicyRefs != null && latestPolicyRefs == null) ||
- (currentPolicyRefs.size() != latestPolicyRefs.size())) {
+ if ((currentPolicyRefs == null && latestPolicyRefs != null) || (currentPolicyRefs != null
+ && latestPolicyRefs == null)) {
+ return false;
+ }
+
+ if ((currentPolicyRefs != null && latestPolicyRefs != null) && (currentPolicyRefs.size() != latestPolicyRefs.size())) {
return false;
}
- if (currentPolicyRefs.isEmpty() && latestPolicyRefs.isEmpty()) {
+ if ((currentPolicyRefs != null && latestPolicyRefs != null) && currentPolicyRefs.isEmpty()
+ && latestPolicyRefs.isEmpty()) {
return true;
}
//both must be non empty lists
- ObjectReference<VirtualNetworkPolicyType> ref1 = currentPolicyRefs.get(0);
- ObjectReference<VirtualNetworkPolicyType> ref2 = latestPolicyRefs.get(0);
+ ObjectReference<VirtualNetworkPolicyType> ref1 = null;
+
+ if (currentPolicyRefs != null) {
+ ref1 = currentPolicyRefs.get(0);
+ }
+
+ ObjectReference<VirtualNetworkPolicyType> ref2 = null;
+
+ if (latestPolicyRefs != null) {
+ ref2 = latestPolicyRefs.get(0);
+ }
+
+ if (ref1 == null && ref2 == null) {
+ return true;
+ }
if ((ref1 != null && ref2 == null) || (ref1 == null && ref2 != null)) {
return false;
}
- if ((ref1.getUuid() != null && ref2.getUuid() == null) || (ref1.getUuid() == null && ref2.getUuid() != null)) {
+ if ((ref1 != null && ref2 != null) && ((ref1.getUuid() != null && ref2.getUuid() == null)
+ || (ref1.getUuid() == null && ref2.getUuid() != null))) {
return false;
}
- if (ref1.getUuid() == null && ref2.getUuid() == null) {
+ if ((ref1 != null && ref2 != null) && (ref1.getUuid() == null && ref2.getUuid() == null)) {
return true;
}
- if (!ref1.getUuid().equals(ref2.getUuid())) {
+ if ((ref1 != null && ref2 != null) && !ref1.getUuid().equals(ref2.getUuid())) {
return false;
}
return true;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualMachineModelTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualMachineModelTest.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualMachineModelTest.java
index f85beb6..1e3944a 100644
--- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualMachineModelTest.java
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualMachineModelTest.java
@@ -28,11 +28,10 @@ import junit.framework.TestCase;
import net.juniper.contrail.api.ApiConnector;
import net.juniper.contrail.api.ApiConnectorMock;
-import org.apache.log4j.Logger;
-import org.junit.Test;
-
import org.apache.cloudstack.network.contrail.management.ContrailManagerImpl;
import org.apache.cloudstack.network.contrail.management.ModelDatabase;
+import org.apache.log4j.Logger;
+import org.junit.Test;
import com.cloud.network.Network;
import com.cloud.network.dao.NetworkVO;
@@ -118,7 +117,5 @@ public class VirtualMachineModelTest extends TestCase {
//verify
assertTrue(vmModel.verify(controller));
-
}
-
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualNetworkModelTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualNetworkModelTest.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualNetworkModelTest.java
index b1b5ae1..3a1e147 100644
--- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualNetworkModelTest.java
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/model/VirtualNetworkModelTest.java
@@ -21,26 +21,138 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.UUID;
import junit.framework.TestCase;
import net.juniper.contrail.api.ApiConnector;
import net.juniper.contrail.api.ApiConnectorMock;
-
-import org.apache.log4j.Logger;
-import org.junit.Test;
+import net.juniper.contrail.api.ObjectReference;
+import net.juniper.contrail.api.types.VirtualNetwork;
+import net.juniper.contrail.api.types.VirtualNetworkPolicyType;
import org.apache.cloudstack.network.contrail.management.ContrailManager;
import org.apache.cloudstack.network.contrail.management.ContrailManagerImpl;
import org.apache.cloudstack.network.contrail.management.ModelDatabase;
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
+import com.cloud.dc.dao.VlanDao;
import com.cloud.network.Network.State;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.dao.NetworkVO;
public class VirtualNetworkModelTest extends TestCase {
+
private static final Logger s_logger = Logger.getLogger(VirtualNetworkModelTest.class);
+ private ModelController controller;
+
+ private VirtualNetworkModel vnModel;
+ private VirtualNetworkModel vnModel1;
+ private VirtualNetworkModel vnModel2;
+ private VirtualNetworkModel vnModel3;
+
+ @Override
+ @Before
+ public void setUp() throws IOException {
+ //Network UUIDs
+ String uuid = UUID.randomUUID().toString();
+ String uuid1 = UUID.randomUUID().toString();
+ String uuid2 = UUID.randomUUID().toString();
+ String uuid3 = UUID.randomUUID().toString();
+
+ //ContrailManager
+ ContrailManagerImpl contrailMgr = mock(ContrailManagerImpl.class);
+
+ controller = mock(ModelController.class);
+ VlanDao vlanDao = mock(VlanDao.class);
+
+ ApiConnector api = mock(ApiConnectorMock.class);
+
+ //Mock classes/methods
+ when(controller.getManager()).thenReturn(contrailMgr);
+ when(controller.getApiAccessor()).thenReturn(api);
+ when(controller.getVlanDao()).thenReturn(vlanDao);
+
+ //Policy References used by vnModel1
+ List<ObjectReference<VirtualNetworkPolicyType>> policyRefs1 = new ArrayList<ObjectReference<VirtualNetworkPolicyType>>();
+ ObjectReference<VirtualNetworkPolicyType> objectReference1 = new ObjectReference<VirtualNetworkPolicyType>();
+ policyRefs1.add(objectReference1);
+
+ //Policy References used by vnModel2
+ List<ObjectReference<VirtualNetworkPolicyType>> policyRefs2 = new ArrayList<ObjectReference<VirtualNetworkPolicyType>>();
+ ObjectReference<VirtualNetworkPolicyType> objectReference2 = new ObjectReference<VirtualNetworkPolicyType>();
+ policyRefs2.add(objectReference2);
+
+ //Policy References used by vnModel3
+ List<ObjectReference<VirtualNetworkPolicyType>> policyRefs3 = new ArrayList<ObjectReference<VirtualNetworkPolicyType>>();
+ ObjectReference<VirtualNetworkPolicyType> objectReference3 = new ObjectReference<VirtualNetworkPolicyType>();
+ objectReference3.setReference(Arrays.asList(""), null, null, UUID.randomUUID().toString());
+
+ policyRefs3.add(objectReference3);
+
+ //Network to be compared with
+ VirtualNetwork vn = mock(VirtualNetwork.class);
+ when(api.findById(VirtualNetwork.class, uuid)).thenReturn(vn);
+
+ //Network to be compared with
+ VirtualNetwork vn1 = mock(VirtualNetwork.class);
+ when(api.findById(VirtualNetwork.class, uuid1)).thenReturn(vn1);
+ when(vn1.getNetworkPolicy()).thenReturn(policyRefs1);
+
+ //Network to be compared to
+ VirtualNetwork vn2 = mock(VirtualNetwork.class);
+ when(api.findById(VirtualNetwork.class, uuid2)).thenReturn(vn2);
+ when(vn2.getNetworkPolicy()).thenReturn(policyRefs2);
+
+ //Network to be compared to
+ VirtualNetwork vn3 = mock(VirtualNetwork.class);
+ when(api.findById(VirtualNetwork.class, uuid3)).thenReturn(vn3);
+ when(vn3.getNetworkPolicy()).thenReturn(policyRefs3);
+
+ //Virtual-Network 1
+ NetworkVO network1 = mock(NetworkVO.class);
+ when(network1.getName()).thenReturn("testnetwork");
+ when(network1.getState()).thenReturn(State.Allocated);
+ when(network1.getGateway()).thenReturn("10.1.1.1");
+ when(network1.getCidr()).thenReturn("10.1.1.0/24");
+ when(network1.getPhysicalNetworkId()).thenReturn(42L);
+ when(network1.getDomainId()).thenReturn(10L);
+ when(network1.getAccountId()).thenReturn(42L);
+
+ //Virtual-Network 2
+ NetworkVO network2 = mock(NetworkVO.class);
+ when(network2.getName()).thenReturn("Testnetwork");
+ when(network2.getState()).thenReturn(State.Allocated);
+ when(network2.getGateway()).thenReturn("10.1.1.1");
+ when(network2.getCidr()).thenReturn("10.1.1.0/24");
+ when(network2.getPhysicalNetworkId()).thenReturn(42L);
+ when(network2.getDomainId()).thenReturn(10L);
+ when(network2.getAccountId()).thenReturn(42L);
+
+ //Virtual-Network 3
+ NetworkVO network3 = mock(NetworkVO.class);
+ when(network3.getName()).thenReturn("Testnetwork");
+ when(network3.getState()).thenReturn(State.Allocated);
+ when(network3.getGateway()).thenReturn("10.1.1.1");
+ when(network3.getCidr()).thenReturn("10.1.1.0/24");
+ when(network3.getPhysicalNetworkId()).thenReturn(42L);
+ when(network3.getDomainId()).thenReturn(10L);
+ when(network3.getAccountId()).thenReturn(42L);
+
+ when(contrailMgr.getCanonicalName(network1)).thenReturn("testnetwork");
+ when(contrailMgr.getProjectId(network1.getDomainId(), network1.getAccountId())).thenReturn("testProjectId");
+
+ vnModel = new VirtualNetworkModel(network1, uuid, "testnetwork", TrafficType.Guest);
+ vnModel1 = new VirtualNetworkModel(network1, uuid1, "testnetwork", TrafficType.Guest);
+ vnModel2 = new VirtualNetworkModel(network2, uuid2, "testnetwork", TrafficType.Guest);
+ vnModel3 = new VirtualNetworkModel(network3, uuid3, "testnetwork", TrafficType.Guest);
+ }
+
@Test
public void testDBLookup() {
ModelDatabase db = new ModelDatabase();
@@ -99,4 +211,27 @@ public class VirtualNetworkModelTest extends TestCase {
assertTrue(vnModel.verify(controller));
}
-}
+ @Test
+ public void testCompareDifferentVirtualNetwork() throws IOException {
+ //This one returns false because one network has Policy References
+ vnModel.read(controller);
+
+ assertFalse(vnModel.compare(controller, vnModel1));
+ }
+
+ @Test
+ public void testCompareSameVirtualNetwork() throws IOException {
+ //This one returns true because both networks have the same Policy References
+ vnModel1.read(controller);
+
+ assertTrue(vnModel1.compare(controller, vnModel2));
+ }
+
+ @Test
+ public void testCompareDifferentDeeperVirtualNetwork() throws IOException {
+ //This one returns false because one network has Policy References
+ vnModel2.read(controller);
+
+ assertFalse(vnModel2.compare(controller, vnModel3));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/utils/src/com/cloud/utils/UuidUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/UuidUtils.java b/utils/src/com/cloud/utils/UuidUtils.java
index 7831bea..28b6b1d 100644
--- a/utils/src/com/cloud/utils/UuidUtils.java
+++ b/utils/src/com/cloud/utils/UuidUtils.java
@@ -16,8 +16,16 @@
// under the License.
package com.cloud.utils;
+import org.apache.xerces.impl.xpath.regex.RegularExpression;
+
public class UuidUtils {
+
public final static String first(String uuid) {
return uuid.substring(0, uuid.indexOf('-'));
}
-}
+
+ public static boolean validateUUID(String uuid) {
+ RegularExpression regex = new RegularExpression("[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}");
+ return regex.matches(uuid);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3199de69/utils/test/com/cloud/utils/UuidUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/UuidUtilsTest.java b/utils/test/com/cloud/utils/UuidUtilsTest.java
new file mode 100644
index 0000000..299e247
--- /dev/null
+++ b/utils/test/com/cloud/utils/UuidUtilsTest.java
@@ -0,0 +1,23 @@
+package com.cloud.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class UuidUtilsTest {
+
+ @Test
+ public void testValidateUUIDPass() throws Exception {
+ String serviceUuid = "f81a9aa3-1f7d-466f-b04b-f2b101486bae";
+
+ assertTrue(UuidUtils.validateUUID(serviceUuid));
+ }
+
+ @Test
+ public void testValidateUUIDFail() throws Exception {
+ String serviceUuid = "6fc6ce7-d503-4f95-9e68-c9cd281b13df";
+
+ assertFalse(UuidUtils.validateUUID(serviceUuid));
+ }
+}
\ No newline at end of file
[32/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-4840: Add missed testcase in previous commit
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b70af44e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b70af44e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b70af44e
Branch: refs/heads/ui-restyle
Commit: b70af44ecfb0b7509a456327d85b5c0aea1ed197
Parents: c969aa2
Author: Girish Shilamkar <gi...@clogeny.com>
Authored: Wed Feb 19 11:15:10 2014 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Wed Feb 19 11:17:22 2014 +0530
----------------------------------------------------------------------
.../component/test_multiple_ips_per_nic.py | 452 +++++++++++++++++++
1 file changed, 452 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b70af44e/test/integration/component/test_multiple_ips_per_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_multiple_ips_per_nic.py b/test/integration/component/test_multiple_ips_per_nic.py
new file mode 100644
index 0000000..7d7e9f1
--- /dev/null
+++ b/test/integration/component/test_multiple_ips_per_nic.py
@@ -0,0 +1,452 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with 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.
+""" Tests for Multiple IPs per NIC feature
+
+ Test Plan: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Multiple+IPs+per+NIC+Test+Plan
+
+ Issue Link: https://issues.apache.org/jira/browse/CLOUDSTACK-4840
+
+ Design Document: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Multiple+IP+address+per+NIC
+"""
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.integration.lib.utils import (cleanup_resources,
+ validateList,
+ random_gen)
+from marvin.integration.lib.base import (Account,
+ ServiceOffering,
+ Network,
+ VirtualMachine,
+ VpcOffering,
+ VPC,
+ NIC,
+ Domain,
+ PublicIPAddress)
+from marvin.integration.lib.common import (get_domain,
+ get_zone,
+ get_template,
+ get_free_vlan,
+ setSharedNetworkParams,
+ createEnabledNetworkOffering,
+ shouldTestBeSkipped)
+
+from nose.plugins.attrib import attr
+from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, SHARED_NETWORK
+from ddt import ddt, data
+
+def createNetwork(self, networkType):
+ """Create a network of given type (isolated/shared/isolated in VPC)"""
+
+ network = None
+
+ if networkType == ISOLATED_NETWORK:
+ try:
+ network = Network.create(self.apiclient,self.services["isolated_network"],
+ networkofferingid=self.isolated_network_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid,
+ zoneid=self.zone.id)
+ except Exception as e:
+ self.fail("Isolated network creation failed because: %s" % e)
+
+ elif networkType == SHARED_NETWORK:
+ physical_network, vlan = get_free_vlan(self.api_client, self.zone.id)
+
+ #create network using the shared network offering created
+ self.services["shared_network"]["acltype"] = "domain"
+ self.services["shared_network"]["vlan"] = vlan
+ self.services["shared_network"]["networkofferingid"] = self.shared_network_offering.id
+ self.services["shared_network"]["physicalnetworkid"] = physical_network.id
+
+ self.services["shared_network"] = setSharedNetworkParams(self.services["shared_network"])
+
+ try:
+ network = Network.create(self.api_client, self.services["shared_network"],
+ networkofferingid=self.shared_network_offering.id, zoneid=self.zone.id)
+ self.cleanup.append(network)
+ except Exception as e:
+ self.fail("Shared Network creation failed because: %s" % e)
+
+ elif networkType == VPC_NETWORK:
+ self.services["vpc"]["cidr"] = "10.1.1.1/16"
+ self.debug("creating a VPC network in the account: %s" %
+ self.account.name)
+ vpc = VPC.create(self.apiclient, self.services["vpc"],
+ vpcofferingid=self.vpc_off.id, zoneid=self.zone.id,
+ account=self.account.name, domainid=self.account.domainid)
+ vpcs = VPC.list(self.apiclient, id=vpc.id)
+ self.assertEqual(validateList(vpcs)[0], PASS, "VPC list validation failed, vpc list is %s" % vpcs)
+
+ network = Network.create(self.api_client,self.services["isolated_network"],
+ networkofferingid=self.isolated_network_offering_vpc.id,
+ accountid=self.account.name,domainid=self.account.domainid,
+ zoneid=self.zone.id, vpcid=vpc.id, gateway="10.1.1.1", netmask="255.255.255.0")
+ return network
+
+def CreateEnabledNetworkOffering(apiclient, networkServices):
+ """Create network offering of given services and enable it"""
+
+ result = createEnabledNetworkOffering(apiclient, networkServices)
+ assert result[0] == PASS, "Network offering creation/enabling failed due to %s" % result[2]
+ return result[1]
+
+@ddt
+class TestBasicOperations(cloudstackTestCase):
+ """Test Basic operations (add/remove/list) IP to/from NIC
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ cloudstackTestClient = super(TestBasicOperations,cls).getClsTestClient()
+ cls.api_client = cloudstackTestClient.getApiClient()
+
+ # Fill services from the external config file
+ cls.services = cloudstackTestClient.getConfigParser().parsedDict
+
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.services)
+ cls.mode = str(cls.zone.networktype).lower()
+ cls.template = get_template(
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
+ cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+ cls.services["virtual_machine"]["template"] = cls.template.id
+ cls.service_offering = ServiceOffering.create(
+ cls.api_client,
+ cls.services["service_offering"]
+ )
+ cls._cleanup = [cls.service_offering]
+ cls.services["shared_network_offering"]["specifyVlan"] = "True"
+ cls.services["shared_network_offering"]["specifyIpRanges"] = "True"
+
+ cls.shared_network_offering = CreateEnabledNetworkOffering(cls.api_client,
+ cls.services["shared_network_offering"])
+ cls._cleanup.append(cls.shared_network_offering)
+
+ if cls.mode == "advanced":
+ cls.isolated_network_offering = CreateEnabledNetworkOffering(cls.api_client,
+ cls.services["isolated_network_offering"])
+ cls._cleanup.append(cls.isolated_network_offering)
+ cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(cls.api_client,
+ cls.services["nw_offering_isolated_vpc"])
+ cls._cleanup.append(cls.isolated_network_offering_vpc)
+ cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"])
+ cls.vpc_off.update(cls.api_client, state='Enabled')
+ cls._cleanup.append(cls.vpc_off)
+ return
+
+ @classmethod
+ def tearDownClass(cls):
+ try:
+ # Cleanup resources used
+ cleanup_resources(cls.api_client, cls._cleanup)
+ except Exception as e:
+ raise Exception("Warning: Exception during cleanup : %s" % e)
+ return
+
+ def setUp(self):
+ self.apiclient = self.testClient.getApiClient()
+ self.dbclient = self.testClient.getDbConnection()
+ self.cleanup = [ ]
+ return
+
+ def tearDown(self):
+ try:
+ # Clean up, terminate the resources created
+ cleanup_resources(self.apiclient, self.cleanup)
+ self.cleanup[:] = []
+ except Exception as e:
+ raise Exception("Warning: Exception during cleanup : %s" % e)
+ return
+
+ def VerifyStaticNatForPublicIp(self, ipaddressid, natrulestatus):
+ """ List public IP and verify that NAT rule status for the IP is as desired """
+
+ publiciplist = PublicIPAddress.list(self.apiclient, id=ipaddressid, listall=True)
+ self.assertEqual(validateList(publiciplist)[0], PASS, "Public IP list validation failed")
+ self.assertEqual(publiciplist[0].isstaticnat, natrulestatus, "isstaticnat should be %s, it is %s" %
+ (natrulestatus, publiciplist[0].isstaticnat))
+
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["basic","advanced"])
+ def test_add_ip_to_nic(self, value):
+ """ Add secondary IP to NIC of a VM"""
+
+ # Steps:
+ # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+ # 2. Deploy a VM in this network and account
+ # 3. Add secondary IP to the default nic of VM
+ # 4. Try to add the same IP again
+ # 5. Try to add secondary IP providing wrong virtual machine id
+ # 6. Try to add secondary IP with correct virtual machine id but wrong IP address
+
+ # Validations:
+ # 1. Step 3 should succeed
+ # 2. Step 4 should fail
+ # 3. Step 5 should should fail
+ # 4. Step 6 should fail
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+ self.cleanup.append(self.account)
+
+ if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)):
+ self.skipTest("Skipping test as %s network is not supported in basic zone" % value)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ try:
+ ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id, ipaddress=ipaddress_1.ipaddress)
+ self.debug("Adding already added secondary IP %s to NIC of vm %s succeeded, should have failed" %
+ (ipaddress_1.ipaddress, virtual_machine.id))
+ except Exception as e:
+ self.debug("Failed while adding already added secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ NIC.addIp(self.apiclient, id=(virtual_machine.nic[0].id + random_gen()))
+ self.fail("Adding secondary IP with wrong NIC id succeded, it shoud have failed")
+ except Exception as e:
+ self.debug("Failed while adding secondary IP to wrong NIC")
+
+ try:
+ NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id, ipaddress = "255.255.255.300")
+ self.fail("Adding secondary IP with wrong ipaddress succeded, it should have failed")
+ except Exception as e:
+ self.debug("Failed while adding wrong secondary IP to NIC of VM %s" % virtual_machine.id)
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["basic","advanced"])
+ def test_remove_ip_from_nic(self, value):
+ """ Remove secondary IP from NIC of a VM"""
+
+ # Steps:
+ # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+ # 2. Deploy a VM in this network and account
+ # 3. Add secondary IP to the default nic of VM
+ # 4. Remove the secondary IP
+ # 5. Try to remove secondary ip by giving incorrect ipaddress id
+
+ # Validations:
+ # 1. Step 4 should succeed
+ # 2. Step 5 should fail
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+ self.cleanup.append(self.account)
+
+ if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)):
+ self.skipTest("Skipping test as %s network is not supported in basic zone" % value)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ try:
+ ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ NIC.removeIp(self.apiclient, ipaddressid=ipaddress_1.id)
+ except Exception as e:
+ self.fail("Removing seondary IP %s from NIC failed as expected with Exception %s" % (ipaddress_1.id,e))
+
+ try:
+ NIC.removeIp(self.apiclient, ipaddressid=(ipaddress_1.id + random_gen()))
+ self.fail("Removing invalid IP address, it should have failed")
+ except Exception as e:
+ self.debug("Removing invalid IP failed as expected with Exception %s" % e)
+ return
+
+ @attr(tags=["basic","advanced"])
+ def test_remove_invalid_ip(self):
+ """ Remove invalid ip"""
+
+ # Steps:
+ # 1. Try to remove secondary ip without passing ip address id
+
+ # Validations:
+ # 1. Step 1 should fail
+
+ try:
+ NIC.removeIp(self.apiclient, ipaddressid="")
+ self.fail("Removing IP address without passing IP succeeded, it should have failed")
+ except Exception as e:
+ self.debug("Removing IP from NIC without passing ipaddressid failed as expected with Exception %s" % e)
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["basic","advanced"])
+ def test_list_nics(self, value):
+ """Test listing nics associated with the ip address"""
+
+ # Steps:
+ # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+ # 2. Deploy a VM in this network and account
+ # 3. Add secondary IP to the default nic of VM
+ # 4. Try to list the secondary ips without passing vm id
+ # 5. Try to list secondary IPs by passing correct vm id
+ # 6. Try to list secondary IPs by passing correct vm id and its nic id
+ # 7. Try to list secondary IPs by passing incorrect vm id and correct nic id
+ # 8. Try to list secondary IPs by passing correct vm id and incorrect nic id
+ # 9. Try to list secondary IPs by passing incorrect vm id and incorrect nic id
+
+ # Validations:
+ # 1. Step 4 should fail
+ # 2. Step 5 should succeed
+ # 3. Step 6 should succeed
+ # 4. Step 7 should fail
+ # 5. Step 8 should fail
+ # 6. Step 9 should fail
+
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+ self.cleanup.append(self.account)
+
+ if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)):
+ self.skipTest("Skipping test as %s network is not supported in basic zone" % value)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ try:
+ NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ nics = NIC.list(self.apiclient)
+ self.fail("Listing NICs without passign VM id succeeded, it should have failed, list is %s" % nics)
+ except Exception as e:
+ self.debug("Listing NICs without passing virtual machine id failed as expected")
+
+ try:
+ NIC.list(self.apiclient, virtualmachineid=virtual_machine.id)
+ except Exception as e:
+ self.fail("Listing NICs for virtual machine %s failed with Exception %s" % (virtual_machine.id, e))
+
+ try:
+ NIC.list(self.apiclient, virtualmachineid=virtual_machine.id, nicid=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Listing NICs for virtual machine %s and nic id %s failed with Exception %s" %
+ (virtual_machine.id, virtual_machine.nic[0].id, e))
+
+ try:
+ nics = NIC.list(self.apiclient, virtualmachineid=(virtual_machine.id + random_gen()), nicid=virtual_machine.nic[0].id)
+ self.fail("Listing NICs with wrong virtual machine id and right nic id succeeded, should have failed")
+ except Exception as e:
+ self.debug("Listing NICs with wrong virtual machine id and right nic failed as expected with Exception %s" % e)
+
+ try:
+ nics = NIC.list(self.apiclient, virtualmachineid=virtual_machine.id, nicid=(virtual_machine.nic[0].id + random_gen()))
+ self.fail("Listing NICs with correct virtual machine id but wrong nic id succeeded, should have failed")
+ except Exception as e:
+ self.debug("Listing NICs with correct virtual machine id but wrong nic id failed as expected with Exception %s" % e)
+
+ try:
+ nics = NIC.list(self.apiclient, virtualmachineid=(virtual_machine.id+random_gen()), nicid=(virtual_machine.nic[0].id + random_gen()))
+ self.fail("Listing NICs with wrong virtual machine id and wrong nic id succeeded, should have failed")
+ except Exception as e:
+ self.debug("Listing NICs with wrong virtual machine id and wrong nic id failed as expected with Exception %s" % e)
+
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["basic","advanced"])
+ def test_operations_non_root_admin_api_client(self, value):
+ """Test basic operations using non root admin apii client"""
+
+ # Steps:
+ # 1. Create Domain and Account in it
+ # 2. Create network in it (isoalted/ shared/ vpc)
+ # 3. Create User API client of this account
+ # 4. Deploy a VM in this network and account
+ # 5. Add secondary IP to the default nic of VM using non root admin api client
+ # 6. List secondary IPs using non root admin api client
+ # 7. Remove secondary IP using non root admin api client
+
+ # Validations:
+ # 1. All the operations should be successful
+
+ child_domain = Domain.create(self.apiclient,services=self.services["domain"],
+ parentdomainid=self.domain.id)
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=child_domain.id)
+ self.cleanup.append(self.account)
+ self.cleanup.append(child_domain)
+
+ apiclient = self.testClient.createUserApiClient(UserName=self.account.name, DomainName=self.account.domain)
+
+ if(shouldTestBeSkipped(networkType=value, zoneType=self.mode)):
+ self.skipTest("Skipping test as %s network is not supported in basic zone" % value)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ try:
+ ipaddress_1 = NIC.addIp(apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ NIC.list(apiclient, virtualmachineid=virtual_machine.id)
+ except Exception as e:
+ self.fail("Listing NICs for virtual machine %s failed with Exception %s" % (virtual_machine.id, e))
+
+ try:
+ NIC.list(apiclient, virtualmachineid=virtual_machine.id, nicid=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Listing NICs for virtual machine %s and nic id %s failed with Exception %s" %
+ (virtual_machine.id, virtual_machine.nic[0].id, e))
+
+ try:
+ NIC.removeIp(apiclient, ipaddressid=ipaddress_1.id)
+ except Exception as e:
+ self.fail("Removing seondary IP %s from NIC failed as expected with Exception %s" % (ipaddress_1.id,e))
+
+ return
[19/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
package.sh: cleaning up formatting
No logic changes made. Tested no syntax errors added.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dda47dbd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dda47dbd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dda47dbd
Branch: refs/heads/ui-restyle
Commit: dda47dbd67a45053f2700f5ed1784b0403af3316
Parents: 9dd57c2
Author: John Kinsella <jl...@stratosec.co>
Authored: Mon Feb 17 10:51:34 2014 -0800
Committer: John Kinsella <jl...@stratosec.co>
Committed: Mon Feb 17 10:51:34 2014 -0800
----------------------------------------------------------------------
packaging/centos63/package.sh | 170 ++++++++++++++++++-------------------
1 file changed, 81 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dda47dbd/packaging/centos63/package.sh
----------------------------------------------------------------------
diff --git a/packaging/centos63/package.sh b/packaging/centos63/package.sh
index bbd8eaa..fa004af 100755
--- a/packaging/centos63/package.sh
+++ b/packaging/centos63/package.sh
@@ -17,101 +17,93 @@
# under the License.
function usage() {
- echo ""
- echo "usage: ./package.sh [-p|--pack] [-h|--help] [ARGS]"
- echo ""
- echo "The commonly used Arguments are:"
- echo "oss|OSS To package with only redistributable libraries (default)"
- echo "noredist|NOREDIST To package with non-redistributable libraries"
- echo ""
- echo "Examples: ./package.sh -p|--pack oss|OSS"
- echo " ./package.sh -p|--pack noredist|NOREDIST"
- echo " ./package.sh (Default OSS)"
- exit 1
+ echo ""
+ echo "usage: ./package.sh [-p|--pack] [-h|--help] [ARGS]"
+ echo ""
+ echo "The commonly used Arguments are:"
+ echo "oss|OSS To package with only redistributable libraries (default)"
+ echo "noredist|NOREDIST To package with non-redistributable libraries"
+ echo ""
+ echo "Examples: ./package.sh -p|--pack oss|OSS"
+ echo " ./package.sh -p|--pack noredist|NOREDIST"
+ echo " ./package.sh (Default OSS)"
+ exit 1
}
function packaging() {
-
-CWD=`pwd`
-RPMDIR=$CWD/../../dist/rpmbuild
-PACK_PROJECT=cloudstack
-if [ -n "$1" ] ; then
- DEFOSSNOSS="-D_ossnoss $packageval"
-fi
-
-
-VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep --color=none '^[0-9]\.'`
-if echo $VERSION | grep SNAPSHOT ; then
- REALVER=`echo $VERSION | cut -d '-' -f 1`
- DEFVER="-D_ver $REALVER"
- DEFPRE="-D_prerelease 1"
- DEFREL="-D_rel SNAPSHOT"
-else
- REALVER=`echo $VERSION`
- DEFVER="-D_ver $REALVER"
- DEFREL="-D_rel 1"
-fi
-
-mkdir -p $RPMDIR/SPECS
-mkdir -p $RPMDIR/BUILD
-mkdir -p $RPMDIR/RPMS
-mkdir -p $RPMDIR/SRPMS
-mkdir -p $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION
-
-
-(cd ../../; tar -c --exclude .git --exclude dist . | tar -C $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -x )
-(cd $RPMDIR/SOURCES/; tar -czf $PACK_PROJECT-$VERSION.tgz $PACK_PROJECT-$VERSION)
-
-cp cloud.spec $RPMDIR/SPECS
-
-(cd $RPMDIR; rpmbuild --define "_topdir $RPMDIR" "${DEFVER}" "${DEFREL}" ${DEFPRE+"${DEFPRE}"} ${DEFOSSNOSS+"$DEFOSSNOSS"} -bb SPECS/cloud.spec)
-
-exit
+ CWD=`pwd`
+ RPMDIR=$CWD/../../dist/rpmbuild
+ PACK_PROJECT=cloudstack
+ if [ -n "$1" ] ; then
+ DEFOSSNOSS="-D_ossnoss $packageval"
+ fi
+
+ VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep --color=none '^[0-9]\.'`
+ if echo $VERSION | grep SNAPSHOT ; then
+ REALVER=`echo $VERSION | cut -d '-' -f 1`
+ DEFVER="-D_ver $REALVER"
+ DEFPRE="-D_prerelease 1"
+ DEFREL="-D_rel SNAPSHOT"
+ else
+ REALVER=`echo $VERSION`
+ DEFVER="-D_ver $REALVER"
+ DEFREL="-D_rel 1"
+ fi
+
+ mkdir -p $RPMDIR/SPECS
+ mkdir -p $RPMDIR/BUILD
+ mkdir -p $RPMDIR/RPMS
+ mkdir -p $RPMDIR/SRPMS
+ mkdir -p $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION
+
+ (cd ../../; tar -c --exclude .git --exclude dist . | tar -C $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -x )
+ (cd $RPMDIR/SOURCES/; tar -czf $PACK_PROJECT-$VERSION.tgz $PACK_PROJECT-$VERSION)
+
+ cp cloud.spec $RPMDIR/SPECS
+
+ (cd $RPMDIR; rpmbuild --define "_topdir $RPMDIR" "${DEFVER}" "${DEFREL}" ${DEFPRE+"${DEFPRE}"} ${DEFOSSNOSS+"$DEFOSSNOSS"} -bb SPECS/cloud.spec)
+
+ exit
}
-
if [ $# -lt 1 ] ; then
-
- packaging
-
+ packaging
elif [ $# -gt 0 ] ; then
-
- SHORTOPTS="hp:"
- LONGOPTS="help,pack:"
-
- ARGS=$(getopt -s bash -u -a --options $SHORTOPTS --longoptions $LONGOPTS --name $0 -- "$@" )
- eval set -- "$ARGS"
-
- while [ $# -gt 0 ] ; do
- case "$1" in
- -h | --help)
- usage
- exit 0
- ;;
- -p | --pack)
- echo "Doing CloudStack Packaging ....."
- packageval=$2
- if [ "$packageval" == "oss" -o "$packageval" == "OSS" ] ; then
- packaging
- elif [ "$packageval" == "noredist" -o "$packageval" == "NOREDIST" ] ; then
- packaging noredist
- else
- echo "Error: Incorrect value provided in package.sh script, Please see help ./package.sh --help|-h for more details."
- exit 1
- fi
- ;;
- -)
- echo "Unrecognized option..."
- usage
- exit 1
- ;;
- *)
- shift
- ;;
- esac
- done
-
+ SHORTOPTS="hp:"
+ LONGOPTS="help,pack:"
+
+ ARGS=$(getopt -s bash -u -a --options $SHORTOPTS --longoptions $LONGOPTS --name $0 -- "$@" )
+ eval set -- "$ARGS"
+
+ while [ $# -gt 0 ] ; do
+ case "$1" in
+ -h | --help)
+ usage
+ exit 0
+ ;;
+ -p | --pack)
+ echo "Doing CloudStack Packaging ....."
+ packageval=$2
+ if [ "$packageval" == "oss" -o "$packageval" == "OSS" ] ; then
+ packaging
+ elif [ "$packageval" == "noredist" -o "$packageval" == "NOREDIST" ] ; then
+ packaging noredist
+ else
+ echo "Error: Incorrect value provided in package.sh script, Please see help ./package.sh --help|-h for more details."
+ exit 1
+ fi
+ ;;
+ -)
+ echo "Unrecognized option..."
+ usage
+ exit 1
+ ;;
+ *)
+ shift
+ ;;
+ esac
+ done
else
- echo "Incorrect choice. Nothing to do." >&2
- echo "Please, execute ./package.sh --help for more help"
+ echo "Incorrect choice. Nothing to do." >&2
+ echo "Please, execute ./package.sh --help for more help"
fi
[37/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6140: UI - template - detailView - move fields that are used more often to the top.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c93b0967
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c93b0967
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c93b0967
Branch: refs/heads/ui-restyle
Commit: c93b0967ef5278049d0940566eb455b38d3e5cbe
Parents: b01720d
Author: Jessica Wang <je...@apache.org>
Authored: Wed Feb 19 15:30:49 2014 -0800
Committer: Jessica Wang <je...@apache.org>
Committed: Wed Feb 19 15:31:02 2014 -0800
----------------------------------------------------------------------
ui/scripts/templates.js | 69 ++++++++++++++++++++++++--------------------
1 file changed, 37 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c93b0967/ui/scripts/templates.js
----------------------------------------------------------------------
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index 716c615..3551613 100644
--- a/ui/scripts/templates.js
+++ b/ui/scripts/templates.js
@@ -938,23 +938,15 @@
required: true
}
}
- }, {
- id: {
- label: 'label.id'
- },
- zonename: {
- label: 'label.zone.name'
- },
- zoneid: {
- label: 'label.zone.id'
+ }, {
+ isready: {
+ label: 'state.ready',
+ converter: cloudStack.converters.toBooleanText
},
- displaytext: {
- label: 'label.description',
- isEditable: true,
- validation: {
- required: true
- }
+ status: {
+ label: 'label.status'
},
+
hypervisor: {
label: 'label.hypervisor'
},
@@ -968,17 +960,8 @@
return false;
},
converter: cloudStack.converters.toBooleanText
- },
- templatetype: {
- label: 'label.type'
- },
- isready: {
- label: 'state.ready',
- converter: cloudStack.converters.toBooleanText
- },
- status: {
- label: 'label.status'
- },
+ },
+
size: {
label: 'label.size',
converter: function(args) {
@@ -1036,12 +1019,8 @@
return false;
},
converter: cloudStack.converters.toBooleanText
- },
- crossZones: {
- label: 'label.cross.zones',
- converter: cloudStack.converters.toBooleanText
- },
-
+ },
+
ostypeid: {
label: 'label.os.type',
isEditable: true,
@@ -1067,6 +1046,21 @@
}
},
+ zonename: {
+ label: 'label.zone.name'
+ },
+ crossZones: {
+ label: 'label.cross.zones',
+ converter: cloudStack.converters.toBooleanText
+ },
+ displaytext: {
+ label: 'label.description',
+ isEditable: true,
+ validation: {
+ required: true
+ }
+ },
+
domain: {
label: 'label.domain'
},
@@ -1076,6 +1070,17 @@
created: {
label: 'label.created',
converter: cloudStack.converters.toLocalDate
+ },
+
+ templatetype: {
+ label: 'label.type'
+ },
+
+ id: {
+ label: 'label.id'
+ },
+ zoneid: {
+ label: 'label.zone.id'
}
}],
[27/50] [abbrv] Fixup the license headers in the utils project. All
files now use the same license header and this is enforced by the
maven-license-check plugin.
Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/Named.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/Named.java b/utils/src/com/cloud/utils/component/Named.java
index 6960b4c..60835b0 100644
--- a/utils/src/com/cloud/utils/component/Named.java
+++ b/utils/src/com/cloud/utils/component/Named.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.component;
public interface Named {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/PluggableService.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/PluggableService.java b/utils/src/com/cloud/utils/component/PluggableService.java
index 7f4303e..60c64bf 100644
--- a/utils/src/com/cloud/utils/component/PluggableService.java
+++ b/utils/src/com/cloud/utils/component/PluggableService.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/Registry.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/Registry.java b/utils/src/com/cloud/utils/component/Registry.java
index c2a74ae..d3a48df 100644
--- a/utils/src/com/cloud/utils/component/Registry.java
+++ b/utils/src/com/cloud/utils/component/Registry.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.component;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/SystemIntegrityChecker.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/SystemIntegrityChecker.java b/utils/src/com/cloud/utils/component/SystemIntegrityChecker.java
index 91b2a54..a0e2581 100755
--- a/utils/src/com/cloud/utils/component/SystemIntegrityChecker.java
+++ b/utils/src/com/cloud/utils/component/SystemIntegrityChecker.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/concurrency/NamedThreadFactory.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/concurrency/NamedThreadFactory.java b/utils/src/com/cloud/utils/concurrency/NamedThreadFactory.java
index 4344c49..ed4d6b0 100644
--- a/utils/src/com/cloud/utils/concurrency/NamedThreadFactory.java
+++ b/utils/src/com/cloud/utils/concurrency/NamedThreadFactory.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.concurrency;
import java.util.concurrent.ThreadFactory;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/concurrency/Scheduler.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/concurrency/Scheduler.java b/utils/src/com/cloud/utils/concurrency/Scheduler.java
index 943f55c..e0dba24 100644
--- a/utils/src/com/cloud/utils/concurrency/Scheduler.java
+++ b/utils/src/com/cloud/utils/concurrency/Scheduler.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.concurrency;
import java.util.Date;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/concurrency/SynchronizationEvent.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/concurrency/SynchronizationEvent.java b/utils/src/com/cloud/utils/concurrency/SynchronizationEvent.java
index 64b862d..5207ad4 100644
--- a/utils/src/com/cloud/utils/concurrency/SynchronizationEvent.java
+++ b/utils/src/com/cloud/utils/concurrency/SynchronizationEvent.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.concurrency;
import org.apache.log4j.Logger;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/concurrency/TestClock.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/concurrency/TestClock.java b/utils/src/com/cloud/utils/concurrency/TestClock.java
index ae52d23..8104a94 100644
--- a/utils/src/com/cloud/utils/concurrency/TestClock.java
+++ b/utils/src/com/cloud/utils/concurrency/TestClock.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.concurrency;
import java.util.Calendar;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/crypt/DBEncryptionUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/crypt/DBEncryptionUtil.java b/utils/src/com/cloud/utils/crypt/DBEncryptionUtil.java
index e2e33c5..52f2034 100755
--- a/utils/src/com/cloud/utils/crypt/DBEncryptionUtil.java
+++ b/utils/src/com/cloud/utils/crypt/DBEncryptionUtil.java
@@ -1,19 +1,22 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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.package com.cloud.utils.crypt;
+// under the License.
+//
+
package com.cloud.utils.crypt;
import java.util.Properties;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java b/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java
index 530e138..0e995c4 100755
--- a/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java
+++ b/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChecker.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.crypt;
import java.io.BufferedReader;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/crypt/EncryptionSecretKeySender.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/crypt/EncryptionSecretKeySender.java b/utils/src/com/cloud/utils/crypt/EncryptionSecretKeySender.java
index 0fe9a35..086e8a8 100755
--- a/utils/src/com/cloud/utils/crypt/EncryptionSecretKeySender.java
+++ b/utils/src/com/cloud/utils/crypt/EncryptionSecretKeySender.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.crypt;
import java.io.PrintWriter;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/crypt/RSAHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/crypt/RSAHelper.java b/utils/src/com/cloud/utils/crypt/RSAHelper.java
index c70b5b7..4960e9e 100644
--- a/utils/src/com/cloud/utils/crypt/RSAHelper.java
+++ b/utils/src/com/cloud/utils/crypt/RSAHelper.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.crypt;
import java.io.ByteArrayInputStream;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/db/DbProperties.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/DbProperties.java b/utils/src/com/cloud/utils/db/DbProperties.java
index 2093d02..8420614 100644
--- a/utils/src/com/cloud/utils/db/DbProperties.java
+++ b/utils/src/com/cloud/utils/db/DbProperties.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.db;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/db/EntityManager.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/EntityManager.java b/utils/src/com/cloud/utils/db/EntityManager.java
index 61adef5..7612a75 100644
--- a/utils/src/com/cloud/utils/db/EntityManager.java
+++ b/utils/src/com/cloud/utils/db/EntityManager.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.db;
import java.io.Serializable;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/db/UUIDManager.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/UUIDManager.java b/utils/src/com/cloud/utils/db/UUIDManager.java
index 6bc3f5d..ae759bc 100644
--- a/utils/src/com/cloud/utils/db/UUIDManager.java
+++ b/utils/src/com/cloud/utils/db/UUIDManager.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.db;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/encoding/URLEncoder.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/encoding/URLEncoder.java b/utils/src/com/cloud/utils/encoding/URLEncoder.java
index c882ec2..58971e7 100644
--- a/utils/src/com/cloud/utils/encoding/URLEncoder.java
+++ b/utils/src/com/cloud/utils/encoding/URLEncoder.java
@@ -1,17 +1,22 @@
-/*
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.encoding;
import java.io.ByteArrayOutputStream;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/events/EventArgs.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/events/EventArgs.java b/utils/src/com/cloud/utils/events/EventArgs.java
index 4bfe206..5c06b4b 100644
--- a/utils/src/com/cloud/utils/events/EventArgs.java
+++ b/utils/src/com/cloud/utils/events/EventArgs.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.events;
import java.io.Serializable;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/events/SubscriptionMgr.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/events/SubscriptionMgr.java b/utils/src/com/cloud/utils/events/SubscriptionMgr.java
index 0ea7295..254c27d 100644
--- a/utils/src/com/cloud/utils/events/SubscriptionMgr.java
+++ b/utils/src/com/cloud/utils/events/SubscriptionMgr.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.events;
import java.lang.reflect.InvocationTargetException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/exception/CSExceptionErrorCode.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/exception/CSExceptionErrorCode.java b/utils/src/com/cloud/utils/exception/CSExceptionErrorCode.java
index ee68fc2..7af8dbf 100755
--- a/utils/src/com/cloud/utils/exception/CSExceptionErrorCode.java
+++ b/utils/src/com/cloud/utils/exception/CSExceptionErrorCode.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
package com.cloud.utils.exception;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/exception/CloudRuntimeException.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/exception/CloudRuntimeException.java b/utils/src/com/cloud/utils/exception/CloudRuntimeException.java
index 148c25b..dd5abc8 100755
--- a/utils/src/com/cloud/utils/exception/CloudRuntimeException.java
+++ b/utils/src/com/cloud/utils/exception/CloudRuntimeException.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.exception;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/exception/ErrorContext.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/exception/ErrorContext.java b/utils/src/com/cloud/utils/exception/ErrorContext.java
index 7680a88..5391373 100644
--- a/utils/src/com/cloud/utils/exception/ErrorContext.java
+++ b/utils/src/com/cloud/utils/exception/ErrorContext.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.exception;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java b/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java
index 0f1b4e0..5a689d4 100644
--- a/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java
+++ b/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.exception;
import java.io.Serializable;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/exception/ExceptionUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/exception/ExceptionUtil.java b/utils/src/com/cloud/utils/exception/ExceptionUtil.java
index 5349082..351d2ab 100644
--- a/utils/src/com/cloud/utils/exception/ExceptionUtil.java
+++ b/utils/src/com/cloud/utils/exception/ExceptionUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.exception;
import java.io.PrintWriter;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/exception/ExecutionException.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/exception/ExecutionException.java b/utils/src/com/cloud/utils/exception/ExecutionException.java
index 94b40fb..7b3bc61 100755
--- a/utils/src/com/cloud/utils/exception/ExecutionException.java
+++ b/utils/src/com/cloud/utils/exception/ExecutionException.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.exception;
import com.cloud.utils.SerialVersionUID;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java b/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java
index 2c0c1cc..55c273b 100755
--- a/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java
+++ b/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.exception;
import com.cloud.utils.SerialVersionUID;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/ChangeEvent.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/ChangeEvent.java b/utils/src/com/cloud/utils/fsm/ChangeEvent.java
index 5b37806..15f4f6e 100755
--- a/utils/src/com/cloud/utils/fsm/ChangeEvent.java
+++ b/utils/src/com/cloud/utils/fsm/ChangeEvent.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.fsm;
public class ChangeEvent {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/FiniteState.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/FiniteState.java b/utils/src/com/cloud/utils/fsm/FiniteState.java
index d501b43..e6f2cd0 100644
--- a/utils/src/com/cloud/utils/fsm/FiniteState.java
+++ b/utils/src/com/cloud/utils/fsm/FiniteState.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.fsm;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/FiniteState2.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/FiniteState2.java b/utils/src/com/cloud/utils/fsm/FiniteState2.java
index 0147ba4..14b9a5e 100755
--- a/utils/src/com/cloud/utils/fsm/FiniteState2.java
+++ b/utils/src/com/cloud/utils/fsm/FiniteState2.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.fsm;
import java.util.Set;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/FiniteStateObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/FiniteStateObject.java b/utils/src/com/cloud/utils/fsm/FiniteStateObject.java
index 89fa152..a57e3b4 100644
--- a/utils/src/com/cloud/utils/fsm/FiniteStateObject.java
+++ b/utils/src/com/cloud/utils/fsm/FiniteStateObject.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.fsm;
public interface FiniteStateObject<S, E> {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/NoTransitionException.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/NoTransitionException.java b/utils/src/com/cloud/utils/fsm/NoTransitionException.java
index ddee291..241e456 100644
--- a/utils/src/com/cloud/utils/fsm/NoTransitionException.java
+++ b/utils/src/com/cloud/utils/fsm/NoTransitionException.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.fsm;
import com.cloud.utils.SerialVersionUID;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/State.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/State.java b/utils/src/com/cloud/utils/fsm/State.java
index eb618e2..0af0e61 100755
--- a/utils/src/com/cloud/utils/fsm/State.java
+++ b/utils/src/com/cloud/utils/fsm/State.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.fsm;
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/StateDao.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/StateDao.java b/utils/src/com/cloud/utils/fsm/StateDao.java
index aa7ed07..43ce25c 100644
--- a/utils/src/com/cloud/utils/fsm/StateDao.java
+++ b/utils/src/com/cloud/utils/fsm/StateDao.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.fsm;
public interface StateDao<S, E, V> {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/StateListener.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/StateListener.java b/utils/src/com/cloud/utils/fsm/StateListener.java
index 8c6b96e..3d0a645 100644
--- a/utils/src/com/cloud/utils/fsm/StateListener.java
+++ b/utils/src/com/cloud/utils/fsm/StateListener.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.fsm;
public interface StateListener<S, E, V> {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/StateMachine.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/StateMachine.java b/utils/src/com/cloud/utils/fsm/StateMachine.java
index 0e7be2e..d6d5b4d 100644
--- a/utils/src/com/cloud/utils/fsm/StateMachine.java
+++ b/utils/src/com/cloud/utils/fsm/StateMachine.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.fsm;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/StateMachine2.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/StateMachine2.java b/utils/src/com/cloud/utils/fsm/StateMachine2.java
index a0c7501..4950a25cb 100644
--- a/utils/src/com/cloud/utils/fsm/StateMachine2.java
+++ b/utils/src/com/cloud/utils/fsm/StateMachine2.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.fsm;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/fsm/StateObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/fsm/StateObject.java b/utils/src/com/cloud/utils/fsm/StateObject.java
index fbf9c47..4ee4dac 100644
--- a/utils/src/com/cloud/utils/fsm/StateObject.java
+++ b/utils/src/com/cloud/utils/fsm/StateObject.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.fsm;
public interface StateObject<S> {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/log/CglibThrowableRenderer.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/log/CglibThrowableRenderer.java b/utils/src/com/cloud/utils/log/CglibThrowableRenderer.java
index 522c030..b102dc4 100644
--- a/utils/src/com/cloud/utils/log/CglibThrowableRenderer.java
+++ b/utils/src/com/cloud/utils/log/CglibThrowableRenderer.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.log;
import java.io.PrintWriter;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/mgmt/JmxUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/mgmt/JmxUtil.java b/utils/src/com/cloud/utils/mgmt/JmxUtil.java
index 52361dc..49076f7 100755
--- a/utils/src/com/cloud/utils/mgmt/JmxUtil.java
+++ b/utils/src/com/cloud/utils/mgmt/JmxUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.mgmt;
import java.lang.management.ManagementFactory;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/mgmt/ManagementBean.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/mgmt/ManagementBean.java b/utils/src/com/cloud/utils/mgmt/ManagementBean.java
index 7df48fd..387052e 100755
--- a/utils/src/com/cloud/utils/mgmt/ManagementBean.java
+++ b/utils/src/com/cloud/utils/mgmt/ManagementBean.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.mgmt;
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/mgmt/PropertyMapDynamicBean.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/mgmt/PropertyMapDynamicBean.java b/utils/src/com/cloud/utils/mgmt/PropertyMapDynamicBean.java
index 5197321..d1689eb 100644
--- a/utils/src/com/cloud/utils/mgmt/PropertyMapDynamicBean.java
+++ b/utils/src/com/cloud/utils/mgmt/PropertyMapDynamicBean.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.mgmt;
import java.util.HashMap;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/net/Ip.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/Ip.java b/utils/src/com/cloud/utils/net/Ip.java
index c405713..e479e21 100644
--- a/utils/src/com/cloud/utils/net/Ip.java
+++ b/utils/src/com/cloud/utils/net/Ip.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.net;
import java.io.Serializable;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/net/Ip4Address.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/Ip4Address.java b/utils/src/com/cloud/utils/net/Ip4Address.java
index 37b5f47..b336d9d 100644
--- a/utils/src/com/cloud/utils/net/Ip4Address.java
+++ b/utils/src/com/cloud/utils/net/Ip4Address.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.net;
public class Ip4Address {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/net/MacAddress.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/MacAddress.java b/utils/src/com/cloud/utils/net/MacAddress.java
index 9e72a39..214ce68 100755
--- a/utils/src/com/cloud/utils/net/MacAddress.java
+++ b/utils/src/com/cloud/utils/net/MacAddress.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.net;
import java.io.BufferedReader;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java
index f64b230..c22e39a 100755
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.net;
import java.io.BufferedReader;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/net/NfsUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/NfsUtils.java b/utils/src/com/cloud/utils/net/NfsUtils.java
index 34e3b1a..23c1007 100644
--- a/utils/src/com/cloud/utils/net/NfsUtils.java
+++ b/utils/src/com/cloud/utils/net/NfsUtils.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.net;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/net/UrlUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/UrlUtil.java b/utils/src/com/cloud/utils/net/UrlUtil.java
index 1131808..539486e 100644
--- a/utils/src/com/cloud/utils/net/UrlUtil.java
+++ b/utils/src/com/cloud/utils/net/UrlUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.net;
import java.net.URI;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/nio/HandlerFactory.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/HandlerFactory.java b/utils/src/com/cloud/utils/nio/HandlerFactory.java
index cd4046b..f6b9c82 100755
--- a/utils/src/com/cloud/utils/nio/HandlerFactory.java
+++ b/utils/src/com/cloud/utils/nio/HandlerFactory.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.nio;
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/nio/Link.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/Link.java b/utils/src/com/cloud/utils/nio/Link.java
index 613480e..0767815 100755
--- a/utils/src/com/cloud/utils/nio/Link.java
+++ b/utils/src/com/cloud/utils/nio/Link.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.nio;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/nio/NioClient.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/NioClient.java b/utils/src/com/cloud/utils/nio/NioClient.java
index c78db07..34d03c2 100755
--- a/utils/src/com/cloud/utils/nio/NioClient.java
+++ b/utils/src/com/cloud/utils/nio/NioClient.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.nio;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/nio/NioConnection.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/NioConnection.java b/utils/src/com/cloud/utils/nio/NioConnection.java
index 021d49a..773b1b0 100755
--- a/utils/src/com/cloud/utils/nio/NioConnection.java
+++ b/utils/src/com/cloud/utils/nio/NioConnection.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.nio;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/nio/NioServer.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/NioServer.java b/utils/src/com/cloud/utils/nio/NioServer.java
index 90407b8..50c33c8 100755
--- a/utils/src/com/cloud/utils/nio/NioServer.java
+++ b/utils/src/com/cloud/utils/nio/NioServer.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.nio;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/nio/Task.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/Task.java b/utils/src/com/cloud/utils/nio/Task.java
index fc65feb..c77c703 100755
--- a/utils/src/com/cloud/utils/nio/Task.java
+++ b/utils/src/com/cloud/utils/nio/Task.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.nio;
import org.apache.log4j.Logger;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/nio/TrustAllManager.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/nio/TrustAllManager.java b/utils/src/com/cloud/utils/nio/TrustAllManager.java
index d07c5ec..5dffd62 100644
--- a/utils/src/com/cloud/utils/nio/TrustAllManager.java
+++ b/utils/src/com/cloud/utils/nio/TrustAllManager.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.nio;
public class TrustAllManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java b/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
index d6bbd66..bf001cd 100644
--- a/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
+++ b/utils/src/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -15,6 +16,7 @@
// specific language governing permissions and limitations
// under the License.
//
+
package com.cloud.utils.rest;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/rest/CloudstackRESTException.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/CloudstackRESTException.java b/utils/src/com/cloud/utils/rest/CloudstackRESTException.java
index 8d74598..5985fa0 100644
--- a/utils/src/com/cloud/utils/rest/CloudstackRESTException.java
+++ b/utils/src/com/cloud/utils/rest/CloudstackRESTException.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.rest;
public class CloudstackRESTException extends Exception {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java b/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
index 15b8be1..77ac8d0 100644
--- a/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
+++ b/utils/src/com/cloud/utils/rest/RESTValidationStrategy.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -15,6 +16,7 @@
// specific language governing permissions and limitations
// under the License.
//
+
package com.cloud.utils.rest;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/script/OutputInterpreter.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/script/OutputInterpreter.java b/utils/src/com/cloud/utils/script/OutputInterpreter.java
index 5845c9c..0153d57 100755
--- a/utils/src/com/cloud/utils/script/OutputInterpreter.java
+++ b/utils/src/com/cloud/utils/script/OutputInterpreter.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.script;
import org.apache.log4j.Logger;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/script/Script.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/script/Script.java b/utils/src/com/cloud/utils/script/Script.java
index 8dad697..dd71cab 100755
--- a/utils/src/com/cloud/utils/script/Script.java
+++ b/utils/src/com/cloud/utils/script/Script.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.script;
import com.cloud.utils.PropertiesUtil;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/script/Script2.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/script/Script2.java b/utils/src/com/cloud/utils/script/Script2.java
index b9d4f46..03c0e0d 100755
--- a/utils/src/com/cloud/utils/script/Script2.java
+++ b/utils/src/com/cloud/utils/script/Script2.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.script;
import java.util.HashMap;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/security/CertificateHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/security/CertificateHelper.java b/utils/src/com/cloud/utils/security/CertificateHelper.java
index 64ba8bf..d43542f 100644
--- a/utils/src/com/cloud/utils/security/CertificateHelper.java
+++ b/utils/src/com/cloud/utils/security/CertificateHelper.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.security;
import java.io.BufferedInputStream;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java b/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java
index ebd65f5..10ada37 100644
--- a/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java
+++ b/utils/src/com/cloud/utils/ssh/SSHCmdHelper.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.ssh;
import java.io.IOException;
[14/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Made VR scripts name to constant string
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/deb55acd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/deb55acd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/deb55acd
Branch: refs/heads/ui-restyle
Commit: deb55acd142a9bcc81daa50256809afebc1db901
Parents: 6bde675
Author: Sheng Yang <sh...@citrix.com>
Authored: Fri Feb 14 17:28:55 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Fri Feb 14 18:10:11 2014 -0800
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 91 +++++++++++++-------
1 file changed, 61 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/deb55acd/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index a287ada..9440897 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -87,6 +87,37 @@ import java.util.Map;
* }
**/
public class VirtualRoutingResource {
+ protected class VRScripts {
+ protected static final String S2SVPN_CHECK = "checkbatchs2svpn.sh";
+ protected static final String S2SVPN_IPSEC = "ipsectunnel.sh";
+ protected static final String DHCP = "edithosts.sh";
+ protected static final String DNSMASQ_CONFIG = "dnsmasq.sh";
+ protected static final String FIREWALL_EGRESS = "firewall_egress.sh";
+ protected static final String FIREWALL_INGRESS = "firewall_ingress.sh";
+ protected static final String FIREWALL_NAT = "firewall_nat.sh";
+ protected static final String IPALIAS_CREATE = "createipAlias.sh";
+ protected static final String IPALIAS_DELETE = "deleteipAlias.sh";
+ protected static final String IPASSOC = "ipassoc.sh";
+ protected static final String LB = "loadbalancer.sh";
+ protected static final String MONITOR_SERVICE = "monitor_service.sh";
+ protected static final String PASSWORD = "savepassword.sh";
+ protected static final String RVR_CHECK = "checkrouter.sh";
+ protected static final String RVR_BUMPUP_PRI = "bumpup_priority.sh";
+ protected static final String VMDATA = "vmdata.py";
+ protected static final String VERSION = "get_template_version.sh";
+ protected static final String VPC_ACL = "vpc_acl.sh";
+ protected static final String VPC_GUEST_NETWORK = "vpc_guestnw.sh";
+ protected static final String VPC_IPASSOC = "vpc_ipassoc.sh";
+ protected static final String VPC_LB = "vpc_loadbalancer.sh";
+ protected static final String VPC_PRIVATEGW = "vpc_privateGateway.sh";
+ protected static final String VPC_PRIVATEGW_ACL = "vpc_privategw_acl.sh";
+ protected static final String VPC_PORTFORWARDING = "vpc_portforwarding.sh";
+ protected static final String VPC_SOURCE_NAT = "vpc_snat.sh";
+ protected static final String VPC_STATIC_NAT = "vpc_staticnat.sh";
+ protected static final String VPC_STATIC_ROUTE = "vpc_staticroute.sh";
+ protected static final String VPN_L2TP = "vpn_l2tp.sh";
+ }
+
private static final Logger s_logger = Logger.getLogger(VirtualRoutingResource.class);
private VirtualRouterDeployer _vrDeployer;
@@ -190,7 +221,7 @@ public class VirtualRoutingResource {
args += "-u ";
args += userpwd.getUsernamePassword();
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpn_l2tp.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPN_L2TP, args);
if (!result.isSuccess()) {
return new Answer(cmd, false, "Configure VPN user failed for user " + userpwd.getUsername() + ":" + result.getDetails());
}
@@ -217,7 +248,7 @@ public class VirtualRoutingResource {
}
args += " -C " + cmd.getLocalCidr();
args += " -i " + cmd.getPublicInterface();
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpn_l2tp.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPN_L2TP, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -259,9 +290,9 @@ public class VirtualRoutingResource {
ExecutionResult result;
if (trafficType == FirewallRule.TrafficType.Egress) {
- result = _vrDeployer.executeInVR(routerAccessIp, "firewall_egress.sh", args);
+ result = _vrDeployer.executeInVR(routerAccessIp, VRScripts.FIREWALL_EGRESS, args);
} else {
- result = _vrDeployer.executeInVR(routerAccessIp, "firewall_ingress.sh", args);
+ result = _vrDeployer.executeInVR(routerAccessIp, VRScripts.FIREWALL_INGRESS, args);
}
if (!result.isSuccess()) {
@@ -288,7 +319,7 @@ public class VirtualRoutingResource {
args.append(" -r ").append(rule.getDstIp());
args.append(" -d ").append(rule.getStringDstPortRange());
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "firewall_nat.sh", args.toString());
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.FIREWALL_NAT, args.toString());
if (!result.isSuccess()) {
results[i++] = "Failed";
@@ -311,7 +342,7 @@ public class VirtualRoutingResource {
args += " -l " + rule.getSrcIp();
args += " -r " + rule.getDstIp();
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_staticnat.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_STATIC_NAT, args);
if (!result.isSuccess()) {
results[i++] = null;
@@ -345,7 +376,7 @@ public class VirtualRoutingResource {
args.append(" -d ").append(rule.getStringSrcPortRange());
args.append(" -G ");
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "firewall_nat.sh", args.toString());
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.FIREWALL_NAT, args.toString());
if (!result.isSuccess()) {
results[i++] = "Failed";
@@ -416,10 +447,10 @@ public class VirtualRoutingResource {
if (cmd.getVpcId() == null) {
args = " -i " + routerIp + args;
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "loadbalancer.sh", args);
+ result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.LB, args);
} else {
args = " -i " + cmd.getNic().getIp() + args;
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_loadbalancer.sh", args);
+ result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_LB, args);
}
return new Answer(cmd, result.isSuccess(), result.getDetails());
@@ -437,7 +468,7 @@ public class VirtualRoutingResource {
String args = "-d " + json;
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vmdata.py", args);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VMDATA, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -449,7 +480,7 @@ public class VirtualRoutingResource {
String args = "-v " + vmIpAddress;
args += " -p " + password;
- ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, "savepassword.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, VRScripts.PASSWORD, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -481,7 +512,7 @@ public class VirtualRoutingResource {
args += " -N";
}
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), "edithosts.sh", args);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), VRScripts.DHCP, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -491,7 +522,7 @@ public class VirtualRoutingResource {
for (IpAliasTO ipaliasto : ipAliasTOs) {
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
}
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "createipAlias.sh", args);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.IPALIAS_CREATE, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -507,7 +538,7 @@ public class VirtualRoutingResource {
for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
}
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "deleteipAlias.sh", args);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.IPALIAS_DELETE, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -517,7 +548,7 @@ public class VirtualRoutingResource {
for (DhcpTO dhcpTo : dhcpTos) {
args = args + dhcpTo.getRouterIp() + ":" + dhcpTo.getGateway() + ":" + dhcpTo.getNetmask() + ":" + dhcpTo.getStartIpOfSubnet() + "-";
}
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "dnsmasq.sh", args);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.DNSMASQ_CONFIG, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -529,14 +560,14 @@ public class VirtualRoutingResource {
args += ip + " ";
}
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, "checkbatchs2svpn.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.S2SVPN_CHECK, args);
return new CheckS2SVpnConnectionsAnswer(cmd, result.isSuccess(), result.getDetails());
}
protected Answer execute(CheckRouterCommand cmd) {
final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
- final ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, "checkrouter.sh", null);
+ final ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, VRScripts.RVR_CHECK, null);
if (!result.isSuccess()) {
return new CheckRouterAnswer(cmd, result.getDetails());
}
@@ -544,14 +575,14 @@ public class VirtualRoutingResource {
}
protected Answer execute(BumpUpPriorityCommand cmd) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), "bumpup_priority.sh", null);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), VRScripts.RVR_BUMPUP_PRI, null);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
protected Answer execute(GetDomRVersionCmd cmd) {
final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
- final ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, "get_template_version.sh", null);
+ final ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, VRScripts.VERSION, null);
if (!result.isSuccess()) {
return new GetDomRVersionAnswer(cmd, "GetDomRVersionCmd failed");
}
@@ -604,7 +635,7 @@ public class VirtualRoutingResource {
args += " -N ";
args += cmd.getPeerGuestCidrList();
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), "ipsectunnel.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), VRScripts.S2SVPN_IPSEC, args);
if (!result.isSuccess()) {
return new Answer(cmd, false, "Configure site to site VPN failed due to " + result.getDetails());
}
@@ -621,7 +652,7 @@ public class VirtualRoutingResource {
args = args + " -d";
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "monitor_service.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.MONITOR_SERVICE, args);
if (!result.isSuccess()) {
return new Answer(cmd, false, result.getDetails());
@@ -663,7 +694,7 @@ public class VirtualRoutingResource {
if (domainName != null && !domainName.isEmpty()) {
args += " -e " + domainName;
}
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_guestnw.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_GUEST_NETWORK, args);
if (!result.isSuccess()) {
return new Answer(cmd, false, "Creating guest network failed due to " + result.getDetails());
@@ -695,12 +726,12 @@ public class VirtualRoutingResource {
args += " -M " + nic.getMac();
if (privateGw != null) {
args += " -a " + rule;
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_privategw_acl.sh", args);
+ result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_PRIVATEGW_ACL, args);
} else {
args += " -i " + nic.getIp();
args += " -m " + netmask;
args += " -a " + rule;
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_acl.sh", args);
+ result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_ACL, args);
}
if (!result.isSuccess()) {
@@ -727,7 +758,7 @@ public class VirtualRoutingResource {
args += pubIP.getPublicIp();
args += " -c ";
args += dev;
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_snat.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_SOURCE_NAT, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -744,7 +775,7 @@ public class VirtualRoutingResource {
args += " -r " + rule.getDstIp();
args += " -d " + rule.getStringDstPortRange().replace(":", "-");
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_portforwarding.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_PORTFORWARDING, args);
if (!result.isSuccess()) {
results[i++] = "Failed";
@@ -787,7 +818,7 @@ public class VirtualRoutingResource {
args += " -n ";
args += NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_ipassoc.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_IPASSOC, args);
if (!result.isSuccess()) {
results[i++] = ip.getPublicIp() + " - vpc_ipassoc failed:" + result.getDetails();
break;
@@ -797,7 +828,7 @@ public class VirtualRoutingResource {
snatArgs += " -l " + ip.getPublicIp();
snatArgs += " -c " + nicName;
- result = _vrDeployer.executeInVR(routerIP, "vpc_privateGateway.sh", snatArgs);
+ result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_PRIVATEGW, snatArgs);
if (result != null) {
results[i++] = ip.getPublicIp() + " - vpc_privateGateway failed:" + result.getDetails();
break;
@@ -821,7 +852,7 @@ public class VirtualRoutingResource {
}
String args = " -a " + sb.toString();
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_staticroute.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_STATIC_ROUTE, args);
if (!result.isSuccess()) {
for (int i = 0; i < results.length; i++) {
@@ -873,7 +904,7 @@ public class VirtualRoutingResource {
args += " -n";
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "ipassoc.sh", args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.IPASSOC, args);
if (result.isSuccess()) {
results[i++] = ip.getPublicIp() + " - success";
} else {
[22/50] [abbrv] Nvp and rest refactoring and more tests
Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
index db8637c..fb103e8 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
@@ -99,7 +99,7 @@ public class NiciraNvpGuestNetworkGuruTest {
guru.agentMgr = agentmgr;
guru.networkDao = netdao;
- DataCenterVO dc = mock(DataCenterVO.class);
+ final DataCenterVO dc = mock(DataCenterVO.class);
when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
@@ -108,12 +108,12 @@ public class NiciraNvpGuestNetworkGuruTest {
@Test
public void testCanHandle() {
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
@@ -142,34 +142,34 @@ public class NiciraNvpGuestNetworkGuruTest {
@Test
public void testDesign() {
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
- NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+ final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
when(device.getId()).thenReturn(1L);
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
- DeploymentPlan plan = mock(DeploymentPlan.class);
- Network network = mock(Network.class);
- Account account = mock(Account.class);
+ final DeploymentPlan plan = mock(DeploymentPlan.class);
+ final Network network = mock(Network.class);
+ final Account account = mock(Account.class);
- Network designednetwork = guru.design(offering, plan, network, account);
+ final Network designednetwork = guru.design(offering, plan, network, account);
assertTrue(designednetwork != null);
assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Lswitch);
}
@Test
public void testDesignNoElementOnPhysicalNetwork() {
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
@@ -177,22 +177,22 @@ public class NiciraNvpGuestNetworkGuruTest {
mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
- DeploymentPlan plan = mock(DeploymentPlan.class);
- Network network = mock(Network.class);
- Account account = mock(Account.class);
+ final DeploymentPlan plan = mock(DeploymentPlan.class);
+ final Network network = mock(Network.class);
+ final Account account = mock(Account.class);
- Network designednetwork = guru.design(offering, plan, network, account);
+ final Network designednetwork = guru.design(offering, plan, network, account);
assertTrue(designednetwork == null);
}
@Test
public void testDesignNoIsolationMethodSTT() {
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VLAN"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
@@ -200,57 +200,57 @@ public class NiciraNvpGuestNetworkGuruTest {
mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
- DeploymentPlan plan = mock(DeploymentPlan.class);
- Network network = mock(Network.class);
- Account account = mock(Account.class);
+ final DeploymentPlan plan = mock(DeploymentPlan.class);
+ final Network network = mock(Network.class);
+ final Account account = mock(Account.class);
- Network designednetwork = guru.design(offering, plan, network, account);
+ final Network designednetwork = guru.design(offering, plan, network, account);
assertTrue(designednetwork == null);
}
@Test
public void testDesignNoConnectivityInOffering() {
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
- NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+ final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
when(device.getId()).thenReturn(1L);
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(false);
- DeploymentPlan plan = mock(DeploymentPlan.class);
- Network network = mock(Network.class);
- Account account = mock(Account.class);
+ final DeploymentPlan plan = mock(DeploymentPlan.class);
+ final Network network = mock(Network.class);
+ final Account account = mock(Account.class);
- Network designednetwork = guru.design(offering, plan, network, account);
+ final Network designednetwork = guru.design(offering, plan, network, account);
assertTrue(designednetwork == null);
}
@Test
public void testImplement() throws InsufficientVirtualNetworkCapcityException {
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
- NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+ final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
when(device.getId()).thenReturn(1L);
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -259,53 +259,53 @@ public class NiciraNvpGuestNetworkGuruTest {
mock(DeploymentPlan.class);
- NetworkVO network = mock(NetworkVO.class);
+ final NetworkVO network = mock(NetworkVO.class);
when(network.getName()).thenReturn("testnetwork");
when(network.getState()).thenReturn(State.Implementing);
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
- DeployDestination dest = mock(DeployDestination.class);
+ final DeployDestination dest = mock(DeployDestination.class);
- DataCenter dc = mock(DataCenter.class);
+ final DataCenter dc = mock(DataCenter.class);
when(dest.getDataCenter()).thenReturn(dc);
- HostVO niciraHost = mock(HostVO.class);
+ final HostVO niciraHost = mock(HostVO.class);
when(hostdao.findById(anyLong())).thenReturn(niciraHost);
when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
when(niciraHost.getId()).thenReturn(NETWORK_ID);
when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
- Domain dom = mock(Domain.class);
+ final Domain dom = mock(Domain.class);
when(dom.getName()).thenReturn("domain");
- Account acc = mock(Account.class);
+ final Account acc = mock(Account.class);
when(acc.getAccountName()).thenReturn("accountname");
- ReservationContext res = mock(ReservationContext.class);
+ final ReservationContext res = mock(ReservationContext.class);
when(res.getDomain()).thenReturn(dom);
when(res.getAccount()).thenReturn(acc);
- CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+ final CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
when(answer.getResult()).thenReturn(true);
when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
- Network implementednetwork = guru.implement(network, offering, dest, res);
+ final Network implementednetwork = guru.implement(network, offering, dest, res);
assertTrue(implementednetwork != null);
verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
}
@Test
public void testImplementWithCidr() throws InsufficientVirtualNetworkCapcityException {
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
- NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+ final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
when(device.getId()).thenReturn(1L);
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -314,39 +314,39 @@ public class NiciraNvpGuestNetworkGuruTest {
mock(DeploymentPlan.class);
- NetworkVO network = mock(NetworkVO.class);
+ final NetworkVO network = mock(NetworkVO.class);
when(network.getName()).thenReturn("testnetwork");
when(network.getState()).thenReturn(State.Implementing);
when(network.getGateway()).thenReturn("10.1.1.1");
when(network.getCidr()).thenReturn("10.1.1.0/24");
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
- DeployDestination dest = mock(DeployDestination.class);
+ final DeployDestination dest = mock(DeployDestination.class);
- DataCenter dc = mock(DataCenter.class);
+ final DataCenter dc = mock(DataCenter.class);
when(dest.getDataCenter()).thenReturn(dc);
- HostVO niciraHost = mock(HostVO.class);
+ final HostVO niciraHost = mock(HostVO.class);
when(hostdao.findById(anyLong())).thenReturn(niciraHost);
when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
when(niciraHost.getId()).thenReturn(NETWORK_ID);
when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
- Domain dom = mock(Domain.class);
+ final Domain dom = mock(Domain.class);
when(dom.getName()).thenReturn("domain");
- Account acc = mock(Account.class);
+ final Account acc = mock(Account.class);
when(acc.getAccountName()).thenReturn("accountname");
- ReservationContext res = mock(ReservationContext.class);
+ final ReservationContext res = mock(ReservationContext.class);
when(res.getDomain()).thenReturn(dom);
when(res.getAccount()).thenReturn(acc);
- CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+ final CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
when(answer.getResult()).thenReturn(true);
when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
- Network implementednetwork = guru.implement(network, offering, dest, res);
+ final Network implementednetwork = guru.implement(network, offering, dest, res);
assertTrue(implementednetwork != null);
assertTrue(implementednetwork.getCidr().equals("10.1.1.0/24"));
assertTrue(implementednetwork.getGateway().equals("10.1.1.1"));
@@ -355,16 +355,16 @@ public class NiciraNvpGuestNetworkGuruTest {
@Test
public void testImplementURIException() throws InsufficientVirtualNetworkCapcityException {
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
- NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+ final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
when(device.getId()).thenReturn(1L);
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -373,53 +373,53 @@ public class NiciraNvpGuestNetworkGuruTest {
mock(DeploymentPlan.class);
- NetworkVO network = mock(NetworkVO.class);
+ final NetworkVO network = mock(NetworkVO.class);
when(network.getName()).thenReturn("testnetwork");
when(network.getState()).thenReturn(State.Implementing);
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
- DeployDestination dest = mock(DeployDestination.class);
+ final DeployDestination dest = mock(DeployDestination.class);
- DataCenter dc = mock(DataCenter.class);
+ final DataCenter dc = mock(DataCenter.class);
when(dest.getDataCenter()).thenReturn(dc);
- HostVO niciraHost = mock(HostVO.class);
+ final HostVO niciraHost = mock(HostVO.class);
when(hostdao.findById(anyLong())).thenReturn(niciraHost);
when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
when(niciraHost.getId()).thenReturn(NETWORK_ID);
when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
- Domain dom = mock(Domain.class);
+ final Domain dom = mock(Domain.class);
when(dom.getName()).thenReturn("domain");
- Account acc = mock(Account.class);
+ final Account acc = mock(Account.class);
when(acc.getAccountName()).thenReturn("accountname");
- ReservationContext res = mock(ReservationContext.class);
+ final ReservationContext res = mock(ReservationContext.class);
when(res.getDomain()).thenReturn(dom);
when(res.getAccount()).thenReturn(acc);
- CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+ final CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
when(answer.getResult()).thenReturn(true);
//when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
- Network implementednetwork = guru.implement(network, offering, dest, res);
+ final Network implementednetwork = guru.implement(network, offering, dest, res);
assertTrue(implementednetwork == null);
verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
}
@Test
public void testShutdown() throws InsufficientVirtualNetworkCapcityException, URISyntaxException {
- PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+ final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
- NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+ final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
when(device.getId()).thenReturn(1L);
- NetworkOffering offering = mock(NetworkOffering.class);
+ final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -428,7 +428,7 @@ public class NiciraNvpGuestNetworkGuruTest {
mock(DeploymentPlan.class);
- NetworkVO network = mock(NetworkVO.class);
+ final NetworkVO network = mock(NetworkVO.class);
when(network.getName()).thenReturn("testnetwork");
when(network.getState()).thenReturn(State.Implementing);
when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
@@ -436,31 +436,31 @@ public class NiciraNvpGuestNetworkGuruTest {
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
when(netdao.findById(NETWORK_ID)).thenReturn(network);
- DeployDestination dest = mock(DeployDestination.class);
+ final DeployDestination dest = mock(DeployDestination.class);
- DataCenter dc = mock(DataCenter.class);
+ final DataCenter dc = mock(DataCenter.class);
when(dest.getDataCenter()).thenReturn(dc);
- HostVO niciraHost = mock(HostVO.class);
+ final HostVO niciraHost = mock(HostVO.class);
when(hostdao.findById(anyLong())).thenReturn(niciraHost);
when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
when(niciraHost.getId()).thenReturn(NETWORK_ID);
when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
- Domain dom = mock(Domain.class);
+ final Domain dom = mock(Domain.class);
when(dom.getName()).thenReturn("domain");
- Account acc = mock(Account.class);
+ final Account acc = mock(Account.class);
when(acc.getAccountName()).thenReturn("accountname");
- ReservationContext res = mock(ReservationContext.class);
+ final ReservationContext res = mock(ReservationContext.class);
when(res.getDomain()).thenReturn(dom);
when(res.getAccount()).thenReturn(acc);
- DeleteLogicalSwitchAnswer answer = mock(DeleteLogicalSwitchAnswer.class);
+ final DeleteLogicalSwitchAnswer answer = mock(DeleteLogicalSwitchAnswer.class);
when(answer.getResult()).thenReturn(true);
when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
- NetworkProfile implementednetwork = mock(NetworkProfile.class);
+ final NetworkProfile implementednetwork = mock(NetworkProfile.class);
when(implementednetwork.getId()).thenReturn(NETWORK_ID);
when(implementednetwork.getBroadcastUri()).thenReturn(new URI("lswitch:aaaa"));
when(offering.getSpecifyVlan()).thenReturn(false);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
index 84b28fb..d4c6596 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
@@ -31,22 +31,22 @@ public class NatRuleTest {
@Test
public void testNatRuleEncoding() {
- Gson gson =
- new GsonBuilder().registerTypeAdapter(NatRule.class, new com.cloud.network.nicira.NiciraNvpApi.NatRuleAdapter())
+ final Gson gson =
+ new GsonBuilder().registerTypeAdapter(NatRule.class, new NiciraNvpApi.NatRuleAdapter())
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.create();
- DestinationNatRule rn1 = new DestinationNatRule();
+ final DestinationNatRule rn1 = new DestinationNatRule();
rn1.setToDestinationIpAddress("10.10.10.10");
rn1.setToDestinationPort(80);
- Match mr1 = new Match();
+ final Match mr1 = new Match();
mr1.setSourceIpAddresses("11.11.11.11/24");
mr1.setEthertype("IPv4");
mr1.setProtocol(6);
rn1.setMatch(mr1);
- String jsonString = gson.toJson(rn1);
- NatRule dnr = gson.fromJson(jsonString, NatRule.class);
+ final String jsonString = gson.toJson(rn1);
+ final NatRule dnr = gson.fromJson(jsonString, NatRule.class);
assertTrue(dnr instanceof DestinationNatRule);
assertTrue(rn1.equals(dnr));
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java
index 7f8f471..ec4ce09 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java
@@ -19,14 +19,15 @@
package com.cloud.network.nicira;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import java.util.UUID;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -84,22 +85,22 @@ public class NiciraNvpApiIT {
scInList = iProfile;
}
}
- Assert.assertEquals("Read a Security Profile different from the one just created and updated",
+ assertEquals("Read a Security Profile different from the one just created and updated",
sProfile, scInList);
// Read them filtered by uuid (get one)
profiles = api.findSecurityProfile(sProfile.getUuid());
- Assert.assertEquals("Read a Security Profile different from the one just created and updated",
+ assertEquals("Read a Security Profile different from the one just created and updated",
sProfile,
profiles.getResults().get(0));
- Assert.assertEquals("Read a Security Profile filtered by unique id (UUID) with more than one item",
+ assertEquals("Read a Security Profile filtered by unique id (UUID) with more than one item",
1, profiles.getResults().size());
// We can now delete the new entity
api.deleteSecurityProfile(sProfile.getUuid());
} catch (final NiciraNvpApiException e) {
e.printStackTrace();
- assertTrue("Errors creating Security Profile", false);
+ assertTrue("Errors in Security Profile CRUD", false);
}
}
@@ -145,22 +146,203 @@ public class NiciraNvpApiIT {
scInList = iAcl;
}
}
- Assert.assertEquals("Read a ACL different from the one just created and updated",
+ assertEquals("Read a ACL different from the one just created and updated",
acl, scInList);
// Read them filtered by uuid (get one)
acls = api.findAcl(acl.getUuid());
- Assert.assertEquals("Read a ACL different from the one just created and updated",
+ assertEquals("Read a ACL different from the one just created and updated",
acl,
acls.getResults().get(0));
- Assert.assertEquals("Read a ACL filtered by unique id (UUID) with more than one item",
+ assertEquals("Read a ACL filtered by unique id (UUID) with more than one item",
1, acls.getResults().size());
// We can now delete the new entity
api.deleteAcl(acl.getUuid());
} catch (final NiciraNvpApiException e) {
e.printStackTrace();
- assertTrue("Errors creating ACL", false);
+ assertTrue("Errors in ACL CRUD", false);
}
}
+
+ @Test
+ public void testCRUDLogicalSwitch() throws NiciraNvpApiException {
+ LogicalSwitch logicalSwitch = new LogicalSwitch();
+ logicalSwitch.setDisplayName("LogicalSwitch"+timestamp);
+ logicalSwitch.setPortIsolationEnabled(true);
+ logicalSwitch.setReplicationMode("service");
+ logicalSwitch.setTags(new ArrayList<NiciraNvpTag>());
+ logicalSwitch.getTags().add(new NiciraNvpTag("anto", "hugo"));
+
+ // In the creation we don't get to specify UUID, href or schema: they don't exist yet
+
+ try {
+ logicalSwitch = api.createLogicalSwitch(logicalSwitch);
+
+ // We can now update the new entity
+ logicalSwitch.setDisplayName("UpdatedLogicalSwitch"+timestamp);
+ api.updateLogicalSwitch(logicalSwitch, logicalSwitch.getUuid());
+
+ // Read them all
+ NiciraNvpList<LogicalSwitch> logicalSwitches = api.findLogicalSwitch();
+ for(final LogicalSwitch iLogicalSwitch : logicalSwitches.getResults()) {
+ if (iLogicalSwitch.getUuid().equalsIgnoreCase(logicalSwitch.getUuid())) {
+ assertEquals("Read a LogicalSwitch different from the one just created and updated",
+ logicalSwitch, iLogicalSwitch);
+ }
+ }
+
+ // Read them filtered by uuid (get one)
+ logicalSwitches = api.findLogicalSwitch(logicalSwitch.getUuid());
+ assertEquals("Read a LogicalSwitch different from the one just created and updated",
+ logicalSwitch,
+ logicalSwitches.getResults().get(0));
+ assertEquals("Read a LogicalSwitch filtered by unique id (UUID) with more than one item",
+ 1, logicalSwitches.getResults().size());
+
+ // Before deleting the test LogicalSwitch, test its ports
+ final List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
+ tags.add(new NiciraNvpTag("cs_account", "OwnerName"));
+
+ LogicalSwitchPort logicalSwitchPort = new LogicalSwitchPort("LSwitchPort"+timestamp, tags, true);
+ logicalSwitchPort = api.createLogicalSwitchPort(logicalSwitch.getUuid(), logicalSwitchPort);
+
+ logicalSwitchPort.setDisplayName("UpdatedLSwitchPort"+timestamp);
+ api.updateLogicalSwitchPort(logicalSwitch.getUuid(), logicalSwitchPort);
+
+ final NiciraNvpList<LogicalSwitchPort> logicalSwitchePorts =
+ api.findLogicalSwitchPortsByUuid(logicalSwitch.getUuid(), logicalSwitchPort.getUuid());
+ for(final LogicalSwitchPort iLSwitchPort : logicalSwitchePorts.getResults()) {
+ if (iLSwitchPort.getUuid().equalsIgnoreCase(logicalSwitchPort.getUuid())) {
+ assertEquals("Read a LogicalSwitchPort different from the one just created and updated",
+ logicalSwitchPort, iLSwitchPort);
+ }
+ }
+
+ // And finally test attachments
+ final String attachmentUuid = UUID.randomUUID().toString();
+ final VifAttachment vifAttachment = new VifAttachment(attachmentUuid);
+ api.updateLogicalSwitchPortAttachment(logicalSwitch.getUuid(), logicalSwitchPort.getUuid(),
+ vifAttachment);
+
+ assertEquals("Read a LogicalSwitchPort by vifAttachment different than expected",
+ api.findLogicalSwitchPortUuidByVifAttachmentUuid(logicalSwitch.getUuid(), vifAttachment.getVifUuid()),
+ logicalSwitchPort.getUuid());
+
+ api.deleteLogicalSwitchPort(logicalSwitch.getUuid(), logicalSwitchPort.getUuid());
+
+ // We can now delete the new entity
+ api.deleteLogicalSwitch(logicalSwitch.getUuid());
+ } catch (final NiciraNvpApiException e) {
+ e.printStackTrace();
+ assertTrue("Errors in LogicalSwitch CRUD", false);
+ }
+ }
+
+ @Test
+ public void testCRUDLogicalRouter() throws NiciraNvpApiException {
+ LogicalRouter logicalRouter = new LogicalRouter();
+ logicalRouter.setDisplayName("LogicalRouter"+timestamp);
+ logicalRouter.setDistributed(true);
+ logicalRouter.setNatSynchronizationEnabled(true);
+ logicalRouter.setReplicationMode(LogicalRouter.REPLICATION_MODE_SERVICE);
+ final RoutingConfig routingConfig = new SingleDefaultRouteImplicitRoutingConfig(
+ new RouterNextHop("192.168.10.20"));
+ logicalRouter.setRoutingConfig(routingConfig);
+
+ // In the creation we don't get to specify UUID, href or schema: they don't exist yet
+
+ try {
+ logicalRouter = api.createLogicalRouter(logicalRouter);
+
+ // We can now update the new entity
+ logicalRouter.setDisplayName("UpdatedLogicalSwitch"+timestamp);
+ api.updateLogicalRouter(logicalRouter, logicalRouter.getUuid());
+
+ // Read them all
+ NiciraNvpList<LogicalRouter> logicalRouters = api.findLogicalRouter();
+ LogicalRouter lsInList = null;
+ for(final LogicalRouter iLogicalRouter : logicalRouters.getResults()) {
+ if (iLogicalRouter.getUuid().equalsIgnoreCase(logicalRouter.getUuid())) {
+ lsInList = iLogicalRouter;
+ }
+ }
+ assertEquals("Read a LogicalRouter different from the one just created and updated",
+ logicalRouter, lsInList);
+
+ // Read them filtered by uuid (get one)
+ logicalRouters = api.findLogicalRouter(logicalRouter.getUuid());
+ assertEquals("Read a LogicalRouter different from the one just created and updated",
+ logicalRouter,
+ logicalRouters.getResults().get(0));
+ assertEquals("Read a LogicalRouter filtered by unique id (UUID) with more than one item",
+ 1, logicalRouters.getResults().size());
+
+ assertEquals("", logicalRouters.getResults().get(0),
+ api.findOneLogicalRouterByUuid(logicalRouter.getUuid()));
+
+ // Before deleting the test LogicalRouter, test its ports
+ final List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
+ tags.add(new NiciraNvpTag("cs_account", "OwnerName"));
+
+ LogicalRouterPort logicalRouterPort = new LogicalRouterPort();
+ logicalRouterPort.setDisplayName("LRouterPort"+timestamp);
+ logicalRouterPort.setTags(tags);
+ logicalRouterPort.setAdminStatusEnabled(true);
+ logicalRouterPort.setPortno(1024);
+ logicalRouterPort.setMacAddress("00:00:00:00:00:00");
+
+ final List<String> ipAddresses = new ArrayList<String>();
+ // Add some ips to this list
+ logicalRouterPort.setIpAddresses(ipAddresses);
+ logicalRouterPort = api.createLogicalRouterPort(logicalRouter.getUuid(), logicalRouterPort);
+
+ logicalRouterPort.setDisplayName("UpdatedLRouterPort"+timestamp);
+ api.updateLogicalRouterPort(logicalRouter.getUuid(), logicalRouterPort);
+
+ final NiciraNvpList<LogicalRouterPort> logicalRouterePorts =
+ api.findLogicalRouterPortsByUuid(logicalRouter.getUuid(), logicalRouterPort.getUuid());
+ for(final LogicalRouterPort iLRouterPort : logicalRouterePorts.getResults()) {
+ if (iLRouterPort.getUuid().equalsIgnoreCase(logicalRouterPort.getUuid())) {
+ assertEquals("Read a LogicalRouterPort different from the one just created and updated",
+ logicalRouterPort, iLRouterPort);
+ }
+ }
+
+ UUID.randomUUID().toString();
+
+ // Test CRUD for Nat Rules
+ SourceNatRule snr = new SourceNatRule();
+ snr.setToSourceIpAddressMin("192.168.10.10");
+ snr.setToSourceIpAddressMax("192.168.10.20");
+ snr.setOrder(200);
+ final Match match = new Match();
+ match.setSourceIpAddresses("192.168.150.150");
+ snr.setMatch(match);
+ snr = (SourceNatRule) api.createLogicalRouterNatRule(logicalRouter.getUuid(), snr);
+ snr.setToSourceIpAddressMax("192.168.10.30");
+ api.updateLogicalRouterNatRule(logicalRouter.getUuid(), snr);
+
+ api.findNatRulesByLogicalRouterUuid(logicalRouter.getUuid());
+ api.deleteLogicalRouterNatRule(logicalRouter.getUuid(), snr.getUuid());
+
+ api.deleteLogicalRouterPort(logicalRouter.getUuid(), logicalRouterPort.getUuid());
+
+ // We can now delete the new entity
+ api.deleteLogicalRouter(logicalRouter.getUuid());
+ } catch (final NiciraNvpApiException e) {
+ e.printStackTrace();
+ assertTrue("Errors in LogicalRouter CRUD", false);
+ }
+ }
+
+ @Test
+ public void testGetControlClusterStatus() throws NiciraNvpApiException {
+ final ControlClusterStatus controlClusterStatus = api.getControlClusterStatus();
+ final String clusterStatus = controlClusterStatus.getClusterStatus();
+ final boolean correctStatus = (clusterStatus.equalsIgnoreCase("stable") ||
+ clusterStatus.equalsIgnoreCase("joining") || clusterStatus.equalsIgnoreCase("unstable"));
+ assertTrue("Not recognizable cluster status", correctStatus);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
index 13d970c..fe41545 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
@@ -19,457 +19,289 @@
package com.cloud.network.nicira;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import java.io.IOException;
-import java.util.Collections;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
import org.junit.Test;
-public class NiciraNvpApiTest {
- protected static final String UUID = "aaaa";
- protected static final String UUID2 = "bbbb";
- protected static final String UUID_SEC_PROFILE_URI = NiciraNvpApi.SEC_PROFILE_URI_PREFIX + "/aaaa";
- protected static final String SCHEMA = "myTestSchema";
- protected static final String SCHEMA2 = "myTestSchema2";
- protected static final String HREF = "myTestHref";
- protected static final String HREF2 = "myTestHref2";
- protected static final String DISPLAY_NAME = "myTestName";
- protected static final String UUID_JSON_RESPONSE = "{\"uuid\" : \"aaaa\"}";
- protected static final String SEC_PROFILE_JSON_RESPONSE =
- "{\"uuid\" : \"aaaa\","
- + "\"display_name\" : \"myTestName\","
- + "\"href\" : \"myTestHref\","
- + "\"schema\" : \"myTestSchema\"}";
-
- protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
- + "\"display_name\" : \"myTestName\","
- + "\"href\" : \"myTestHref\","
- + "\"schema\" : \"myTestSchema\"},"
- + "{ \"uuid\" : \"bbbb\","
- + "\"display_name\" : \"myTestName2\","
- + "\"href\" : \"myTestHref2\","
- + "\"schema\" : \"myTestSchema2\"}],"
- + "\"result_count\": 2}";
-
- NiciraNvpApi api;
- HttpClient client = mock(HttpClient.class);
- HttpMethod method;
- String type;
- String uri;
-
- @Before
- public void setUp() {
- final HttpClientParams hmp = mock(HttpClientParams.class);
- when(client.getParams()).thenReturn(hmp);
- api = new NiciraNvpApi() {
- @Override
- protected HttpClient createHttpClient() {
- return client;
- }
-
- @Override
- protected HttpMethod createMethod(final String newType, final String newUri) {
- type = newType;
- uri = newUri;
- return method;
- }
- };
- api.setAdminCredentials("admin", "adminpass");
- api.setControllerAddress("localhost");
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteLoginWithoutHostname() throws NiciraNvpApiException {
- api.setControllerAddress(null);
- api.login();
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteLoginWithoutCredentials() throws NiciraNvpApiException {
- api.setAdminCredentials(null, null);
- api.login();
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteUpdateObjectWithoutHostname() throws NiciraNvpApiException {
- api.setControllerAddress(null);
- api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteUpdateObjectWithoutCredentials() throws NiciraNvpApiException {
- api.setAdminCredentials(null, null);
- api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteCreateObjectWithoutHostname() throws NiciraNvpApiException {
- api.setControllerAddress(null);
- api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteCreateObjectWithoutCredentials() throws NiciraNvpApiException {
- api.setAdminCredentials(null, null);
- api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteDeleteObjectWithoutHostname() throws NiciraNvpApiException {
- api.setControllerAddress(null);
- api.executeDeleteObject("/");
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteDeleteObjectWithoutCredentials() throws NiciraNvpApiException {
- api.setAdminCredentials(null, null);
- api.executeDeleteObject("/");
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteRetrieveObjectWithoutHostname() throws NiciraNvpApiException {
- api.setControllerAddress(null);
- api.executeRetrieveObject(String.class, "/", Collections.<String, String> emptyMap());
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteRetrieveObjectWithoutCredentials() throws NiciraNvpApiException {
- api.setAdminCredentials(null, null);
- api.executeDeleteObject("/");
- }
-
- @Test
- public void executeMethodTest() throws NiciraNvpApiException {
- final GetMethod gm = mock(GetMethod.class);
-
- when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- api.executeMethod(gm);
- verify(gm, times(1)).getStatusCode();
- }
-
- /* Bit of a roundabout way to ensure that login is called after an un authorized result
- * It not possible to properly mock login()
- */
- @Test(expected = NiciraNvpApiException.class)
- public void executeMethodTestWithLogin() throws NiciraNvpApiException, HttpException, IOException {
- final GetMethod gm = mock(GetMethod.class);
- when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
- when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
- api.executeMethod(gm);
- verify(gm, times(1)).getStatusCode();
- }
-
- @Test
- public void testExecuteCreateObject() throws NiciraNvpApiException, IOException {
- LogicalSwitch ls = new LogicalSwitch();
- method = mock(PostMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
- when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
- ls = api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
- assertTrue(UUID.equals(ls.getUuid()));
- verify(method, times(1)).releaseConnection();
-
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteCreateObjectFailure() throws NiciraNvpApiException, IOException {
- LogicalSwitch ls = new LogicalSwitch();
- method = mock(PostMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- final Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(method.getResponseHeader("Content-Type")).thenReturn(header);
- when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- when(method.isRequestSent()).thenReturn(true);
- try {
- ls = api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(method, times(1)).releaseConnection();
- }
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteCreateObjectException() throws NiciraNvpApiException, IOException {
- LogicalSwitch ls = new LogicalSwitch();
- when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
- method = mock(PostMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- final Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(method.getResponseHeader("Content-Type")).thenReturn(header);
- when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- try {
- ls = api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(method, times(1)).releaseConnection();
- }
- }
+import com.google.gson.Gson;
+import com.google.gson.JsonParseException;
- @Test
- public void testExecuteUpdateObject() throws NiciraNvpApiException, IOException {
- final LogicalSwitch ls = new LogicalSwitch();
- method = mock(PutMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
- verify(method, times(1)).releaseConnection();
- verify(client, times(1)).executeMethod(method);
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteUpdateObjectFailure() throws NiciraNvpApiException, IOException {
- final LogicalSwitch ls = new LogicalSwitch();
- method = mock(PutMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- final Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(method.getResponseHeader("Content-Type")).thenReturn(header);
- when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- when(method.isRequestSent()).thenReturn(true);
- try {
- api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(method, times(1)).releaseConnection();
- }
- }
-
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteUpdateObjectException() throws NiciraNvpApiException, IOException {
- final LogicalSwitch ls = new LogicalSwitch();
- method = mock(PutMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- when(client.executeMethod((HttpMethod)any())).thenThrow(new IOException());
- try {
- api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(method, times(1)).releaseConnection();
- }
- }
-
- @Test
- public void testExecuteDeleteObject() throws NiciraNvpApiException, IOException {
- method = mock(DeleteMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
- api.executeDeleteObject("/");
- verify(method, times(1)).releaseConnection();
- verify(client, times(1)).executeMethod(method);
- }
+public class NiciraNvpApiTest {
+// protected static final String UUID = "aaaa";
+// protected static final String UUID2 = "bbbb";
+// protected static final String UUID_SEC_PROFILE_URI = NiciraNvpApi.SEC_PROFILE_URI_PREFIX + "/aaaa";
+// protected static final String SCHEMA = "myTestSchema";
+// protected static final String SCHEMA2 = "myTestSchema2";
+// protected static final String HREF = "myTestHref";
+// protected static final String HREF2 = "myTestHref2";
+// protected static final String DISPLAY_NAME = "myTestName";
+// protected static final String UUID_JSON_RESPONSE = "{\"uuid\" : \"aaaa\"}";
+// protected static final String SEC_PROFILE_JSON_RESPONSE =
+// "{\"uuid\" : \"aaaa\","
+// + "\"display_name\" : \"myTestName\","
+// + "\"href\" : \"myTestHref\","
+// + "\"schema\" : \"myTestSchema\"}";
+//
+// protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
+// + "\"display_name\" : \"myTestName\","
+// + "\"href\" : \"myTestHref\","
+// + "\"schema\" : \"myTestSchema\"},"
+// + "{ \"uuid\" : \"bbbb\","
+// + "\"display_name\" : \"myTestName2\","
+// + "\"href\" : \"myTestHref2\","
+// + "\"schema\" : \"myTestSchema2\"}],"
+// + "\"result_count\": 2}";
+//
+// NiciraNvpApi api;
+// HttpClient client = mock(HttpClient.class);
+// HttpMethod method;
+// String type;
+// String uri;
+//
+// @Before
+// public void setUp() {
+// final HttpClientParams hmp = mock(HttpClientParams.class);
+// when(client.getParams()).thenReturn(hmp);
+// api = new NiciraNvpApi();
+//
+// api.restConnector = new RESTServiceConnector() {
+// @Override
+// public HttpClient createHttpClient() {
+// return client;
+// }
+//
+// @Override
+// public HttpMethod createMethod(final String newType, final String newUri) {
+// type = newType;
+// uri = newUri;
+// return method;
+// }
+// };
+//
+// api.setAdminCredentials("admin", "adminpass");
+// api.setControllerAddress("localhost");
+// }
+//
+// @Test
+// public void testFindSecurityProfile() throws NiciraNvpApiException, IOException {
+// // Prepare
+// method = mock(GetMethod.class);
+// when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+// when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
+// final NameValuePair[] queryString = new NameValuePair[]{
+// new NameValuePair("fields","*")};
+//
+// // Execute
+// final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile();
+//
+// // Assert
+// verify(method, times(1)).releaseConnection();
+// verify(method, times(1)).setQueryString(queryString);
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// UUID, actualProfiles.getResults().get(0).getUuid());
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// HREF, actualProfiles.getResults().get(0).getHref());
+// assertEquals("Wrong Schema in the newly created SecurityProfile",
+// SCHEMA, actualProfiles.getResults().get(0).getSchema());
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// UUID2, actualProfiles.getResults().get(1).getUuid());
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// HREF2, actualProfiles.getResults().get(1).getHref());
+// assertEquals("Wrong Schema in the newly created SecurityProfile",
+// SCHEMA2, actualProfiles.getResults().get(1).getSchema());
+// assertEquals("Wrong Schema in the newly created SecurityProfile",
+// 2, actualProfiles.getResultCount());
+// assertEquals("Wrong URI for SecurityProfile creation REST service",
+// NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+// assertEquals("Wrong URI for SecurityProfile creation REST service",
+// NiciraNvpApi.GET_METHOD_TYPE, type);
+// }
+//
+// @Test
+// public void testFindSecurityProfileByUuid() throws NiciraNvpApiException, IOException {
+// // Prepare
+// method = mock(GetMethod.class);
+// when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+// when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
+// final NameValuePair[] queryString = new NameValuePair[]{
+// new NameValuePair("uuid", UUID),
+// new NameValuePair("fields","*")
+// };
+//
+// // Execute
+// final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);
+//
+// // Assert
+// verify(method, times(1)).releaseConnection();
+// verify(method, times(1)).setQueryString(queryString);
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// UUID, actualProfiles.getResults().get(0).getUuid());
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// HREF, actualProfiles.getResults().get(0).getHref());
+// assertEquals("Wrong Schema in the newly created SecurityProfile",
+// SCHEMA, actualProfiles.getResults().get(0).getSchema());
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// UUID2, actualProfiles.getResults().get(1).getUuid());
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// HREF2, actualProfiles.getResults().get(1).getHref());
+// assertEquals("Wrong Schema in the newly created SecurityProfile",
+// SCHEMA2, actualProfiles.getResults().get(1).getSchema());
+// assertEquals("Wrong Schema in the newly created SecurityProfile",
+// 2, actualProfiles.getResultCount());
+// assertEquals("Wrong URI for SecurityProfile creation REST service",
+// NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+// assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+// NiciraNvpApi.GET_METHOD_TYPE, type);
+// }
+//
+// @Test
+// public void testCreateSecurityProfile() throws NiciraNvpApiException, IOException {
+// // Prepare
+// final SecurityProfile inputSecProfile = new SecurityProfile();
+// method = mock(PostMethod.class);
+// when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
+// when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_JSON_RESPONSE);
+//
+// // Execute
+// final SecurityProfile actualSecProfile = api.createSecurityProfile(inputSecProfile);
+//
+// // Assert
+// verify(method, times(1)).releaseConnection();
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// UUID, actualSecProfile.getUuid());
+// assertEquals("Wrong Uuid in the newly created SecurityProfile",
+// HREF, actualSecProfile.getHref());
+// assertEquals("Wrong Schema in the newly created SecurityProfile",
+// SCHEMA, actualSecProfile.getSchema());
+// assertEquals("Wrong URI for SecurityProfile creation REST service",
+// NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+// assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+// NiciraNvpApi.POST_METHOD_TYPE, type);
+// }
+//
+// @Test
+// public void testUpdateSecurityProfile() throws NiciraNvpApiException, IOException {
+// // Prepare
+// final SecurityProfile inputSecProfile = new SecurityProfile();
+// method = mock(PutMethod.class);
+// when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+//
+// // Execute
+// api.updateSecurityProfile(inputSecProfile, UUID);
+//
+// // Assert
+// verify(method, times(1)).releaseConnection();
+// assertEquals("Wrong URI for SecurityProfile creation REST service",
+// UUID_SEC_PROFILE_URI, uri);
+// assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+// NiciraNvpApi.PUT_METHOD_TYPE, type);
+// }
+//
+// @Test
+// public void testDeleteSecurityProfile() throws NiciraNvpApiException, IOException {
+// // Prepare
+// method = mock(DeleteMethod.class);
+// when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+//
+// // Execute
+// api.deleteSecurityProfile(UUID);
+//
+// // Assert
+// verify(method, times(1)).releaseConnection();
+// assertEquals("Wrong URI for SecurityProfile deletion REST service", UUID_SEC_PROFILE_URI, uri);
+// assertEquals("Wrong HTTP method for SecurityProfile deletion REST service", NiciraNvpApi.DELETE_METHOD_TYPE, type);
+// }
+
+ @Test(expected = JsonParseException.class)
+ public void testRoutingConfigAdapterNoType() throws NiciraNvpApiException, IOException {
+ // Prepare
+ final NiciraNvpApi api = new NiciraNvpApi();
+ final Gson gson = api.restConnector.getGson();
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteDeleteObjectFailure() throws NiciraNvpApiException, IOException {
- method = mock(DeleteMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- final Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(method.getResponseHeader("Content-Type")).thenReturn(header);
- when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- when(method.isRequestSent()).thenReturn(true);
- try {
- api.executeDeleteObject("/");
- } finally {
- verify(method, times(1)).releaseConnection();
- }
- }
+ // Execute
+ gson.fromJson("{}", RoutingConfig.class);
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteDeleteObjectException() throws NiciraNvpApiException, IOException {
- method = mock(DeleteMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
- when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
- try {
- api.executeDeleteObject("/");
- } finally {
- verify(method, times(1)).releaseConnection();
- }
+ // Assert: JsonParseException should be thrown
}
- @Test
- public void testExecuteRetrieveObject() throws NiciraNvpApiException, IOException {
- method = mock(GetMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
- api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
- verify(method, times(1)).releaseConnection();
- verify(client, times(1)).executeMethod(method);
- }
+ @Test(expected = JsonParseException.class)
+ public void testRoutingConfigAdapterWrongType() throws NiciraNvpApiException, IOException {
+ // Prepare
+ final NiciraNvpApi api = new NiciraNvpApi();
+ final Gson gson = api.restConnector.getGson();
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteRetrieveObjectFailure() throws NiciraNvpApiException, IOException {
- method = mock(GetMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
- when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
- final Header header = mock(Header.class);
- when(header.getValue()).thenReturn("text/html");
- when(method.getResponseHeader("Content-Type")).thenReturn(header);
- when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
- when(method.isRequestSent()).thenReturn(true);
- try {
- api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(method, times(1)).releaseConnection();
- }
- }
+ // Execute
+ gson.fromJson("{type : \"WrongType\"}", RoutingConfig.class);
- @Test(expected = NiciraNvpApiException.class)
- public void testExecuteRetrieveObjectException() throws NiciraNvpApiException, IOException {
- method = mock(GetMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
- when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
- try {
- api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
- } finally {
- verify(method, times(1)).releaseConnection();
- }
+ // Assert: JsonParseException should be thrown
}
- @Test
- public void testFindSecurityProfile() throws NiciraNvpApiException, IOException {
+ @Test()
+ public void testRoutingConfigAdapter() throws NiciraNvpApiException, IOException {
// Prepare
- method = mock(GetMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
- final NameValuePair[] queryString = new NameValuePair[]{
- new NameValuePair("fields","*")};
+ final NiciraNvpApi api = new NiciraNvpApi();
+ final Gson gson = api.restConnector.getGson();
// Execute
- final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile();
+ final SingleDefaultRouteImplicitRoutingConfig singleDefaultRouteImplicitRoutingConfig =
+ (SingleDefaultRouteImplicitRoutingConfig) gson.fromJson("{type : \"SingleDefaultRouteImplicitRoutingConfig\"}", RoutingConfig.class);
- // Assert
- verify(method, times(1)).releaseConnection();
- verify(method, times(1)).setQueryString(queryString);
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- UUID, actualProfiles.getResults().get(0).getUuid());
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- HREF, actualProfiles.getResults().get(0).getHref());
- assertEquals("Wrong Schema in the newly created SecurityProfile",
- SCHEMA, actualProfiles.getResults().get(0).getSchema());
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- UUID2, actualProfiles.getResults().get(1).getUuid());
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- HREF2, actualProfiles.getResults().get(1).getHref());
- assertEquals("Wrong Schema in the newly created SecurityProfile",
- SCHEMA2, actualProfiles.getResults().get(1).getSchema());
- assertEquals("Wrong Schema in the newly created SecurityProfile",
- 2, actualProfiles.getResultCount());
- assertEquals("Wrong URI for SecurityProfile creation REST service",
- NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
- assertEquals("Wrong URI for SecurityProfile creation REST service",
- NiciraNvpApi.GET_METHOD_TYPE, type);
+ // Assert: JsonParseException should be thrown
+ assertEquals("", SingleDefaultRouteImplicitRoutingConfig.class, singleDefaultRouteImplicitRoutingConfig.getClass());
}
- @Test
- public void testFindSecurityProfileByUuid() throws NiciraNvpApiException, IOException {
+ @Test(expected = JsonParseException.class)
+ public void testNatRuleAdapterNoType() throws NiciraNvpApiException, IOException {
// Prepare
- method = mock(GetMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
- final NameValuePair[] queryString = new NameValuePair[]{
- new NameValuePair("uuid", UUID),
- new NameValuePair("fields","*")
- };
+ final NiciraNvpApi api = new NiciraNvpApi();
+ final Gson gson = api.restConnector.getGson();
// Execute
- final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);
+ gson.fromJson("{}", NatRule.class);
- // Assert
- verify(method, times(1)).releaseConnection();
- verify(method, times(1)).setQueryString(queryString);
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- UUID, actualProfiles.getResults().get(0).getUuid());
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- HREF, actualProfiles.getResults().get(0).getHref());
- assertEquals("Wrong Schema in the newly created SecurityProfile",
- SCHEMA, actualProfiles.getResults().get(0).getSchema());
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- UUID2, actualProfiles.getResults().get(1).getUuid());
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- HREF2, actualProfiles.getResults().get(1).getHref());
- assertEquals("Wrong Schema in the newly created SecurityProfile",
- SCHEMA2, actualProfiles.getResults().get(1).getSchema());
- assertEquals("Wrong Schema in the newly created SecurityProfile",
- 2, actualProfiles.getResultCount());
- assertEquals("Wrong URI for SecurityProfile creation REST service",
- NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
- assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
- NiciraNvpApi.GET_METHOD_TYPE, type);
+ // Assert: JsonParseException should be thrown
}
- @Test
- public void testCreateSecurityProfile() throws NiciraNvpApiException, IOException {
+ @Test(expected = JsonParseException.class)
+ public void testNatRuleAdapterWrongType() throws NiciraNvpApiException, IOException {
// Prepare
- final SecurityProfile inputSecProfile = new SecurityProfile();
- method = mock(PostMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
- when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_JSON_RESPONSE);
+ final NiciraNvpApi api = new NiciraNvpApi();
+ final Gson gson = api.restConnector.getGson();
// Execute
- final SecurityProfile actualSecProfile = api.createSecurityProfile(inputSecProfile);
+ gson.fromJson("{type : \"WrongType\"}", NatRule.class);
- // Assert
- verify(method, times(1)).releaseConnection();
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- UUID, actualSecProfile.getUuid());
- assertEquals("Wrong Uuid in the newly created SecurityProfile",
- HREF, actualSecProfile.getHref());
- assertEquals("Wrong Schema in the newly created SecurityProfile",
- SCHEMA, actualSecProfile.getSchema());
- assertEquals("Wrong URI for SecurityProfile creation REST service",
- NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
- assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
- NiciraNvpApi.POST_METHOD_TYPE, type);
+ // Assert: JsonParseException should be thrown
}
- @Test
- public void testUpdateSecurityProfile() throws NiciraNvpApiException, IOException {
+ @Test()
+ public void testRoutingConfigAdapterWithSourceNatRule() throws NiciraNvpApiException, IOException {
// Prepare
- final SecurityProfile inputSecProfile = new SecurityProfile();
- method = mock(PutMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+ final NiciraNvpApi api = new NiciraNvpApi();
+ final Gson gson = api.restConnector.getGson();
// Execute
- api.updateSecurityProfile(inputSecProfile, UUID);
+ final SourceNatRule sourceNatRule =
+ (SourceNatRule) gson.fromJson("{type : \"SourceNatRule\"}", NatRule.class);
- // Assert
- verify(method, times(1)).releaseConnection();
- assertEquals("Wrong URI for SecurityProfile creation REST service",
- UUID_SEC_PROFILE_URI, uri);
- assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
- NiciraNvpApi.PUT_METHOD_TYPE, type);
+ // Assert: JsonParseException should be thrown
+ assertEquals("", SourceNatRule.class, sourceNatRule.getClass());
}
- @Test
- public void testDeleteSecurityProfile() throws NiciraNvpApiException, IOException {
+ @Test()
+ public void testRoutingConfigAdapterWithDestinationNatRule() throws NiciraNvpApiException, IOException {
// Prepare
- method = mock(DeleteMethod.class);
- when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+ final NiciraNvpApi api = new NiciraNvpApi();
+ final Gson gson = api.restConnector.getGson();
// Execute
- api.deleteSecurityProfile(UUID);
+ final DestinationNatRule destinationNatRule =
+ (DestinationNatRule) gson.fromJson("{type : \"DestinationNatRule\"}", NatRule.class);
- // Assert
- verify(method, times(1)).releaseConnection();
- assertEquals("Wrong URI for SecurityProfile deletion REST service",
- UUID_SEC_PROFILE_URI, uri);
- assertEquals("Wrong HTTP method for SecurityProfile deletion REST service",
- NiciraNvpApi.DELETE_METHOD_TYPE, type);
+ // Assert: JsonParseException should be thrown
+ assertEquals("", DestinationNatRule.class, destinationNatRule.getClass());
}
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java
index 58dcedc..7a31264 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java
@@ -26,21 +26,21 @@ import org.junit.Test;
public class NiciraTagTest {
@Test
public void testCreateTag() {
- NiciraNvpTag tag = new NiciraNvpTag("scope", "tag");
+ final NiciraNvpTag tag = new NiciraNvpTag("scope", "tag");
assertEquals("scope part set", "scope", tag.getScope());
assertEquals("tag part set", "tag", tag.getTag());
}
@Test
public void testCreateLongTag() {
- NiciraNvpTag tag = new NiciraNvpTag("scope", "verylongtagthatshouldattheminimumexceedthefortycharacterlenght");
+ final NiciraNvpTag tag = new NiciraNvpTag("scope", "verylongtagthatshouldattheminimumexceedthefortycharacterlenght");
assertEquals("scope part set", "scope", tag.getScope());
assertEquals("tag part set", "verylongtagthatshouldattheminimumexceedt", tag.getTag());
}
@Test
public void testSetTag() {
- NiciraNvpTag tag = new NiciraNvpTag();
+ final NiciraNvpTag tag = new NiciraNvpTag();
tag.setScope("scope");
tag.setTag("tag");
assertEquals("scope part set", "scope", tag.getScope());
@@ -49,7 +49,7 @@ public class NiciraTagTest {
@Test
public void testSetLongTag() {
- NiciraNvpTag tag = new NiciraNvpTag();
+ final NiciraNvpTag tag = new NiciraNvpTag();
tag.setScope("scope");
tag.setTag("verylongtagthatshouldattheminimumexceedthefortycharacterlenght");
assertEquals("scope part set", "scope", tag.getScope());
[49/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fix parameter index in getCount function.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/19b15a1b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/19b15a1b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/19b15a1b
Branch: refs/heads/ui-restyle
Commit: 19b15a1bdcb7f55ca363adb6edeaeaaa27117a7f
Parents: fe83a85
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Feb 20 14:04:51 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Thu Feb 20 15:13:29 2014 +0100
----------------------------------------------------------------------
framework/db/src/com/cloud/utils/db/GenericDaoBase.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19b15a1b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
index 9f18c34..cecea84 100755
--- a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
+++ b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
@@ -1878,10 +1878,10 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
PreparedStatement pstmt = null;
try {
pstmt = txn.prepareAutoCloseStatement(sql);
- int i = 0;
+ int i = 1;
if (clause != null) {
for (final Pair<Attribute, Object> value : sc.getValues()) {
- prepareAttribute(++i, pstmt, value.first(), value.second());
+ prepareAttribute(i++, pstmt, value.first(), value.second());
}
}
[04/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Findbugs : Fix several "of concern" findings.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cc6938e3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cc6938e3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cc6938e3
Branch: refs/heads/ui-restyle
Commit: cc6938e3a8bfa29d4aeccc7ce4218633f17b125a
Parents: 091694c
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Feb 10 21:10:24 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:46 2014 +0100
----------------------------------------------------------------------
.../PremiumSecondaryStorageManagerImpl.java | 28 ++++++++++----------
.../SecondaryStorageManagerImpl.java | 2 --
2 files changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cc6938e3/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java
index af96ed2..15d58be 100755
--- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java
+++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/PremiumSecondaryStorageManagerImpl.java
@@ -64,8 +64,8 @@ public class PremiumSecondaryStorageManagerImpl extends SecondaryStorageManagerI
HostDao _hostDao;
@Inject
ResourceManager _resourceMgr;
- protected SearchBuilder<CommandExecLogVO> ActiveCommandSearch;
- protected SearchBuilder<HostVO> HostSearch;
+ protected SearchBuilder<CommandExecLogVO> activeCommandSearch;
+ protected SearchBuilder<HostVO> hostSearch;
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@@ -77,16 +77,16 @@ public class PremiumSecondaryStorageManagerImpl extends SecondaryStorageManagerI
int nMaxExecutionMinutes = NumbersUtil.parseInt(_configDao.getValue(Config.SecStorageCmdExecutionTimeMax.key()), 30);
_maxExecutionTimeMs = nMaxExecutionMinutes * 60 * 1000;
- HostSearch = _hostDao.createSearchBuilder();
- HostSearch.and("dc", HostSearch.entity().getDataCenterId(), Op.EQ);
- HostSearch.and("status", HostSearch.entity().getStatus(), Op.EQ);
+ hostSearch = _hostDao.createSearchBuilder();
+ hostSearch.and("dc", hostSearch.entity().getDataCenterId(), Op.EQ);
+ hostSearch.and("status", hostSearch.entity().getStatus(), Op.EQ);
- ActiveCommandSearch = _cmdExecLogDao.createSearchBuilder();
- ActiveCommandSearch.and("created", ActiveCommandSearch.entity().getCreated(), Op.GTEQ);
- ActiveCommandSearch.join("hostSearch", HostSearch, ActiveCommandSearch.entity().getInstanceId(), HostSearch.entity().getId(), JoinType.INNER);
+ activeCommandSearch = _cmdExecLogDao.createSearchBuilder();
+ activeCommandSearch.and("created", activeCommandSearch.entity().getCreated(), Op.GTEQ);
+ activeCommandSearch.join("hostSearch", hostSearch, activeCommandSearch.entity().getInstanceId(), hostSearch.entity().getId(), JoinType.INNER);
- HostSearch.done();
- ActiveCommandSearch.done();
+ hostSearch.done();
+ activeCommandSearch.done();
return true;
}
@@ -112,12 +112,12 @@ public class PremiumSecondaryStorageManagerImpl extends SecondaryStorageManagerI
}
List<SecondaryStorageVmVO> alreadyRunning =
- _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, dataCenterId, State.Running, State.Migrating, State.Starting);
+ _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, dataCenterId, State.Running, State.Migrating, State.Starting);
if (alreadyRunning.size() == 0) {
s_logger.info("No running secondary storage vms found in datacenter id=" + dataCenterId + ", starting one");
List<SecondaryStorageVmVO> stopped =
- _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, dataCenterId, State.Stopped, State.Stopping);
+ _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, dataCenterId, State.Stopped, State.Stopping);
if (stopped.size() == 0 || !suspendAutoLoading) {
List<SecondaryStorageVmVO> stopping = _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, State.Stopping);
if (stopping.size() > 0) {
@@ -141,7 +141,7 @@ public class PremiumSecondaryStorageManagerImpl extends SecondaryStorageManagerI
List<CommandExecLogVO> activeCmds = listActiveCommands(dataCenterId, cutTime);
if (alreadyRunning.size() * _capacityPerSSVM - activeCmds.size() < _standbyCapacity) {
s_logger.info("secondary storage command execution standby capactiy low (running VMs: " + alreadyRunning.size() + ", active cmds: " + activeCmds.size() +
- "), starting a new one");
+ "), starting a new one");
return new Pair<AfterScanAction, Object>(AfterScanAction.expand, SecondaryStorageVm.Role.commandExecutor);
}
}
@@ -166,7 +166,7 @@ public class PremiumSecondaryStorageManagerImpl extends SecondaryStorageManagerI
}
private List<CommandExecLogVO> listActiveCommands(long dcId, Date cutTime) {
- SearchCriteria<CommandExecLogVO> sc = ActiveCommandSearch.create();
+ SearchCriteria<CommandExecLogVO> sc = activeCommandSearch.create();
sc.setParameters("created", cutTime);
sc.setJoinParameters("hostSearch", "dc", dcId);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cc6938e3/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
index 4a59d8f..6fc7eef 100755
--- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
+++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
@@ -123,7 +123,6 @@ import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.events.SubscriptionMgr;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
-import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.SecondaryStorageVm;
@@ -371,7 +370,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
allowedCidrs.add(cidr);
}
}
- List<? extends Nic> nics = _networkModel.getNicsForTraffic(secStorageVm.getId(), TrafficType.Management);
setupCmd.setAllowedInternalSites(allowedCidrs.toArray(new String[allowedCidrs.size()]));
}
String copyPasswd = _configDao.getValue("secstorage.copy.password");
[47/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Fix typo
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ca683958
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ca683958
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ca683958
Branch: refs/heads/ui-restyle
Commit: ca683958d831f19b94e57c234b9bf2946a52cc16
Parents: d429be7
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 21:15:46 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 21:15:46 2014 -0800
----------------------------------------------------------------------
.../agent/resource/virtualnetwork/VirtualRoutingResource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca683958/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index fd96572..ef0d739 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -298,7 +298,7 @@ public class VirtualRoutingResource {
// Use the last answer as final answer
if (answersCount == 1) {
- ExecutionResult result = new ExecutionResult(true, "Not configure to be apply");
+ ExecutionResult result = new ExecutionResult(true, "No configure to be applied");
for (ConfigItem c : cfg) {
result = applyConfigToVR(cmd, c);
if (!result.isSuccess()) {
[33/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fix and add some Rest unit and IT tests. Fix by adding a missing type of RoutingConfig.
Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/808c6df6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/808c6df6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/808c6df6
Branch: refs/heads/ui-restyle
Commit: 808c6df6d76af1d4a048cbc7037903aca99d4c4d
Parents: b70af44
Author: Antonio Fornie <af...@schubergphilis.com>
Authored: Tue Feb 18 17:02:12 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Wed Feb 19 09:30:57 2014 +0100
----------------------------------------------------------------------
.../com/cloud/network/nicira/NiciraNvpApi.java | 7 +-
.../nicira/RoutingTableRoutingConfig.java | 30 ++
.../cloud/network/nicira/NiciraNvpApiTest.java | 383 ++++++++++---------
.../utils/rest/RESTServiceConnectorTest.java | 53 +--
4 files changed, 263 insertions(+), 210 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/808c6df6/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
index 3861d63..810453c 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
@@ -634,6 +634,9 @@ public class NiciraNvpApi {
public static class RoutingConfigAdapter implements JsonDeserializer<RoutingConfig> {
+ private static final String ROUTING_TABLE_ROUTING_CONFIG = "RoutingTableRoutingConfig";
+ private static final String SINGLE_DEFAULT_ROUTE_IMPLICIT_ROUTING_CONFIG = "SingleDefaultRouteImplicitRoutingConfig";
+
@Override
public RoutingConfig deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context) throws JsonParseException {
final JsonObject jsonObject = jsonElement.getAsJsonObject();
@@ -643,8 +646,10 @@ public class NiciraNvpApi {
}
final String routingConfigType = jsonObject.get("type").getAsString();
- if ("SingleDefaultRouteImplicitRoutingConfig".equals(routingConfigType)) {
+ if (SINGLE_DEFAULT_ROUTE_IMPLICIT_ROUTING_CONFIG.equals(routingConfigType)) {
return context.deserialize(jsonElement, SingleDefaultRouteImplicitRoutingConfig.class);
+ } else if (ROUTING_TABLE_ROUTING_CONFIG.equals(routingConfigType)) {
+ return context.deserialize(jsonElement, RoutingTableRoutingConfig.class);
}
throw new JsonParseException("Failed to deserialize type \"" + routingConfigType + "\"");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/808c6df6/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RoutingTableRoutingConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RoutingTableRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RoutingTableRoutingConfig.java
new file mode 100644
index 0000000..f0a80b8
--- /dev/null
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RoutingTableRoutingConfig.java
@@ -0,0 +1,30 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
+package com.cloud.network.nicira;
+
+/**
+ *
+ */
+public class RoutingTableRoutingConfig extends RoutingConfig {
+ public final String type = "RoutingTableRoutingConfig";
+
+ public RoutingTableRoutingConfig() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/808c6df6/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
index fe41545..51964bf 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
@@ -20,199 +20,214 @@
package com.cloud.network.nicira;
import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.io.IOException;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.params.HttpClientParams;
+import org.junit.Before;
import org.junit.Test;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
+import com.cloud.utils.rest.RESTServiceConnector;
+import com.cloud.utils.rest.RESTValidationStrategy;
+
public class NiciraNvpApiTest {
-// protected static final String UUID = "aaaa";
-// protected static final String UUID2 = "bbbb";
-// protected static final String UUID_SEC_PROFILE_URI = NiciraNvpApi.SEC_PROFILE_URI_PREFIX + "/aaaa";
-// protected static final String SCHEMA = "myTestSchema";
-// protected static final String SCHEMA2 = "myTestSchema2";
-// protected static final String HREF = "myTestHref";
-// protected static final String HREF2 = "myTestHref2";
-// protected static final String DISPLAY_NAME = "myTestName";
-// protected static final String UUID_JSON_RESPONSE = "{\"uuid\" : \"aaaa\"}";
-// protected static final String SEC_PROFILE_JSON_RESPONSE =
-// "{\"uuid\" : \"aaaa\","
-// + "\"display_name\" : \"myTestName\","
-// + "\"href\" : \"myTestHref\","
-// + "\"schema\" : \"myTestSchema\"}";
-//
-// protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
-// + "\"display_name\" : \"myTestName\","
-// + "\"href\" : \"myTestHref\","
-// + "\"schema\" : \"myTestSchema\"},"
-// + "{ \"uuid\" : \"bbbb\","
-// + "\"display_name\" : \"myTestName2\","
-// + "\"href\" : \"myTestHref2\","
-// + "\"schema\" : \"myTestSchema2\"}],"
-// + "\"result_count\": 2}";
-//
-// NiciraNvpApi api;
-// HttpClient client = mock(HttpClient.class);
-// HttpMethod method;
-// String type;
-// String uri;
-//
-// @Before
-// public void setUp() {
-// final HttpClientParams hmp = mock(HttpClientParams.class);
-// when(client.getParams()).thenReturn(hmp);
-// api = new NiciraNvpApi();
-//
-// api.restConnector = new RESTServiceConnector() {
-// @Override
-// public HttpClient createHttpClient() {
-// return client;
-// }
-//
-// @Override
-// public HttpMethod createMethod(final String newType, final String newUri) {
-// type = newType;
-// uri = newUri;
-// return method;
-// }
-// };
-//
-// api.setAdminCredentials("admin", "adminpass");
-// api.setControllerAddress("localhost");
-// }
-//
-// @Test
-// public void testFindSecurityProfile() throws NiciraNvpApiException, IOException {
-// // Prepare
-// method = mock(GetMethod.class);
-// when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-// when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
-// final NameValuePair[] queryString = new NameValuePair[]{
-// new NameValuePair("fields","*")};
-//
-// // Execute
-// final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile();
-//
-// // Assert
-// verify(method, times(1)).releaseConnection();
-// verify(method, times(1)).setQueryString(queryString);
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// UUID, actualProfiles.getResults().get(0).getUuid());
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// HREF, actualProfiles.getResults().get(0).getHref());
-// assertEquals("Wrong Schema in the newly created SecurityProfile",
-// SCHEMA, actualProfiles.getResults().get(0).getSchema());
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// UUID2, actualProfiles.getResults().get(1).getUuid());
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// HREF2, actualProfiles.getResults().get(1).getHref());
-// assertEquals("Wrong Schema in the newly created SecurityProfile",
-// SCHEMA2, actualProfiles.getResults().get(1).getSchema());
-// assertEquals("Wrong Schema in the newly created SecurityProfile",
-// 2, actualProfiles.getResultCount());
-// assertEquals("Wrong URI for SecurityProfile creation REST service",
-// NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
-// assertEquals("Wrong URI for SecurityProfile creation REST service",
-// NiciraNvpApi.GET_METHOD_TYPE, type);
-// }
-//
-// @Test
-// public void testFindSecurityProfileByUuid() throws NiciraNvpApiException, IOException {
-// // Prepare
-// method = mock(GetMethod.class);
-// when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-// when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
-// final NameValuePair[] queryString = new NameValuePair[]{
-// new NameValuePair("uuid", UUID),
-// new NameValuePair("fields","*")
-// };
-//
-// // Execute
-// final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);
-//
-// // Assert
-// verify(method, times(1)).releaseConnection();
-// verify(method, times(1)).setQueryString(queryString);
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// UUID, actualProfiles.getResults().get(0).getUuid());
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// HREF, actualProfiles.getResults().get(0).getHref());
-// assertEquals("Wrong Schema in the newly created SecurityProfile",
-// SCHEMA, actualProfiles.getResults().get(0).getSchema());
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// UUID2, actualProfiles.getResults().get(1).getUuid());
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// HREF2, actualProfiles.getResults().get(1).getHref());
-// assertEquals("Wrong Schema in the newly created SecurityProfile",
-// SCHEMA2, actualProfiles.getResults().get(1).getSchema());
-// assertEquals("Wrong Schema in the newly created SecurityProfile",
-// 2, actualProfiles.getResultCount());
-// assertEquals("Wrong URI for SecurityProfile creation REST service",
-// NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
-// assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
-// NiciraNvpApi.GET_METHOD_TYPE, type);
-// }
-//
-// @Test
-// public void testCreateSecurityProfile() throws NiciraNvpApiException, IOException {
-// // Prepare
-// final SecurityProfile inputSecProfile = new SecurityProfile();
-// method = mock(PostMethod.class);
-// when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
-// when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_JSON_RESPONSE);
-//
-// // Execute
-// final SecurityProfile actualSecProfile = api.createSecurityProfile(inputSecProfile);
-//
-// // Assert
-// verify(method, times(1)).releaseConnection();
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// UUID, actualSecProfile.getUuid());
-// assertEquals("Wrong Uuid in the newly created SecurityProfile",
-// HREF, actualSecProfile.getHref());
-// assertEquals("Wrong Schema in the newly created SecurityProfile",
-// SCHEMA, actualSecProfile.getSchema());
-// assertEquals("Wrong URI for SecurityProfile creation REST service",
-// NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
-// assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
-// NiciraNvpApi.POST_METHOD_TYPE, type);
-// }
-//
-// @Test
-// public void testUpdateSecurityProfile() throws NiciraNvpApiException, IOException {
-// // Prepare
-// final SecurityProfile inputSecProfile = new SecurityProfile();
-// method = mock(PutMethod.class);
-// when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-//
-// // Execute
-// api.updateSecurityProfile(inputSecProfile, UUID);
-//
-// // Assert
-// verify(method, times(1)).releaseConnection();
-// assertEquals("Wrong URI for SecurityProfile creation REST service",
-// UUID_SEC_PROFILE_URI, uri);
-// assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
-// NiciraNvpApi.PUT_METHOD_TYPE, type);
-// }
-//
-// @Test
-// public void testDeleteSecurityProfile() throws NiciraNvpApiException, IOException {
-// // Prepare
-// method = mock(DeleteMethod.class);
-// when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
-//
-// // Execute
-// api.deleteSecurityProfile(UUID);
-//
-// // Assert
-// verify(method, times(1)).releaseConnection();
-// assertEquals("Wrong URI for SecurityProfile deletion REST service", UUID_SEC_PROFILE_URI, uri);
-// assertEquals("Wrong HTTP method for SecurityProfile deletion REST service", NiciraNvpApi.DELETE_METHOD_TYPE, type);
-// }
+ protected static final String UUID = "aaaa";
+ protected static final String UUID2 = "bbbb";
+ protected static final String UUID_SEC_PROFILE_URI = NiciraNvpApi.SEC_PROFILE_URI_PREFIX + "/aaaa";
+ protected static final String SCHEMA = "myTestSchema";
+ protected static final String SCHEMA2 = "myTestSchema2";
+ protected static final String HREF = "myTestHref";
+ protected static final String HREF2 = "myTestHref2";
+ protected static final String SEC_PROFILE_JSON_RESPONSE =
+ "{\"uuid\" : \"aaaa\","
+ + "\"display_name\" : \"myTestName\","
+ + "\"href\" : \"myTestHref\","
+ + "\"schema\" : \"myTestSchema\"}";
+
+ protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
+ + "\"display_name\" : \"myTestName\","
+ + "\"href\" : \"myTestHref\","
+ + "\"schema\" : \"myTestSchema\"},"
+ + "{ \"uuid\" : \"bbbb\","
+ + "\"display_name\" : \"myTestName2\","
+ + "\"href\" : \"myTestHref2\","
+ + "\"schema\" : \"myTestSchema2\"}],"
+ + "\"result_count\": 2}";
+
+ NiciraNvpApi api;
+ HttpClient client = mock(HttpClient.class);
+ HttpMethod method;
+ String type;
+ String uri;
+
+ @Before
+ public void setUp() {
+ final HttpClientParams hmp = mock(HttpClientParams.class);
+ when(client.getParams()).thenReturn(hmp);
+ api = new NiciraNvpApi();
+
+ api.restConnector = new RESTServiceConnector(new RESTValidationStrategy()) {
+ @Override
+ public HttpClient createHttpClient() {
+ return client;
+ }
+
+ @Override
+ public HttpMethod createMethod(final String newType, final String newUri) {
+ type = newType;
+ uri = newUri;
+ return method;
+ }
+ };
+
+ api.setAdminCredentials("admin", "adminpass");
+ api.setControllerAddress("localhost");
+ }
+
+ @Test
+ public void testFindSecurityProfile() throws NiciraNvpApiException, IOException {
+ // Prepare
+ method = mock(GetMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+ when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
+ final NameValuePair[] queryString = new NameValuePair[]{
+ new NameValuePair("fields","*")};
+
+ // Execute
+ final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile();
+
+ // Assert
+ verify(method, times(1)).releaseConnection();
+ verify(method, times(1)).setQueryString(queryString);
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ UUID, actualProfiles.getResults().get(0).getUuid());
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ HREF, actualProfiles.getResults().get(0).getHref());
+ assertEquals("Wrong Schema in the newly created SecurityProfile",
+ SCHEMA, actualProfiles.getResults().get(0).getSchema());
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ UUID2, actualProfiles.getResults().get(1).getUuid());
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ HREF2, actualProfiles.getResults().get(1).getHref());
+ assertEquals("Wrong Schema in the newly created SecurityProfile",
+ SCHEMA2, actualProfiles.getResults().get(1).getSchema());
+ assertEquals("Wrong Schema in the newly created SecurityProfile",
+ 2, actualProfiles.getResultCount());
+ assertEquals("Wrong URI for SecurityProfile creation REST service",
+ NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+ assertEquals("Wrong URI for SecurityProfile creation REST service",
+ NiciraNvpApi.GET_METHOD_TYPE, type);
+ }
+
+ @Test
+ public void testFindSecurityProfileByUuid() throws NiciraNvpApiException, IOException {
+ // Prepare
+ method = mock(GetMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+ when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
+ final NameValuePair[] queryString = new NameValuePair[]{
+ new NameValuePair("uuid", UUID),
+ new NameValuePair("fields","*")
+ };
+
+ // Execute
+ final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);
+
+ // Assert
+ verify(method, times(1)).releaseConnection();
+ verify(method, times(1)).setQueryString(queryString);
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ UUID, actualProfiles.getResults().get(0).getUuid());
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ HREF, actualProfiles.getResults().get(0).getHref());
+ assertEquals("Wrong Schema in the newly created SecurityProfile",
+ SCHEMA, actualProfiles.getResults().get(0).getSchema());
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ UUID2, actualProfiles.getResults().get(1).getUuid());
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ HREF2, actualProfiles.getResults().get(1).getHref());
+ assertEquals("Wrong Schema in the newly created SecurityProfile",
+ SCHEMA2, actualProfiles.getResults().get(1).getSchema());
+ assertEquals("Wrong Schema in the newly created SecurityProfile",
+ 2, actualProfiles.getResultCount());
+ assertEquals("Wrong URI for SecurityProfile creation REST service",
+ NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+ assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+ NiciraNvpApi.GET_METHOD_TYPE, type);
+ }
+
+ @Test
+ public void testCreateSecurityProfile() throws NiciraNvpApiException, IOException {
+ // Prepare
+ final SecurityProfile inputSecProfile = new SecurityProfile();
+ method = mock(PostMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
+ when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_JSON_RESPONSE);
+
+ // Execute
+ final SecurityProfile actualSecProfile = api.createSecurityProfile(inputSecProfile);
+
+ // Assert
+ verify(method, times(1)).releaseConnection();
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ UUID, actualSecProfile.getUuid());
+ assertEquals("Wrong Uuid in the newly created SecurityProfile",
+ HREF, actualSecProfile.getHref());
+ assertEquals("Wrong Schema in the newly created SecurityProfile",
+ SCHEMA, actualSecProfile.getSchema());
+ assertEquals("Wrong URI for SecurityProfile creation REST service",
+ NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+ assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+ NiciraNvpApi.POST_METHOD_TYPE, type);
+ }
+
+ @Test
+ public void testUpdateSecurityProfile() throws NiciraNvpApiException, IOException {
+ // Prepare
+ final SecurityProfile inputSecProfile = new SecurityProfile();
+ method = mock(PutMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+
+ // Execute
+ api.updateSecurityProfile(inputSecProfile, UUID);
+
+ // Assert
+ verify(method, times(1)).releaseConnection();
+ assertEquals("Wrong URI for SecurityProfile creation REST service",
+ UUID_SEC_PROFILE_URI, uri);
+ assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+ NiciraNvpApi.PUT_METHOD_TYPE, type);
+ }
+
+ @Test
+ public void testDeleteSecurityProfile() throws NiciraNvpApiException, IOException {
+ // Prepare
+ method = mock(DeleteMethod.class);
+ when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+
+ // Execute
+ api.deleteSecurityProfile(UUID);
+
+ // Assert
+ verify(method, times(1)).releaseConnection();
+ assertEquals("Wrong URI for SecurityProfile deletion REST service", UUID_SEC_PROFILE_URI, uri);
+ assertEquals("Wrong HTTP method for SecurityProfile deletion REST service", NiciraNvpApi.DELETE_METHOD_TYPE, type);
+ }
@Test(expected = JsonParseException.class)
public void testRoutingConfigAdapterNoType() throws NiciraNvpApiException, IOException {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/808c6df6/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
index 17864b4..6d58b5b 100644
--- a/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
+++ b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
@@ -28,7 +28,6 @@ import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.Collections;
-//import java.util.List;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
@@ -45,28 +44,7 @@ import org.junit.Test;
public class RESTServiceConnectorTest {
protected static final String UUID = "aaaa";
- protected static final String UUID2 = "bbbb";
- protected static final String SCHEMA = "myTestSchema";
- protected static final String SCHEMA2 = "myTestSchema2";
- protected static final String HREF = "myTestHref";
- protected static final String HREF2 = "myTestHref2";
- protected static final String DISPLAY_NAME = "myTestName";
protected static final String UUID_JSON_RESPONSE = "{\"uuid\" : \"aaaa\"}";
- protected static final String SEC_PROFILE_JSON_RESPONSE =
- "{\"uuid\" : \"aaaa\","
- + "\"display_name\" : \"myTestName\","
- + "\"href\" : \"myTestHref\","
- + "\"schema\" : \"myTestSchema\"}";
-
- protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
- + "\"display_name\" : \"myTestName\","
- + "\"href\" : \"myTestHref\","
- + "\"schema\" : \"myTestSchema\"},"
- + "{ \"uuid\" : \"bbbb\","
- + "\"display_name\" : \"myTestName2\","
- + "\"href\" : \"myTestHref2\","
- + "\"schema\" : \"myTestSchema2\"}],"
- + "\"result_count\": 2}";
RESTServiceConnector connector;
HttpClient client = mock(HttpClient.class);
@@ -175,9 +153,6 @@ public class RESTServiceConnectorTest {
verify(gm, times(1)).getStatusCode();
}
- /* Bit of a roundabout way to ensure that login is called after an un authorized result
- * It not possible to properly mock login()
- */
@Test(expected = CloudstackRESTException.class)
public void testExecuteMethodWithLogin() throws CloudstackRESTException, HttpException, IOException {
final GetMethod gm = mock(GetMethod.class);
@@ -187,6 +162,34 @@ public class RESTServiceConnectorTest {
verify(gm, times(1)).getStatusCode();
}
+ /* Bit of a roundabout way to ensure that login is called after an un authorized result
+ * It not possible to properly mock login()
+ */
+ public void testExecuteMethodWithLoginSucced2ndAttempt() throws CloudstackRESTException, HttpException, IOException {
+ // Prepare
+ final GetMethod gm = mock(GetMethod.class);
+ when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
+
+ final RESTValidationStrategy previousValidationStrategy = connector.validation;
+ connector.validation = new RESTValidationStrategy(){
+ @Override
+ protected void login(final String protocol, final HttpClient client)
+ throws CloudstackRESTException {
+ // Do nothing
+ }
+ };
+ connector.setAdminCredentials("admin", "adminpass");
+ connector.setControllerAddress("localhost");
+
+ // Execute
+ connector.executeMethod(gm);
+ // Leave mock object as is was
+ connector.validation = previousValidationStrategy;
+
+ // Assert/verify
+ verify(gm, times(2)).getStatusCode();
+ }
+
@Test
public void testExecuteCreateObject() throws CloudstackRESTException, IOException {
JsonEntity ls = new JsonEntity();
[48/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Add support for Primary Storage on Gluster using the libvirt backend
The support for Gluster as Primary Storage is mostly based on the
implementation for NFS. Like NFS, libvirt can address a Gluster environment
through the 'netfs' pool-type.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fe83a854
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fe83a854
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fe83a854
Branch: refs/heads/ui-restyle
Commit: fe83a854368fb5161a5edce07607e70c0ff91b4b
Parents: ca68395
Author: Niels de Vos <nd...@redhat.com>
Authored: Wed Nov 20 13:42:18 2013 +0000
Committer: Wido den Hollander <wi...@widodh.nl>
Committed: Thu Feb 20 14:52:01 2014 +0100
----------------------------------------------------------------------
api/src/com/cloud/storage/Storage.java | 3 +-
.../kvm/resource/LibvirtComputingResource.java | 16 +++++++++--
.../kvm/resource/LibvirtStoragePoolDef.java | 29 ++++++++++++++++++--
.../resource/LibvirtStoragePoolXMLParser.java | 18 ++++++++++++
.../hypervisor/kvm/resource/LibvirtVMDef.java | 10 +++++--
.../kvm/storage/KVMStorageProcessor.java | 6 ++++
.../kvm/storage/LibvirtStorageAdaptor.java | 27 +++++++++++++-----
...CloudStackPrimaryDataStoreLifeCycleImpl.java | 17 +++++++++++-
8 files changed, 111 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe83a854/api/src/com/cloud/storage/Storage.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/Storage.java b/api/src/com/cloud/storage/Storage.java
index ff83dfc..8ab2463 100755
--- a/api/src/com/cloud/storage/Storage.java
+++ b/api/src/com/cloud/storage/Storage.java
@@ -98,7 +98,8 @@ public class Storage {
PreSetup(true), // for XenServer, Storage Pool is set up by customers.
EXT(false), // XenServer local EXT SR
OCFS2(true),
- SMB(true);
+ SMB(true),
+ Gluster(true);
boolean shared;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe83a854/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index f624379..e6c750b 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1750,8 +1750,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
if (pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) {
return "CLVM";
- } else if ((poolType == StoragePoolType.NetworkFilesystem || poolType == StoragePoolType.SharedMountPoint || poolType == StoragePoolType.Filesystem) &&
- volFormat == PhysicalDiskFormat.QCOW2) {
+ } else if ((poolType == StoragePoolType.NetworkFilesystem
+ || poolType == StoragePoolType.SharedMountPoint
+ || poolType == StoragePoolType.Filesystem
+ || poolType == StoragePoolType.Gluster)
+ && volFormat == PhysicalDiskFormat.QCOW2 ) {
return "QCOW2";
}
return null;
@@ -3702,6 +3705,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
*/
disk.defNetworkBasedDisk(physicalDisk.getPath().replace("rbd:", ""), pool.getSourceHost(), pool.getSourcePort(), pool.getAuthUserName(),
pool.getUuid(), devId, diskBusType, diskProtocol.RBD);
+ } else if (pool.getType() == StoragePoolType.Gluster) {
+ String mountpoint = pool.getLocalPath();
+ String path = physicalDisk.getPath();
+ String glusterVolume = pool.getSourceDir().replace("/", "");
+ disk.defNetworkBasedDisk(glusterVolume + path.replace(mountpoint, ""), pool.getSourceHost(), pool.getSourcePort(), null,
+ null, devId, diskBusType, diskProtocol.GLUSTER);
} else if (pool.getType() == StoragePoolType.CLVM || physicalDisk.getFormat() == PhysicalDiskFormat.RAW) {
disk.defBlockBasedDisk(physicalDisk.getPath(), devId, diskBusType);
} else {
@@ -3859,6 +3868,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
if (attachingPool.getType() == StoragePoolType.RBD) {
diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), attachingPool.getAuthUserName(),
attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD);
+ } else if (attachingPool.getType() == StoragePoolType.Gluster) {
+ diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), null,
+ null, devId, DiskDef.diskBus.VIRTIO, diskProtocol.GLUSTER);
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.QCOW2) {
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, DiskDef.diskBus.VIRTIO, DiskDef.diskFmtType.QCOW2);
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe83a854/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java
index dbe5d4b..7631169 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java
@@ -18,7 +18,7 @@ package com.cloud.hypervisor.kvm.resource;
public class LibvirtStoragePoolDef {
public enum poolType {
- ISCSI("iscsi"), NETFS("netfs"), LOGICAL("logical"), DIR("dir"), RBD("rbd");
+ ISCSI("iscsi"), NETFS("netfs"), LOGICAL("logical"), DIR("dir"), RBD("rbd"), GLUSTERFS("glusterfs");
String _poolType;
poolType(String poolType) {
@@ -127,7 +127,15 @@ public class LibvirtStoragePoolDef {
@Override
public String toString() {
StringBuilder storagePoolBuilder = new StringBuilder();
- storagePoolBuilder.append("<pool type='" + _poolType + "'>\n");
+ if (_poolType == poolType.GLUSTERFS) {
+ /* libvirt mounts a Gluster volume, similar to NFS */
+ storagePoolBuilder.append("<pool type='netfs'>\n");
+ } else {
+ storagePoolBuilder.append("<pool type='");
+ storagePoolBuilder.append(_poolType);
+ storagePoolBuilder.append("'>\n");
+ }
+
storagePoolBuilder.append("<name>" + _poolName + "</name>\n");
if (_uuid != null)
storagePoolBuilder.append("<uuid>" + _uuid + "</uuid>\n");
@@ -148,6 +156,23 @@ public class LibvirtStoragePoolDef {
}
storagePoolBuilder.append("</source>\n");
}
+ if (_poolType == poolType.GLUSTERFS) {
+ storagePoolBuilder.append("<source>\n");
+ storagePoolBuilder.append("<host name='");
+ storagePoolBuilder.append(_sourceHost);
+ if (_sourcePort != 0) {
+ storagePoolBuilder.append("' port='");
+ storagePoolBuilder.append(_sourcePort);
+ }
+ storagePoolBuilder.append("'/>\n");
+ storagePoolBuilder.append("<dir path='");
+ storagePoolBuilder.append(_sourceDir);
+ storagePoolBuilder.append("'/>\n");
+ storagePoolBuilder.append("<format type='");
+ storagePoolBuilder.append(_poolType);
+ storagePoolBuilder.append("'/>\n");
+ storagePoolBuilder.append("</source>\n");
+ }
if (_poolType != poolType.RBD) {
storagePoolBuilder.append("<target>\n");
storagePoolBuilder.append("<path>" + _targetPath + "</path>\n");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe83a854/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java
index a6186f6..3f7909e 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java
@@ -52,6 +52,7 @@ public class LibvirtStoragePoolXMLParser {
Element source = (Element)rootElement.getElementsByTagName("source").item(0);
String host = getAttrValue("host", "name", source);
+ String format = getAttrValue("format", "type", source);
if (type.equalsIgnoreCase("rbd")) {
int port = Integer.parseInt(getAttrValue("host", "port", source));
@@ -67,6 +68,23 @@ public class LibvirtStoragePoolXMLParser {
} else {
return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(type.toUpperCase()), poolName, uuid, host, port, pool, "");
}
+ /* Gluster is a sub-type of LibvirtStoragePoolDef.poolType.NETFS, need to check format */
+ } else if (format != null && format.equalsIgnoreCase("glusterfs")) {
+ /* libvirt does not return the default port, but requires it for a disk-definition */
+ int port = 24007;
+
+ String path = getAttrValue("dir", "path", source);
+
+ Element target = (Element) rootElement.getElementsByTagName(
+ "target").item(0);
+ String targetPath = getTagValue("path", target);
+
+ String portValue = getAttrValue("host", "port", source);
+ if (portValue != "")
+ port = Integer.parseInt(portValue);
+
+ return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(format.toUpperCase()),
+ poolName, uuid, host, port, path, targetPath);
} else {
String path = getAttrValue("dir", "path", source);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe83a854/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index ff75d61..290c5a9 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -378,7 +378,7 @@ public class LibvirtVMDef {
}
public enum diskProtocol {
- RBD("rbd"), SHEEPDOG("sheepdog");
+ RBD("rbd"), SHEEPDOG("sheepdog"), GLUSTER("gluster");
String _diskProtocol;
diskProtocol(String protocol) {
@@ -664,7 +664,13 @@ public class LibvirtVMDef {
diskBuilder.append(" protocol='" + _diskProtocol + "'");
diskBuilder.append(" name='" + _sourcePath + "'");
diskBuilder.append(">\n");
- diskBuilder.append("<host name='" + _sourceHost + "' port='" + _sourcePort + "'/>\n");
+ diskBuilder.append("<host name='");
+ diskBuilder.append(_sourceHost);
+ if (_sourcePort != 0) {
+ diskBuilder.append("' port='");
+ diskBuilder.append(_sourcePort);
+ }
+ diskBuilder.append("'/>\n");
diskBuilder.append("</source>\n");
if (_authUserName != null) {
diskBuilder.append("<auth username='" + _authUserName + "'>\n");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe83a854/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
index 8cdecd8..1c37607 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
@@ -931,6 +931,12 @@ public class KVMStorageProcessor implements StorageProcessor {
if (attachingPool.getType() == StoragePoolType.RBD) {
diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), attachingPool.getAuthUserName(),
attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD);
+ } else if (attachingPool.getType() == StoragePoolType.Gluster) {
+ String mountpoint = attachingPool.getLocalPath();
+ String path = attachingDisk.getPath();
+ String glusterVolume = attachingPool.getSourceDir().replace("/", "");
+ diskdef.defNetworkBasedDisk(glusterVolume + path.replace(mountpoint, ""), attachingPool.getSourceHost(), attachingPool.getSourcePort(), null,
+ null, devId, DiskDef.diskBus.VIRTIO, diskProtocol.GLUSTER);
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.QCOW2) {
diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, DiskDef.diskBus.VIRTIO, DiskDef.diskFmtType.QCOW2);
} else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe83a854/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index a5f33eb..4a8f1f1 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -129,9 +129,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
}
}
- private StoragePool createNfsStoragePool(Connect conn, String uuid, String host, String path) throws LibvirtException {
+ private StoragePool createNetfsStoragePool(poolType fsType, Connect conn, String uuid, String host, String path) throws LibvirtException {
String targetPath = _mountPoint + File.separator + uuid;
- LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.NETFS, uuid, uuid, host, path, targetPath);
+ LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(fsType, uuid, uuid, host, path, targetPath);
_storageLayer.mkdir(targetPath);
StoragePool sp = null;
try {
@@ -170,7 +170,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
}
sp.free();
} catch (LibvirtException l) {
- s_logger.debug("Failed to undefine nfs storage pool with: " + l.toString());
+ s_logger.debug("Failed to undefine " + fsType.toString() + " storage pool with: " + l.toString());
}
}
return null;
@@ -345,14 +345,19 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
type = StoragePoolType.RBD;
} else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.LOGICAL) {
type = StoragePoolType.CLVM;
+ } else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.GLUSTERFS) {
+ type = StoragePoolType.Gluster;
}
LibvirtStoragePool pool = new LibvirtStoragePool(uuid, storage.getName(), type, this, storage);
- if (pool.getType() != StoragePoolType.RBD) {
+ if (pool.getType() != StoragePoolType.RBD)
pool.setLocalPath(spd.getTargetPath());
- } else {
+ else
pool.setLocalPath("");
+
+ if (pool.getType() == StoragePoolType.RBD
+ || pool.getType() == StoragePoolType.Gluster) {
pool.setSourceHost(spd.getSourceHost());
pool.setSourcePort(spd.getSourcePort());
pool.setSourceDir(spd.getSourceDir());
@@ -484,9 +489,17 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
if (type == StoragePoolType.NetworkFilesystem) {
try {
- sp = createNfsStoragePool(conn, name, host, path);
+ sp = createNetfsStoragePool(poolType.NETFS, conn, name, host, path);
+ } catch (LibvirtException e) {
+ s_logger.error("Failed to create netfs mount: " + host + ":" + path , e);
+ s_logger.error(e.getStackTrace());
+ throw new CloudRuntimeException(e.toString());
+ }
+ } else if (type == StoragePoolType.Gluster) {
+ try {
+ sp = createNetfsStoragePool(poolType.GLUSTERFS, conn, name, host, path);
} catch (LibvirtException e) {
- s_logger.error("Failed to create mount");
+ s_logger.error("Failed to create glusterfs mount: " + host + ":" + path , e);
s_logger.error(e.getStackTrace());
throw new CloudRuntimeException(e.toString());
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe83a854/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
index b90d5fc..3c1b76a 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
@@ -166,6 +166,12 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
if (uriPath == null) {
throw new InvalidParameterValueException("host or path is null, should be rbd://hostname/pool");
}
+ } else if (uri.getScheme().equalsIgnoreCase("gluster")) {
+ String uriHost = uri.getHost();
+ String uriPath = uri.getPath();
+ if (uriHost == null || uriPath == null || uriHost.trim().isEmpty() || uriPath.trim().isEmpty()) {
+ throw new InvalidParameterValueException("host or path is null, should be gluster://hostname/volume");
+ }
}
} catch (URISyntaxException e) {
throw new InvalidParameterValueException(url + " is not a valid uri");
@@ -288,6 +294,14 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
parameters.setHost("clustered");
parameters.setPort(port);
parameters.setPath(hostPath);
+ } else if (scheme.equalsIgnoreCase("gluster")) {
+ if (port == -1) {
+ port = 24007;
+ }
+ parameters.setType(StoragePoolType.Gluster);
+ parameters.setHost(storageHost);
+ parameters.setPort(port);
+ parameters.setPath(hostPath);
} else {
StoragePoolType type = Enum.valueOf(StoragePoolType.class, scheme);
@@ -349,7 +363,8 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem &&
pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.VMFS &&
pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2 &&
- pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB) {
+ pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB &&
+ pool.getPoolType() != StoragePoolType.Gluster) {
s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType());
return false;
}
[30/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Prevent a ClassCastException when the answer is not a SetupAnswer (which happends when something goes wrong while connecting)
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/24309f60
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/24309f60
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/24309f60
Branch: refs/heads/ui-restyle
Commit: 24309f600157327b5af2cdf2e156d80dea412ff3
Parents: f113984
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Tue Feb 18 12:37:36 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Feb 18 12:37:36 2014 +0100
----------------------------------------------------------------------
.../xen/discoverer/XcpServerDiscoverer.java | 35 ++++++++++----------
1 file changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24309f60/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
index 58fe015..fbfd222 100755
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java
@@ -34,6 +34,13 @@ import javax.persistence.EntityExistsException;
import org.apache.log4j.Logger;
import org.apache.xmlrpc.XmlRpcException;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.Host;
+import com.xensource.xenapi.Pool;
+import com.xensource.xenapi.Session;
+import com.xensource.xenapi.Types.SessionAuthenticationFailed;
+import com.xensource.xenapi.Types.XenAPIException;
+
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
import com.cloud.agent.api.AgentControlAnswer;
@@ -92,12 +99,6 @@ import com.cloud.utils.db.QueryBuilder;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.exception.HypervisorVersionChangedException;
-import com.xensource.xenapi.Connection;
-import com.xensource.xenapi.Host;
-import com.xensource.xenapi.Pool;
-import com.xensource.xenapi.Session;
-import com.xensource.xenapi.Types.SessionAuthenticationFailed;
-import com.xensource.xenapi.Types.XenAPIException;
@Local(value = Discoverer.class)
public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
@@ -157,7 +158,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
@Override
public Map<? extends ServerResource, Map<String, String>>
- find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
+ find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
Map<CitrixResourceBase, Map<String, String>> resources = new HashMap<CitrixResourceBase, Map<String, String>>();
Connection conn = null;
if (!url.getScheme().equals("http")) {
@@ -486,8 +487,8 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
}
String msg =
- "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0, 6.2.0 but this one is " +
- prodBrand + " " + prodVersion;
+ "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0, 6.2.0 but this one is " +
+ prodBrand + " " + prodVersion;
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, dcId, podId, msg, msg);
s_logger.debug(msg);
throw new RuntimeException(msg);
@@ -574,8 +575,8 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
if (tmplt == null) {
id = _tmpltDao.getNextInSequence(Long.class, "id");
VMTemplateVO template =
- VMTemplateVO.createPreHostIso(id, isoName, isoName, ImageFormat.ISO, true, true, TemplateType.PERHOST, null, null, true, 64, Account.ACCOUNT_ID_SYSTEM,
- null, "xen-pv-drv-iso", false, 1, false, HypervisorType.XenServer);
+ VMTemplateVO.createPreHostIso(id, isoName, isoName, ImageFormat.ISO, true, true, TemplateType.PERHOST, null, null, true, 64, Account.ACCOUNT_ID_SYSTEM,
+ null, "xen-pv-drv-iso", false, 1, false, HypervisorType.XenServer);
_tmpltDao.persist(template);
} else {
id = tmplt.getId();
@@ -646,8 +647,8 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
if (resource == null) {
String msg =
- "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, 5.6 FP1, 5.6 SP2 and Xenserver 6.0 , 6.0.2, 6.1.0, 6.2.0 but this one is " +
- prodBrand + " " + prodVersion;
+ "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, 5.6 FP1, 5.6 SP2 and Xenserver 6.0 , 6.0.2, 6.1.0, 6.2.0 but this one is " +
+ prodBrand + " " + prodVersion;
s_logger.debug(msg);
throw new RuntimeException(msg);
}
@@ -674,12 +675,12 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
}
try {
- SetupAnswer answer = (SetupAnswer)_agentMgr.send(agentId, setup);
- if (answer != null && answer.getResult()) {
+ Answer answer = _agentMgr.send(agentId, setup);
+ if (answer != null && answer.getResult() && answer instanceof SetupAnswer) {
host.setSetup(true);
host.setLastPinged((System.currentTimeMillis() >> 10) - 5 * 60);
_hostDao.update(host.getId(), host);
- if (answer.needReconnect()) {
+ if (((SetupAnswer)answer).needReconnect()) {
throw new ConnectionException(false, "Reinitialize agent after setup.");
}
return;
@@ -763,7 +764,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
}
if (!success) {
String msg =
- "Unable to eject host " + host.getGuid() + " due to there is no host up in this cluster, please execute xe pool-eject host-uuid=" + host.getGuid() +
+ "Unable to eject host " + host.getGuid() + " due to there is no host up in this cluster, please execute xe pool-eject host-uuid=" + host.getGuid() +
"in this host " + host.getPrivateIpAddress();
s_logger.warn(msg);
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Unable to eject host " + host.getGuid(), msg);
[09/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
findbugs: check for system template id == -> equals()
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/15fa2ef8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/15fa2ef8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/15fa2ef8
Branch: refs/heads/ui-restyle
Commit: 15fa2ef8df10234ddaad81a3f164e45e64ebe7c0
Parents: 0d7a965
Author: Daan Hoogland <da...@onecht.net>
Authored: Tue Feb 11 12:22:53 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:47 2014 +0100
----------------------------------------------------------------------
.../com/cloud/template/TemplateManagerImpl.java | 16 ++++++++++------
.../cloud/template/TemplateManagerImplTest.java | 19 +++++++++++++++++++
2 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15fa2ef8/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 6d7eece..7466670 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -1753,12 +1753,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
throw ex;
}
- // Don't allow to modify system template
- if (id == Long.valueOf(1)) {
- InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id");
- ex.addProxyObject(String.valueOf(id), "templateId");
- throw ex;
- }
+ verifyTemplateId(id);
// do a permission check
_accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template);
@@ -1835,6 +1830,15 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
return _tmpltDao.findById(id);
}
+ void verifyTemplateId(Long id) {
+ // Don't allow to modify system template
+ if (id.equals(Long.valueOf(1))) {
+ InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id");
+ ex.addProxyObject(String.valueOf(id), "templateId");
+ throw ex;
+ }
+ }
+
@Override
public String getConfigComponentName() {
return TemplateManager.class.getSimpleName();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15fa2ef8/server/test/com/cloud/template/TemplateManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/template/TemplateManagerImplTest.java b/server/test/com/cloud/template/TemplateManagerImplTest.java
new file mode 100644
index 0000000..3788393
--- /dev/null
+++ b/server/test/com/cloud/template/TemplateManagerImplTest.java
@@ -0,0 +1,19 @@
+package com.cloud.template;
+
+import org.junit.Test;
+
+import com.cloud.exception.InvalidParameterValueException;
+
+public class TemplateManagerImplTest {
+
+ TemplateManagerImpl tmgr = new TemplateManagerImpl();
+
+ @Test(expected = InvalidParameterValueException.class)
+ public void testVerifyTemplateIdOfSystemTemplate() {
+ tmgr.verifyTemplateId(1L);
+ }
+
+ public void testVerifyTemplateIdOfNonSystemTemplate() {
+ tmgr.verifyTemplateId(1L);
+ }
+}
[50/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Merge branch 'master' into ui-restyle
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c64bfa5d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c64bfa5d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c64bfa5d
Branch: refs/heads/ui-restyle
Commit: c64bfa5d855a8e9be44081c6368379033a5a7c5a
Parents: 849d601 19b15a1
Author: Brian Federle <bf...@gmail.com>
Authored: Thu Feb 20 11:15:26 2014 -0800
Committer: Brian Federle <bf...@gmail.com>
Committed: Thu Feb 20 11:15:26 2014 -0800
----------------------------------------------------------------------
.../SYSCONFDIR/rc.d/init.d/cloud-agent.in | 8 +-
.../SYSCONFDIR/rc.d/init.d/cloud-agent.in | 8 +-
.../sles/SYSCONFDIR/init.d/cloud-agent.in | 8 +-
.../rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in | 8 +-
.../sles/SYSCONFDIR/init.d/cloud-agent.in | 8 +-
api/src/com/cloud/event/EventTypes.java | 6 +
.../com/cloud/network/MonitoringService.java | 2 +-
api/src/com/cloud/network/Network.java | 1 +
api/src/com/cloud/network/NetworkService.java | 4 +-
.../cloud/network/firewall/FirewallService.java | 2 +
.../com/cloud/network/rules/RulesService.java | 2 +
.../cloud/network/vpc/NetworkACLService.java | 5 +-
api/src/com/cloud/network/vpc/VpcService.java | 3 +-
.../network/vpn/RemoteAccessVpnService.java | 5 +
.../cloud/network/vpn/Site2SiteVpnService.java | 4 +
.../cloud/server/ResourceMetaDataService.java | 3 +-
api/src/com/cloud/server/ResourceTag.java | 3 +-
api/src/com/cloud/storage/Storage.java | 6 +-
api/src/com/cloud/storage/Volume.java | 2 +-
api/src/com/cloud/storage/VolumeApiService.java | 2 +-
.../org/apache/cloudstack/api/ApiConstants.java | 2 +
.../cloudstack/api/BaseAsyncCustomIdCmd.java | 7 +-
api/src/org/apache/cloudstack/api/BaseCmd.java | 6 +-
.../apache/cloudstack/api/BaseCustomIdCmd.java | 7 +-
.../command/admin/alert/GenerateAlertCmd.java | 2 +-
.../command/user/address/UpdateIPAddrCmd.java | 122 +
.../autoscale/ListAutoScaleVmProfilesCmd.java | 8 +
.../autoscale/UpdateAutoScaleVmGroupCmd.java | 14 +-
.../autoscale/UpdateAutoScaleVmProfileCmd.java | 14 +-
.../firewall/CreatePortForwardingRuleCmd.java | 3 +-
.../firewall/UpdateEgressFirewallRuleCmd.java | 113 +
.../user/firewall/UpdateFirewallRuleCmd.java | 114 +
.../firewall/UpdatePortForwardingRuleCmd.java | 32 +-
.../UpdateApplicationLoadBalancerCmd.java | 96 +
.../loadbalancer/UpdateLoadBalancerRuleCmd.java | 14 +-
.../user/network/UpdateNetworkACLItemCmd.java | 16 +-
.../user/network/UpdateNetworkACLListCmd.java | 91 +
.../command/user/network/UpdateNetworkCmd.java | 15 +-
.../api/command/user/vm/UpdateVMCmd.java | 11 +-
.../user/volume/AddResourceDetailCmd.java | 13 +-
.../user/volume/ListResourceDetailsCmd.java | 2 +-
.../command/user/volume/UpdateVolumeCmd.java | 22 +-
.../api/command/user/vpc/UpdateVPCCmd.java | 17 +-
.../user/vpn/UpdateRemoteAccessVpnCmd.java | 102 +
.../user/vpn/UpdateVpnConnectionCmd.java | 90 +
.../command/user/vpn/UpdateVpnGatewayCmd.java | 89 +
.../api/response/ResourceTagResponse.java | 31 +
.../Site2SiteVpnConnectionResponse.java | 5 +-
.../cloudstack/api/response/VolumeResponse.java | 24 +-
.../lb/ApplicationLoadBalancerService.java | 2 +
.../bridge/io/DimeDelimitedInputStream.java | 12 +-
.../com/cloud/bridge/model/SObjectItemVO.java | 2 +-
.../bridge/service/EC2SoapServiceImpl.java | 1 +
.../classes/resources/messages.properties | 91 +
.../classes/resources/messages_ja_JP.properties | 133 +-
.../classes/resources/messages_zh_CN.properties | 127 +-
client/pom.xml | 36 +-
client/tomcatconf/commands.properties.in | 14 +
.../com/cloud/agent/api/CheckRouterCommand.java | 5 +
.../api/CheckS2SVpnConnectionsCommand.java | 9 +-
.../com/cloud/agent/api/GetDomRVersionCmd.java | 5 +
.../agent/api/SetupGuestNetworkAnswer.java | 26 -
.../cloud/agent/api/routing/GroupAnswer.java | 40 +
.../cloud/agent/api/routing/IpAssocCommand.java | 4 +
.../agent/api/routing/IpAssocVpcCommand.java | 6 +
.../api/routing/NetworkElementCommand.java | 9 +
.../api/routing/SetFirewallRulesCommand.java | 9 +-
.../agent/api/routing/SetNetworkACLCommand.java | 11 +-
.../routing/SetPortForwardingRulesCommand.java | 10 +-
.../SetPortForwardingRulesVpcCommand.java | 4 +-
.../api/routing/SetStaticNatRulesCommand.java | 9 +-
.../agent/api/routing/SetStaticRouteAnswer.java | 13 +-
.../api/routing/SetStaticRouteCommand.java | 13 +-
.../virtualnetwork/VirtualRoutingResource.java | 797 +++---
.../VirtualRoutingResourceTest.java | 783 ++++++
.../api/storage/StorageCacheManager.java | 2 +
.../api/storage/type/VolumeTypeBase.java | 39 +-
.../api/storage/type/VolumeTypeHelper.java | 25 +-
.../api/storage/type/VolumeTypeHelperTest.java | 101 +
.../cloud/network/vpc/NetworkACLManager.java | 3 +-
.../src/com/cloud/template/TemplateManager.java | 9 +
.../com/cloud/agent/manager/AgentAttache.java | 2 +-
.../cloud/agent/manager/AgentManagerImpl.java | 53 +-
.../com/cloud/vm/VirtualMachineManagerImpl.java | 357 +--
.../orchestration/NetworkOrchestrator.java | 35 +-
.../orchestration/VolumeOrchestrator.java | 17 +-
.../cloud/vm/VirtualMachineManagerImplTest.java | 71 +-
.../orchestration/NetworkOrchestratorTest.java | 164 ++
engine/pom.xml | 13 +
.../spring-engine-schema-core-daos-context.xml | 1 +
.../src/com/cloud/dc/DataCenterDetailVO.java | 3 +-
.../src/com/cloud/dc/dao/DataCenterDaoImpl.java | 2 +-
.../cloud/dc/dao/DataCenterDetailsDaoImpl.java | 4 +-
.../cloud/network/as/AutoScaleVmGroupVO.java | 4 +
.../cloud/network/as/AutoScaleVmProfileVO.java | 4 +
.../network/dao/FirewallRulesCidrsDaoImpl.java | 1 -
.../network/dao/MonitoringServiceDaoImpl.java | 4 +-
.../cloud/network/dao/MonitoringServiceVO.java | 28 +-
.../com/cloud/network/dao/NetworkDetailVO.java | 3 +-
.../network/dao/NetworkDetailsDaoImpl.java | 4 +-
.../cloud/network/dao/RemoteAccessVpnVO.java | 4 +
.../network/dao/Site2SiteVpnConnectionVO.java | 4 +
.../network/dao/Site2SiteVpnGatewayVO.java | 4 +
.../com/cloud/network/vpc/NetworkACLItemVO.java | 4 +
.../src/com/cloud/network/vpc/NetworkACLVO.java | 3 +
.../schema/src/com/cloud/network/vpc/VpcVO.java | 5 +
.../cloud/service/ServiceOfferingDetailsVO.java | 3 +-
.../service/dao/ServiceOfferingDaoImpl.java | 2 +-
.../dao/ServiceOfferingDetailsDaoImpl.java | 4 +-
.../com/cloud/storage/VMTemplateDetailVO.java | 3 +-
.../src/com/cloud/storage/VolumeDetailVO.java | 3 +-
.../storage/dao/SnapshotDetailsDaoImpl.java | 4 +-
.../cloud/storage/dao/SnapshotDetailsVO.java | 9 +-
.../storage/dao/StoragePoolDetailsDaoImpl.java | 4 +-
.../cloud/storage/dao/VMTemplateDaoImpl.java | 40 +-
.../storage/dao/VMTemplateDetailsDaoImpl.java | 4 +-
.../cloud/storage/dao/VolumeDetailsDaoImpl.java | 4 +-
engine/schema/src/com/cloud/vm/NicDetailVO.java | 3 +-
.../schema/src/com/cloud/vm/UserVmDetailVO.java | 3 +-
.../src/com/cloud/vm/dao/NicDetailsDaoImpl.java | 4 +-
.../src/com/cloud/vm/dao/UserVmDaoImpl.java | 2 +-
.../com/cloud/vm/dao/UserVmDetailsDaoImpl.java | 4 +-
.../cloud/vm/snapshot/VMSnapshotDetailsVO.java | 9 +-
.../snapshot/dao/VMSnapshotDetailsDaoImpl.java | 4 +-
.../AutoScaleVmGroupDetailVO.java | 82 +
.../AutoScaleVmProfileDetailVO.java | 3 +-
.../resourcedetail/DiskOfferingDetailVO.java | 3 +-
.../resourcedetail/FirewallRuleDetailVO.java | 3 +-
.../resourcedetail/NetworkACLItemDetailVO.java | 3 +-
.../resourcedetail/NetworkACLListDetailVO.java | 3 +-
.../resourcedetail/RemoteAccessVpnDetailVO.java | 3 +-
.../resourcedetail/ResourceDetailsDao.java | 2 +-
.../resourcedetail/ResourceDetailsDaoBase.java | 5 +-
.../Site2SiteCustomerGatewayDetailVO.java | 3 +-
.../Site2SiteVpnConnectionDetailVO.java | 3 +-
.../Site2SiteVpnGatewayDetailVO.java | 3 +-
.../resourcedetail/UserIpAddressDetailVO.java | 3 +-
.../cloudstack/resourcedetail/VpcDetailVO.java | 3 +-
.../resourcedetail/VpcGatewayDetailVO.java | 3 +-
.../dao/AutoScaleVmGroupDetailsDao.java | 26 +
.../dao/AutoScaleVmGroupDetailsDaoImpl.java | 33 +
.../dao/AutoScaleVmProfileDetailsDaoImpl.java | 4 +-
.../dao/DiskOfferingDetailsDaoImpl.java | 4 +-
.../dao/FirewallRuleDetailsDaoImpl.java | 4 +-
.../dao/NetworkACLItemDetailsDaoImpl.java | 4 +-
.../dao/NetworkACLListDetailsDaoImpl.java | 4 +-
.../dao/RemoteAccessVpnDetailsDaoImpl.java | 4 +-
.../Site2SiteCustomerGatewayDetailsDaoImpl.java | 4 +-
.../Site2SiteVpnConnectionDetailsDaoImpl.java | 4 +-
.../dao/Site2SiteVpnGatewayDetailsDaoImpl.java | 4 +-
.../resourcedetail/dao/UserDetailsDaoImpl.java | 2 +-
.../dao/UserIpAddressDetailsDaoImpl.java | 4 +-
.../resourcedetail/dao/VpcDetailsDaoImpl.java | 4 +-
.../dao/VpcGatewayDetailsDaoImpl.java | 4 +-
.../storage/datastore/db/ImageStoreVO.java | 7 +-
.../datastore/db/PrimaryDataStoreDaoImpl.java | 4 +-
.../datastore/db/PrimaryDataStoreDetailVO.java | 3 +-
.../datastore/db/StoragePoolDetailVO.java | 3 +-
.../storage/datastore/db/StoragePoolVO.java | 12 +-
.../cache/allocator/StorageCacheAllocator.java | 3 +
.../allocator/StorageCacheRandomAllocator.java | 38 +
.../cache/manager/StorageCacheManagerImpl.java | 13 +
.../motion/AncientDataMotionStrategy.java | 4 +-
.../vm/snapshot/dao/VmSnapshotDaoTest.java | 2 +-
.../storage/allocator/StorageAllocatorTest.java | 4 +-
.../storage/test/ChildTestConfiguration.java | 6 -
.../storage/snapshot/SnapshotObject.java | 5 +-
.../storage/snapshot/SnapshotServiceImpl.java | 8 +-
.../snapshot/XenserverSnapshotStrategy.java | 5 +
.../endpoint/DefaultEndPointSelector.java | 3 +-
.../image/datastore/ImageStoreHelper.java | 26 +
.../storage/image/format/ImageFormatHelper.java | 2 +-
.../datastore/PrimaryDataStoreHelper.java | 30 +-
.../db/PrimaryDataStoreDetailsDaoImpl.java | 4 +-
.../storage/datastore/PrimaryDataStoreImpl.java | 5 +-
.../storage/volume/VolumeServiceImpl.java | 42 +-
.../db/src/com/cloud/dao/EntityManagerImpl.java | 1 +
framework/db/src/com/cloud/utils/db/Filter.java | 2 +-
.../src/com/cloud/utils/db/GenericDaoBase.java | 59 +-
.../db/src/com/cloud/utils/db/GroupBy.java | 31 +-
.../db/src/com/cloud/utils/db/SearchBase.java | 87 +-
.../db/test/com/cloud/utils/db/GroupByTest.java | 81 +
framework/pom.xml | 13 +
packaging/centos63/cloud-agent.rc | 8 +-
packaging/centos63/cloud-ipallocator.rc | 8 +-
packaging/centos63/package.sh | 170 +-
.../dedicated/DedicatedResourceManagerImpl.java | 38 +-
.../mom/inmemory/InMemoryEventBus.java | 53 +-
.../mom/inmemory/InMemoryEventBusTest.java | 162 ++
.../HypervResource/CloudStackTypes.cs | 9 +-
.../HypervResource/HypervResourceController.cs | 84 +-
.../HypervResource/IWmiCallsV2.cs | 1 +
.../ServerResource/HypervResource/WmiCallsV2.cs | 33 +-
.../resource/HypervDirectConnectResource.java | 51 +-
.../kvm/resource/LibvirtComputingResource.java | 130 +-
.../kvm/resource/LibvirtDomainXMLParser.java | 7 +-
.../kvm/resource/LibvirtStoragePoolDef.java | 29 +-
.../resource/LibvirtStoragePoolXMLParser.java | 18 +
.../hypervisor/kvm/resource/LibvirtVMDef.java | 26 +-
.../kvm/storage/KVMStorageProcessor.java | 13 +-
.../kvm/storage/LibvirtStorageAdaptor.java | 39 +-
.../apache/cloudstack/utils/qemu/QemuImg.java | 6 +-
.../cloudstack/utils/qemu/QemuImgFile.java | 1 -
.../resource/LibvirtComputingResourceTest.java | 7 +
.../resource/LibvirtDomainXMLParserTest.java | 194 ++
.../cloud/agent/manager/MockNetworkManager.java | 3 +-
.../agent/manager/MockNetworkManagerImpl.java | 9 +-
.../com/cloud/hypervisor/guru/VMwareGuru.java | 61 +-
.../vmware/VmwareServerDiscoverer.java | 6 -
.../vmware/manager/VmwareManagerImpl.java | 100 +-
.../vmware/resource/VmwareResource.java | 85 +-
.../resource/VmwareStorageProcessor.java | 78 +-
.../VmwareStorageSubsystemCommandHandler.java | 51 +-
.../vmware/VmwareDatacenterApiUnitTest.java | 6 -
.../xen/src/com/cloud/ha/XenServerFencer.java | 1 -
.../xen/discoverer/XcpServerDiscoverer.java | 35 +-
.../xen/resource/CitrixResourceBase.java | 36 +-
.../test/com/cloud/ha/XenServerFencerTest.java | 39 +
.../xen/resource/CitrixResourceBaseTest.java | 16 +
.../network/cisco/CiscoVnmcConnectionTest.java | 209 +-
.../lb/ElasticLoadBalancerManagerImpl.java | 486 +---
.../network/lb/LoadBalanceRuleHandler.java | 466 ++++
.../lb/ElasticLoadBalancerManagerImplTest.java | 101 +
.../network/lb/LoadBalanceRuleHandlerTest.java | 215 ++
.../contrail/spring-contrail-context.xml | 4 +
...ring-contrail-system-context-inheritable.xml | 41 +
.../contrail/management/ContrailGuru.java | 62 +-
.../contrail/management/ContrailManager.java | 11 +
.../management/ContrailManagerImpl.java | 177 +-
.../management/ContrailVpcElementImpl.java | 199 ++
.../network/contrail/management/EventUtils.java | 56 +-
.../contrail/management/ServerDBSyncImpl.java | 18 +-
.../network/contrail/model/ModelObject.java | 10 +-
.../contrail/model/NetworkPolicyModel.java | 2 +-
.../contrail/model/ServiceInstanceModel.java | 21 +-
.../contrail/model/VirtualMachineModel.java | 78 +-
.../contrail/model/VirtualNetworkModel.java | 171 +-
.../IntegrationTestConfiguration.java | 6 -
.../contrail/model/VirtualMachineModelTest.java | 9 +-
.../contrail/model/VirtualNetworkModelTest.java | 143 +-
plugins/network-elements/netscaler/pom.xml | 8 +-
.../network/resource/NetscalerResource.java | 149 +-
.../network/nicira/AccessConfiguration.java | 90 +-
.../src/com/cloud/network/nicira/Acl.java | 1 -
.../cloud/network/nicira/BaseNiciraEntity.java | 85 +
.../network/nicira/BaseNiciraNamedEntity.java | 44 +
.../com/cloud/network/nicira/LogicalRouter.java | 71 +
.../network/nicira/LogicalRouterConfig.java | 65 -
.../cloud/network/nicira/LogicalRouterPort.java | 41 +-
.../com/cloud/network/nicira/LogicalSwitch.java | 68 +-
.../cloud/network/nicira/LogicalSwitchPort.java | 50 +-
.../com/cloud/network/nicira/NiciraNvpApi.java | 750 ++---
.../nicira/RoutingTableRoutingConfig.java | 30 +
...SingleDefaultRouteImplicitRoutingConfig.java | 40 +
.../SingleDefaultRouteImplictRoutingConfig.java | 40 -
.../com/cloud/network/nicira/VifAttachment.java | 35 +-
.../network/resource/NiciraNvpResource.java | 20 +-
.../network/element/NiciraNvpElementTest.java | 42 +-
.../guru/NiciraNvpGuestNetworkGuruTest.java | 154 +-
.../com/cloud/network/nicira/NatRuleTest.java | 12 +-
.../cloud/network/nicira/NiciraNvpApiIT.java | 200 +-
.../cloud/network/nicira/NiciraNvpApiTest.java | 367 +--
.../com/cloud/network/nicira/NiciraTagTest.java | 8 +-
.../network/resource/NiciraNvpResourceTest.java | 258 +-
.../com/cloud/network/element/OvsElement.java | 283 +-
.../cloud/network/guru/OvsGuestNetworkGuru.java | 4 -
.../com/cloud/network/ovs/OvsTunnelManager.java | 4 +-
.../cloud/network/ovs/OvsTunnelManagerImpl.java | 148 +-
.../cloudstack/network/element/SspClient.java | 244 +-
.../cloudstack/network/element/SspElement.java | 21 +-
.../stratosphere-ssp/sspmock/sspmock.py | 58 +-
.../network/element/SspClientTest.java | 55 +-
plugins/pom.xml | 25 +-
...CloudStackPrimaryDataStoreLifeCycleImpl.java | 36 +-
.../CloudStackPrimaryDataStoreProviderImpl.java | 9 +-
pom.xml | 33 +-
.../SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in | 8 +-
.../SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in | 8 +-
.../SYSCONFDIR/init.d/cloud-ipallocator.in | 8 +-
.../SYSCONFDIR/rc.d/init.d/cloud-ipallocator.in | 8 +-
.../sles/SYSCONFDIR/init.d/cloud-ipallocator.in | 8 +-
.../SYSCONFDIR/init.d/cloud-ipallocator.in | 8 +-
.../spring-server-core-managers-context.xml | 6 -
server/src/com/cloud/api/ApiDispatcher.java | 12 +-
server/src/com/cloud/api/ApiResponseHelper.java | 5 +-
.../com/cloud/api/query/QueryManagerImpl.java | 5 +-
.../api/query/dao/ImageStoreJoinDaoImpl.java | 4 +-
.../cloud/api/query/dao/VolumeJoinDaoImpl.java | 3 +-
.../com/cloud/api/query/vo/UserVmJoinVO.java | 23 +-
.../com/cloud/api/query/vo/VolumeJoinVO.java | 6 +
server/src/com/cloud/configuration/Config.java | 6 +
.../configuration/ConfigurationManagerImpl.java | 76 +-
.../com/cloud/consoleproxy/AgentHookBase.java | 5 +-
.../ConsoleProxyBalanceAllocator.java | 3 -
.../consoleproxy/StaticConsoleProxyManager.java | 18 -
.../src/com/cloud/dc/DedicatedResourceVO.java | 10 +-
.../deploy/DeploymentPlanningManagerImpl.java | 97 +-
.../src/com/cloud/event/ActionEventUtils.java | 9 +
.../metadata/ResourceMetaDataManagerImpl.java | 12 +-
.../com/cloud/network/IpAddressManagerImpl.java | 57 +-
.../src/com/cloud/network/NetworkModelImpl.java | 9 +-
.../com/cloud/network/NetworkServiceImpl.java | 35 +-
.../cloud/network/as/AutoScaleManagerImpl.java | 26 +-
.../network/firewall/FirewallManagerImpl.java | 31 +-
.../lb/LoadBalancingRulesManagerImpl.java | 15 +-
.../router/VirtualNetworkApplianceManager.java | 4 +
.../VirtualNetworkApplianceManagerImpl.java | 1605 +++++------
.../VpcVirtualNetworkApplianceManagerImpl.java | 33 +-
.../cloud/network/rules/RulesManagerImpl.java | 20 +-
.../network/vpc/NetworkACLManagerImpl.java | 9 +-
.../network/vpc/NetworkACLServiceImpl.java | 33 +-
.../com/cloud/network/vpc/VpcManagerImpl.java | 22 +-
.../network/vpn/RemoteAccessVpnManagerImpl.java | 26 +-
.../network/vpn/Site2SiteVpnManagerImpl.java | 42 +-
.../com/cloud/resource/ResourceManagerImpl.java | 66 +-
.../PremiumSecondaryStorageManagerImpl.java | 185 --
.../cloud/server/ConfigurationServerImpl.java | 413 +--
.../com/cloud/server/ManagementServerImpl.java | 55 +-
.../com/cloud/storage/VolumeApiServiceImpl.java | 194 +-
.../storage/download/DownloadMonitorImpl.java | 29 +-
.../secondary/SecondaryStorageListener.java | 5 +-
.../secondary/SecondaryStorageManagerImpl.java | 1389 ----------
.../storage/snapshot/SnapshotManagerImpl.java | 66 +-
.../cloud/storage/upload/UploadMonitorImpl.java | 27 +-
.../cloud/tags/TaggedResourceManagerImpl.java | 2 +
.../template/HypervisorTemplateAdapter.java | 18 +-
.../com/cloud/template/TemplateManagerImpl.java | 191 +-
.../src/com/cloud/uuididentity/UUIDManager.java | 37 -
.../com/cloud/uuididentity/UUIDManagerImpl.java | 1 +
server/src/com/cloud/vm/UserVmManagerImpl.java | 73 +-
.../lb/ApplicationLoadBalancerManagerImpl.java | 23 +-
.../cloudstack/network/lb/CertServiceImpl.java | 14 +-
.../metadata/ResourceMetaDataManagerTest.java | 2 +-
.../cloud/network/MockFirewallManagerImpl.java | 6 +
.../cloud/template/TemplateManagerImplTest.java | 37 +
.../com/cloud/vpc/MockNetworkManagerImpl.java | 13 +-
.../cloud/vpc/MockSite2SiteVpnManagerImpl.java | 15 +-
.../com/cloud/vpc/NetworkACLManagerTest.java | 9 +-
.../affinity/AffinityApiUnitTest.java | 9 +
.../networkoffering/ChildTestConfiguration.java | 6 -
services/console-proxy-rdp/rdpconsole/pom.xml | 2 +-
.../rdpconsole/src/main/java/common/Client.java | 92 +-
.../src/main/java/streamer/ByteBuffer.java | 122 +-
.../src/test/java/common/ClientTest.java | 43 +
.../src/test/java/rdpclient/MockServerTest.java | 9 +-
.../src/test/java/streamer/ByteBufferTest.java | 152 ++
.../consoleproxy/ConsoleProxyRdpClient.java | 159 +-
.../ConsoleProxyThumbnailHandler.java | 1 +
.../consoleproxy/ConsoleProxyRdpClientTest.java | 62 +
services/pom.xml | 13 +
services/secondary-storage/controller/pom.xml | 50 +
...econdary-storage-controller-core-context.xml | 33 +
.../PremiumSecondaryStorageManagerImpl.java | 186 ++
.../SecondaryStorageManagerImpl.java | 1386 ++++++++++
services/secondary-storage/pom.xml | 85 +-
.../module.properties | 18 -
...ing-secondary-storage-discoverer-context.xml | 36 -
services/secondary-storage/server/pom.xml | 105 +
.../module.properties | 18 +
...ing-secondary-storage-discoverer-context.xml | 36 +
.../LocalNfsSecondaryStorageResource.java | 95 +
.../resource/LocalSecondaryStorageResource.java | 240 ++
.../resource/NfsSecondaryStorageResource.java | 2430 +++++++++++++++++
.../resource/SecondaryStorageDiscoverer.java | 312 +++
.../resource/SecondaryStorageResource.java | 29 +
.../SecondaryStorageResourceHandler.java | 24 +
.../storage/template/DownloadManager.java | 108 +
.../storage/template/DownloadManagerImpl.java | 1080 ++++++++
.../storage/template/UploadManager.java | 82 +
.../storage/template/UploadManagerImpl.java | 550 ++++
.../LocalNfsSecondaryStorageResourceTest.java | 143 +
.../NfsSecondaryStorageResourceTest.java | 110 +
.../LocalNfsSecondaryStorageResource.java | 95 -
.../resource/LocalSecondaryStorageResource.java | 240 --
.../resource/NfsSecondaryStorageResource.java | 2553 ------------------
.../resource/SecondaryStorageDiscoverer.java | 319 ---
.../resource/SecondaryStorageResource.java | 29 -
.../SecondaryStorageResourceHandler.java | 24 -
.../storage/template/DownloadManager.java | 108 -
.../storage/template/DownloadManagerImpl.java | 1149 --------
.../storage/template/UploadManager.java | 82 -
.../storage/template/UploadManagerImpl.java | 646 -----
.../LocalNfsSecondaryStorageResourceTest.java | 143 -
.../NfsSecondaryStorageResourceTest.java | 110 -
setup/db/create-schema.sql | 2 +-
setup/db/db/schema-421to430.sql | 2 +-
setup/db/db/schema-430to440.sql | 79 +-
.../rc.d/init.d/cloud-console-proxy.in | 8 +-
.../rc.d/init.d/cloud-console-proxy.in | 8 +-
.../rc.d/init.d/cloud-console-proxy.in | 8 +-
.../SYSCONFDIR/init.d/cloud-console-proxy.in | 8 +-
.../patches/debian/config/etc/dnsmasq.conf.tmpl | 2 +-
.../debian/config/etc/init.d/cloud-early-config | 10 +
.../patches/debian/config/etc/vpcdnsmasq.conf | 2 +-
.../debian/config/opt/cloud/bin/edithosts.sh | 53 +-
.../config/opt/cloud/bin/monitor_service.sh | 27 +-
.../debian/config/opt/cloud/bin/vpc_acl.sh | 19 +-
.../debian/config/opt/cloud/bin/vpc_guestnw.sh | 44 +-
systemvm/scripts/_run.sh | 7 +
.../component/test_multiple_ips_per_nic.py | 452 ++++
test/integration/component/test_portable_ip.py | 132 +-
test/integration/smoke/test_vm_life_cycle.py | 84 +-
tools/apidoc/gen_toc.py | 17 +-
tools/appliance/build.sh | 48 +-
.../definitions/systemvm64template/base.sh | 6 +-
.../systemvm64template/definition.rb | 6 +-
.../systemvm64template/postinstall.sh | 17 +-
.../definitions/systemvmtemplate/base.sh | 4 +-
.../definitions/systemvmtemplate/definition.rb | 6 +-
.../definitions/systemvmtemplate/postinstall.sh | 13 +-
.../devcloud-kvm-advanced-fusion.cfg | 139 +
tools/devcloud-kvm/devcloud-kvm-advanced.cfg | 4 +-
tools/marvin/marvin/codes.py | 4 +
tools/marvin/marvin/integration/lib/base.py | 29 +
tools/marvin/marvin/integration/lib/common.py | 96 +-
ui/dictionary.jsp | 87 +-
ui/lib/jquery.validate.js | 34 +-
ui/scripts/accounts.js | 2 +-
ui/scripts/autoscaler.js | 26 +-
ui/scripts/cloudStack.js | 4 +-
ui/scripts/configuration.js | 12 +-
ui/scripts/domains.js | 2 +-
ui/scripts/installWizard.js | 4 +-
ui/scripts/instanceWizard.js | 6 +-
ui/scripts/instances.js | 73 +-
ui/scripts/regions.js | 78 +-
ui/scripts/sharedFunctions.js | 2 +-
ui/scripts/system.js | 174 +-
ui/scripts/templates.js | 91 +-
ui/scripts/ui/dialog.js | 5 +
ui/scripts/ui/widgets/detailView.js | 3 +-
ui/scripts/ui/widgets/listView.js | 27 +-
ui/scripts/zoneWizard.js | 15 +-
utils/conf/db.properties | 6 +-
utils/conf/log4j-vmops.xml | 34 +-
utils/pom.xml | 70 +-
utils/src/com/cloud/maint/Version.java | 3 +
utils/src/com/cloud/utils/ActionDelegate.java | 7 +-
.../com/cloud/utils/CloudResourceBundle.java | 7 +-
utils/src/com/cloud/utils/DateUtil.java | 7 +-
utils/src/com/cloud/utils/EnumUtils.java | 7 +-
utils/src/com/cloud/utils/ExecutionResult.java | 2 +
utils/src/com/cloud/utils/FileUtil.java | 7 +-
utils/src/com/cloud/utils/IteratorUtil.java | 7 +-
utils/src/com/cloud/utils/Journal.java | 7 +-
utils/src/com/cloud/utils/LogUtils.java | 7 +-
utils/src/com/cloud/utils/MethodCapturer.java | 7 +-
utils/src/com/cloud/utils/NumbersUtil.java | 7 +-
utils/src/com/cloud/utils/Pair.java | 7 +-
.../src/com/cloud/utils/PasswordGenerator.java | 7 +-
utils/src/com/cloud/utils/Predicate.java | 7 +-
utils/src/com/cloud/utils/ProcessUtil.java | 7 +-
utils/src/com/cloud/utils/Profiler.java | 7 +-
utils/src/com/cloud/utils/PropertiesUtil.java | 7 +-
utils/src/com/cloud/utils/ReflectUtil.java | 7 +-
utils/src/com/cloud/utils/S3Utils.java | 37 +-
utils/src/com/cloud/utils/SerialVersionUID.java | 7 +-
utils/src/com/cloud/utils/StringUtils.java | 15 +-
utils/src/com/cloud/utils/SwiftUtil.java | 41 +-
utils/src/com/cloud/utils/Ternary.java | 7 +-
utils/src/com/cloud/utils/UriUtils.java | 92 +-
.../cloud/utils/UsernamePasswordValidator.java | 7 +-
utils/src/com/cloud/utils/UuidUtils.java | 13 +-
.../cloud/utils/backoff/BackoffAlgorithm.java | 7 +-
.../utils/backoff/impl/ConstantTimeBackoff.java | 7 +-
.../backoff/impl/ConstantTimeBackoffMBean.java | 7 +-
.../utils/cisco/n1kv/vsm/NetconfHelper.java | 7 +-
.../cloud/utils/cisco/n1kv/vsm/PolicyMap.java | 7 +-
.../cloud/utils/cisco/n1kv/vsm/PortProfile.java | 7 +-
.../cloud/utils/cisco/n1kv/vsm/VsmCommand.java | 7 +-
.../utils/cisco/n1kv/vsm/VsmOkResponse.java | 7 +-
.../cisco/n1kv/vsm/VsmPolicyMapResponse.java | 7 +-
.../cisco/n1kv/vsm/VsmPortProfileResponse.java | 7 +-
.../cloud/utils/cisco/n1kv/vsm/VsmResponse.java | 7 +-
.../src/com/cloud/utils/component/Adapter.java | 7 +-
.../com/cloud/utils/component/AdapterBase.java | 7 +-
.../com/cloud/utils/component/AdapterList.java | 7 +-
.../cloud/utils/component/ComponentContext.java | 6 +-
.../ComponentInstantiationPostProcessor.java | 7 +-
.../utils/component/ComponentLifecycle.java | 7 +-
.../utils/component/ComponentLifecycleBase.java | 7 +-
.../component/ComponentMethodInterceptable.java | 7 +-
.../component/ComponentMethodInterceptor.java | 7 +-
.../utils/component/ComponentNamingPolicy.java | 7 +-
.../src/com/cloud/utils/component/Manager.java | 7 +-
.../com/cloud/utils/component/ManagerBase.java | 7 +-
utils/src/com/cloud/utils/component/Named.java | 37 +-
.../cloud/utils/component/PluggableService.java | 7 +-
.../src/com/cloud/utils/component/Registry.java | 37 +-
.../utils/component/SystemIntegrityChecker.java | 7 +-
.../utils/concurrency/NamedThreadFactory.java | 7 +-
.../com/cloud/utils/concurrency/Scheduler.java | 7 +-
.../utils/concurrency/SynchronizationEvent.java | 7 +-
.../com/cloud/utils/concurrency/TestClock.java | 7 +-
.../com/cloud/utils/crypt/DBEncryptionUtil.java | 9 +-
.../utils/crypt/EncryptionSecretKeyChecker.java | 7 +-
.../utils/crypt/EncryptionSecretKeySender.java | 7 +-
utils/src/com/cloud/utils/crypt/RSAHelper.java | 7 +-
utils/src/com/cloud/utils/db/DbProperties.java | 37 +-
utils/src/com/cloud/utils/db/EntityManager.java | 5 +
utils/src/com/cloud/utils/db/UUIDManager.java | 40 +
.../com/cloud/utils/encoding/URLEncoder.java | 33 +-
utils/src/com/cloud/utils/events/EventArgs.java | 7 +-
.../com/cloud/utils/events/SubscriptionMgr.java | 7 +-
.../utils/exception/CSExceptionErrorCode.java | 6 +-
.../utils/exception/CloudRuntimeException.java | 7 +-
.../com/cloud/utils/exception/ErrorContext.java | 3 +
.../utils/exception/ExceptionProxyObject.java | 7 +-
.../cloud/utils/exception/ExceptionUtil.java | 7 +-
.../utils/exception/ExecutionException.java | 7 +-
.../HypervisorVersionChangedException.java | 7 +-
utils/src/com/cloud/utils/fsm/ChangeEvent.java | 37 +-
utils/src/com/cloud/utils/fsm/FiniteState.java | 7 +-
utils/src/com/cloud/utils/fsm/FiniteState2.java | 37 +-
.../com/cloud/utils/fsm/FiniteStateObject.java | 7 +-
.../cloud/utils/fsm/NoTransitionException.java | 7 +-
utils/src/com/cloud/utils/fsm/State.java | 37 +-
utils/src/com/cloud/utils/fsm/StateDao.java | 7 +-
.../src/com/cloud/utils/fsm/StateListener.java | 7 +-
utils/src/com/cloud/utils/fsm/StateMachine.java | 7 +-
.../src/com/cloud/utils/fsm/StateMachine2.java | 7 +-
utils/src/com/cloud/utils/fsm/StateObject.java | 7 +-
.../cloud/utils/log/CglibThrowableRenderer.java | 7 +-
utils/src/com/cloud/utils/mgmt/JmxUtil.java | 7 +-
.../com/cloud/utils/mgmt/ManagementBean.java | 7 +-
.../utils/mgmt/PropertyMapDynamicBean.java | 7 +-
utils/src/com/cloud/utils/net/Ip.java | 9 +-
utils/src/com/cloud/utils/net/Ip4Address.java | 7 +-
utils/src/com/cloud/utils/net/MacAddress.java | 7 +-
utils/src/com/cloud/utils/net/NetUtils.java | 7 +-
utils/src/com/cloud/utils/net/NfsUtils.java | 7 +-
utils/src/com/cloud/utils/net/UrlUtil.java | 7 +-
.../src/com/cloud/utils/nio/HandlerFactory.java | 7 +-
utils/src/com/cloud/utils/nio/Link.java | 7 +-
utils/src/com/cloud/utils/nio/NioClient.java | 7 +-
.../src/com/cloud/utils/nio/NioConnection.java | 7 +-
utils/src/com/cloud/utils/nio/NioServer.java | 7 +-
utils/src/com/cloud/utils/nio/Task.java | 7 +-
.../com/cloud/utils/nio/TrustAllManager.java | 7 +-
.../BasicEncodedRESTValidationStrategy.java | 66 +
.../utils/rest/CloudstackRESTException.java | 39 +
.../cloud/utils/rest/RESTServiceConnector.java | 377 +++
.../utils/rest/RESTValidationStrategy.java | 165 ++
.../cloud/utils/script/OutputInterpreter.java | 7 +-
utils/src/com/cloud/utils/script/Script.java | 7 +-
utils/src/com/cloud/utils/script/Script2.java | 7 +-
.../cloud/utils/security/CertificateHelper.java | 7 +-
utils/src/com/cloud/utils/ssh/SSHCmdHelper.java | 7 +-
.../src/com/cloud/utils/ssh/SSHKeysHelper.java | 7 +-
utils/src/com/cloud/utils/ssh/SshException.java | 7 +-
utils/src/com/cloud/utils/ssh/SshHelper.java | 2 +
.../storage/encoding/DecodedDataObject.java | 47 +-
.../storage/encoding/DecodedDataStore.java | 51 +-
.../cloud/utils/storage/encoding/Decoder.java | 37 +-
.../utils/storage/encoding/EncodingType.java | 37 +-
.../com/cloud/utils/time/InaccurateClock.java | 7 +-
.../cloud/utils/time/InaccurateClockMBean.java | 7 +-
.../com/cloud/utils/xmlobject/XmlObject.java | 3 +
.../cloud/utils/xmlobject/XmlObjectParser.java | 3 +
.../utils/identity/ManagementServerNode.java | 3 +
.../ssl/EasySSLProtocolSocketFactory.java | 53 +-
.../contrib/ssl/EasyX509TrustManager.java | 43 +-
utils/test/com/cloud/utils/DummyImpl.java | 7 +-
utils/test/com/cloud/utils/DummyInterface.java | 7 +-
.../test/com/cloud/utils/DummyPremiumImpl.java | 7 +-
utils/test/com/cloud/utils/NumbersUtilTest.java | 10 +-
.../com/cloud/utils/PasswordGeneratorTest.java | 7 +-
utils/test/com/cloud/utils/ProcessUtilTest.java | 33 +-
.../com/cloud/utils/PropertiesUtilsTest.java | 3 +
utils/test/com/cloud/utils/ReflectUtilTest.java | 9 +-
utils/test/com/cloud/utils/ScriptTest.java | 7 +-
utils/test/com/cloud/utils/StringUtilsTest.java | 18 +-
utils/test/com/cloud/utils/TernaryTest.java | 6 +-
utils/test/com/cloud/utils/TestProfiler.java | 7 +-
utils/test/com/cloud/utils/UriUtilsTest.java | 60 +
utils/test/com/cloud/utils/UuidUtilsTest.java | 42 +
.../backoff/impl/ConstantTimeBackoffTest.java | 7 +-
.../com/cloud/utils/crypto/RSAHelperTest.java | 3 +
.../cloud/utils/encoding/UrlEncoderTest.java | 37 +-
.../utils/exception/ExceptionUtilTest.java | 37 +-
utils/test/com/cloud/utils/net/IpTest.java | 46 +
.../test/com/cloud/utils/net/NetUtilsTest.java | 7 +-
.../utils/rest/RESTServiceConnectorTest.java | 395 +++
.../com/cloud/utils/ssh/SSHKeysHelperTest.java | 3 +
.../utils/testcase/Log4jEnabledTestCase.java | 7 +-
.../test/com/cloud/utils/testcase/NioTest.java | 7 +-
.../cloud/utils/xmlobject/TestXmlObject.java | 3 +
.../cloud/utils/xmlobject/TestXmlObject2.java | 3 +
.../com/cloud/utils/QualifierTestContext.xml | 30 +-
.../utils/db/transactionContextBuilderTest.xml | 30 +-
utils/test/resources/log4j.xml | 30 +-
utils/test/resources/testContext.xml | 34 +-
.../hypervisor/vmware/mo/VirtualMachineMO.java | 76 +-
593 files changed, 22050 insertions(+), 14435 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c64bfa5d/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c64bfa5d/ui/dictionary.jsp
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c64bfa5d/ui/scripts/sharedFunctions.js
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c64bfa5d/ui/scripts/ui/dialog.js
----------------------------------------------------------------------
diff --cc ui/scripts/ui/dialog.js
index 6d6bb0a,fd81e25..9653337
--- a/ui/scripts/ui/dialog.js
+++ b/ui/scripts/ui/dialog.js
@@@ -122,9 -114,13 +123,13 @@@
$(this).dialog('destroy');
$('.hovered-elem').hide();
+
+ if (cancel) {
+ cancel();
+ }
}
}]
- }).closest('.ui-dialog').overlay();
+ });
};
var isLastAsync = function(idx) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c64bfa5d/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c64bfa5d/ui/scripts/ui/widgets/listView.js
----------------------------------------------------------------------
diff --cc ui/scripts/ui/widgets/listView.js
index 2ee3f1a,9e399e1..b028bad
--- a/ui/scripts/ui/widgets/listView.js
+++ b/ui/scripts/ui/widgets/listView.js
@@@ -1175,9 -1180,19 +1175,18 @@@
if (actionName == 'moveDrag') return false;
rowActions[actionName]($tr);
+ var map1 = {};
$tr.closest('tbody').find('tr').each(function() {
+ /*
+ * fire only one sorting API call(updateXXXXXXX&sortKey=n&id=UUID) for items who have the same UUID.
+ * e.g. An Template/ISO of multiple zones have the same UUID.
+ */
+ var objId = $(this).data('json-obj').id;
+ if(!(objId in map1)) {
sort($(this), action);
+ map1[objId] = 1;
+ }
});
- $tr.closest('.data-table').dataTable('selectRow', $tr.index());
return false;
});
[11/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6120: UI > listView widget > sorting order > fire only one sorting API call(updateXXXXXXX&sortKey=n&id=UUID) for items who have the same UUID.
e.g. An Template/ISO of multiple zones have the same UUID.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e1e16a23
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e1e16a23
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e1e16a23
Branch: refs/heads/ui-restyle
Commit: e1e16a2301a75c6746bdb69774a6d9fb996455ca
Parents: 443acac
Author: Jessica Wang <je...@apache.org>
Authored: Fri Feb 14 12:55:53 2014 -0800
Committer: Jessica Wang <je...@apache.org>
Committed: Fri Feb 14 12:55:53 2014 -0800
----------------------------------------------------------------------
ui/scripts/ui/widgets/listView.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1e16a23/ui/scripts/ui/widgets/listView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js
index cb4544c..daf86ff 100644
--- a/ui/scripts/ui/widgets/listView.js
+++ b/ui/scripts/ui/widgets/listView.js
@@ -1180,8 +1180,17 @@
if (actionName == 'moveDrag') return false;
rowActions[actionName]($tr);
+ var map1 = {};
$tr.closest('tbody').find('tr').each(function() {
+ /*
+ * fire only one sorting API call(updateXXXXXXX&sortKey=n&id=UUID) for items who have the same UUID.
+ * e.g. An Template/ISO of multiple zones have the same UUID.
+ */
+ var objId = $(this).data('json-obj').id;
+ if(!(objId in map1)) {
sort($(this), action);
+ map1[objId] = 1;
+ }
});
$tr.closest('.data-table').dataTable('selectRow', $tr.index());
@@ -1203,7 +1212,15 @@
rowActions._std($tr, function() {});
$tr.closest('tbody').find('tr').each(function() {
+ /*
+ * fire only one sorting API call(updateXXXXXXX&sortKey=n&id=UUID) for items who have the same UUID.
+ * e.g. An Template/ISO of multiple zones have the same UUID.
+ */
+ var objId = $(this).data('json-obj').id;
+ if(!(objId in map1)) {
sort($(this), reorder.moveDrag);
+ map1[objId] = 1;
+ }
});
}
});
[39/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Make sure every commands to VR resource is NetworkElementCommand
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5332f67a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5332f67a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5332f67a
Branch: refs/heads/ui-restyle
Commit: 5332f67ae87b87af352db92355ca328de6df29dd
Parents: c171e2c
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 19:12:06 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 19:46:49 2014 -0800
----------------------------------------------------------------------
.../agent/resource/virtualnetwork/VirtualRoutingResource.java | 7 +++----
.../hypervisor/kvm/resource/LibvirtComputingResource.java | 2 +-
.../com/cloud/hypervisor/vmware/resource/VmwareResource.java | 2 +-
.../com/cloud/hypervisor/xen/resource/CitrixResourceBase.java | 2 +-
4 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5332f67a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 9ecbe7f..2ac6f4f 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -22,7 +22,6 @@ import com.cloud.agent.api.CheckRouterAnswer;
import com.cloud.agent.api.CheckRouterCommand;
import com.cloud.agent.api.CheckS2SVpnConnectionsAnswer;
import com.cloud.agent.api.CheckS2SVpnConnectionsCommand;
-import com.cloud.agent.api.Command;
import com.cloud.agent.api.GetDomRVersionAnswer;
import com.cloud.agent.api.GetDomRVersionCmd;
import com.cloud.agent.api.SetupGuestNetworkCommand;
@@ -130,9 +129,9 @@ public class VirtualRoutingResource {
this._vrDeployer = deployer;
}
- public Answer executeRequest(final Command cmd) {
+ public Answer executeRequest(final NetworkElementCommand cmd) {
try {
- ExecutionResult rc = _vrDeployer.prepareCommand((NetworkElementCommand)cmd);
+ ExecutionResult rc = _vrDeployer.prepareCommand(cmd);
if (!rc.isSuccess()) {
s_logger.error("Failed to prepare VR command due to " + rc.getDetails());
return new Answer(cmd, false, rc.getDetails());
@@ -194,7 +193,7 @@ public class VirtualRoutingResource {
} catch (final IllegalArgumentException e) {
return new Answer(cmd, false, e.getMessage());
} finally {
- ExecutionResult rc = _vrDeployer.cleanupCommand((NetworkElementCommand)cmd);
+ ExecutionResult rc = _vrDeployer.cleanupCommand(cmd);
if (!rc.isSuccess()) {
s_logger.error("Failed to cleanup VR command due to " + rc.getDetails());
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5332f67a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index d63b643..f624379 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1313,7 +1313,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
} else if (cmd instanceof UnPlugNicCommand) {
return execute((UnPlugNicCommand)cmd);
} else if (cmd instanceof NetworkElementCommand) {
- return _virtRouterResource.executeRequest(cmd);
+ return _virtRouterResource.executeRequest((NetworkElementCommand)cmd);
} else if (cmd instanceof CheckSshCommand) {
return execute((CheckSshCommand)cmd);
} else if (cmd instanceof NetworkUsageCommand) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5332f67a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index c74a278..60c5909 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -395,7 +395,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if (clz == CreateCommand.class) {
answer = execute((CreateCommand)cmd);
} else if (cmd instanceof NetworkElementCommand) {
- return _vrResource.executeRequest(cmd);
+ return _vrResource.executeRequest((NetworkElementCommand)cmd);
} else if (clz == ReadyCommand.class) {
answer = execute((ReadyCommand)cmd);
} else if (clz == GetHostStatsCommand.class) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5332f67a/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 e463072..48ae3ea 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
@@ -412,7 +412,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
if (clazz == CreateCommand.class) {
return execute((CreateCommand)cmd);
} else if (cmd instanceof NetworkElementCommand) {
- return _vrResource.executeRequest(cmd);
+ return _vrResource.executeRequest((NetworkElementCommand)cmd);
} else if (clazz == CheckConsoleProxyLoadCommand.class) {
return execute((CheckConsoleProxyLoadCommand)cmd);
} else if (clazz == WatchConsoleProxyLoadCommand.class) {
[28/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fixup the license headers in the utils project. All files now use the same license header and this is enforced by the maven-license-check plugin.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/594b51c6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/594b51c6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/594b51c6
Branch: refs/heads/ui-restyle
Commit: 594b51c629a2ad929cb7fb0d2ed27aa0238e130c
Parents: 860b020
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Tue Feb 18 11:12:50 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Feb 18 12:08:36 2014 +0100
----------------------------------------------------------------------
pom.xml | 9 ----
utils/conf/db.properties | 6 ++-
utils/conf/log4j-vmops.xml | 34 +++++++------
utils/pom.xml | 43 ++++++++++------
utils/src/com/cloud/maint/Version.java | 3 ++
utils/src/com/cloud/utils/ActionDelegate.java | 7 ++-
.../com/cloud/utils/CloudResourceBundle.java | 7 ++-
utils/src/com/cloud/utils/DateUtil.java | 7 ++-
utils/src/com/cloud/utils/EnumUtils.java | 7 ++-
utils/src/com/cloud/utils/ExecutionResult.java | 2 +
utils/src/com/cloud/utils/FileUtil.java | 7 ++-
utils/src/com/cloud/utils/IteratorUtil.java | 7 ++-
utils/src/com/cloud/utils/Journal.java | 7 ++-
utils/src/com/cloud/utils/LogUtils.java | 7 ++-
utils/src/com/cloud/utils/MethodCapturer.java | 7 ++-
utils/src/com/cloud/utils/NumbersUtil.java | 7 ++-
utils/src/com/cloud/utils/Pair.java | 7 ++-
.../src/com/cloud/utils/PasswordGenerator.java | 7 ++-
utils/src/com/cloud/utils/Predicate.java | 7 ++-
utils/src/com/cloud/utils/ProcessUtil.java | 7 ++-
utils/src/com/cloud/utils/Profiler.java | 7 ++-
utils/src/com/cloud/utils/PropertiesUtil.java | 7 ++-
utils/src/com/cloud/utils/ReflectUtil.java | 7 ++-
utils/src/com/cloud/utils/S3Utils.java | 37 +++++++-------
utils/src/com/cloud/utils/SerialVersionUID.java | 7 ++-
utils/src/com/cloud/utils/StringUtils.java | 7 ++-
utils/src/com/cloud/utils/SwiftUtil.java | 41 +++++++--------
utils/src/com/cloud/utils/Ternary.java | 7 ++-
utils/src/com/cloud/utils/UriUtils.java | 7 ++-
.../cloud/utils/UsernamePasswordValidator.java | 7 ++-
utils/src/com/cloud/utils/UuidUtils.java | 3 ++
.../cloud/utils/backoff/BackoffAlgorithm.java | 7 ++-
.../utils/backoff/impl/ConstantTimeBackoff.java | 7 ++-
.../backoff/impl/ConstantTimeBackoffMBean.java | 7 ++-
.../utils/cisco/n1kv/vsm/NetconfHelper.java | 7 ++-
.../cloud/utils/cisco/n1kv/vsm/PolicyMap.java | 7 ++-
.../cloud/utils/cisco/n1kv/vsm/PortProfile.java | 7 ++-
.../cloud/utils/cisco/n1kv/vsm/VsmCommand.java | 7 ++-
.../utils/cisco/n1kv/vsm/VsmOkResponse.java | 7 ++-
.../cisco/n1kv/vsm/VsmPolicyMapResponse.java | 7 ++-
.../cisco/n1kv/vsm/VsmPortProfileResponse.java | 7 ++-
.../cloud/utils/cisco/n1kv/vsm/VsmResponse.java | 7 ++-
.../src/com/cloud/utils/component/Adapter.java | 7 ++-
.../com/cloud/utils/component/AdapterBase.java | 7 ++-
.../com/cloud/utils/component/AdapterList.java | 7 ++-
.../cloud/utils/component/ComponentContext.java | 6 ++-
.../ComponentInstantiationPostProcessor.java | 7 ++-
.../utils/component/ComponentLifecycle.java | 7 ++-
.../utils/component/ComponentLifecycleBase.java | 7 ++-
.../component/ComponentMethodInterceptable.java | 7 ++-
.../component/ComponentMethodInterceptor.java | 7 ++-
.../utils/component/ComponentNamingPolicy.java | 7 ++-
.../src/com/cloud/utils/component/Manager.java | 7 ++-
.../com/cloud/utils/component/ManagerBase.java | 7 ++-
utils/src/com/cloud/utils/component/Named.java | 37 +++++++-------
.../cloud/utils/component/PluggableService.java | 7 ++-
.../src/com/cloud/utils/component/Registry.java | 37 +++++++-------
.../utils/component/SystemIntegrityChecker.java | 7 ++-
.../utils/concurrency/NamedThreadFactory.java | 7 ++-
.../com/cloud/utils/concurrency/Scheduler.java | 7 ++-
.../utils/concurrency/SynchronizationEvent.java | 7 ++-
.../com/cloud/utils/concurrency/TestClock.java | 7 ++-
.../com/cloud/utils/crypt/DBEncryptionUtil.java | 9 ++--
.../utils/crypt/EncryptionSecretKeyChecker.java | 7 ++-
.../utils/crypt/EncryptionSecretKeySender.java | 7 ++-
utils/src/com/cloud/utils/crypt/RSAHelper.java | 7 ++-
utils/src/com/cloud/utils/db/DbProperties.java | 37 +++++++-------
utils/src/com/cloud/utils/db/EntityManager.java | 3 ++
utils/src/com/cloud/utils/db/UUIDManager.java | 3 ++
.../com/cloud/utils/encoding/URLEncoder.java | 33 ++++++------
utils/src/com/cloud/utils/events/EventArgs.java | 7 ++-
.../com/cloud/utils/events/SubscriptionMgr.java | 7 ++-
.../utils/exception/CSExceptionErrorCode.java | 6 ++-
.../utils/exception/CloudRuntimeException.java | 7 ++-
.../com/cloud/utils/exception/ErrorContext.java | 3 ++
.../utils/exception/ExceptionProxyObject.java | 7 ++-
.../cloud/utils/exception/ExceptionUtil.java | 7 ++-
.../utils/exception/ExecutionException.java | 7 ++-
.../HypervisorVersionChangedException.java | 7 ++-
utils/src/com/cloud/utils/fsm/ChangeEvent.java | 37 +++++++-------
utils/src/com/cloud/utils/fsm/FiniteState.java | 7 ++-
utils/src/com/cloud/utils/fsm/FiniteState2.java | 37 +++++++-------
.../com/cloud/utils/fsm/FiniteStateObject.java | 7 ++-
.../cloud/utils/fsm/NoTransitionException.java | 7 ++-
utils/src/com/cloud/utils/fsm/State.java | 37 +++++++-------
utils/src/com/cloud/utils/fsm/StateDao.java | 7 ++-
.../src/com/cloud/utils/fsm/StateListener.java | 7 ++-
utils/src/com/cloud/utils/fsm/StateMachine.java | 7 ++-
.../src/com/cloud/utils/fsm/StateMachine2.java | 7 ++-
utils/src/com/cloud/utils/fsm/StateObject.java | 7 ++-
.../cloud/utils/log/CglibThrowableRenderer.java | 7 ++-
utils/src/com/cloud/utils/mgmt/JmxUtil.java | 7 ++-
.../com/cloud/utils/mgmt/ManagementBean.java | 7 ++-
.../utils/mgmt/PropertyMapDynamicBean.java | 7 ++-
utils/src/com/cloud/utils/net/Ip.java | 7 ++-
utils/src/com/cloud/utils/net/Ip4Address.java | 7 ++-
utils/src/com/cloud/utils/net/MacAddress.java | 7 ++-
utils/src/com/cloud/utils/net/NetUtils.java | 7 ++-
utils/src/com/cloud/utils/net/NfsUtils.java | 7 ++-
utils/src/com/cloud/utils/net/UrlUtil.java | 7 ++-
.../src/com/cloud/utils/nio/HandlerFactory.java | 7 ++-
utils/src/com/cloud/utils/nio/Link.java | 7 ++-
utils/src/com/cloud/utils/nio/NioClient.java | 7 ++-
.../src/com/cloud/utils/nio/NioConnection.java | 7 ++-
utils/src/com/cloud/utils/nio/NioServer.java | 7 ++-
utils/src/com/cloud/utils/nio/Task.java | 7 ++-
.../com/cloud/utils/nio/TrustAllManager.java | 7 ++-
.../BasicEncodedRESTValidationStrategy.java | 2 +
.../utils/rest/CloudstackRESTException.java | 3 ++
.../utils/rest/RESTValidationStrategy.java | 2 +
.../cloud/utils/script/OutputInterpreter.java | 7 ++-
utils/src/com/cloud/utils/script/Script.java | 7 ++-
utils/src/com/cloud/utils/script/Script2.java | 7 ++-
.../cloud/utils/security/CertificateHelper.java | 7 ++-
utils/src/com/cloud/utils/ssh/SSHCmdHelper.java | 7 ++-
.../src/com/cloud/utils/ssh/SSHKeysHelper.java | 7 ++-
utils/src/com/cloud/utils/ssh/SshException.java | 7 ++-
utils/src/com/cloud/utils/ssh/SshHelper.java | 2 +
.../storage/encoding/DecodedDataObject.java | 47 ++++++++---------
.../storage/encoding/DecodedDataStore.java | 51 ++++++++++---------
.../cloud/utils/storage/encoding/Decoder.java | 37 +++++++-------
.../utils/storage/encoding/EncodingType.java | 37 +++++++-------
.../com/cloud/utils/time/InaccurateClock.java | 7 ++-
.../cloud/utils/time/InaccurateClockMBean.java | 7 ++-
.../com/cloud/utils/xmlobject/XmlObject.java | 3 ++
.../cloud/utils/xmlobject/XmlObjectParser.java | 3 ++
.../utils/identity/ManagementServerNode.java | 3 ++
.../ssl/EasySSLProtocolSocketFactory.java | 53 ++++++++------------
.../contrib/ssl/EasyX509TrustManager.java | 43 +++++++---------
utils/test/com/cloud/utils/DummyImpl.java | 7 ++-
utils/test/com/cloud/utils/DummyInterface.java | 7 ++-
.../test/com/cloud/utils/DummyPremiumImpl.java | 7 ++-
utils/test/com/cloud/utils/NumbersUtilTest.java | 7 ++-
.../com/cloud/utils/PasswordGeneratorTest.java | 7 ++-
utils/test/com/cloud/utils/ProcessUtilTest.java | 33 ++++++------
.../com/cloud/utils/PropertiesUtilsTest.java | 3 ++
utils/test/com/cloud/utils/ReflectUtilTest.java | 9 ++--
utils/test/com/cloud/utils/ScriptTest.java | 7 ++-
utils/test/com/cloud/utils/StringUtilsTest.java | 7 ++-
utils/test/com/cloud/utils/TernaryTest.java | 6 ++-
utils/test/com/cloud/utils/TestProfiler.java | 7 ++-
utils/test/com/cloud/utils/UriUtilsTest.java | 7 ++-
utils/test/com/cloud/utils/UuidUtilsTest.java | 2 +
.../backoff/impl/ConstantTimeBackoffTest.java | 7 ++-
.../com/cloud/utils/crypto/RSAHelperTest.java | 3 ++
.../cloud/utils/encoding/UrlEncoderTest.java | 37 +++++++-------
.../utils/exception/ExceptionUtilTest.java | 37 +++++++-------
utils/test/com/cloud/utils/net/IpTest.java | 7 ++-
.../test/com/cloud/utils/net/NetUtilsTest.java | 7 ++-
.../utils/rest/RESTServiceConnectorTest.java | 2 +
.../com/cloud/utils/ssh/SSHKeysHelperTest.java | 3 ++
.../utils/testcase/Log4jEnabledTestCase.java | 7 ++-
.../test/com/cloud/utils/testcase/NioTest.java | 7 ++-
.../cloud/utils/xmlobject/TestXmlObject.java | 3 ++
.../cloud/utils/xmlobject/TestXmlObject2.java | 3 ++
.../com/cloud/utils/QualifierTestContext.xml | 30 +++++------
.../utils/db/transactionContextBuilderTest.xml | 30 +++++------
utils/test/resources/log4j.xml | 30 +++++------
utils/test/resources/testContext.xml | 34 +++++++------
159 files changed, 1091 insertions(+), 679 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d9bd2de..1e9e8d8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -610,15 +610,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.3</version>
- <configuration>
- <port>9000</port>
- <tempWebappDirectory>${basedir}/target/site/tempdir</tempWebappDirectory>
- </configuration>
- </plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only.
It has no influence on the Maven build itself. -->
<plugin>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/conf/db.properties
----------------------------------------------------------------------
diff --git a/utils/conf/db.properties b/utils/conf/db.properties
index e1b5fe9..cdd2909 100644
--- a/utils/conf/db.properties
+++ b/utils/conf/db.properties
@@ -1,3 +1,4 @@
+#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -5,15 +6,16 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with 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.
+#
# management server clustering parameters, change cluster.node.IP to the machine IP address
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/conf/log4j-vmops.xml
----------------------------------------------------------------------
diff --git a/utils/conf/log4j-vmops.xml b/utils/conf/log4j-vmops.xml
index fafb8ee..36f4128 100644
--- a/utils/conf/log4j-vmops.xml
+++ b/utils/conf/log4j-vmops.xml
@@ -1,21 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with 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.
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with 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.
+
-->
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/pom.xml
----------------------------------------------------------------------
diff --git a/utils/pom.xml b/utils/pom.xml
index f3b8f5f..f76d2de 100755
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -1,20 +1,22 @@
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with 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.
- 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -170,6 +172,19 @@
</excludes>
</configuration>
</plugin>
+ <plugin>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>cloudstack-checklicence</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<resources>
<resource>
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/maint/Version.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/maint/Version.java b/utils/src/com/cloud/maint/Version.java
index b798b6b..22b2f33 100644
--- a/utils/src/com/cloud/maint/Version.java
+++ b/utils/src/com/cloud/maint/Version.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.maint;
public class Version {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/ActionDelegate.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ActionDelegate.java b/utils/src/com/cloud/utils/ActionDelegate.java
index f1bb625..02f76d9 100644
--- a/utils/src/com/cloud/utils/ActionDelegate.java
+++ b/utils/src/com/cloud/utils/ActionDelegate.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
public interface ActionDelegate<T> {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/CloudResourceBundle.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/CloudResourceBundle.java b/utils/src/com/cloud/utils/CloudResourceBundle.java
index ebf8d05..cf27d79 100755
--- a/utils/src/com/cloud/utils/CloudResourceBundle.java
+++ b/utils/src/com/cloud/utils/CloudResourceBundle.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.util.Locale;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/DateUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/DateUtil.java b/utils/src/com/cloud/utils/DateUtil.java
index 560c92b..fc7fd01 100644
--- a/utils/src/com/cloud/utils/DateUtil.java
+++ b/utils/src/com/cloud/utils/DateUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.text.DateFormat;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/EnumUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/EnumUtils.java b/utils/src/com/cloud/utils/EnumUtils.java
index 642538e..02b6a25 100644
--- a/utils/src/com/cloud/utils/EnumUtils.java
+++ b/utils/src/com/cloud/utils/EnumUtils.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
public class EnumUtils {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/ExecutionResult.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ExecutionResult.java b/utils/src/com/cloud/utils/ExecutionResult.java
index 8edb55b..c8b620a 100644
--- a/utils/src/com/cloud/utils/ExecutionResult.java
+++ b/utils/src/com/cloud/utils/ExecutionResult.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
package com.cloud.utils;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/FileUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/FileUtil.java b/utils/src/com/cloud/utils/FileUtil.java
index bec828b..c55dd74 100644
--- a/utils/src/com/cloud/utils/FileUtil.java
+++ b/utils/src/com/cloud/utils/FileUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/IteratorUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/IteratorUtil.java b/utils/src/com/cloud/utils/IteratorUtil.java
index 9ac1e98..8ab88f5 100644
--- a/utils/src/com/cloud/utils/IteratorUtil.java
+++ b/utils/src/com/cloud/utils/IteratorUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/Journal.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/Journal.java b/utils/src/com/cloud/utils/Journal.java
index 2222b06..e88dba3 100644
--- a/utils/src/com/cloud/utils/Journal.java
+++ b/utils/src/com/cloud/utils/Journal.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/LogUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/LogUtils.java b/utils/src/com/cloud/utils/LogUtils.java
index ce11a93..d86766c 100644
--- a/utils/src/com/cloud/utils/LogUtils.java
+++ b/utils/src/com/cloud/utils/LogUtils.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/MethodCapturer.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/MethodCapturer.java b/utils/src/com/cloud/utils/MethodCapturer.java
index f8e0fdd..655a45d 100644
--- a/utils/src/com/cloud/utils/MethodCapturer.java
+++ b/utils/src/com/cloud/utils/MethodCapturer.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.lang.reflect.Method;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/NumbersUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/NumbersUtil.java b/utils/src/com/cloud/utils/NumbersUtil.java
index 88d4c15..fd5c77f 100755
--- a/utils/src/com/cloud/utils/NumbersUtil.java
+++ b/utils/src/com/cloud/utils/NumbersUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.nio.ByteBuffer;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/Pair.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/Pair.java b/utils/src/com/cloud/utils/Pair.java
index 1d3fa79..9deb896 100755
--- a/utils/src/com/cloud/utils/Pair.java
+++ b/utils/src/com/cloud/utils/Pair.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
public class Pair<T, U> {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/PasswordGenerator.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/PasswordGenerator.java b/utils/src/com/cloud/utils/PasswordGenerator.java
index d7e588a..b6e4bed 100644
--- a/utils/src/com/cloud/utils/PasswordGenerator.java
+++ b/utils/src/com/cloud/utils/PasswordGenerator.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.security.SecureRandom;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/Predicate.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/Predicate.java b/utils/src/com/cloud/utils/Predicate.java
index 9253f7b..6079d16 100644
--- a/utils/src/com/cloud/utils/Predicate.java
+++ b/utils/src/com/cloud/utils/Predicate.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
public interface Predicate {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/ProcessUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ProcessUtil.java b/utils/src/com/cloud/utils/ProcessUtil.java
index 8698fb5..f6859d6 100644
--- a/utils/src/com/cloud/utils/ProcessUtil.java
+++ b/utils/src/com/cloud/utils/ProcessUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/Profiler.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/Profiler.java b/utils/src/com/cloud/utils/Profiler.java
index b989bfa..e75da0e 100644
--- a/utils/src/com/cloud/utils/Profiler.java
+++ b/utils/src/com/cloud/utils/Profiler.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
public class Profiler {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/PropertiesUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/PropertiesUtil.java b/utils/src/com/cloud/utils/PropertiesUtil.java
index c8799ba..3b1070c 100755
--- a/utils/src/com/cloud/utils/PropertiesUtil.java
+++ b/utils/src/com/cloud/utils/PropertiesUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/ReflectUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ReflectUtil.java b/utils/src/com/cloud/utils/ReflectUtil.java
index 2689fd0..379f1c0 100755
--- a/utils/src/com/cloud/utils/ReflectUtil.java
+++ b/utils/src/com/cloud/utils/ReflectUtil.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import static java.beans.Introspector.getBeanInfo;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/S3Utils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/S3Utils.java b/utils/src/com/cloud/utils/S3Utils.java
index 9d097d8..d9b850d 100644
--- a/utils/src/com/cloud/utils/S3Utils.java
+++ b/utils/src/com/cloud/utils/S3Utils.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils;
import static com.amazonaws.Protocol.HTTP;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/SerialVersionUID.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/SerialVersionUID.java b/utils/src/com/cloud/utils/SerialVersionUID.java
index 90fafdd..e4ea217 100755
--- a/utils/src/com/cloud/utils/SerialVersionUID.java
+++ b/utils/src/com/cloud/utils/SerialVersionUID.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/StringUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/StringUtils.java b/utils/src/com/cloud/utils/StringUtils.java
index 21993a6..1600488 100644
--- a/utils/src/com/cloud/utils/StringUtils.java
+++ b/utils/src/com/cloud/utils/StringUtils.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/SwiftUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/SwiftUtil.java b/utils/src/com/cloud/utils/SwiftUtil.java
index 829159f..e876290 100644
--- a/utils/src/com/cloud/utils/SwiftUtil.java
+++ b/utils/src/com/cloud/utils/SwiftUtil.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils;
import java.io.File;
@@ -124,7 +125,7 @@ public class SwiftUtil {
}
public static String[] list(SwiftClientCfg swift, String container, String rFilename) {
- String swiftCli = getSwiftCLIPath();
+ getSwiftCLIPath();
Script command = new Script("/bin/bash", logger);
command.add("-c");
@@ -231,7 +232,7 @@ public class SwiftUtil {
command.add(swiftCmdBuilder.toString());
OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
- String result = command.execute(parser);
+ command.execute(parser);
return true;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/Ternary.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/Ternary.java b/utils/src/com/cloud/utils/Ternary.java
index 4b0e0af..fdc2fc9 100644
--- a/utils/src/com/cloud/utils/Ternary.java
+++ b/utils/src/com/cloud/utils/Ternary.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
public class Ternary<T, U, V> {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/UriUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/UriUtils.java b/utils/src/com/cloud/utils/UriUtils.java
index bee660d..a329503 100644
--- a/utils/src/com/cloud/utils/UriUtils.java
+++ b/utils/src/com/cloud/utils/UriUtils.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/UsernamePasswordValidator.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/UsernamePasswordValidator.java b/utils/src/com/cloud/utils/UsernamePasswordValidator.java
index 9173fec..f11186c 100644
--- a/utils/src/com/cloud/utils/UsernamePasswordValidator.java
+++ b/utils/src/com/cloud/utils/UsernamePasswordValidator.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.util.regex.Matcher;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/UuidUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/UuidUtils.java b/utils/src/com/cloud/utils/UuidUtils.java
index 28b6b1d..9c4a756 100644
--- a/utils/src/com/cloud/utils/UuidUtils.java
+++ b/utils/src/com/cloud/utils/UuidUtils.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import org.apache.xerces.impl.xpath.regex.RegularExpression;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/backoff/BackoffAlgorithm.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/backoff/BackoffAlgorithm.java b/utils/src/com/cloud/utils/backoff/BackoffAlgorithm.java
index dbe934c..b8f3f00 100755
--- a/utils/src/com/cloud/utils/backoff/BackoffAlgorithm.java
+++ b/utils/src/com/cloud/utils/backoff/BackoffAlgorithm.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.backoff;
import com.cloud.utils.component.Adapter;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java b/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java
index 24bae47..24d4d11 100755
--- a/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java
+++ b/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoff.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.backoff.impl;
import java.util.Collection;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoffMBean.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoffMBean.java b/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoffMBean.java
index f310bf6..4dc9f9c 100755
--- a/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoffMBean.java
+++ b/utils/src/com/cloud/utils/backoff/impl/ConstantTimeBackoffMBean.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.backoff.impl;
import java.util.Collection;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java
index f4e0f73..a6d905d 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/NetconfHelper.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.cisco.n1kv.vsm;
import java.io.InputStream;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/cisco/n1kv/vsm/PolicyMap.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/PolicyMap.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/PolicyMap.java
index effb461..01605d7 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/PolicyMap.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/PolicyMap.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.cisco.n1kv.vsm;
public class PolicyMap {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/cisco/n1kv/vsm/PortProfile.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/PortProfile.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/PortProfile.java
index 91b9287..53d9728 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/PortProfile.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/PortProfile.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.cisco.n1kv.vsm;
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.BindingType;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java
index 87a0533..447e21b 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.cisco.n1kv.vsm;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmOkResponse.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmOkResponse.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmOkResponse.java
index d126915..8c56b22 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmOkResponse.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmOkResponse.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.cisco.n1kv.vsm;
import org.w3c.dom.Element;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java
index 4f48426..c0ed6ee 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPolicyMapResponse.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.cisco.n1kv.vsm;
import org.apache.log4j.Logger;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java
index 921dbab..0a3de18 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmPortProfileResponse.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.cisco.n1kv.vsm;
import java.util.StringTokenizer;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java
index f02155b..d82b0dc 100644
--- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java
+++ b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmResponse.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.cisco.n1kv.vsm;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/Adapter.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/Adapter.java b/utils/src/com/cloud/utils/component/Adapter.java
index ec03474..d50b8d9 100755
--- a/utils/src/com/cloud/utils/component/Adapter.java
+++ b/utils/src/com/cloud/utils/component/Adapter.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/AdapterBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/AdapterBase.java b/utils/src/com/cloud/utils/component/AdapterBase.java
index 3cb543d7..703b532 100644
--- a/utils/src/com/cloud/utils/component/AdapterBase.java
+++ b/utils/src/com/cloud/utils/component/AdapterBase.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/AdapterList.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/AdapterList.java b/utils/src/com/cloud/utils/component/AdapterList.java
index 6096a72..dad3391 100644
--- a/utils/src/com/cloud/utils/component/AdapterList.java
+++ b/utils/src/com/cloud/utils/component/AdapterList.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/ComponentContext.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentContext.java b/utils/src/com/cloud/utils/component/ComponentContext.java
index 08e835a..7f9dc11 100644
--- a/utils/src/com/cloud/utils/component/ComponentContext.java
+++ b/utils/src/com/cloud/utils/component/ComponentContext.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
package com.cloud.utils.component;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/ComponentInstantiationPostProcessor.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentInstantiationPostProcessor.java b/utils/src/com/cloud/utils/component/ComponentInstantiationPostProcessor.java
index 0c0af4a..6704371 100644
--- a/utils/src/com/cloud/utils/component/ComponentInstantiationPostProcessor.java
+++ b/utils/src/com/cloud/utils/component/ComponentInstantiationPostProcessor.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
import java.beans.PropertyDescriptor;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/ComponentLifecycle.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentLifecycle.java b/utils/src/com/cloud/utils/component/ComponentLifecycle.java
index 96d95a7..897ddb1 100644
--- a/utils/src/com/cloud/utils/component/ComponentLifecycle.java
+++ b/utils/src/com/cloud/utils/component/ComponentLifecycle.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java b/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java
index 5351123..829dc9b 100644
--- a/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java
+++ b/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
import java.util.HashMap;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/ComponentMethodInterceptable.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentMethodInterceptable.java b/utils/src/com/cloud/utils/component/ComponentMethodInterceptable.java
index 5a95c43..4d94391 100644
--- a/utils/src/com/cloud/utils/component/ComponentMethodInterceptable.java
+++ b/utils/src/com/cloud/utils/component/ComponentMethodInterceptable.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/ComponentMethodInterceptor.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentMethodInterceptor.java b/utils/src/com/cloud/utils/component/ComponentMethodInterceptor.java
index ad0960e..dca688a 100644
--- a/utils/src/com/cloud/utils/component/ComponentMethodInterceptor.java
+++ b/utils/src/com/cloud/utils/component/ComponentMethodInterceptor.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
import java.lang.reflect.Method;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/ComponentNamingPolicy.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentNamingPolicy.java b/utils/src/com/cloud/utils/component/ComponentNamingPolicy.java
index 8520238..33d1dd4 100644
--- a/utils/src/com/cloud/utils/component/ComponentNamingPolicy.java
+++ b/utils/src/com/cloud/utils/component/ComponentNamingPolicy.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
import net.sf.cglib.core.NamingPolicy;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/Manager.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/Manager.java b/utils/src/com/cloud/utils/component/Manager.java
index 079443c..3200b46 100755
--- a/utils/src/com/cloud/utils/component/Manager.java
+++ b/utils/src/com/cloud/utils/component/Manager.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/component/ManagerBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ManagerBase.java b/utils/src/com/cloud/utils/component/ManagerBase.java
index 2e471ae..01e4f40 100644
--- a/utils/src/com/cloud/utils/component/ManagerBase.java
+++ b/utils/src/com/cloud/utils/component/ManagerBase.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.component;
public class ManagerBase extends ComponentLifecycleBase implements ComponentMethodInterceptable {
[15/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-5779: Fix VR commands which didn't use accessIp to VR
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/cc8eebec
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/cc8eebec
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/cc8eebec
Branch: refs/heads/ui-restyle
Commit: cc8eebeca56b5ed90627263be9700f19203f4b0a
Parents: deb55ac
Author: Sheng Yang <sh...@citrix.com>
Authored: Fri Feb 14 19:15:54 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Fri Feb 14 19:20:00 2014 -0800
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 35 +++++++-------------
1 file changed, 12 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cc8eebec/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 9440897..a5647bc 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -474,13 +474,12 @@ public class VirtualRoutingResource {
protected Answer execute(final SavePasswordCommand cmd) {
final String password = cmd.getPassword();
- final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
final String vmIpAddress = cmd.getVmIpAddress();
String args = "-v " + vmIpAddress;
args += " -p " + password;
- ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, VRScripts.PASSWORD, args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.PASSWORD, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -512,7 +511,7 @@ public class VirtualRoutingResource {
args += " -N";
}
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), VRScripts.DHCP, args);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.DHCP, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -553,21 +552,17 @@ public class VirtualRoutingResource {
}
private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) {
- final String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
-
String args = "";
for (String ip : cmd.getVpnIps()) {
args += ip + " ";
}
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.S2SVPN_CHECK, args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.S2SVPN_CHECK, args);
return new CheckS2SVpnConnectionsAnswer(cmd, result.isSuccess(), result.getDetails());
}
protected Answer execute(CheckRouterCommand cmd) {
- final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
-
- final ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, VRScripts.RVR_CHECK, null);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.RVR_CHECK, null);
if (!result.isSuccess()) {
return new CheckRouterAnswer(cmd, result.getDetails());
}
@@ -575,14 +570,12 @@ public class VirtualRoutingResource {
}
protected Answer execute(BumpUpPriorityCommand cmd) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), VRScripts.RVR_BUMPUP_PRI, null);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.RVR_BUMPUP_PRI, null);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
protected Answer execute(GetDomRVersionCmd cmd) {
- final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
-
- final ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, VRScripts.VERSION, null);
+ final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VERSION, null);
if (!result.isSuccess()) {
return new GetDomRVersionAnswer(cmd, "GetDomRVersionCmd failed");
}
@@ -635,7 +628,7 @@ public class VirtualRoutingResource {
args += " -N ";
args += cmd.getPeerGuestCidrList();
}
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), VRScripts.S2SVPN_IPSEC, args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.S2SVPN_IPSEC, args);
if (!result.isSuccess()) {
return new Answer(cmd, false, "Configure site to site VPN failed due to " + result.getDetails());
}
@@ -662,7 +655,6 @@ public class VirtualRoutingResource {
protected Answer execute(SetupGuestNetworkCommand cmd) {
NicTO nic = cmd.getNic();
- String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
String routerGIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
String gateway = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
String cidr = Long.toString(NetUtils.getCidrSize(nic.getNetmask()));
@@ -694,7 +686,7 @@ public class VirtualRoutingResource {
if (domainName != null && !domainName.isEmpty()) {
args += " -e " + domainName;
}
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_GUEST_NETWORK, args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_GUEST_NETWORK, args);
if (!result.isSuccess()) {
return new Answer(cmd, false, "Creating guest network failed due to " + result.getDetails());
@@ -750,7 +742,6 @@ public class VirtualRoutingResource {
}
protected Answer execute(SetSourceNatCommand cmd) {
- String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
IpAddressTO pubIP = cmd.getIpAddress();
String dev = "eth" + pubIP.getNicDevId();
String args = " -A ";
@@ -758,7 +749,7 @@ public class VirtualRoutingResource {
args += pubIP.getPublicIp();
args += " -c ";
args += dev;
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_SOURCE_NAT, args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_SOURCE_NAT, args);
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -788,7 +779,6 @@ public class VirtualRoutingResource {
}
public IpAssocAnswer execute(IpAssocVpcCommand cmd) {
- String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
String[] results = new String[cmd.getIpAddresses().length];
String args = "";
String snatArgs = "";
@@ -818,7 +808,7 @@ public class VirtualRoutingResource {
args += " -n ";
args += NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_IPASSOC, args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_IPASSOC, args);
if (!result.isSuccess()) {
results[i++] = ip.getPublicIp() + " - vpc_ipassoc failed:" + result.getDetails();
break;
@@ -828,7 +818,7 @@ public class VirtualRoutingResource {
snatArgs += " -l " + ip.getPublicIp();
snatArgs += " -c " + nicName;
- result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_PRIVATEGW, snatArgs);
+ result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_PRIVATEGW, snatArgs);
if (result != null) {
results[i++] = ip.getPublicIp() + " - vpc_privateGateway failed:" + result.getDetails();
break;
@@ -840,7 +830,6 @@ public class VirtualRoutingResource {
}
private SetStaticRouteAnswer execute(SetStaticRouteCommand cmd) {
- String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
try {
String[] results = new String[cmd.getStaticRoutes().length];
String[][] rules = cmd.generateSRouteRules();
@@ -852,7 +841,7 @@ public class VirtualRoutingResource {
}
String args = " -a " + sb.toString();
- ExecutionResult result = _vrDeployer.executeInVR(routerIP, VRScripts.VPC_STATIC_ROUTE, args);
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VPC_STATIC_ROUTE, args);
if (!result.isSuccess()) {
for (int i = 0; i < results.length; i++) {
[03/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fix findbugs findings in cloud-plugin-network-ovs
OvsTunnelManagerImpl.java:456, RC_REF_COMPARISON, Priority: High
Serveral low priority fixes
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ef2ced75
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ef2ced75
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ef2ced75
Branch: refs/heads/ui-restyle
Commit: ef2ced7564d2c8a7920458e9db482d3d09ec5ff3
Parents: cc6938e
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Feb 10 13:09:53 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:46 2014 +0100
----------------------------------------------------------------------
.../com/cloud/network/element/OvsElement.java | 283 +++++++++----------
.../cloud/network/guru/OvsGuestNetworkGuru.java | 4 -
.../com/cloud/network/ovs/OvsTunnelManager.java | 4 +-
.../cloud/network/ovs/OvsTunnelManagerImpl.java | 148 +++++-----
4 files changed, 213 insertions(+), 226 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef2ced75/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
index ea46f93..03eeedd 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/element/OvsElement.java
@@ -75,12 +75,12 @@ import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.DomainRouterDao;
@Local(value = {NetworkElement.class, ConnectivityProvider.class,
- SourceNatServiceProvider.class, StaticNatServiceProvider.class,
- PortForwardingServiceProvider.class, IpDeployer.class})
+ SourceNatServiceProvider.class, StaticNatServiceProvider.class,
+ PortForwardingServiceProvider.class, IpDeployer.class})
public class OvsElement extends AdapterBase implements NetworkElement,
- OvsElementService, ConnectivityProvider, ResourceStateAdapter,
- PortForwardingServiceProvider, LoadBalancingServiceProvider,
- StaticNatServiceProvider, IpDeployer {
+OvsElementService, ConnectivityProvider, ResourceStateAdapter,
+PortForwardingServiceProvider, LoadBalancingServiceProvider,
+StaticNatServiceProvider, IpDeployer {
@Inject
OvsTunnelManager _ovsTunnelMgr;
@Inject
@@ -109,21 +109,21 @@ public class OvsElement extends AdapterBase implements NetworkElement,
protected boolean canHandle(Network network, Service service) {
s_logger.debug("Checking if OvsElement can handle service "
- + service.getName() + " on network " + network.getDisplayText());
+ + service.getName() + " on network " + network.getDisplayText());
if (network.getBroadcastDomainType() != BroadcastDomainType.Vswitch) {
return false;
}
if (!_networkModel.isProviderForNetwork(getProvider(), network.getId())) {
s_logger.debug("OvsElement is not a provider for network "
- + network.getDisplayText());
+ + network.getDisplayText());
return false;
}
if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(),
- service, Network.Provider.Ovs)) {
+ service, Network.Provider.Ovs)) {
s_logger.debug("OvsElement can't provide the " + service.getName()
- + " service on network " + network.getDisplayText());
+ + " service on network " + network.getDisplayText());
return false;
}
@@ -132,7 +132,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean configure(String name, Map<String, Object> params)
- throws ConfigurationException {
+ throws ConfigurationException {
super.configure(name, params);
_resourceMgr.registerResourceStateAdapter(name, this);
return true;
@@ -140,12 +140,12 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean implement(Network network, NetworkOffering offering,
- DeployDestination dest, ReservationContext context)
- throws ConcurrentOperationException, ResourceUnavailableException,
- InsufficientCapacityException {
+ DeployDestination dest, ReservationContext context)
+ throws ConcurrentOperationException, ResourceUnavailableException,
+ InsufficientCapacityException {
s_logger.debug("entering OvsElement implement function for network "
- + network.getDisplayText() + " (state " + network.getState()
- + ")");
+ + network.getDisplayText() + " (state " + network.getState()
+ + ")");
if (!canHandle(network, Service.Connectivity)) {
return false;
@@ -155,10 +155,10 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean prepare(Network network, NicProfile nic,
- VirtualMachineProfile vm,
- DeployDestination dest, ReservationContext context)
- throws ConcurrentOperationException, ResourceUnavailableException,
- InsufficientCapacityException {
+ VirtualMachineProfile vm,
+ DeployDestination dest, ReservationContext context)
+ throws ConcurrentOperationException, ResourceUnavailableException,
+ InsufficientCapacityException {
if (!canHandle(network, Service.Connectivity)) {
return false;
}
@@ -171,16 +171,16 @@ public class OvsElement extends AdapterBase implements NetworkElement,
return false;
}
- _ovsTunnelMgr.VmCheckAndCreateTunnel(vm, network, dest);
+ _ovsTunnelMgr.vmCheckAndCreateTunnel(vm, network, dest);
return true;
}
@Override
public boolean release(Network network, NicProfile nic,
- VirtualMachineProfile vm,
- ReservationContext context) throws ConcurrentOperationException,
- ResourceUnavailableException {
+ VirtualMachineProfile vm,
+ ReservationContext context) throws ConcurrentOperationException,
+ ResourceUnavailableException {
if (!canHandle(network, Service.Connectivity)) {
return false;
}
@@ -192,14 +192,14 @@ public class OvsElement extends AdapterBase implements NetworkElement,
return false;
}
- _ovsTunnelMgr.CheckAndDestroyTunnel(vm.getVirtualMachine(), network);
+ _ovsTunnelMgr.checkAndDestroyTunnel(vm.getVirtualMachine(), network);
return true;
}
@Override
public boolean shutdown(Network network, ReservationContext context,
- boolean cleanup) throws ConcurrentOperationException,
- ResourceUnavailableException {
+ boolean cleanup) throws ConcurrentOperationException,
+ ResourceUnavailableException {
if (!canHandle(network, Service.Connectivity)) {
return false;
}
@@ -208,7 +208,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean destroy(Network network, ReservationContext context)
- throws ConcurrentOperationException, ResourceUnavailableException {
+ throws ConcurrentOperationException, ResourceUnavailableException {
if (!canHandle(network, Service.Connectivity)) {
return false;
}
@@ -222,8 +222,8 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean shutdownProviderInstances(
- PhysicalNetworkServiceProvider provider, ReservationContext context)
- throws ConcurrentOperationException, ResourceUnavailableException {
+ PhysicalNetworkServiceProvider provider, ReservationContext context)
+ throws ConcurrentOperationException, ResourceUnavailableException {
return true;
}
@@ -275,90 +275,90 @@ public class OvsElement extends AdapterBase implements NetworkElement,
method = new LbStickinessMethod(StickinessMethodType.LBCookieBased, "This is loadbalancer cookie based stickiness method.");
method.addParam("cookie-name", false, "Cookie name passed in http header by the LB to the client.", false);
method.addParam("mode", false,
- "Valid values: insert, rewrite, prefix. Default value: insert. In the insert mode cookie will be created" +
- " by the LB. In other modes, cookie will be created by the server and LB modifies it.", false);
+ "Valid values: insert, rewrite, prefix. Default value: insert. In the insert mode cookie will be created" +
+ " by the LB. In other modes, cookie will be created by the server and LB modifies it.", false);
method.addParam(
- "nocache",
- false,
- "This option is recommended in conjunction with the insert mode when there is a cache between the client" +
- " and HAProxy, as it ensures that a cacheable response will be tagged non-cacheable if a cookie needs " +
- "to be inserted. This is important because if all persistence cookies are added on a cacheable home page" +
- " for instance, then all customers will then fetch the page from an outer cache and will all share the " +
- "same persistence cookie, leading to one server receiving much more traffic than others. See also the " +
- "insert and postonly options. ",
- true);
+ "nocache",
+ false,
+ "This option is recommended in conjunction with the insert mode when there is a cache between the client" +
+ " and HAProxy, as it ensures that a cacheable response will be tagged non-cacheable if a cookie needs " +
+ "to be inserted. This is important because if all persistence cookies are added on a cacheable home page" +
+ " for instance, then all customers will then fetch the page from an outer cache and will all share the " +
+ "same persistence cookie, leading to one server receiving much more traffic than others. See also the " +
+ "insert and postonly options. ",
+ true);
method.addParam(
- "indirect",
- false,
- "When this option is specified in insert mode, cookies will only be added when the server was not reached" +
- " after a direct access, which means that only when a server is elected after applying a load-balancing algorithm," +
- " or after a redispatch, then the cookie will be inserted. If the client has all the required information" +
- " to connect to the same server next time, no further cookie will be inserted. In all cases, when the " +
- "indirect option is used in insert mode, the cookie is always removed from the requests transmitted to " +
- "the server. The persistence mechanism then becomes totally transparent from the application point of view.",
- true);
+ "indirect",
+ false,
+ "When this option is specified in insert mode, cookies will only be added when the server was not reached" +
+ " after a direct access, which means that only when a server is elected after applying a load-balancing algorithm," +
+ " or after a redispatch, then the cookie will be inserted. If the client has all the required information" +
+ " to connect to the same server next time, no further cookie will be inserted. In all cases, when the " +
+ "indirect option is used in insert mode, the cookie is always removed from the requests transmitted to " +
+ "the server. The persistence mechanism then becomes totally transparent from the application point of view.",
+ true);
method.addParam(
- "postonly",
- false,
- "This option ensures that cookie insertion will only be performed on responses to POST requests. It is an" +
- " alternative to the nocache option, because POST responses are not cacheable, so this ensures that the " +
- "persistence cookie will never get cached.Since most sites do not need any sort of persistence before the" +
- " first POST which generally is a login request, this is a very efficient method to optimize caching " +
- "without risking to find a persistence cookie in the cache. See also the insert and nocache options.",
- true);
+ "postonly",
+ false,
+ "This option ensures that cookie insertion will only be performed on responses to POST requests. It is an" +
+ " alternative to the nocache option, because POST responses are not cacheable, so this ensures that the " +
+ "persistence cookie will never get cached.Since most sites do not need any sort of persistence before the" +
+ " first POST which generally is a login request, this is a very efficient method to optimize caching " +
+ "without risking to find a persistence cookie in the cache. See also the insert and nocache options.",
+ true);
method.addParam(
- "domain",
- false,
- "This option allows to specify the domain at which a cookie is inserted. It requires exactly one parameter:" +
- " a valid domain name. If the domain begins with a dot, the browser is allowed to use it for any host " +
- "ending with that name. It is also possible to specify several domain names by invoking this option multiple" +
- " times. Some browsers might have small limits on the number of domains, so be careful when doing that. " +
- "For the record, sending 10 domains to MSIE 6 or Firefox 2 works as expected.",
- false);
+ "domain",
+ false,
+ "This option allows to specify the domain at which a cookie is inserted. It requires exactly one parameter:" +
+ " a valid domain name. If the domain begins with a dot, the browser is allowed to use it for any host " +
+ "ending with that name. It is also possible to specify several domain names by invoking this option multiple" +
+ " times. Some browsers might have small limits on the number of domains, so be careful when doing that. " +
+ "For the record, sending 10 domains to MSIE 6 or Firefox 2 works as expected.",
+ false);
methodList.add(method);
method = new LbStickinessMethod(StickinessMethodType.AppCookieBased,
- "This is App session based sticky method. Define session stickiness on an existing application cookie. " +
+ "This is App session based sticky method. Define session stickiness on an existing application cookie. " +
"It can be used only for a specific http traffic");
method.addParam("cookie-name", false, "This is the name of the cookie used by the application and which LB will " +
- "have to learn for each new session. Default value: Auto geneared based on ip", false);
+ "have to learn for each new session. Default value: Auto geneared based on ip", false);
method.addParam("length", false, "This is the max number of characters that will be memorized and checked in " +
- "each cookie value. Default value:52", false);
+ "each cookie value. Default value:52", false);
method.addParam(
- "holdtime",
- false,
- "This is the time after which the cookie will be removed from memory if unused. The value should be in " +
- "the format Example : 20s or 30m or 4h or 5d . only seconds(s), minutes(m) hours(h) and days(d) are valid," +
- " cannot use th combinations like 20h30m. Default value:3h ",
- false);
+ "holdtime",
+ false,
+ "This is the time after which the cookie will be removed from memory if unused. The value should be in " +
+ "the format Example : 20s or 30m or 4h or 5d . only seconds(s), minutes(m) hours(h) and days(d) are valid," +
+ " cannot use th combinations like 20h30m. Default value:3h ",
+ false);
method.addParam(
- "request-learn",
- false,
- "If this option is specified, then haproxy will be able to learn the cookie found in the request in case the server does not specify any in response. This is typically what happens with PHPSESSID cookies, or when haproxy's session expires before the application's session and the correct server is selected. It is recommended to specify this option to improve reliability",
- true);
+ "request-learn",
+ false,
+ "If this option is specified, then haproxy will be able to learn the cookie found in the request in case the server does not specify any in response. This is typically what happens with PHPSESSID cookies, or when haproxy's session expires before the application's session and the correct server is selected. It is recommended to specify this option to improve reliability",
+ true);
method.addParam(
- "prefix",
- false,
- "When this option is specified, haproxy will match on the cookie prefix (or URL parameter prefix). "
- +
- "The appsession value is the data following this prefix. Example : appsession ASPSESSIONID len 64 timeout 3h prefix This will match the cookie ASPSESSIONIDXXXX=XXXXX, the appsession value will be XXXX=XXXXX.",
- true);
+ "prefix",
+ false,
+ "When this option is specified, haproxy will match on the cookie prefix (or URL parameter prefix). "
+ +
+ "The appsession value is the data following this prefix. Example : appsession ASPSESSIONID len 64 timeout 3h prefix This will match the cookie ASPSESSIONIDXXXX=XXXXX, the appsession value will be XXXX=XXXXX.",
+ true);
method.addParam(
- "mode",
- false,
- "This option allows to change the URL parser mode. 2 modes are currently supported : - path-parameters " +
- ": The parser looks for the appsession in the path parameters part (each parameter is separated by a semi-colon), " +
- "which is convenient for JSESSIONID for example.This is the default mode if the option is not set. - query-string :" +
- " In this mode, the parser will look for the appsession in the query string.",
- false);
+ "mode",
+ false,
+ "This option allows to change the URL parser mode. 2 modes are currently supported : - path-parameters " +
+ ": The parser looks for the appsession in the path parameters part (each parameter is separated by a semi-colon), " +
+ "which is convenient for JSESSIONID for example.This is the default mode if the option is not set. - query-string :" +
+ " In this mode, the parser will look for the appsession in the query string.",
+ false);
methodList.add(method);
method = new LbStickinessMethod(StickinessMethodType.SourceBased, "This is source based Stickiness method, " +
- "it can be used for any type of protocol.");
+ "it can be used for any type of protocol.");
method.addParam("tablesize", false, "Size of table to store source ip addresses. example: tablesize=200k or 300m" +
- " or 400g. Default value:200k", false);
+ " or 400g. Default value:200k", false);
method.addParam("expire", false, "Entry in source ip table will expire after expire duration. units can be s,m,h,d ." +
- " example: expire=30m 20s 50h 4d. Default value:3h", false);
+ " example: expire=30m 20s 50h 4d. Default value:3h", false);
methodList.add(method);
Gson gson = new Gson();
@@ -374,14 +374,14 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public HostVO createHostVOForConnectedAgent(HostVO host,
- StartupCommand[] cmd) {
+ StartupCommand[] cmd) {
return null;
}
@Override
public HostVO createHostVOForDirectConnectAgent(HostVO host,
- StartupCommand[] startup, ServerResource resource,
- Map<String, String> details, List<String> hostTags) {
+ StartupCommand[] startup, ServerResource resource,
+ Map<String, String> details, List<String> hostTags) {
if (!(startup[0] instanceof StartupOvsCommand)) {
return null;
}
@@ -391,7 +391,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
- boolean isForceDeleteStorage) throws UnableDeleteHostException {
+ boolean isForceDeleteStorage) throws UnableDeleteHostException {
if (!(host.getType() == Host.Type.L2Networking)) {
return null;
}
@@ -405,8 +405,8 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean applyIps(Network network,
- List<? extends PublicIpAddress> ipAddress, Set<Service> services)
- throws ResourceUnavailableException {
+ List<? extends PublicIpAddress> ipAddress, Set<Service> services)
+ throws ResourceUnavailableException {
boolean canHandle = true;
for (Service service : services) {
// check if Ovs can handle services except SourceNat & Firewall
@@ -417,11 +417,11 @@ public class OvsElement extends AdapterBase implements NetworkElement,
}
if (canHandle) {
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
- network.getId(), Role.VIRTUAL_ROUTER);
+ network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router element doesn't need to associate ip addresses on the backend; virtual "
- + "router doesn't exist in the network "
- + network.getId());
+ + "router doesn't exist in the network "
+ + network.getId());
return true;
}
@@ -433,15 +433,15 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean applyStaticNats(Network network, List<? extends StaticNat> rules)
- throws ResourceUnavailableException {
+ throws ResourceUnavailableException {
if (!canHandle(network, Service.StaticNat)) {
return false;
}
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
- network.getId(), Role.VIRTUAL_ROUTER);
+ network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Ovs element doesn't need to apply static nat on the backend; virtual "
- + "router doesn't exist in the network " + network.getId());
+ + "router doesn't exist in the network " + network.getId());
return true;
}
@@ -450,15 +450,15 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean applyPFRules(Network network, List<PortForwardingRule> rules)
- throws ResourceUnavailableException {
+ throws ResourceUnavailableException {
if (!canHandle(network, Service.PortForwarding)) {
return false;
}
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
- network.getId(), Role.VIRTUAL_ROUTER);
+ network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Ovs element doesn't need to apply firewall rules on the backend; virtual "
- + "router doesn't exist in the network " + network.getId());
+ + "router doesn't exist in the network " + network.getId());
return true;
}
@@ -467,25 +467,25 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public boolean applyLBRules(Network network, List<LoadBalancingRule> rules)
- throws ResourceUnavailableException {
+ throws ResourceUnavailableException {
if (canHandle(network, Service.Lb)) {
if (!canHandleLbRules(rules)) {
return false;
}
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
- network.getId(), Role.VIRTUAL_ROUTER);
+ network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual "
- + "router doesn't exist in the network "
- + network.getId());
+ + "router doesn't exist in the network "
+ + network.getId());
return true;
}
if (!_routerMgr.applyLoadBalancingRules(network, rules, routers)) {
throw new CloudRuntimeException(
- "Failed to apply load balancing rules in network "
- + network.getId());
+ "Failed to apply load balancing rules in network "
+ + network.getId());
} else {
return true;
}
@@ -500,7 +500,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
rules.add(rule);
if (canHandle(network, Service.Lb) && canHandleLbRules(rules)) {
List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(
- network.getId(), Role.VIRTUAL_ROUTER);
+ network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.isEmpty()) {
return true;
}
@@ -511,21 +511,21 @@ public class OvsElement extends AdapterBase implements NetworkElement,
@Override
public List<LoadBalancerTO> updateHealthChecks(Network network,
- List<LoadBalancingRule> lbrules) {
+ List<LoadBalancingRule> lbrules) {
// TODO Auto-generated method stub
return null;
}
private boolean canHandleLbRules(List<LoadBalancingRule> rules) {
- Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+ Map<Capability, String> lbCaps = getCapabilities().get(Service.Lb);
if (!lbCaps.isEmpty()) {
String schemeCaps = lbCaps.get(Capability.LbSchemes);
if (schemeCaps != null) {
for (LoadBalancingRule rule : rules) {
if (!schemeCaps.contains(rule.getScheme().toString())) {
s_logger.debug("Scheme " + rules.get(0).getScheme()
- + " is not supported by the provider "
- + this.getName());
+ + " is not supported by the provider "
+ + getName());
return false;
}
}
@@ -539,13 +539,13 @@ public class OvsElement extends AdapterBase implements NetworkElement,
for (LbStickinessPolicy stickinessPolicy : rule.getStickinessPolicies()) {
List<Pair<String, String>> paramsList = stickinessPolicy
- .getParams();
+ .getParams();
if (StickinessMethodType.LBCookieBased.getName().equalsIgnoreCase(
- stickinessPolicy.getMethodName())) {
+ stickinessPolicy.getMethodName())) {
} else if (StickinessMethodType.SourceBased.getName()
- .equalsIgnoreCase(stickinessPolicy.getMethodName())) {
+ .equalsIgnoreCase(stickinessPolicy.getMethodName())) {
String tablesize = "200k"; // optional
String expire = "30m"; // optional
@@ -559,38 +559,29 @@ public class OvsElement extends AdapterBase implements NetworkElement,
expire = value;
}
if ((expire != null)
- && !containsOnlyNumbers(expire, timeEndChar)) {
+ && !containsOnlyNumbers(expire, timeEndChar)) {
throw new InvalidParameterValueException(
- "Failed LB in validation rule id: " + rule.getId()
+ "Failed LB in validation rule id: " + rule.getId()
+ " Cause: expire is not in timeformat: "
+ expire);
}
if ((tablesize != null)
- && !containsOnlyNumbers(tablesize, "kmg")) {
+ && !containsOnlyNumbers(tablesize, "kmg")) {
throw new InvalidParameterValueException(
- "Failed LB in validation rule id: "
- + rule.getId()
- + " Cause: tablesize is not in size format: "
- + tablesize);
+ "Failed LB in validation rule id: "
+ + rule.getId()
+ + " Cause: tablesize is not in size format: "
+ + tablesize);
}
} else if (StickinessMethodType.AppCookieBased.getName()
- .equalsIgnoreCase(stickinessPolicy.getMethodName())) {
- /*
- * FORMAT : appsession <cookie> len <length> timeout <holdtime>
- * [request-learn] [prefix] [mode
- * <path-parameters|query-string>]
- */
- /* example: appsession JSESSIONID len 52 timeout 3h */
- String cookieName = null; // optional
+ .equalsIgnoreCase(stickinessPolicy.getMethodName())) {
String length = null; // optional
String holdTime = null; // optional
for (Pair<String, String> paramKV : paramsList) {
String key = paramKV.first();
String value = paramKV.second();
- if ("cookie-name".equalsIgnoreCase(key))
- cookieName = value;
if ("length".equalsIgnoreCase(key))
length = value;
if ("holdtime".equalsIgnoreCase(key))
@@ -599,15 +590,15 @@ public class OvsElement extends AdapterBase implements NetworkElement,
if ((length != null) && (!containsOnlyNumbers(length, null))) {
throw new InvalidParameterValueException(
- "Failed LB in validation rule id: " + rule.getId()
+ "Failed LB in validation rule id: " + rule.getId()
+ " Cause: length is not a number: "
+ length);
}
if ((holdTime != null)
- && (!containsOnlyNumbers(holdTime, timeEndChar) && !containsOnlyNumbers(
- holdTime, null))) {
+ && (!containsOnlyNumbers(holdTime, timeEndChar) && !containsOnlyNumbers(
+ holdTime, null))) {
throw new InvalidParameterValueException(
- "Failed LB in validation rule id: " + rule.getId()
+ "Failed LB in validation rule id: " + rule.getId()
+ " Cause: holdtime is not in timeformat: "
+ holdTime);
}
@@ -630,7 +621,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
boolean matchedEndChar = false;
if (str.length() < 2)
return false; // atleast one numeric and one char. example:
- // 3h
+ // 3h
char strEnd = str.toCharArray()[str.length() - 1];
for (char c : endChar.toCharArray()) {
if (strEnd == c) {
@@ -643,7 +634,7 @@ public class OvsElement extends AdapterBase implements NetworkElement,
return false;
}
try {
- int i = Integer.parseInt(number);
+ Integer.parseInt(number);
} catch (NumberFormatException e) {
return false;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef2ced75/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
index 6aacbb2..8fa636d 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/guru/OvsGuestNetworkGuru.java
@@ -144,10 +144,6 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
if (network.getCidr() != null) {
implemented.setCidr(network.getCidr());
}
- String name = network.getName();
- if (name == null || name.isEmpty()) {
- name = ((NetworkVO)network).getUuid();
- }
// do we need to create switch right now?
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef2ced75/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManager.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManager.java
index eaf2d66..118beeb 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManager.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManager.java
@@ -26,8 +26,8 @@ public interface OvsTunnelManager extends Manager {
boolean isOvsTunnelEnabled();
- public void VmCheckAndCreateTunnel(VirtualMachineProfile vm, Network nw, DeployDestination dest);
+ public void vmCheckAndCreateTunnel(VirtualMachineProfile vm, Network nw, DeployDestination dest);
- public void CheckAndDestroyTunnel(VirtualMachine vm, Network nw);
+ public void checkAndDestroyTunnel(VirtualMachine vm, Network nw);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ef2ced75/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
index aa0f42e..320568b 100644
--- a/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
+++ b/plugins/network-elements/ovs/src/com/cloud/network/ovs/OvsTunnelManagerImpl.java
@@ -104,7 +104,7 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
@Override
public boolean configure(String name, Map<String, Object> params)
- throws ConfigurationException {
+ throws ConfigurationException {
_executorPool = Executors.newScheduledThreadPool(10, new NamedThreadFactory("OVS"));
_cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("OVS-Cleanup"));
@@ -113,13 +113,13 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
@DB
protected OvsTunnelInterfaceVO createInterfaceRecord(String ip,
- String netmask, String mac, long hostId, String label) {
+ String netmask, String mac, long hostId, String label) {
OvsTunnelInterfaceVO ti = null;
try {
ti = new OvsTunnelInterfaceVO(ip, netmask, mac, hostId, label);
// TODO: Is locking really necessary here?
OvsTunnelInterfaceVO lock = _tunnelInterfaceDao
- .acquireInLockTable(Long.valueOf(1));
+ .acquireInLockTable(Long.valueOf(1));
if (lock == null) {
s_logger.warn("Cannot lock table ovs_tunnel_account");
return null;
@@ -128,7 +128,7 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
_tunnelInterfaceDao.releaseFromLockTable(lock.getId());
} catch (EntityExistsException e) {
s_logger.debug("A record for the interface for network " + label
- + " on host id " + hostId + " already exists");
+ + " on host id " + hostId + " already exists");
}
return ti;
}
@@ -138,13 +138,13 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
if (ans.getResult()) {
if (ans.getIp() != null && !("".equals(ans.getIp()))) {
OvsTunnelInterfaceVO ti = createInterfaceRecord(ans.getIp(),
- ans.getNetmask(), ans.getMac(), hostId, ans.getLabel());
+ 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());
+ + ans.getDetails());
return null;
}
@@ -169,22 +169,22 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
private void handleCreateTunnelAnswer(Answer[] answers) {
OvsCreateTunnelAnswer r = (OvsCreateTunnelAnswer)answers[0];
String s =
- String.format("(hostIP:%1$s, remoteIP:%2$s, bridge:%3$s," + "greKey:%4$s, portName:%5$s)", r.getFromIp(), r.getToIp(), r.getBridge(), r.getKey(),
- r.getInPortName());
+ String.format("(hostIP:%1$s, remoteIP:%2$s, bridge:%3$s," + "greKey:%4$s, portName:%5$s)", r.getFromIp(), r.getToIp(), r.getBridge(), r.getKey(),
+ r.getInPortName());
Long from = r.getFrom();
Long to = r.getTo();
long networkId = r.getNetworkId();
OvsTunnelNetworkVO tunnel = _tunnelNetworkDao.getByFromToNetwork(from, to, networkId);
if (tunnel == null) {
throw new CloudRuntimeException(
- String.format("Unable find tunnelNetwork record" +
- "(from=%1$s,to=%2$s, account=%3$s",
- from, to, networkId));
+ String.format("Unable find tunnelNetwork record" +
+ "(from=%1$s,to=%2$s, account=%3$s",
+ from, to, networkId));
}
if (!r.getResult()) {
tunnel.setState("FAILED");
s_logger.warn("Create GRE tunnel failed due to " + r.getDetails()
- + s);
+ + s);
} else {
tunnel.setState("SUCCESS");
tunnel.setPortName(r.getInPortName());
@@ -194,31 +194,31 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
}
private String getGreEndpointIP(Host host, Network nw)
- throws AgentUnavailableException, OperationTimedoutException {
+ throws AgentUnavailableException, OperationTimedoutException {
String endpointIp = null;
// 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);
+ _physNetTTDao.findBy(physNetId, TrafficType.Guest);
HypervisorType hvType = host.getHypervisorType();
String label = null;
switch (hvType) {
- case XenServer:
- label = physNetTT.getXenNetworkLabel();
- if ((label != null) && (!label.equals(""))) {
- physNetLabel = label;
- }
- break;
- case KVM:
- label = physNetTT.getKvmNetworkLabel();
- if ((label != null) && (!label.equals(""))) {
- physNetLabel = label;
- }
- break;
- default:
- throw new CloudRuntimeException("Hypervisor " +
+ case XenServer:
+ label = physNetTT.getXenNetworkLabel();
+ if ((label != null) && (!label.equals(""))) {
+ physNetLabel = label;
+ }
+ break;
+ case KVM:
+ label = physNetTT.getKvmNetworkLabel();
+ if ((label != null) && (!label.equals(""))) {
+ physNetLabel = label;
+ }
+ break;
+ default:
+ throw new CloudRuntimeException("Hypervisor " +
hvType.toString() +
" unsupported by OVS Tunnel Manager");
}
@@ -226,16 +226,16 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
// Try to fetch GRE endpoint IP address for cloud db
// If not found, then find it on the hypervisor
OvsTunnelInterfaceVO tunnelIface =
- _tunnelInterfaceDao.getByHostAndLabel(host.getId(),
- physNetLabel);
+ _tunnelInterfaceDao.getByHostAndLabel(host.getId(),
+ physNetLabel);
if (tunnelIface == null) {
//Now find and fetch configuration for physical interface
//for network with label on target host
Commands fetchIfaceCmds =
- new Commands(new OvsFetchInterfaceCommand(physNetLabel));
+ new Commands(new OvsFetchInterfaceCommand(physNetLabel));
s_logger.debug("Ask host " + host.getId() +
- " to retrieve interface for phy net with label:" +
- physNetLabel);
+ " to retrieve interface for phy net with label:" +
+ physNetLabel);
Answer[] fetchIfaceAnswers = _agentMgr.send(host.getId(), fetchIfaceCmds);
//And finally save it for future use
endpointIp = handleFetchInterfaceAnswer(fetchIfaceAnswers, host.getId());
@@ -255,26 +255,26 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
// !! not in the case of lswitch/pvlan/(possibly)vswitch
// So we now feel quite safe in converting it into a string
// by calling the appropriate BroadcastDomainType method
- key = Integer.valueOf(keyStr);
+ key = Integer.parseInt(keyStr);
return key;
} catch (NumberFormatException e) {
s_logger.debug("Well well, how did '" + key
- + "' end up in the broadcast URI for the network?");
+ + "' end up in the broadcast URI for the network?");
throw new CloudRuntimeException(String.format(
- "Invalid GRE key parsed from"
- + "network broadcast URI (%s)", network
- .getBroadcastUri().toString()));
+ "Invalid GRE key parsed from"
+ + "network broadcast URI (%s)", network
+ .getBroadcastUri().toString()));
}
}
@DB
- protected void CheckAndCreateTunnel(VirtualMachine instance, Network nw, DeployDestination dest) {
+ protected void checkAndCreateTunnel(VirtualMachine instance, Network nw, DeployDestination dest) {
s_logger.debug("Creating tunnels with OVS tunnel manager");
if (instance.getType() != VirtualMachine.Type.User
- && instance.getType() != VirtualMachine.Type.DomainRouter) {
+ && instance.getType() != VirtualMachine.Type.DomainRouter) {
s_logger.debug("Will not work if you're not"
- + "an instance or a virtual router");
+ + "an instance or a virtual router");
return;
}
@@ -282,8 +282,8 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
int key = getGreKey(nw);
// Find active VMs with a NIC on the target network
List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(nw.getId(),
- State.Running, State.Starting, State.Stopping, State.Unknown,
- State.Migrating);
+ State.Running, State.Starting, State.Stopping, State.Unknown,
+ State.Migrating);
// Find routers for the network
List<DomainRouterVO> routers = _routerDao.findByNetwork(nw.getId());
List<VMInstanceVO> ins = new ArrayList<VMInstanceVO>();
@@ -313,14 +313,14 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
}
ta = _tunnelNetworkDao.getByFromToNetwork(rh.longValue(),
- hostId, nw.getId());
+ hostId, nw.getId());
// Try and create the tunnel even if a previous attempt failed
if (ta == null || ta.getState().equals("FAILED")) {
s_logger.debug("Attempting to create tunnel from:" +
- rh.longValue() + " to:" + hostId);
+ rh.longValue() + " to:" + hostId);
if (ta == null) {
createTunnelRecord(rh.longValue(), hostId,
- nw.getId(), key);
+ nw.getId(), key);
}
if (!fromHostIds.contains(rh)) {
fromHostIds.add(rh);
@@ -338,14 +338,14 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
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());
+ "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));
+ new OvsCreateTunnelCommand(otherIp, key,
+ Long.valueOf(hostId), i, nw.getId(), myIp));
s_logger.debug("Ask host " + hostId
- + " to create gre tunnel to " + i);
+ + " to create gre tunnel to " + i);
Answer[] answers = _agentMgr.send(hostId, cmds);
handleCreateTunnelAnswer(answers);
noHost = false;
@@ -355,9 +355,9 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
HostVO rHost = _hostDao.findById(i);
String otherIp = getGreEndpointIP(rHost, nw);
Commands cmds = new Commands(new OvsCreateTunnelCommand(myIp,
- key, i, Long.valueOf(hostId), nw.getId(), otherIp));
+ key, i, Long.valueOf(hostId), nw.getId(), otherIp));
s_logger.debug("Ask host " + i + " to create gre tunnel to "
- + hostId);
+ + hostId);
Answer[] answers = _agentMgr.send(i, cmds);
handleCreateTunnelAnswer(answers);
noHost = false;
@@ -367,13 +367,13 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
// This will ensure VIF rules will be triggered
if (noHost) {
Commands cmds = new Commands(new OvsSetupBridgeCommand(key,
- hostId, nw.getId()));
+ hostId, nw.getId()));
s_logger.debug("Ask host " + hostId
- + " to configure bridge for network:" + nw.getId());
+ + " to configure bridge for network:" + nw.getId());
Answer[] answers = _agentMgr.send(hostId, cmds);
handleSetupBridgeAnswer(answers);
}
- } catch (Exception e) {
+ } catch (GreTunnelException | OperationTimedoutException | AgentUnavailableException e) {
// I really thing we should do a better handling of these exceptions
s_logger.warn("Ovs Tunnel network created tunnel failed", e);
}
@@ -385,9 +385,9 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
}
@Override
- public void VmCheckAndCreateTunnel(VirtualMachineProfile vm,
- Network nw, DeployDestination dest) {
- CheckAndCreateTunnel(vm.getVirtualMachine(), nw, dest);
+ public void vmCheckAndCreateTunnel(VirtualMachineProfile vm,
+ Network nw, DeployDestination dest) {
+ checkAndCreateTunnel(vm.getVirtualMachine(), nw, dest);
}
@DB
@@ -396,9 +396,9 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
OvsTunnelNetworkVO lock = _tunnelNetworkDao.acquireInLockTable(Long.valueOf(1));
if (lock == null) {
s_logger.warn(String.format("failed to lock" +
- "ovs_tunnel_account, remove record of " +
- "tunnel(from=%1$s, to=%2$s account=%3$s) failed",
- from, to, networkId));
+ "ovs_tunnel_account, remove record of " +
+ "tunnel(from=%1$s, to=%2$s account=%3$s) failed",
+ from, to, networkId));
return;
}
@@ -406,8 +406,8 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
_tunnelNetworkDao.releaseFromLockTable(lock.getId());
s_logger.debug(String.format("Destroy tunnel(account:%1$s," +
- "from:%2$s, to:%3$s) successful",
- networkId, from, to));
+ "from:%2$s, to:%3$s) successful",
+ networkId, from, to));
} else {
s_logger.debug(String.format("Destroy tunnel(account:%1$s," + "from:%2$s, to:%3$s) failed", networkId, from, to));
}
@@ -427,10 +427,10 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
_tunnelNetworkDao.releaseFromLockTable(lock.getId());
s_logger.debug(String.format("Destroy bridge for" +
- "network %1$s successful", networkId));
+ "network %1$s successful", networkId));
} else {
s_logger.debug(String.format("Destroy bridge for" +
- "network %1$s failed", networkId));
+ "network %1$s failed", networkId));
}
}
@@ -440,7 +440,7 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
}
@Override
- public void CheckAndDestroyTunnel(VirtualMachine vm, Network nw) {
+ public void checkAndDestroyTunnel(VirtualMachine vm, Network nw) {
// if (!_isEnabled) {
// return;
// }
@@ -453,7 +453,7 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
List<DomainRouterVO> routers = _routerDao.findByNetwork(nw.getId());
for (DomainRouterVO router : routers) {
- if (router.getHostId() == vm.getHostId()) {
+ if (router.getHostId().equals(vm.getHostId())) {
return;
}
}
@@ -471,18 +471,18 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
/* Then ask hosts have peer tunnel with me to destroy them */
List<OvsTunnelNetworkVO> peers =
- _tunnelNetworkDao.listByToNetwork(vm.getHostId(),
- nw.getId());
+ _tunnelNetworkDao.listByToNetwork(vm.getHostId(),
+ nw.getId());
for (OvsTunnelNetworkVO p : peers) {
// If the tunnel was not successfully created don't bother to remove it
if (p.getState().equals("SUCCESS")) {
cmd = new OvsDestroyTunnelCommand(p.getNetworkId(), key,
- p.getPortName());
+ p.getPortName());
s_logger.debug("Destroying tunnel to " + vm.getHostId() +
- " from " + p.getFrom());
+ " from " + p.getFrom());
ans = _agentMgr.send(p.getFrom(), cmd);
handleDestroyTunnelAnswer(ans, p.getFrom(),
- p.getTo(), p.getNetworkId());
+ p.getTo(), p.getNetworkId());
}
}
} catch (Exception e) {
[35/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Fixed on master for jenkins buildslave
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5e717cbb
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5e717cbb
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5e717cbb
Branch: refs/heads/ui-restyle
Commit: 5e717cbb89d253ec6875da8e4a30c79effe53f96
Parents: fefddc0
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Wed Feb 19 16:21:43 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Wed Feb 19 16:21:43 2014 +0100
----------------------------------------------------------------------
tools/appliance/build.sh | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5e717cbb/tools/appliance/build.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh
index 658aa8d..7ba0611 100644
--- a/tools/appliance/build.sh
+++ b/tools/appliance/build.sh
@@ -26,7 +26,14 @@ else
fi
build_date=`date +%Y-%m-%d`
-branch=`git status | grep '# On branch' | awk '{print $4}'`
+
+# set fixed or leave empty to use git to determine
+branch=master
+
+if [ -z "$branch" ] ; then
+ branch=`git status | grep '# On branch' | awk '{print $4}'`
+fi
+
if [ -z "$branch" ] ; then
branch=unknown
fi
[02/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Findbugs finding
Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/33c2c872
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/33c2c872
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/33c2c872
Branch: refs/heads/ui-restyle
Commit: 33c2c872878874f83c25c656de4325a32c3b8d8c
Parents: 1237bf3
Author: Ian Southam <is...@schubergphilis.com>
Authored: Mon Feb 10 16:04:48 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Feb 14 18:37:46 2014 +0100
----------------------------------------------------------------------
.../consoleproxy/ConsoleProxyRdpClient.java | 12 ++++--
.../consoleproxy/ConsoleProxyRdpClientTest.java | 45 ++++++++++++++++++++
2 files changed, 53 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/33c2c872/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java
index 7d49b19..dc3f31b 100644
--- a/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/ConsoleProxyRdpClient.java
@@ -179,9 +179,11 @@ public class ConsoleProxyRdpClient extends ConsoleProxyClientBase {
int mod = mapModifier(modifiers);
switch (code) {
case 0:
- return mod = mod | MouseEvent.BUTTON1_DOWN_MASK;
+ mod = mod | MouseEvent.BUTTON1_DOWN_MASK;
+ break;
case 2:
- return mod = mod | MouseEvent.BUTTON3_DOWN_MASK;
+ mod = mod | MouseEvent.BUTTON3_DOWN_MASK;
+ break;
default:
}
return mod;
@@ -191,9 +193,11 @@ public class ConsoleProxyRdpClient extends ConsoleProxyClientBase {
int mod = mapModifier(modifiers);
switch (code) {
case 0:
- return mod = mod | MouseEvent.BUTTON1_MASK;
+ mod = mod | MouseEvent.BUTTON1_MASK;
+ break;
case 2:
- return mod = mod | MouseEvent.BUTTON3_MASK;
+ mod = mod | MouseEvent.BUTTON3_MASK;
+ break;
default:
}
return mod;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/33c2c872/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java b/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java
new file mode 100644
index 0000000..038f438
--- /dev/null
+++ b/services/console-proxy/server/test/com/cloud/consoleproxy/ConsoleProxyRdpClientTest.java
@@ -0,0 +1,45 @@
+package com.cloud.consoleproxy;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class ConsoleProxyRdpClientTest {
+
+ @Test
+ public void testMapMouseDownModifierButton1Mask() throws Exception {
+ int code = 0;
+ int modifiers = 960;
+ int expected = 1024 + 960;
+
+ ConsoleProxyRdpClient rdpc = new ConsoleProxyRdpClient();
+ int actual = rdpc.mapMouseDownModifier(code, modifiers);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testMapMouseDownModifierButton2() throws Exception {
+ int code = 1;
+ int modifiers = 0xffff;
+ int expected = 960;
+
+ ConsoleProxyRdpClient rdpc = new ConsoleProxyRdpClient();
+ int actual = rdpc.mapMouseDownModifier(code, modifiers);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+ @Test
+ public void testMapMouseDownModifierButton3Mask() throws Exception {
+ int code = 2;
+ int modifiers = 960;
+ int expected = 4096 + 960;
+
+ ConsoleProxyRdpClient rdpc = new ConsoleProxyRdpClient();
+ int actual = rdpc.mapMouseDownModifier(code, modifiers);
+
+ Assert.assertEquals(expected, actual);
+ }
+
+}
[46/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Fix fail to enable VPN
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d429be75
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d429be75
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d429be75
Branch: refs/heads/ui-restyle
Commit: d429be75a72d426be5f17b36c55024cbed3432bd
Parents: 3bbbda8
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 21:05:51 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 21:05:51 2014 -0800
----------------------------------------------------------------------
.../agent/resource/virtualnetwork/VirtualRoutingResource.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d429be75/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 48ff421..fd96572 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -298,7 +298,7 @@ public class VirtualRoutingResource {
// Use the last answer as final answer
if (answersCount == 1) {
- ExecutionResult result = new ExecutionResult(false, "Not executed");
+ ExecutionResult result = new ExecutionResult(true, "Not configure to be apply");
for (ConfigItem c : cfg) {
result = applyConfigToVR(cmd, c);
if (!result.isSuccess()) {
[25/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-4840: Adding first set of test cases for Multiple IPs per NIC feature
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/860b0209
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/860b0209
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/860b0209
Branch: refs/heads/ui-restyle
Commit: 860b02095087d5b8a6a32efd46992f89c1aa4c05
Parents: a369647
Author: Ashutosh K <as...@clogeny.com>
Authored: Tue Feb 18 15:51:57 2014 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Tue Feb 18 15:51:57 2014 +0530
----------------------------------------------------------------------
tools/marvin/marvin/codes.py | 4 ++
tools/marvin/marvin/integration/lib/base.py | 29 +++++++++++
tools/marvin/marvin/integration/lib/common.py | 56 +++++++++++++++++++++-
3 files changed, 87 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/860b0209/tools/marvin/marvin/codes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py
index 74fb05d..3882f0d 100644
--- a/tools/marvin/marvin/codes.py
+++ b/tools/marvin/marvin/codes.py
@@ -47,3 +47,7 @@ YES = "yes"
FAILED = "FAILED"
UNKNOWN_ERROR = "Unknown Error"
EXCEPTION = "EXCEPTION"
+BASIC_ZONE = "basic"
+ISOLATED_NETWORK = "ISOLATED"
+SHARED_NETWORK = "SHARED"
+VPC_NETWORK = "VPC"
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/860b0209/tools/marvin/marvin/integration/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py
index aa23029..1d8229d 100755
--- a/tools/marvin/marvin/integration/lib/base.py
+++ b/tools/marvin/marvin/integration/lib/base.py
@@ -3623,3 +3623,32 @@ class Resources:
cmd = updateResourceCount.updateResourceCountCmd()
[setattr(cmd, k, v) for k, v in kwargs.items()]
return(apiclient.updateResourceCount(cmd))
+
+class NIC:
+ """NIC related API"""
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def addIp(cls, apiclient, id, ipaddress=None):
+ """Add Ip (secondary) to NIC"""
+ cmd = addIpToNic.addIpToNicCmd()
+ cmd.nicid = id
+ if ipaddress:
+ cmd.ipaddress = ipaddress
+ return(apiclient.addIpToNic(cmd))
+
+ @classmethod
+ def removeIp(cls,apiclient,ipaddressid):
+ """Remove secondary Ip from NIC"""
+ cmd = removeIpFromNic.removeIpFromNicCmd()
+ cmd.id = ipaddressid
+ return(apiclient.addIpToNic(cmd))
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List NICs belonging to a virtual machine"""
+
+ cmd = listNics.listNicsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNics(cmd))
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/860b0209/tools/marvin/marvin/integration/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py
index e202391..5b56c73 100644
--- a/tools/marvin/marvin/integration/lib/common.py
+++ b/tools/marvin/marvin/integration/lib/common.py
@@ -63,13 +63,14 @@ from marvin.integration.lib.base import (Configurations,
Resources,
PhysicalNetwork,
Host,
- PublicIPAddress)
+ PublicIPAddress,
+ NetworkOffering)
from marvin.integration.lib.utils import (get_process_status,
xsplit,
validateList)
from marvin.sshClient import SshClient
-from marvin.codes import PASS
+from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, BASIC_ZONE, FAIL
import random
#Import System modules
@@ -917,3 +918,54 @@ def is_public_ip_in_correct_state(apiclient, ipaddressid, state):
time.sleep(60)
continue
return True
+
+def setSharedNetworkParams(networkServices, range=20):
+ """Fill up the services dictionary for shared network using random subnet"""
+
+ # @range: range decides the endip. Pass the range as "x" if you want the difference between the startip
+ # and endip as "x"
+ # Set the subnet number of shared networks randomly prior to execution
+ # of each test case to avoid overlapping of ip addresses
+ shared_network_subnet_number = random.randrange(1,254)
+
+ networkServices["gateway"] = "172.16."+str(shared_network_subnet_number)+".1"
+ networkServices["startip"] = "172.16."+str(shared_network_subnet_number)+".2"
+ networkServices["endip"] = "172.16."+str(shared_network_subnet_number)+"."+str(range+1)
+ networkServices["netmask"] = "255.255.255.0"
+ return networkServices
+
+def createEnabledNetworkOffering(apiclient, networkServices):
+ """Create and enable network offering according to the type
+
+ @output: List, containing [ Result,Network Offering,Reason ]
+ Ist Argument('Result') : FAIL : If exception or assertion error occurs
+ PASS : If network offering
+ is created and enabled successfully
+ IInd Argument(Net Off) : Enabled network offering
+ In case of exception or
+ assertion error, it will be None
+ IIIrd Argument(Reason) : Reason for failure,
+ default to None
+ """
+ try:
+ resultSet = [FAIL, None, None]
+ # Create network offering
+ network_offering = NetworkOffering.create(apiclient, networkServices, conservemode=False)
+
+ # Update network offering state from disabled to enabled.
+ NetworkOffering.update(network_offering, apiclient, id=network_offering.id,
+ state="enabled")
+ except Exception as e:
+ resultSet[2] = e
+ return resultSet
+ return [PASS, network_offering, None]
+
+def shouldTestBeSkipped(networkType, zoneType):
+ """Decide which test to skip, according to type of network and zone type"""
+
+ # If network type is isolated or vpc and zone type is basic, then test should be skipped
+ skipIt = False
+ if ((networkType.lower() == str(ISOLATED_NETWORK).lower() or networkType.lower() == str(VPC_NETWORK).lower())
+ and (zoneType.lower() == BASIC_ZONE)):
+ skipIt = True
+ return skipIt
[12/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-5779: Fix missing clean up period for VR
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/161e7d93
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/161e7d93
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/161e7d93
Branch: refs/heads/ui-restyle
Commit: 161e7d93ca9d03e9aa7e7be9e12d1ad337de9b14
Parents: e1e16a2
Author: Sheng Yang <sh...@citrix.com>
Authored: Fri Feb 14 17:28:55 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Fri Feb 14 18:10:00 2014 -0800
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 62 ++++++++++++--------
.../xen/resource/CitrixResourceBase.java | 2 +-
2 files changed, 37 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/161e7d93/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 3efbe33..0b90cc9 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -109,59 +109,69 @@ public class VirtualRoutingResource {
return new Answer(cmd, false, rc.getDetails());
}
+ Answer answer;
if (cmd instanceof SetPortForwardingRulesVpcCommand) {
- return execute((SetPortForwardingRulesVpcCommand)cmd);
+ answer = execute((SetPortForwardingRulesVpcCommand)cmd);
} else if (cmd instanceof SetPortForwardingRulesCommand) {
- return execute((SetPortForwardingRulesCommand)cmd);
+ answer = execute((SetPortForwardingRulesCommand)cmd);
} else if (cmd instanceof SetStaticRouteCommand) {
- return execute((SetStaticRouteCommand)cmd);
+ answer = execute((SetStaticRouteCommand)cmd);
} else if (cmd instanceof SetStaticNatRulesCommand) {
- return execute((SetStaticNatRulesCommand)cmd);
+ answer = execute((SetStaticNatRulesCommand)cmd);
} else if (cmd instanceof LoadBalancerConfigCommand) {
- return execute((LoadBalancerConfigCommand)cmd);
+ answer = execute((LoadBalancerConfigCommand)cmd);
} else if (cmd instanceof SavePasswordCommand) {
- return execute((SavePasswordCommand)cmd);
+ answer = execute((SavePasswordCommand)cmd);
} else if (cmd instanceof DhcpEntryCommand) {
- return execute((DhcpEntryCommand)cmd);
+ answer = execute((DhcpEntryCommand)cmd);
} else if (cmd instanceof CreateIpAliasCommand) {
- return execute((CreateIpAliasCommand)cmd);
+ answer = execute((CreateIpAliasCommand)cmd);
} else if (cmd instanceof DnsMasqConfigCommand) {
- return execute((DnsMasqConfigCommand)cmd);
+ answer = execute((DnsMasqConfigCommand)cmd);
} else if (cmd instanceof DeleteIpAliasCommand) {
- return execute((DeleteIpAliasCommand)cmd);
+ answer = execute((DeleteIpAliasCommand)cmd);
} else if (cmd instanceof VmDataCommand) {
- return execute((VmDataCommand)cmd);
+ answer = execute((VmDataCommand)cmd);
} else if (cmd instanceof CheckRouterCommand) {
- return execute((CheckRouterCommand)cmd);
+ answer = execute((CheckRouterCommand)cmd);
} else if (cmd instanceof SetFirewallRulesCommand) {
- return execute((SetFirewallRulesCommand)cmd);
+ answer = execute((SetFirewallRulesCommand)cmd);
} else if (cmd instanceof BumpUpPriorityCommand) {
- return execute((BumpUpPriorityCommand)cmd);
+ answer = execute((BumpUpPriorityCommand)cmd);
} else if (cmd instanceof RemoteAccessVpnCfgCommand) {
- return execute((RemoteAccessVpnCfgCommand)cmd);
+ answer = execute((RemoteAccessVpnCfgCommand)cmd);
} else if (cmd instanceof VpnUsersCfgCommand) {
- return execute((VpnUsersCfgCommand)cmd);
+ answer = execute((VpnUsersCfgCommand)cmd);
} else if (cmd instanceof GetDomRVersionCmd) {
- return execute((GetDomRVersionCmd)cmd);
+ answer = execute((GetDomRVersionCmd)cmd);
} else if (cmd instanceof Site2SiteVpnCfgCommand) {
- return execute((Site2SiteVpnCfgCommand)cmd);
+ answer = execute((Site2SiteVpnCfgCommand)cmd);
} else if (cmd instanceof CheckS2SVpnConnectionsCommand) {
- return execute((CheckS2SVpnConnectionsCommand)cmd);
+ answer = execute((CheckS2SVpnConnectionsCommand)cmd);
} else if (cmd instanceof SetMonitorServiceCommand) {
- return execute((SetMonitorServiceCommand)cmd);
+ answer = execute((SetMonitorServiceCommand)cmd);
} else if (cmd instanceof SetupGuestNetworkCommand) {
- return execute((SetupGuestNetworkCommand)cmd);
+ answer = execute((SetupGuestNetworkCommand)cmd);
} else if (cmd instanceof SetNetworkACLCommand) {
- return execute((SetNetworkACLCommand)cmd);
+ answer = execute((SetNetworkACLCommand)cmd);
} else if (cmd instanceof SetSourceNatCommand) {
- return execute((SetSourceNatCommand)cmd);
+ answer = execute((SetSourceNatCommand)cmd);
} else if (cmd instanceof IpAssocVpcCommand) {
- return execute((IpAssocVpcCommand)cmd);
+ answer = execute((IpAssocVpcCommand)cmd);
} else if (cmd instanceof IpAssocCommand) {
- return execute((IpAssocCommand)cmd);
+ answer = execute((IpAssocCommand)cmd);
} else {
- return Answer.createUnsupportedCommandAnswer(cmd);
+ answer = Answer.createUnsupportedCommandAnswer(cmd);
}
+
+ rc = _vrDeployer.cleanupCommand((NetworkElementCommand)cmd);
+ if (!rc.isSuccess()) {
+ s_logger.error("Failed to clean up VR command due to " + rc.getDetails());
+ // TODO fail it more properly in the future, some commands may need specific answer rather than generic answer
+ answer = new Answer(cmd, false, rc.getDetails());
+ }
+
+ return answer;
} catch (final IllegalArgumentException e) {
return new Answer(cmd, false, e.getMessage());
} finally {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/161e7d93/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 2cabc58..e463072 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
@@ -569,7 +569,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
@Override
public ExecutionResult cleanupCommand(NetworkElementCommand cmd) {
if (cmd instanceof IpAssocCommand && !(cmd instanceof IpAssocVpcCommand)) {
- cleanupNetworkElementCommand((IpAssocCommand)cmd);
+ return cleanupNetworkElementCommand((IpAssocCommand)cmd);
}
return new ExecutionResult(true, null);
}
[44/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Introduce QueryCommand
QueryCommand is a kind of command which request the state rather than configure.
QueryCommands need to be executed immediately and cannot be aggregated.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/711b3083
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/711b3083
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/711b3083
Branch: refs/heads/ui-restyle
Commit: 711b3083701e8b9852714e1817a022f039bf3235
Parents: 8b341b0
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 19:12:07 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 19:47:14 2014 -0800
----------------------------------------------------------------------
.../com/cloud/agent/api/CheckRouterCommand.java | 5 +
.../api/CheckS2SVpnConnectionsCommand.java | 9 +-
.../com/cloud/agent/api/GetDomRVersionCmd.java | 5 +
.../api/routing/NetworkElementCommand.java | 4 +
.../virtualnetwork/VirtualRoutingResource.java | 281 ++++++++-----------
5 files changed, 132 insertions(+), 172 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/711b3083/core/src/com/cloud/agent/api/CheckRouterCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/CheckRouterCommand.java b/core/src/com/cloud/agent/api/CheckRouterCommand.java
index 6215fc3..c89cdf7 100644
--- a/core/src/com/cloud/agent/api/CheckRouterCommand.java
+++ b/core/src/com/cloud/agent/api/CheckRouterCommand.java
@@ -27,4 +27,9 @@ public class CheckRouterCommand extends NetworkElementCommand {
public CheckRouterCommand() {
super();
}
+
+ @Override
+ public boolean isQuery() {
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/711b3083/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java b/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java
index 9cfb53b..bbd7c5f 100644
--- a/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java
+++ b/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java
@@ -16,10 +16,10 @@
// under the License.
package com.cloud.agent.api;
-import java.util.List;
-
import com.cloud.agent.api.routing.NetworkElementCommand;
+import java.util.List;
+
public class CheckS2SVpnConnectionsCommand extends NetworkElementCommand {
List<String> vpnIps;
@@ -36,4 +36,9 @@ public class CheckS2SVpnConnectionsCommand extends NetworkElementCommand {
public List<String> getVpnIps() {
return vpnIps;
}
+
+ @Override
+ public boolean isQuery() {
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/711b3083/core/src/com/cloud/agent/api/GetDomRVersionCmd.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/GetDomRVersionCmd.java b/core/src/com/cloud/agent/api/GetDomRVersionCmd.java
index 577c386..7a73fac 100644
--- a/core/src/com/cloud/agent/api/GetDomRVersionCmd.java
+++ b/core/src/com/cloud/agent/api/GetDomRVersionCmd.java
@@ -27,4 +27,9 @@ public class GetDomRVersionCmd extends NetworkElementCommand {
public GetDomRVersionCmd() {
super();
}
+
+ @Override
+ public boolean isQuery() {
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/711b3083/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
index f13037c..120c717 100644
--- a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
+++ b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java
@@ -66,4 +66,8 @@ public abstract class NetworkElementCommand extends Command {
public int getAnswersCount() {
return 1;
}
+
+ public boolean isQuery() {
+ return false;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/711b3083/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 49a5c0a..7845da0 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -133,59 +133,58 @@ public class VirtualRoutingResource {
return new Answer(cmd, false, rc.getDetails());
}
+ if (cmd.isQuery()) {
+ return executeQueryCommand(cmd);
+ }
+
+ List<ConfigItem> cfg;
if (cmd instanceof SetPortForwardingRulesVpcCommand) {
- return execute((SetPortForwardingRulesVpcCommand)cmd);
+ cfg = generateConfig((SetPortForwardingRulesVpcCommand)cmd);
} else if (cmd instanceof SetPortForwardingRulesCommand) {
- return execute((SetPortForwardingRulesCommand)cmd);
+ cfg = generateConfig((SetPortForwardingRulesCommand)cmd);
} else if (cmd instanceof SetStaticRouteCommand) {
- return execute((SetStaticRouteCommand)cmd);
+ cfg = generateConfig((SetStaticRouteCommand)cmd);
} else if (cmd instanceof SetStaticNatRulesCommand) {
- return execute((SetStaticNatRulesCommand)cmd);
+ cfg = generateConfig((SetStaticNatRulesCommand)cmd);
} else if (cmd instanceof LoadBalancerConfigCommand) {
- return execute((LoadBalancerConfigCommand)cmd);
+ cfg = generateConfig((LoadBalancerConfigCommand)cmd);
} else if (cmd instanceof SavePasswordCommand) {
- return execute((SavePasswordCommand)cmd);
+ cfg = generateConfig((SavePasswordCommand)cmd);
} else if (cmd instanceof DhcpEntryCommand) {
- return execute((DhcpEntryCommand)cmd);
+ cfg = generateConfig((DhcpEntryCommand)cmd);
} else if (cmd instanceof CreateIpAliasCommand) {
- return execute((CreateIpAliasCommand)cmd);
+ cfg = generateConfig((CreateIpAliasCommand)cmd);
} else if (cmd instanceof DnsMasqConfigCommand) {
- return execute((DnsMasqConfigCommand)cmd);
+ cfg = generateConfig((DnsMasqConfigCommand)cmd);
} else if (cmd instanceof DeleteIpAliasCommand) {
- return execute((DeleteIpAliasCommand)cmd);
+ cfg = generateConfig((DeleteIpAliasCommand)cmd);
} else if (cmd instanceof VmDataCommand) {
- return execute((VmDataCommand)cmd);
- } else if (cmd instanceof CheckRouterCommand) {
- return execute((CheckRouterCommand)cmd);
+ cfg = generateConfig((VmDataCommand)cmd);
} else if (cmd instanceof SetFirewallRulesCommand) {
- return execute((SetFirewallRulesCommand)cmd);
+ cfg = generateConfig((SetFirewallRulesCommand)cmd);
} else if (cmd instanceof BumpUpPriorityCommand) {
- return execute((BumpUpPriorityCommand)cmd);
+ cfg = generateConfig((BumpUpPriorityCommand)cmd);
} else if (cmd instanceof RemoteAccessVpnCfgCommand) {
- return execute((RemoteAccessVpnCfgCommand)cmd);
+ cfg = generateConfig((RemoteAccessVpnCfgCommand)cmd);
} else if (cmd instanceof VpnUsersCfgCommand) {
- return execute((VpnUsersCfgCommand)cmd);
- } else if (cmd instanceof GetDomRVersionCmd) {
- return execute((GetDomRVersionCmd)cmd);
+ cfg = generateConfig((VpnUsersCfgCommand)cmd);
} else if (cmd instanceof Site2SiteVpnCfgCommand) {
- return execute((Site2SiteVpnCfgCommand)cmd);
- } else if (cmd instanceof CheckS2SVpnConnectionsCommand) {
- return execute((CheckS2SVpnConnectionsCommand)cmd);
+ cfg = generateConfig((Site2SiteVpnCfgCommand)cmd);
} else if (cmd instanceof SetMonitorServiceCommand) {
- return execute((SetMonitorServiceCommand)cmd);
+ cfg = generateConfig((SetMonitorServiceCommand)cmd);
} else if (cmd instanceof SetupGuestNetworkCommand) {
- return execute((SetupGuestNetworkCommand)cmd);
+ cfg = generateConfig((SetupGuestNetworkCommand)cmd);
} else if (cmd instanceof SetNetworkACLCommand) {
- return execute((SetNetworkACLCommand)cmd);
+ cfg = generateConfig((SetNetworkACLCommand)cmd);
} else if (cmd instanceof SetSourceNatCommand) {
- return execute((SetSourceNatCommand)cmd);
- } else if (cmd instanceof IpAssocVpcCommand) {
- return execute((IpAssocVpcCommand)cmd);
+ cfg = generateConfig((SetSourceNatCommand)cmd);
} else if (cmd instanceof IpAssocCommand) {
- return execute((IpAssocCommand)cmd);
+ cfg = generateConfig((IpAssocCommand)cmd);
} else {
return Answer.createUnsupportedCommandAnswer(cmd);
}
+
+ return applyConfig(cmd, cfg);
} catch (final IllegalArgumentException e) {
return new Answer(cmd, false, e.getMessage());
} finally {
@@ -200,10 +199,22 @@ public class VirtualRoutingResource {
private String script;
private String args;
private String info;
+ private String filePath;
+ private String fileName;
+ private String fileContents;
+ private boolean isFile;
public ConfigItem(String script, String args) {
this.script = script;
this.args = args;
+ this.isFile = false;
+ }
+
+ public ConfigItem(String filePath, String fileName, String fileContents) {
+ this.filePath = filePath;
+ this.fileName = fileName;
+ this.fileContents = fileContents;
+ this.isFile = true;
}
public String getScript() {
@@ -229,15 +240,69 @@ public class VirtualRoutingResource {
public void setInfo(String info) {
this.info = info;
}
+
+ public String getFilePath() {
+ return filePath;
+ }
+
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public String getFileContents() {
+ return fileContents;
+ }
+
+ public void setFileContents(String fileContents) {
+ this.fileContents = fileContents;
+ }
+
+ public boolean isFile() {
+ return isFile;
+ }
+ }
+
+ private Answer executeQueryCommand(NetworkElementCommand cmd) {
+ if (cmd instanceof CheckRouterCommand) {
+ return execute((CheckRouterCommand)cmd);
+ } else if (cmd instanceof GetDomRVersionCmd) {
+ return execute((GetDomRVersionCmd)cmd);
+ } else if (cmd instanceof CheckS2SVpnConnectionsCommand) {
+ return execute((CheckS2SVpnConnectionsCommand)cmd);
+ } else {
+ s_logger.error("Unknown query command in VirtualRoutingResource!");
+ return Answer.createUnsupportedCommandAnswer(cmd);
+ }
+ }
+
+ private ExecutionResult applyConfigToVR(NetworkElementCommand cmd, ConfigItem c) {
+ if (c.isFile()) {
+ return _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), c.getFilePath(), c.getFileName(), c.getFileContents());
+ } else {
+ return _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+ }
}
private Answer applyConfig(NetworkElementCommand cmd, List<ConfigItem> cfg) {
int answersCount = cmd.getAnswersCount();
- assert (cfg.size() <= answersCount) : "Why there are more commands than answers?";
- if (cfg.size() == 1 && answersCount == 1) {
- ConfigItem c = cfg.get(0);
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+ // Use the last answer as final answer
+ if (answersCount == 1) {
+ ExecutionResult result = new ExecutionResult(false, "Not executed");
+ for (ConfigItem c : cfg) {
+ result = applyConfigToVR(cmd, c);
+ if (!result.isSuccess()) {
+ break;
+ }
+ }
return new Answer(cmd, result.isSuccess(), result.getDetails());
}
@@ -246,7 +311,7 @@ public class VirtualRoutingResource {
boolean finalResult = true;
int i = 0, j;
for (ConfigItem c : cfg) {
- results[i] = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+ results[i] = applyConfigToVR(cmd, c);
if (c.getInfo() != null) {
if (results[i].isSuccess()) {
results[i].setDetails(c.getInfo() + " - success: " + results[i].getDetails());
@@ -287,11 +352,6 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(VpnUsersCfgCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(RemoteAccessVpnCfgCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
String args = "";
@@ -316,11 +376,6 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(RemoteAccessVpnCfgCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(SetFirewallRulesCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -361,11 +416,6 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(SetFirewallRulesCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(SetPortForwardingRulesCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -383,11 +433,6 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(SetPortForwardingRulesCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(SetStaticNatRulesCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
if (cmd.getVpcId() != null) {
@@ -419,16 +464,23 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(SetStaticNatRulesCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(LoadBalancerConfigCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
LoadBalancerConfigurator cfgtr = new HAProxyConfigurator();
+
+ String[] config = cfgtr.generateConfiguration(cmd);
+ String tmpCfgFileContents = "";
+ for (int i = 0; i < config.length; i++) {
+ tmpCfgFileContents += config[i];
+ tmpCfgFileContents += "\n";
+ }
+
+ String tmpCfgFilePath = "/etc/haproxy/";
+ String tmpCfgFileName = "haproxy.cfg.new";
+ cfg.add(new ConfigItem(tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents));
+
String[][] rules = cfgtr.generateFwRules(cmd);
String[] addRules = rules[LoadBalancerConfigurator.ADD];
@@ -473,37 +525,6 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(LoadBalancerConfigCommand cmd) {
- String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
-
- if (routerIp == null) {
- return new Answer(cmd);
- }
-
- LoadBalancerConfigurator cfgtr = new HAProxyConfigurator();
- String[] config = cfgtr.generateConfiguration(cmd);
- String tmpCfgFileContents = "";
- for (int i = 0; i < config.length; i++) {
- tmpCfgFileContents += config[i];
- tmpCfgFileContents += "\n";
- }
-
- String tmpCfgFilePath = "/etc/haproxy/";
- String tmpCfgFileName = "haproxy.cfg.new";
- ExecutionResult result = _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents);
-
- if (!result.isSuccess()) {
- return new Answer(cmd, false, "Fail to copy LB config file to VR");
- }
-
- List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
-
- return new Answer(cmd, result.isSuccess(), result.getDetails());
- }
-
-
private List<ConfigItem> generateConfig(VmDataCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
Map<String, List<String[]>> data = new HashMap<String, List<String[]>>();
@@ -520,11 +541,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(VmDataCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(SavePasswordCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -538,11 +554,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(final SavePasswordCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(DhcpEntryCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -577,11 +588,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(final DhcpEntryCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(CreateIpAliasCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -595,11 +601,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(final CreateIpAliasCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(DeleteIpAliasCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -619,11 +620,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(final DeleteIpAliasCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private List<ConfigItem> generateConfig(DnsMasqConfigCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -637,11 +633,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(final DnsMasqConfigCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) {
String args = "";
for (String ip : cmd.getVpnIps()) {
@@ -666,11 +657,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(BumpUpPriorityCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
protected Answer execute(GetDomRVersionCmd cmd) {
final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VERSION, null);
if (!result.isSuccess()) {
@@ -732,11 +718,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(Site2SiteVpnCfgCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
protected List<ConfigItem> generateConfig(SetMonitorServiceCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -752,11 +733,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(SetMonitorServiceCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
protected List<ConfigItem> generateConfig(SetupGuestNetworkCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -797,11 +773,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(SetupGuestNetworkCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
protected List<ConfigItem> generateConfig(SetNetworkACLCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -836,11 +807,6 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(SetNetworkACLCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
protected List<ConfigItem> generateConfig(SetSourceNatCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -856,11 +822,6 @@ public class VirtualRoutingResource {
return cfg;
}
- protected Answer execute(SetSourceNatCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
protected List<ConfigItem> generateConfig(SetPortForwardingRulesVpcCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -878,16 +839,6 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(SetPortForwardingRulesVpcCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
- public Answer execute(IpAssocVpcCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
protected List<ConfigItem> generateConfig(SetStaticRouteCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
@@ -905,11 +856,6 @@ public class VirtualRoutingResource {
return cfg;
}
- private Answer execute(SetStaticRouteCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
protected List<ConfigItem> generateConfig(IpAssocCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
ConfigItem c;
@@ -989,11 +935,6 @@ public class VirtualRoutingResource {
return cfg;
}
- public Answer execute(IpAssocCommand cmd) {
- List<ConfigItem> cfg = generateConfig(cmd);
- return applyConfig(cmd, cfg);
- }
-
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
_name = name;
[16/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
Revert "CLOUDSTACK-5779: Fix missing clean up period for VR"
This reverts commit 161e7d93ca9d03e9aa7e7be9e12d1ad337de9b14.
Duplicate code, bad memory...
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2b1b4352
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2b1b4352
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2b1b4352
Branch: refs/heads/ui-restyle
Commit: 2b1b4352bc6af037430cff76b38d3eca061de0f7
Parents: cc8eebe
Author: Sheng Yang <sh...@citrix.com>
Authored: Fri Feb 14 19:38:32 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Fri Feb 14 19:40:00 2014 -0800
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 62 ++++++++------------
1 file changed, 26 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2b1b4352/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index a5647bc..9ecbe7f 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -138,69 +138,59 @@ public class VirtualRoutingResource {
return new Answer(cmd, false, rc.getDetails());
}
- Answer answer;
if (cmd instanceof SetPortForwardingRulesVpcCommand) {
- answer = execute((SetPortForwardingRulesVpcCommand)cmd);
+ return execute((SetPortForwardingRulesVpcCommand)cmd);
} else if (cmd instanceof SetPortForwardingRulesCommand) {
- answer = execute((SetPortForwardingRulesCommand)cmd);
+ return execute((SetPortForwardingRulesCommand)cmd);
} else if (cmd instanceof SetStaticRouteCommand) {
- answer = execute((SetStaticRouteCommand)cmd);
+ return execute((SetStaticRouteCommand)cmd);
} else if (cmd instanceof SetStaticNatRulesCommand) {
- answer = execute((SetStaticNatRulesCommand)cmd);
+ return execute((SetStaticNatRulesCommand)cmd);
} else if (cmd instanceof LoadBalancerConfigCommand) {
- answer = execute((LoadBalancerConfigCommand)cmd);
+ return execute((LoadBalancerConfigCommand)cmd);
} else if (cmd instanceof SavePasswordCommand) {
- answer = execute((SavePasswordCommand)cmd);
+ return execute((SavePasswordCommand)cmd);
} else if (cmd instanceof DhcpEntryCommand) {
- answer = execute((DhcpEntryCommand)cmd);
+ return execute((DhcpEntryCommand)cmd);
} else if (cmd instanceof CreateIpAliasCommand) {
- answer = execute((CreateIpAliasCommand)cmd);
+ return execute((CreateIpAliasCommand)cmd);
} else if (cmd instanceof DnsMasqConfigCommand) {
- answer = execute((DnsMasqConfigCommand)cmd);
+ return execute((DnsMasqConfigCommand)cmd);
} else if (cmd instanceof DeleteIpAliasCommand) {
- answer = execute((DeleteIpAliasCommand)cmd);
+ return execute((DeleteIpAliasCommand)cmd);
} else if (cmd instanceof VmDataCommand) {
- answer = execute((VmDataCommand)cmd);
+ return execute((VmDataCommand)cmd);
} else if (cmd instanceof CheckRouterCommand) {
- answer = execute((CheckRouterCommand)cmd);
+ return execute((CheckRouterCommand)cmd);
} else if (cmd instanceof SetFirewallRulesCommand) {
- answer = execute((SetFirewallRulesCommand)cmd);
+ return execute((SetFirewallRulesCommand)cmd);
} else if (cmd instanceof BumpUpPriorityCommand) {
- answer = execute((BumpUpPriorityCommand)cmd);
+ return execute((BumpUpPriorityCommand)cmd);
} else if (cmd instanceof RemoteAccessVpnCfgCommand) {
- answer = execute((RemoteAccessVpnCfgCommand)cmd);
+ return execute((RemoteAccessVpnCfgCommand)cmd);
} else if (cmd instanceof VpnUsersCfgCommand) {
- answer = execute((VpnUsersCfgCommand)cmd);
+ return execute((VpnUsersCfgCommand)cmd);
} else if (cmd instanceof GetDomRVersionCmd) {
- answer = execute((GetDomRVersionCmd)cmd);
+ return execute((GetDomRVersionCmd)cmd);
} else if (cmd instanceof Site2SiteVpnCfgCommand) {
- answer = execute((Site2SiteVpnCfgCommand)cmd);
+ return execute((Site2SiteVpnCfgCommand)cmd);
} else if (cmd instanceof CheckS2SVpnConnectionsCommand) {
- answer = execute((CheckS2SVpnConnectionsCommand)cmd);
+ return execute((CheckS2SVpnConnectionsCommand)cmd);
} else if (cmd instanceof SetMonitorServiceCommand) {
- answer = execute((SetMonitorServiceCommand)cmd);
+ return execute((SetMonitorServiceCommand)cmd);
} else if (cmd instanceof SetupGuestNetworkCommand) {
- answer = execute((SetupGuestNetworkCommand)cmd);
+ return execute((SetupGuestNetworkCommand)cmd);
} else if (cmd instanceof SetNetworkACLCommand) {
- answer = execute((SetNetworkACLCommand)cmd);
+ return execute((SetNetworkACLCommand)cmd);
} else if (cmd instanceof SetSourceNatCommand) {
- answer = execute((SetSourceNatCommand)cmd);
+ return execute((SetSourceNatCommand)cmd);
} else if (cmd instanceof IpAssocVpcCommand) {
- answer = execute((IpAssocVpcCommand)cmd);
+ return execute((IpAssocVpcCommand)cmd);
} else if (cmd instanceof IpAssocCommand) {
- answer = execute((IpAssocCommand)cmd);
+ return execute((IpAssocCommand)cmd);
} else {
- answer = Answer.createUnsupportedCommandAnswer(cmd);
+ return Answer.createUnsupportedCommandAnswer(cmd);
}
-
- rc = _vrDeployer.cleanupCommand((NetworkElementCommand)cmd);
- if (!rc.isSuccess()) {
- s_logger.error("Failed to clean up VR command due to " + rc.getDetails());
- // TODO fail it more properly in the future, some commands may need specific answer rather than generic answer
- answer = new Answer(cmd, false, rc.getDetails());
- }
-
- return answer;
} catch (final IllegalArgumentException e) {
return new Answer(cmd, false, e.getMessage());
} finally {
[26/50] [abbrv] Fixup the license headers in the utils project. All
files now use the same license header and this is enforced by the
maven-license-check plugin.
Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java b/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java
index f72b77b..ab54c2c 100644
--- a/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java
+++ b/utils/src/com/cloud/utils/ssh/SSHKeysHelper.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.ssh;
import java.io.ByteArrayOutputStream;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/ssh/SshException.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ssh/SshException.java b/utils/src/com/cloud/utils/ssh/SshException.java
index 7c9d35c..a9d9ed8 100644
--- a/utils/src/com/cloud/utils/ssh/SshException.java
+++ b/utils/src/com/cloud/utils/ssh/SshException.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.ssh;
import com.cloud.utils.SerialVersionUID;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/ssh/SshHelper.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ssh/SshHelper.java b/utils/src/com/cloud/utils/ssh/SshHelper.java
index 41625eb..3aac427 100755
--- a/utils/src/com/cloud/utils/ssh/SshHelper.java
+++ b/utils/src/com/cloud/utils/ssh/SshHelper.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
package com.cloud.utils.ssh;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java b/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
index 8fee932..d8d354d 100644
--- a/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
+++ b/utils/src/com/cloud/utils/storage/encoding/DecodedDataObject.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.storage.encoding;
public class DecodedDataObject {
@@ -33,22 +34,22 @@ public class DecodedDataObject {
}
public String getObjType() {
- return this.objType;
+ return objType;
}
public Long getSize() {
- return this.size;
+ return size;
}
public String getName() {
- return this.name;
+ return name;
}
public String getPath() {
- return this.path;
+ return path;
}
public DecodedDataStore getStore() {
- return this.store;
+ return store;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/storage/encoding/DecodedDataStore.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/DecodedDataStore.java b/utils/src/com/cloud/utils/storage/encoding/DecodedDataStore.java
index a1f8217..ac8af8b 100644
--- a/utils/src/com/cloud/utils/storage/encoding/DecodedDataStore.java
+++ b/utils/src/com/cloud/utils/storage/encoding/DecodedDataStore.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.storage.encoding;
public class DecodedDataStore {
@@ -38,30 +39,30 @@ public class DecodedDataStore {
}
public String getRole() {
- return this.role;
+ return role;
}
public String getUuid() {
- return this.uuid;
+ return uuid;
}
public String getProviderName() {
- return this.providerName;
+ return providerName;
}
public String getScheme() {
- return this.scheme;
+ return scheme;
}
public String getUrl() {
- return this.url;
+ return url;
}
public String getServer() {
- return this.server;
+ return server;
}
public String getPath() {
- return this.path;
+ return path;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/storage/encoding/Decoder.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/Decoder.java b/utils/src/com/cloud/utils/storage/encoding/Decoder.java
index 17b96eb..1fe2ed9 100644
--- a/utils/src/com/cloud/utils/storage/encoding/Decoder.java
+++ b/utils/src/com/cloud/utils/storage/encoding/Decoder.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.storage.encoding;
import java.net.URI;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/storage/encoding/EncodingType.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/storage/encoding/EncodingType.java b/utils/src/com/cloud/utils/storage/encoding/EncodingType.java
index 5b99bc1..f40f4f9 100644
--- a/utils/src/com/cloud/utils/storage/encoding/EncodingType.java
+++ b/utils/src/com/cloud/utils/storage/encoding/EncodingType.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.storage.encoding;
public enum EncodingType {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/time/InaccurateClock.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/time/InaccurateClock.java b/utils/src/com/cloud/utils/time/InaccurateClock.java
index 59cb030..77582c1 100644
--- a/utils/src/com/cloud/utils/time/InaccurateClock.java
+++ b/utils/src/com/cloud/utils/time/InaccurateClock.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.time;
import java.util.concurrent.Executors;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/time/InaccurateClockMBean.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/time/InaccurateClockMBean.java b/utils/src/com/cloud/utils/time/InaccurateClockMBean.java
index 7d27e58..acc4615 100755
--- a/utils/src/com/cloud/utils/time/InaccurateClockMBean.java
+++ b/utils/src/com/cloud/utils/time/InaccurateClockMBean.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.time;
public interface InaccurateClockMBean {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/xmlobject/XmlObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/xmlobject/XmlObject.java b/utils/src/com/cloud/utils/xmlobject/XmlObject.java
index 1b8ba15..e03a84d 100755
--- a/utils/src/com/cloud/utils/xmlobject/XmlObject.java
+++ b/utils/src/com/cloud/utils/xmlobject/XmlObject.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.xmlobject;
import java.lang.reflect.Field;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java b/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
index 658f361..321af0c 100644
--- a/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
+++ b/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.xmlobject;
import java.io.ByteArrayInputStream;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java b/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java
index 7dee846..fdd80f7 100755
--- a/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java
+++ b/utils/src/org/apache/cloudstack/utils/identity/ManagementServerNode.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package org.apache.cloudstack.utils.identity;
import javax.ejb.Local;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java b/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
index 73550e2..fab7d45 100644
--- a/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
+++ b/utils/src/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java
@@ -1,32 +1,21 @@
-/*
- * $HeadURL$
- * $Revision$
- * $Date$
- *
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
package org.apache.commons.httpclient.contrib.ssl;
@@ -121,10 +110,10 @@ public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory
}
private SSLContext getSSLContext() {
- if (this.sslcontext == null) {
- this.sslcontext = createEasySSLContext();
+ if (sslcontext == null) {
+ sslcontext = createEasySSLContext();
}
- return this.sslcontext;
+ return sslcontext;
}
/**
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/src/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java b/utils/src/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java
index a5cc48a..eb23eb2 100644
--- a/utils/src/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java
+++ b/utils/src/org/apache/commons/httpclient/contrib/ssl/EasyX509TrustManager.java
@@ -1,28 +1,21 @@
-/*
- * ====================================================================
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
package org.apache.commons.httpclient.contrib.ssl;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/DummyImpl.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/DummyImpl.java b/utils/test/com/cloud/utils/DummyImpl.java
index 82c5dde..e2360c0 100644
--- a/utils/test/com/cloud/utils/DummyImpl.java
+++ b/utils/test/com/cloud/utils/DummyImpl.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import org.springframework.stereotype.Component;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/DummyInterface.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/DummyInterface.java b/utils/test/com/cloud/utils/DummyInterface.java
index 8e93441..4f6a777 100644
--- a/utils/test/com/cloud/utils/DummyInterface.java
+++ b/utils/test/com/cloud/utils/DummyInterface.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
public interface DummyInterface {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/DummyPremiumImpl.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/DummyPremiumImpl.java b/utils/test/com/cloud/utils/DummyPremiumImpl.java
index 57807a6..9c71368 100644
--- a/utils/test/com/cloud/utils/DummyPremiumImpl.java
+++ b/utils/test/com/cloud/utils/DummyPremiumImpl.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
public class DummyPremiumImpl implements DummyInterface {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/NumbersUtilTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/NumbersUtilTest.java b/utils/test/com/cloud/utils/NumbersUtilTest.java
index 989c3a9..82b2305 100644
--- a/utils/test/com/cloud/utils/NumbersUtilTest.java
+++ b/utils/test/com/cloud/utils/NumbersUtilTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/PasswordGeneratorTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/PasswordGeneratorTest.java b/utils/test/com/cloud/utils/PasswordGeneratorTest.java
index 0797666..3e82d98 100644
--- a/utils/test/com/cloud/utils/PasswordGeneratorTest.java
+++ b/utils/test/com/cloud/utils/PasswordGeneratorTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import org.junit.Assert;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/ProcessUtilTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/ProcessUtilTest.java b/utils/test/com/cloud/utils/ProcessUtilTest.java
index 503a855..38e25a3 100644
--- a/utils/test/com/cloud/utils/ProcessUtilTest.java
+++ b/utils/test/com/cloud/utils/ProcessUtilTest.java
@@ -1,19 +1,22 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
-// // or more contributor license agreements. See the NOTICE file
-// // distributed with this work for additional information
-// // regarding copyright ownership. The ASF licenses this file
-// // to you under the Apache License, Version 2.0 (the
-// // "License"); you may not use this file except in compliance
-// // with 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.
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/PropertiesUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/PropertiesUtilsTest.java b/utils/test/com/cloud/utils/PropertiesUtilsTest.java
index 14bcf3f..84ad523 100644
--- a/utils/test/com/cloud/utils/PropertiesUtilsTest.java
+++ b/utils/test/com/cloud/utils/PropertiesUtilsTest.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/ReflectUtilTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/ReflectUtilTest.java b/utils/test/com/cloud/utils/ReflectUtilTest.java
index 0c49081..c024a2e 100644
--- a/utils/test/com/cloud/utils/ReflectUtilTest.java
+++ b/utils/test/com/cloud/utils/ReflectUtilTest.java
@@ -1,19 +1,22 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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.package com.cloud.utils;
+// under the License.
+//
+
package com.cloud.utils;
import static com.cloud.utils.ReflectUtil.flattenProperties;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/ScriptTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/ScriptTest.java b/utils/test/com/cloud/utils/ScriptTest.java
index ddf1786..4848988 100644
--- a/utils/test/com/cloud/utils/ScriptTest.java
+++ b/utils/test/com/cloud/utils/ScriptTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import org.apache.commons.lang.SystemUtils;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/StringUtilsTest.java b/utils/test/com/cloud/utils/StringUtilsTest.java
index af7e4e3..5a90300 100644
--- a/utils/test/com/cloud/utils/StringUtilsTest.java
+++ b/utils/test/com/cloud/utils/StringUtilsTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/TernaryTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/TernaryTest.java b/utils/test/com/cloud/utils/TernaryTest.java
index 216d31d..cacbecb 100644
--- a/utils/test/com/cloud/utils/TernaryTest.java
+++ b/utils/test/com/cloud/utils/TernaryTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
package com.cloud.utils;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/TestProfiler.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/TestProfiler.java b/utils/test/com/cloud/utils/TestProfiler.java
index 465fdf8..2690a26 100644
--- a/utils/test/com/cloud/utils/TestProfiler.java
+++ b/utils/test/com/cloud/utils/TestProfiler.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import org.apache.log4j.Logger;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/UriUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/UriUtilsTest.java b/utils/test/com/cloud/utils/UriUtilsTest.java
index e15456a..d2fd997 100644
--- a/utils/test/com/cloud/utils/UriUtilsTest.java
+++ b/utils/test/com/cloud/utils/UriUtilsTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils;
import junit.framework.Assert;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/UuidUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/UuidUtilsTest.java b/utils/test/com/cloud/utils/UuidUtilsTest.java
index a39eae7..2ef6bbd 100644
--- a/utils/test/com/cloud/utils/UuidUtilsTest.java
+++ b/utils/test/com/cloud/utils/UuidUtilsTest.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -15,6 +16,7 @@
// specific language governing permissions and limitations
// under the License.
//
+
package com.cloud.utils;
import static org.junit.Assert.assertFalse;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java b/utils/test/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java
index e3a0646..d397511 100644
--- a/utils/test/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java
+++ b/utils/test/com/cloud/utils/backoff/impl/ConstantTimeBackoffTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.backoff.impl;
import java.util.HashMap;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/crypto/RSAHelperTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/crypto/RSAHelperTest.java b/utils/test/com/cloud/utils/crypto/RSAHelperTest.java
index e9a74a8..27d9d50 100644
--- a/utils/test/com/cloud/utils/crypto/RSAHelperTest.java
+++ b/utils/test/com/cloud/utils/crypto/RSAHelperTest.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.crypto;
import static org.junit.Assert.assertNotNull;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/encoding/UrlEncoderTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/encoding/UrlEncoderTest.java b/utils/test/com/cloud/utils/encoding/UrlEncoderTest.java
index 73d9a21..3d4dfc9 100644
--- a/utils/test/com/cloud/utils/encoding/UrlEncoderTest.java
+++ b/utils/test/com/cloud/utils/encoding/UrlEncoderTest.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.encoding;
import org.junit.Assert;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/exception/ExceptionUtilTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/exception/ExceptionUtilTest.java b/utils/test/com/cloud/utils/exception/ExceptionUtilTest.java
index 370f3e5..e2cb01f 100644
--- a/utils/test/com/cloud/utils/exception/ExceptionUtilTest.java
+++ b/utils/test/com/cloud/utils/exception/ExceptionUtilTest.java
@@ -1,21 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with 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.
- */
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with 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.
+//
+
package com.cloud.utils.exception;
import static org.junit.Assert.fail;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/net/IpTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/net/IpTest.java b/utils/test/com/cloud/utils/net/IpTest.java
index 48615d7..d11b779 100644
--- a/utils/test/com/cloud/utils/net/IpTest.java
+++ b/utils/test/com/cloud/utils/net/IpTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.net;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/net/NetUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/net/NetUtilsTest.java b/utils/test/com/cloud/utils/net/NetUtilsTest.java
index 600b69e..d3e283c 100644
--- a/utils/test/com/cloud/utils/net/NetUtilsTest.java
+++ b/utils/test/com/cloud/utils/net/NetUtilsTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.net;
import java.math.BigInteger;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
index ac535ce..17864b4 100644
--- a/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
+++ b/utils/test/com/cloud/utils/rest/RESTServiceConnectorTest.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -15,6 +16,7 @@
// specific language governing permissions and limitations
// under the License.
//
+
package com.cloud.utils.rest;
import static org.junit.Assert.assertTrue;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/ssh/SSHKeysHelperTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/ssh/SSHKeysHelperTest.java b/utils/test/com/cloud/utils/ssh/SSHKeysHelperTest.java
index 3cad883..a3daf91 100644
--- a/utils/test/com/cloud/utils/ssh/SSHKeysHelperTest.java
+++ b/utils/test/com/cloud/utils/ssh/SSHKeysHelperTest.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.ssh;
import static org.junit.Assert.assertTrue;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/testcase/Log4jEnabledTestCase.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/testcase/Log4jEnabledTestCase.java b/utils/test/com/cloud/utils/testcase/Log4jEnabledTestCase.java
index eb1e0b7..51cde2c 100644
--- a/utils/test/com/cloud/utils/testcase/Log4jEnabledTestCase.java
+++ b/utils/test/com/cloud/utils/testcase/Log4jEnabledTestCase.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.testcase;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/testcase/NioTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/testcase/NioTest.java b/utils/test/com/cloud/utils/testcase/NioTest.java
index 64198f7..fc16684 100644
--- a/utils/test/com/cloud/utils/testcase/NioTest.java
+++ b/utils/test/com/cloud/utils/testcase/NioTest.java
@@ -1,12 +1,13 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
-// the License. You may obtain a copy of the License at
+// with the License. You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// 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
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.testcase;
import java.nio.channels.ClosedChannelException;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java b/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
index b117cd0..cbd24b0 100644
--- a/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
+++ b/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.xmlobject;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java b/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java
index 95bc590..9a27ca1 100644
--- a/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java
+++ b/utils/test/com/cloud/utils/xmlobject/TestXmlObject2.java
@@ -1,3 +1,4 @@
+//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -14,6 +15,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+//
+
package com.cloud.utils.xmlobject;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/resources/com/cloud/utils/QualifierTestContext.xml
----------------------------------------------------------------------
diff --git a/utils/test/resources/com/cloud/utils/QualifierTestContext.xml b/utils/test/resources/com/cloud/utils/QualifierTestContext.xml
index a475e56..39f494b 100644
--- a/utils/test/resources/com/cloud/utils/QualifierTestContext.xml
+++ b/utils/test/resources/com/cloud/utils/QualifierTestContext.xml
@@ -1,21 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with 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.
- 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.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/resources/com/cloud/utils/db/transactionContextBuilderTest.xml
----------------------------------------------------------------------
diff --git a/utils/test/resources/com/cloud/utils/db/transactionContextBuilderTest.xml b/utils/test/resources/com/cloud/utils/db/transactionContextBuilderTest.xml
index 686b67e..81ca058 100644
--- a/utils/test/resources/com/cloud/utils/db/transactionContextBuilderTest.xml
+++ b/utils/test/resources/com/cloud/utils/db/transactionContextBuilderTest.xml
@@ -1,21 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with 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.
- 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.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/resources/log4j.xml
----------------------------------------------------------------------
diff --git a/utils/test/resources/log4j.xml b/utils/test/resources/log4j.xml
index fbb8939..cdae2fa 100755
--- a/utils/test/resources/log4j.xml
+++ b/utils/test/resources/log4j.xml
@@ -1,21 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with 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.
-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.
-->
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/594b51c6/utils/test/resources/testContext.xml
----------------------------------------------------------------------
diff --git a/utils/test/resources/testContext.xml b/utils/test/resources/testContext.xml
index 5cccfcd..cb5b9b8 100644
--- a/utils/test/resources/testContext.xml
+++ b/utils/test/resources/testContext.xml
@@ -1,20 +1,22 @@
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with 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.
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with 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.
+
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
[41/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6047: Generalize execution in VirtualRoutingResource
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ebf7ee40
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ebf7ee40
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ebf7ee40
Branch: refs/heads/ui-restyle
Commit: ebf7ee40b11cf50c99d7699100ea8d98862fb6e9
Parents: 8fccb8c
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Feb 19 19:12:07 2014 -0800
Committer: Sheng Yang <sh...@citrix.com>
Committed: Wed Feb 19 19:46:59 2014 -0800
----------------------------------------------------------------------
.../virtualnetwork/VirtualRoutingResource.java | 66 +++++++-------------
1 file changed, 23 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ebf7ee40/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index d51e8bb..faa826a 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -236,6 +236,16 @@ public class VirtualRoutingResource {
}
}
+ private Answer applyConfigSingle(NetworkElementCommand cmd, List<ConfigItem> cfg) {
+ for (ConfigItem c : cfg) {
+ ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
+ if (!result.isSuccess()) {
+ return new Answer(cmd, false, result.getDetails());
+ }
+ }
+ return new Answer(cmd);
+ }
+
private List<ConfigItem> generateConfig(VpnUsersCfgCommand cmd) {
LinkedList<ConfigItem> cfg = new LinkedList<>();
for (VpnUsersCfgCommand.UsernamePassword userpwd : cmd.getUserpwds()) {
@@ -254,13 +264,7 @@ public class VirtualRoutingResource {
private Answer execute(VpnUsersCfgCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- for (ConfigItem c : cfg) {
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- if (!result.isSuccess()) {
- return new Answer(cmd, false, "Configure VPN user failed: " + result.getDetails());
- }
- }
- return new Answer(cmd);
+ return applyConfigSingle(cmd, cfg);
}
private List<ConfigItem> generateConfig(RemoteAccessVpnCfgCommand cmd) {
@@ -289,9 +293,7 @@ public class VirtualRoutingResource {
private Answer execute(RemoteAccessVpnCfgCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
private List<ConfigItem> generateConfig(SetFirewallRulesCommand cmd) {
@@ -543,9 +545,7 @@ public class VirtualRoutingResource {
protected Answer execute(VmDataCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
private List<ConfigItem> generateConfig(SavePasswordCommand cmd) {
@@ -563,9 +563,7 @@ public class VirtualRoutingResource {
protected Answer execute(final SavePasswordCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
private List<ConfigItem> generateConfig(DhcpEntryCommand cmd) {
@@ -604,9 +602,7 @@ public class VirtualRoutingResource {
protected Answer execute(final DhcpEntryCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
private List<ConfigItem> generateConfig(CreateIpAliasCommand cmd) {
@@ -624,9 +620,7 @@ public class VirtualRoutingResource {
protected Answer execute(final CreateIpAliasCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
private List<ConfigItem> generateConfig(DeleteIpAliasCommand cmd) {
@@ -650,9 +644,7 @@ public class VirtualRoutingResource {
protected Answer execute(final DeleteIpAliasCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
private List<ConfigItem> generateConfig(DnsMasqConfigCommand cmd) {
@@ -670,9 +662,7 @@ public class VirtualRoutingResource {
protected Answer execute(final DnsMasqConfigCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) {
@@ -701,9 +691,7 @@ public class VirtualRoutingResource {
protected Answer execute(BumpUpPriorityCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
protected Answer execute(GetDomRVersionCmd cmd) {
@@ -769,9 +757,7 @@ public class VirtualRoutingResource {
protected Answer execute(Site2SiteVpnCfgCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetMonitorServiceCommand cmd) {
@@ -791,9 +777,7 @@ public class VirtualRoutingResource {
protected Answer execute(SetMonitorServiceCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetupGuestNetworkCommand cmd) {
@@ -838,9 +822,7 @@ public class VirtualRoutingResource {
protected Answer execute(SetupGuestNetworkCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetNetworkACLCommand cmd) {
@@ -911,9 +893,7 @@ public class VirtualRoutingResource {
protected Answer execute(SetSourceNatCommand cmd) {
List<ConfigItem> cfg = generateConfig(cmd);
- ConfigItem c = cfg.get(0);
- final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs());
- return new Answer(cmd, result.isSuccess(), result.getDetails());
+ return applyConfigSingle(cmd, cfg);
}
protected List<ConfigItem> generateConfig(SetPortForwardingRulesVpcCommand cmd) {
[17/50] [abbrv] git commit: updated refs/heads/ui-restyle to c64bfa5
Posted by bf...@apache.org.
CLOUDSTACK-6123: Ensuring no color in grep output
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9f72443b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9f72443b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9f72443b
Branch: refs/heads/ui-restyle
Commit: 9f72443bb14688a7299ed74a6085163af300a7b6
Parents: 2b1b435
Author: John Kinsella <jl...@stratosec.co>
Authored: Sat Feb 15 21:26:40 2014 -0800
Committer: John Kinsella <jl...@stratosec.co>
Committed: Sat Feb 15 21:26:40 2014 -0800
----------------------------------------------------------------------
packaging/centos63/package.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f72443b/packaging/centos63/package.sh
----------------------------------------------------------------------
diff --git a/packaging/centos63/package.sh b/packaging/centos63/package.sh
index 04b9258..bbd8eaa 100755
--- a/packaging/centos63/package.sh
+++ b/packaging/centos63/package.sh
@@ -40,7 +40,7 @@ if [ -n "$1" ] ; then
fi
-VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep '^[0-9]\.'`
+VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep --color=none '^[0-9]\.'`
if echo $VERSION | grep SNAPSHOT ; then
REALVER=`echo $VERSION | cut -d '-' -f 1`
DEFVER="-D_ver $REALVER"