cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [26/39] git commit: updated refs/heads/master to 3e28747
Date Thu, 02 Apr 2015 18:23:07 GMT
Refactoring PingTestCommand to cope with new design
   - Basic tests added


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

Branch: refs/heads/master
Commit: 18470a48d0db69e4bd97d22c023f7a5ae3bcbd97
Parents: 3a70912
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Thu Mar 26 11:10:35 2015 +0100
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Tue Mar 31 10:38:30 2015 +0200

----------------------------------------------------------------------
 .../xenserver/resource/CitrixResourceBase.java  |  6 +--
 .../wrapper/CitrixPingTestCommandWrapper.java   | 47 ++++++++++++++++++++
 .../resource/wrapper/CitrixRequestWrapper.java  |  2 +
 .../wrapper/CitrixRequestWrapperTest.java       | 14 ++++++
 4 files changed, 65 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/18470a48/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index 8fa9e4c..50859af 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -453,8 +453,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
 
         if (cmd instanceof NetworkElementCommand) {
             return _vrResource.executeRequest((NetworkElementCommand)cmd);
-        } else if (clazz == PingTestCommand.class) {
-            return execute((PingTestCommand)cmd);
         } else if (clazz == CheckOnHostCommand.class) {
             return execute((CheckOnHostCommand)cmd);
         } else if (clazz == ModifySshKeysCommand.class) {
@@ -1945,7 +1943,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
         return new Answer(cmd);
     }
 
-    private boolean doPingTest(final Connection conn, final String computingHostIp) {
+    public boolean doPingTest(final Connection conn, final String computingHostIp) {
         final com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_host.getIp(),
22);
         try {
             sshConnection.connect(null, 60000, 60000);
@@ -1970,7 +1968,7 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
         return new CheckOnHostAnswer(cmd, null, "Not Implmeneted");
     }
 
-    private boolean doPingTest(final Connection conn, final String domRIp, final String vmIp)
{
+    public boolean doPingTest(final Connection conn, final String domRIp, final String vmIp)
{
         final String args = "-i " + domRIp + " -p " + vmIp;
         final String result = callHostPlugin(conn, "vmops", "pingtest", "args", args);
         if (result == null || result.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/18470a48/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java
new file mode 100644
index 0000000..8a7a01c
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixPingTestCommandWrapper.java
@@ -0,0 +1,47 @@
+//
+// 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.hypervisor.xenserver.resource.wrapper;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.PingTestCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+import com.xensource.xenapi.Connection;
+
+public final class CitrixPingTestCommandWrapper extends CommandWrapper<PingTestCommand,
Answer, CitrixResourceBase> {
+
+    @Override
+    public Answer execute(final PingTestCommand command, final CitrixResourceBase citrixResourceBase)
{
+        final Connection conn = citrixResourceBase.getConnection();
+        boolean result = false;
+        final String computingHostIp = command.getComputingHostIp();
+
+        if (computingHostIp != null) {
+            result = citrixResourceBase.doPingTest(conn, computingHostIp);
+        } else {
+            result = citrixResourceBase.doPingTest(conn, command.getRouterIp(), command.getPrivateIp());
+        }
+
+        if (!result) {
+            return new Answer(command, false, "PingTestCommand failed");
+        }
+        return new Answer(command);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/18470a48/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java
index 6d262ee..badc892 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapper.java
@@ -37,6 +37,7 @@ import com.cloud.agent.api.GetVncPortCommand;
 import com.cloud.agent.api.MaintainCommand;
 import com.cloud.agent.api.MigrateCommand;
 import com.cloud.agent.api.ModifyStoragePoolCommand;
+import com.cloud.agent.api.PingTestCommand;
 import com.cloud.agent.api.PrepareForMigrationCommand;
 import com.cloud.agent.api.ReadyCommand;
 import com.cloud.agent.api.RebootCommand;
@@ -99,6 +100,7 @@ public class CitrixRequestWrapper extends RequestWrapper {
         map.put(GetVncPortCommand.class, new CitrixGetVncPortCommandWrapper());
         map.put(SetupCommand.class, new CitrixSetupCommandWrapper());
         map.put(MaintainCommand.class, new CitrixMaintainCommandWrapper());
+        map.put(PingTestCommand.class, new CitrixPingTestCommandWrapper());
     }
 
     public static CitrixRequestWrapper getInstance() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/18470a48/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java
index 45bdea1..0ba9d1a 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/CitrixRequestWrapperTest.java
@@ -38,6 +38,7 @@ import com.cloud.agent.api.GetVncPortCommand;
 import com.cloud.agent.api.MaintainCommand;
 import com.cloud.agent.api.MigrateCommand;
 import com.cloud.agent.api.ModifyStoragePoolCommand;
+import com.cloud.agent.api.PingTestCommand;
 import com.cloud.agent.api.PrepareForMigrationCommand;
 import com.cloud.agent.api.ReadyCommand;
 import com.cloud.agent.api.RebootAnswer;
@@ -554,6 +555,19 @@ public class CitrixRequestWrapperTest {
 
         assertFalse(answer.getResult());
     }
+
+    @Test
+    public void testPingTestCommandHostIp() {
+        final PingTestCommand storageDownloadCommand = new PingTestCommand("127.0.0.1");
+
+        final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
+        assertNotNull(wrapper);
+
+        final Answer answer = wrapper.execute(storageDownloadCommand, citrixResourceBase);
+        verify(citrixResourceBase, times(1)).getConnection();
+
+        assertFalse(answer.getResult());
+    }
 }
 
 class NotAValidCommand extends Command {


Mime
View raw message