cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [2/2] git commit: updated refs/heads/master to a963fd3
Date Fri, 18 Jul 2014 07:28:59 GMT
Remove duplicated code


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5651a13c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5651a13c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5651a13c

Branch: refs/heads/master
Commit: 5651a13cfde96b91dd40858490c4a450321624ef
Parents: 1e4695b
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Thu Jul 17 12:13:48 2014 +0200
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Fri Jul 18 09:28:42 2014 +0200

----------------------------------------------------------------------
 .../virtualnetwork/VirtualRoutingResource.java  | 44 +++-----------------
 .../kvm/resource/LibvirtComputingResource.java  | 23 ++++------
 2 files changed, 14 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5651a13c/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 00501e3..1c08446 100755
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@ -193,7 +193,6 @@ public class VirtualRoutingResource {
         }
     }
 
-
     private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) {
 
         StringBuffer buff = new StringBuffer();
@@ -226,7 +225,7 @@ public class VirtualRoutingResource {
         }
     }
 
-    protected Answer execute(CheckRouterCommand cmd) {
+    private Answer execute(CheckRouterCommand cmd) {
         final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.RVR_CHECK,
null);
         if (!result.isSuccess()) {
             return new CheckRouterAnswer(cmd, result.getDetails());
@@ -234,7 +233,7 @@ public class VirtualRoutingResource {
         return new CheckRouterAnswer(cmd, result.getDetails(), true);
     }
 
-    protected Answer execute(GetDomRVersionCmd cmd) {
+    private Answer execute(GetDomRVersionCmd cmd) {
         final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VERSION,
null);
         if (!result.isSuccess()) {
             return new GetDomRVersionAnswer(cmd, "GetDomRVersionCmd failed");
@@ -246,7 +245,6 @@ public class VirtualRoutingResource {
         return new GetDomRVersionAnswer(cmd, result.getDetails(), lines[0], lines[1]);
     }
 
-
     public boolean configure(final String name, final Map<String, Object> params) throws
ConfigurationException {
         _name = name;
 
@@ -270,44 +268,12 @@ public class VirtualRoutingResource {
         return true;
     }
 
-    public String connect(final String ipAddress) {
+    public boolean connect(final String ipAddress) {
         return connect(ipAddress, _port);
     }
 
-    public String connect(final String ipAddress, final int port) {
-        for (int i = 0; i <= _retry; i++) {
-            SocketChannel sch = null;
-            try {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Trying to connect to " + ipAddress);
-                }
-                sch = SocketChannel.open();
-                sch.configureBlocking(true);
-
-                final InetSocketAddress addr = new InetSocketAddress(ipAddress, port);
-                sch.connect(addr);
-                return null;
-            } catch (final IOException e) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Could not connect to " + ipAddress);
-                }
-            } finally {
-                if (sch != null) {
-                    try {
-                        sch.close();
-                    } catch (final IOException e) {
-                    }
-                }
-            }
-            try {
-                Thread.sleep(_sleep);
-            } catch (final InterruptedException e) {
-            }
-        }
-
-        s_logger.debug("Unable to logon to " + ipAddress);
-
-        return "Unable to connect";
+    public boolean connect(final String ipAddress, final int port) {
+        return connect(ipAddress, port, _sleep);
     }
 
     public boolean connect(final String ipAddress, int retry, int sleep) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5651a13c/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 d4d663c..2ebab78 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
@@ -1822,10 +1822,10 @@ 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
-                  || poolType == StoragePoolType.Gluster)
-                  && volFormat == PhysicalDiskFormat.QCOW2 ) {
+                || poolType == StoragePoolType.SharedMountPoint
+                || poolType == StoragePoolType.Filesystem
+                || poolType == StoragePoolType.Gluster)
+                && volFormat == PhysicalDiskFormat.QCOW2 ) {
             return "QCOW2";
         }
         return null;
@@ -2141,7 +2141,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
     protected ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) {
         Connect conn;
         String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
-        String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         IpAddressTO pubIP = cmd.getIpAddress();
 
         try {
@@ -2179,7 +2179,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
 
     protected ExecutionResult prepareNetworkElementCommand(IpAssocVpcCommand cmd) {
         Connect conn;
-        int i = 0;
         String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
 
         try {
@@ -2295,12 +2294,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
             int nicNum = 0;
             for (IpAddressTO ip : ips) {
 
-                boolean newNic = false;
                 if (!broadcastUriAllocatedToVM.containsKey(ip.getBroadcastUri())) {
                     /* plug a vif into router */
                     VifHotPlug(conn, routerName, ip.getBroadcastUri(), ip.getVifMacAddress());
                     broadcastUriAllocatedToVM.put(ip.getBroadcastUri(), nicPos++);
-                    newNic = true;
                 }
                 nicNum = broadcastUriAllocatedToVM.get(ip.getBroadcastUri());
 
@@ -3441,12 +3438,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
 
     protected Answer execute(RebootRouterCommand cmd) {
         RebootAnswer answer = (RebootAnswer)execute((RebootCommand)cmd);
-        String result = _virtRouterResource.connect(cmd.getPrivateIpAddress());
-        if (result == null) {
+        if (_virtRouterResource.connect(cmd.getPrivateIpAddress())) {
             networkUsage(cmd.getPrivateIpAddress(), "create", null);
             return answer;
         } else {
-            return new Answer(cmd, false, result);
+            return new Answer(cmd, false, "Failed to connect to virtual router " + cmd.getVmName());
         }
     }
 
@@ -4057,9 +4053,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
             s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort);
         }
 
-        String result = _virtRouterResource.connect(privateIp, cmdPort);
-        if (result != null) {
-            return new CheckSshAnswer(cmd, "Can not ping System vm " + vmName + "due to:"
+ result);
+        if (!_virtRouterResource.connect(privateIp, cmdPort)) {
+            return new CheckSshAnswer(cmd, "Can not ping System vm " + vmName + " because
of a connection failure");
         }
 
         if (s_logger.isDebugEnabled()) {


Mime
View raw message