You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/04/02 20:22:55 UTC
[14/39] git commit: updated refs/heads/master to 3e28747
Refactor the CheckHealthCommand and GetVmDiskStatsCommand classes in CitrixResourceBase
- Added basic tests for both wrappers
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c7830efe
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c7830efe
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c7830efe
Branch: refs/heads/master
Commit: c7830efef5d168adf37e64da639908f4186a01c2
Parents: 8f04108
Author: wilderrodrigues <wr...@schubergphilis.com>
Authored: Tue Mar 24 11:05:43 2015 +0100
Committer: wilderrodrigues <wr...@schubergphilis.com>
Committed: Tue Mar 31 10:38:26 2015 +0200
----------------------------------------------------------------------
.../xenserver/resource/CitrixResourceBase.java | 2 +-
.../wrapper/CheckHealthCommandWrapper.java | 35 ++++++++++++++++++++
.../resource/wrapper/CitrixRequestWrapper.java | 4 +++
.../wrapper/GetVmDiskStatsCommandWrapper.java | 34 +++++++++++++++++++
.../wrapper/CitrixRequestWrapperTest.java | 26 +++++++++++++++
5 files changed, 100 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7830efe/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 024307d..c7405fc 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
@@ -394,7 +394,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
- protected boolean pingXAPI() {
+ public boolean pingXAPI() {
final Connection conn = getConnection();
try {
final Host host = Host.getByUuid(conn, _host.getUuid());
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7830efe/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CheckHealthCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CheckHealthCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CheckHealthCommandWrapper.java
new file mode 100644
index 0000000..fa2e0ca
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/CheckHealthCommandWrapper.java
@@ -0,0 +1,35 @@
+//
+// 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.CheckHealthAnswer;
+import com.cloud.agent.api.CheckHealthCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+
+public final class CheckHealthCommandWrapper extends CommandWrapper<CheckHealthCommand, Answer, CitrixResourceBase> {
+
+ @Override
+ public Answer execute(final CheckHealthCommand command, final CitrixResourceBase citrixResourceBase) {
+ final boolean result = citrixResourceBase.pingXAPI();
+ return new CheckHealthAnswer(command, result);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7830efe/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 9c2f08d..b3996c1 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
@@ -22,8 +22,10 @@ package com.cloud.hypervisor.xenserver.resource.wrapper;
import java.util.Hashtable;
import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckHealthCommand;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.GetHostStatsCommand;
+import com.cloud.agent.api.GetVmDiskStatsCommand;
import com.cloud.agent.api.GetVmStatsCommand;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.RebootRouterCommand;
@@ -59,6 +61,8 @@ public class CitrixRequestWrapper extends RequestWrapper {
map.put(ReadyCommand.class, new CitrixReadyCommandWrapper());
map.put(GetHostStatsCommand.class, new GetHostStatsCommandWrapper());
map.put(GetVmStatsCommand.class, new GetVmStatsCommandWrapper());
+ map.put(GetVmDiskStatsCommand.class, new GetVmDiskStatsCommandWrapper());
+ map.put(CheckHealthCommand.class, new CheckHealthCommandWrapper());
}
public static CitrixRequestWrapper getInstance() {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7830efe/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/GetVmDiskStatsCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/GetVmDiskStatsCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/GetVmDiskStatsCommandWrapper.java
new file mode 100644
index 0000000..a403322
--- /dev/null
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/GetVmDiskStatsCommandWrapper.java
@@ -0,0 +1,34 @@
+//
+// 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.GetVmDiskStatsAnswer;
+import com.cloud.agent.api.GetVmDiskStatsCommand;
+import com.cloud.hypervisor.xenserver.resource.CitrixResourceBase;
+import com.cloud.resource.CommandWrapper;
+
+public final class GetVmDiskStatsCommandWrapper extends CommandWrapper<GetVmDiskStatsCommand, Answer, CitrixResourceBase> {
+
+ @Override
+ public Answer execute(final GetVmDiskStatsCommand command, final CitrixResourceBase citrixResourceBase) {
+ return new GetVmDiskStatsAnswer(command, null, null, null);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7830efe/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 e54e809..69071c0 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
@@ -17,8 +17,10 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckHealthCommand;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.GetHostStatsCommand;
+import com.cloud.agent.api.GetVmDiskStatsCommand;
import com.cloud.agent.api.GetVmStatsCommand;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.RebootAnswer;
@@ -151,6 +153,30 @@ public class CitrixRequestWrapperTest {
assertTrue(answer.getResult());
}
+
+ @Test
+ public void testGetVmDiskStatsCommandCommand() {
+ final GetVmDiskStatsCommand statsCommand = new GetVmDiskStatsCommand(new ArrayList<String>(), null, null);
+
+ final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
+ assertNotNull(wrapper);
+
+ final Answer answer = wrapper.execute(statsCommand, citrixResourceBase);
+
+ assertTrue(answer.getResult());
+ }
+
+ @Test
+ public void testCheckHealthCommandCommand() {
+ final CheckHealthCommand statsCommand = new CheckHealthCommand();
+
+ final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
+ assertNotNull(wrapper);
+
+ final Answer answer = wrapper.execute(statsCommand, citrixResourceBase);
+
+ assertFalse(answer.getResult());
+ }
}
class NotAValidCommand extends Command {