cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject [27/50] [abbrv] git commit: updated refs/heads/CLOUDSTACK-8301 to 8ff9000
Date Tue, 19 May 2015 16:21:13 GMT
Refactoring the LibvirtComputingResource
  - Adding LibvirtNetworkElementCommandWrapper and LibvirtStorageSubSystemCommandWrapper
  - 2 unit tests added
  - KVM hypervisor plugin with 22.2% coverage

I also refactored the StorageSubSystemCommand interface into an abstract class
  - Remove the pseudo-multiple-inheritance implementation
    - The StorageSubSystemCommand was an interface, not related to the Command class
      and its implementation were extending the Command class anyway. The whole structure
is better now.


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

Branch: refs/heads/CLOUDSTACK-8301
Commit: 09656ca84ef1afbc2603b2cd70186c52430daa5c
Parents: 08106e3
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Wed May 6 14:31:02 2015 +0200
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Wed May 6 19:24:16 2015 +0200

----------------------------------------------------------------------
 .../storage/command/AttachCommand.java          | 13 +++----
 .../command/AttachPrimaryDataStoreCmd.java      |  7 ++--
 .../cloudstack/storage/command/CopyCommand.java | 31 ++++++++--------
 .../storage/command/CreateObjectCommand.java    |  7 ++--
 .../command/CreatePrimaryDataStoreCmd.java      | 11 +++---
 .../storage/command/DeleteCommand.java          |  7 ++--
 .../storage/command/DettachCommand.java         | 19 +++++-----
 .../storage/command/ForgetObjectCmd.java        |  9 ++---
 .../storage/command/IntroduceObjectCmd.java     |  9 ++---
 .../storage/command/SnapshotAndCopyCommand.java | 14 +++----
 .../command/StorageSubSystemCommand.java        |  8 ++--
 .../kvm/resource/LibvirtComputingResource.java  |  9 ++---
 .../LibvirtNetworkElementCommandWrapper.java    | 35 ++++++++++++++++++
 .../resource/wrapper/LibvirtRequestWrapper.java |  5 +++
 .../LibvirtStorageSubSystemCommandWrapper.java  | 36 ++++++++++++++++++
 .../resource/LibvirtComputingResourceTest.java  | 39 ++++++++++++++++++++
 16 files changed, 182 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/AttachCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/AttachCommand.java b/core/src/org/apache/cloudstack/storage/command/AttachCommand.java
index 795deb2..34aaac9 100644
--- a/core/src/org/apache/cloudstack/storage/command/AttachCommand.java
+++ b/core/src/org/apache/cloudstack/storage/command/AttachCommand.java
@@ -19,15 +19,14 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DiskTO;
 
-public final class AttachCommand extends Command implements StorageSubSystemCommand {
+public final class AttachCommand extends StorageSubSystemCommand {
     private DiskTO disk;
     private String vmName;
-    private boolean inSeq = false;
+    private boolean inSeq;
 
-    public AttachCommand(DiskTO disk, String vmName) {
+    public AttachCommand(final DiskTO disk, final String vmName) {
         super();
         this.disk = disk;
         this.vmName = vmName;
@@ -42,7 +41,7 @@ public final class AttachCommand extends Command implements StorageSubSystemComm
         return disk;
     }
 
-    public void setDisk(DiskTO disk) {
+    public void setDisk(final DiskTO disk) {
         this.disk = disk;
     }
 
@@ -50,12 +49,12 @@ public final class AttachCommand extends Command implements StorageSubSystemComm
         return vmName;
     }
 
-    public void setVmName(String vmName) {
+    public void setVmName(final String vmName) {
         this.vmName = vmName;
     }
 
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
+    public void setExecuteInSequence(final boolean inSeq) {
         this.inSeq = inSeq;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
index 4a72c97..9f4d14e 100644
--- a/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
+++ b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java
@@ -19,17 +19,16 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
 
-public final class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand
{
+public final class AttachPrimaryDataStoreCmd extends StorageSubSystemCommand {
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
+    public void setExecuteInSequence(final boolean inSeq) {
 
     }
 
     private final String dataStore;
 
-    public AttachPrimaryDataStoreCmd(String uri) {
+    public AttachPrimaryDataStoreCmd(final String uri) {
         super();
         dataStore = uri;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/CopyCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java
index cfede14..f1895a4 100644
--- a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java
+++ b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java
@@ -22,10 +22,9 @@ package org.apache.cloudstack.storage.command;
 import java.util.HashMap;
 import java.util.Map;
 
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DataTO;
 
-public final class CopyCommand extends Command implements StorageSubSystemCommand {
+public final class CopyCommand extends StorageSubSystemCommand {
     private DataTO srcTO;
     private DataTO destTO;
     private DataTO cacheTO;
@@ -33,28 +32,28 @@ public final class CopyCommand extends Command implements StorageSubSystemComman
     private Map<String, String> options = new HashMap<String, String>();
     private Map<String, String> options2 = new HashMap<String, String>();
 
-    public CopyCommand(DataTO srcData, DataTO destData, int timeout, boolean executeInSequence)
{
+    public CopyCommand(final DataTO srcData, final DataTO destData, final int timeout, final
boolean executeInSequence) {
         super();
-        this.srcTO = srcData;
-        this.destTO = destData;
-        this.setWait(timeout);
+        srcTO = srcData;
+        destTO = destData;
+        setWait(timeout);
         this.executeInSequence = executeInSequence;
     }
 
     public DataTO getDestTO() {
-        return this.destTO;
+        return destTO;
     }
 
-    public void setSrcTO(DataTO srcTO) {
+    public void setSrcTO(final DataTO srcTO) {
         this.srcTO = srcTO;
     }
 
-    public void setDestTO(DataTO destTO) {
+    public void setDestTO(final DataTO destTO) {
         this.destTO = destTO;
     }
 
     public DataTO getSrcTO() {
-        return this.srcTO;
+        return srcTO;
     }
 
     @Override
@@ -66,15 +65,15 @@ public final class CopyCommand extends Command implements StorageSubSystemComman
         return cacheTO;
     }
 
-    public void setCacheTO(DataTO cacheTO) {
+    public void setCacheTO(final DataTO cacheTO) {
         this.cacheTO = cacheTO;
     }
 
     public int getWaitInMillSeconds() {
-        return this.getWait() * 1000;
+        return getWait() * 1000;
     }
 
-    public void setOptions(Map<String, String> options) {
+    public void setOptions(final Map<String, String> options) {
         this.options = options;
     }
 
@@ -82,7 +81,7 @@ public final class CopyCommand extends Command implements StorageSubSystemComman
         return options;
     }
 
-    public void setOptions2(Map<String, String> options2) {
+    public void setOptions2(final Map<String, String> options2) {
         this.options2 = options2;
     }
 
@@ -91,7 +90,7 @@ public final class CopyCommand extends Command implements StorageSubSystemComman
     }
 
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
-        this.executeInSequence = inSeq;
+    public void setExecuteInSequence(final boolean inSeq) {
+        executeInSequence = inSeq;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java b/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
index 6079a95..88a582d 100644
--- a/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
+++ b/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java
@@ -19,13 +19,12 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DataTO;
 
-public final class CreateObjectCommand extends Command implements StorageSubSystemCommand
{
+public final class CreateObjectCommand extends StorageSubSystemCommand {
     private DataTO data;
 
-    public CreateObjectCommand(DataTO obj) {
+    public CreateObjectCommand(final DataTO obj) {
         super();
         data = obj;
     }
@@ -44,7 +43,7 @@ public final class CreateObjectCommand extends Command implements StorageSubSyst
     }
 
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
+    public void setExecuteInSequence(final boolean inSeq) {
 
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
b/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
index 0017dd2..b1f32a9 100644
--- a/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
+++ b/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java
@@ -19,18 +19,17 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
 
-public final class CreatePrimaryDataStoreCmd extends Command implements StorageSubSystemCommand
{
+public final class CreatePrimaryDataStoreCmd extends StorageSubSystemCommand {
     private final String dataStore;
 
-    public CreatePrimaryDataStoreCmd(String uri) {
+    public CreatePrimaryDataStoreCmd(final String uri) {
         super();
-        this.dataStore = uri;
+        dataStore = uri;
     }
 
     public String getDataStore() {
-        return this.dataStore;
+        return dataStore;
     }
 
     @Override
@@ -39,7 +38,7 @@ public final class CreatePrimaryDataStoreCmd extends Command implements
StorageS
     }
 
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
+    public void setExecuteInSequence(final boolean inSeq) {
 
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java b/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java
index 5683f41..6f82fa9 100644
--- a/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java
+++ b/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java
@@ -19,13 +19,12 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DataTO;
 
-public final class DeleteCommand extends Command implements StorageSubSystemCommand {
+public final class DeleteCommand extends StorageSubSystemCommand {
     private DataTO data;
 
-    public DeleteCommand(DataTO data) {
+    public DeleteCommand(final DataTO data) {
         super();
         this.data = data;
     }
@@ -44,7 +43,7 @@ public final class DeleteCommand extends Command implements StorageSubSystemComm
     }
 
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
+    public void setExecuteInSequence(final boolean inSeq) {
 
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/DettachCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/DettachCommand.java b/core/src/org/apache/cloudstack/storage/command/DettachCommand.java
index b699862..8d89dd5 100644
--- a/core/src/org/apache/cloudstack/storage/command/DettachCommand.java
+++ b/core/src/org/apache/cloudstack/storage/command/DettachCommand.java
@@ -19,10 +19,9 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DiskTO;
 
-public class DettachCommand extends Command implements StorageSubSystemCommand {
+public class DettachCommand extends StorageSubSystemCommand {
     private DiskTO disk;
     private String vmName;
     private boolean _managed;
@@ -30,7 +29,7 @@ public class DettachCommand extends Command implements StorageSubSystemCommand
{
     private String _storageHost;
     private int _storagePort;
 
-    public DettachCommand(DiskTO disk, String vmName) {
+    public DettachCommand(final DiskTO disk, final String vmName) {
         super();
         this.disk = disk;
         this.vmName = vmName;
@@ -45,7 +44,7 @@ public class DettachCommand extends Command implements StorageSubSystemCommand
{
         return disk;
     }
 
-    public void setDisk(DiskTO disk) {
+    public void setDisk(final DiskTO disk) {
         this.disk = disk;
     }
 
@@ -53,11 +52,11 @@ public class DettachCommand extends Command implements StorageSubSystemCommand
{
         return vmName;
     }
 
-    public void setVmName(String vmName) {
+    public void setVmName(final String vmName) {
         this.vmName = vmName;
     }
 
-    public void setManaged(boolean managed) {
+    public void setManaged(final boolean managed) {
         _managed = managed;
     }
 
@@ -65,7 +64,7 @@ public class DettachCommand extends Command implements StorageSubSystemCommand
{
         return _managed;
     }
 
-    public void set_iScsiName(String iScsiName) {
+    public void set_iScsiName(final String iScsiName) {
         _iScsiName = iScsiName;
     }
 
@@ -73,7 +72,7 @@ public class DettachCommand extends Command implements StorageSubSystemCommand
{
         return _iScsiName;
     }
 
-    public void setStorageHost(String storageHost) {
+    public void setStorageHost(final String storageHost) {
         _storageHost = storageHost;
     }
 
@@ -81,7 +80,7 @@ public class DettachCommand extends Command implements StorageSubSystemCommand
{
         return _storageHost;
     }
 
-    public void setStoragePort(int storagePort) {
+    public void setStoragePort(final int storagePort) {
         _storagePort = storagePort;
     }
 
@@ -90,7 +89,7 @@ public class DettachCommand extends Command implements StorageSubSystemCommand
{
     }
 
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
+    public void setExecuteInSequence(final boolean inSeq) {
 
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java b/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java
index 9bcaa62..c47ee88 100644
--- a/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java
+++ b/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java
@@ -19,13 +19,12 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DataTO;
 
-public class ForgetObjectCmd extends Command implements StorageSubSystemCommand {
-    private DataTO dataTO;
+public class ForgetObjectCmd extends StorageSubSystemCommand {
+    private final DataTO dataTO;
 
-    public ForgetObjectCmd(DataTO data) {
+    public ForgetObjectCmd(final DataTO data) {
         dataTO = data;
     }
 
@@ -39,7 +38,7 @@ public class ForgetObjectCmd extends Command implements StorageSubSystemCommand
     }
 
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
+    public void setExecuteInSequence(final boolean inSeq) {
 
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java b/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java
index c20c50f..8c3bc5e 100644
--- a/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java
+++ b/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java
@@ -19,13 +19,12 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.to.DataTO;
 
-public class IntroduceObjectCmd extends Command implements StorageSubSystemCommand {
-    private DataTO dataTO;
+public class IntroduceObjectCmd extends StorageSubSystemCommand {
+    private final DataTO dataTO;
 
-    public IntroduceObjectCmd(DataTO dataTO) {
+    public IntroduceObjectCmd(final DataTO dataTO) {
         this.dataTO = dataTO;
     }
 
@@ -39,7 +38,7 @@ public class IntroduceObjectCmd extends Command implements StorageSubSystemComma
     }
 
     @Override
-    public void setExecuteInSequence(boolean inSeq) {
+    public void setExecuteInSequence(final boolean inSeq) {
 
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java b/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java
index c599916..0a1a84d 100644
--- a/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java
+++ b/core/src/org/apache/cloudstack/storage/command/SnapshotAndCopyCommand.java
@@ -19,18 +19,16 @@
 
 package org.apache.cloudstack.storage.command;
 
-import com.cloud.agent.api.Command;
-
 import java.util.Map;
 
-public final class SnapshotAndCopyCommand extends Command implements StorageSubSystemCommand
{
-    private String _uuidOfSourceVdi;
-    private Map<String, String> _sourceDetails;
-    private Map<String, String> _destDetails;
+public final class SnapshotAndCopyCommand extends StorageSubSystemCommand {
+    private final String _uuidOfSourceVdi;
+    private final Map<String, String> _sourceDetails;
+    private final Map<String, String> _destDetails;
 
     private boolean _executeInSequence = true;
 
-    public SnapshotAndCopyCommand(String uuidOfSourceVdi, Map<String, String> sourceDetails,
Map<String, String> destDetails) {
+    public SnapshotAndCopyCommand(final String uuidOfSourceVdi, final Map<String, String>
sourceDetails, final Map<String, String> destDetails) {
         _uuidOfSourceVdi = uuidOfSourceVdi;
         _sourceDetails = sourceDetails;
         _destDetails = destDetails;
@@ -49,7 +47,7 @@ public final class SnapshotAndCopyCommand extends Command implements StorageSubS
     }
 
     @Override
-    public void setExecuteInSequence(boolean executeInSequence) {
+    public void setExecuteInSequence(final boolean executeInSequence) {
         _executeInSequence = executeInSequence;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java
index 5893f62..6507bb0 100644
--- a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java
+++ b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java
@@ -19,6 +19,8 @@
 
 package org.apache.cloudstack.storage.command;
 
-public interface StorageSubSystemCommand {
-    void setExecuteInSequence(boolean inSeq);
-}
+import com.cloud.agent.api.Command;
+
+public abstract class StorageSubSystemCommand extends Command {
+    abstract void setExecuteInSequence(boolean inSeq);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/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 e98e945..d7b4b18 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -45,7 +45,6 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
 import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
 import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
@@ -408,6 +407,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
         return _resizeVolumePath;
     }
 
+    public StorageSubsystemCommandHandler getStorageHandler() {
+        return storageHandler;
+    }
+
     private static final class KeyValueInterpreter extends OutputInterpreter {
         private final Map<String, String> map = new HashMap<String, String>();
 
@@ -1257,10 +1260,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements
Serv
         try {
             if (cmd instanceof StartCommand) {
                 return execute((StartCommand)cmd);
-            } else if (cmd instanceof NetworkElementCommand) {
-                return _virtRouterResource.executeRequest((NetworkElementCommand)cmd);
-            } else if (cmd instanceof StorageSubSystemCommand) {
-                return storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd);
             } else {
                 s_logger.warn("Unsupported command ");
                 return Answer.createUnsupportedCommandAnswer(cmd);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.java
new file mode 100644
index 0000000..3046b09
--- /dev/null
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtNetworkElementCommandWrapper.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.kvm.resource.wrapper;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.routing.NetworkElementCommand;
+import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
+import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
+import com.cloud.resource.CommandWrapper;
+
+public final class LibvirtNetworkElementCommandWrapper extends CommandWrapper<NetworkElementCommand,
Answer, LibvirtComputingResource> {
+
+    @Override
+    public Answer execute(final NetworkElementCommand command, final LibvirtComputingResource
libvirtComputingResource) {
+        final VirtualRoutingResource virtRouterResource = libvirtComputingResource.getVirtRouterResource();
+        return virtRouterResource.executeRequest(command);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java
index 363981d..e8b7b8c 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRequestWrapper.java
@@ -20,6 +20,8 @@ package com.cloud.hypervisor.kvm.resource.wrapper;
 
 import java.util.Hashtable;
 
+import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
+
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.AttachIsoCommand;
 import com.cloud.agent.api.AttachVolumeCommand;
@@ -70,6 +72,7 @@ import com.cloud.agent.api.UpgradeSnapshotCommand;
 import com.cloud.agent.api.check.CheckSshCommand;
 import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
 import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
+import com.cloud.agent.api.routing.NetworkElementCommand;
 import com.cloud.agent.api.storage.CopyVolumeCommand;
 import com.cloud.agent.api.storage.CreateCommand;
 import com.cloud.agent.api.storage.DestroyCommand;
@@ -150,6 +153,8 @@ public class LibvirtRequestWrapper extends RequestWrapper {
         linbvirtCommands.put(CopyVolumeCommand.class, new LibvirtCopyVolumeCommandWrapper());
         linbvirtCommands.put(PvlanSetupCommand.class, new LibvirtPvlanSetupCommandWrapper());
         linbvirtCommands.put(ResizeVolumeCommand.class, new LibvirtResizeVolumeCommandWrapper());
+        linbvirtCommands.put(NetworkElementCommand.class, new LibvirtNetworkElementCommandWrapper());
+        linbvirtCommands.put(StorageSubSystemCommand.class, new LibvirtStorageSubSystemCommandWrapper());
 
         resources.put(LibvirtComputingResource.class, linbvirtCommands);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.java
new file mode 100644
index 0000000..d2044ed
--- /dev/null
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStorageSubSystemCommandWrapper.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.hypervisor.kvm.resource.wrapper;
+
+import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.storage.resource.StorageSubsystemCommandHandler;
+
+public final class LibvirtStorageSubSystemCommandWrapper extends CommandWrapper<StorageSubSystemCommand,
Answer, LibvirtComputingResource> {
+
+    @Override
+    public Answer execute(final StorageSubSystemCommand command, final LibvirtComputingResource
libvirtComputingResource) {
+        final StorageSubsystemCommandHandler handler = libvirtComputingResource.getStorageHandler();
+        return handler.handleStorageCommands(command);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09656ca8/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
index 4e8d7bd..140262f 100644
--- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
+++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
@@ -46,6 +46,8 @@ import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
+import org.apache.cloudstack.storage.command.AttachAnswer;
+import org.apache.cloudstack.storage.command.AttachCommand;
 import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
 import org.apache.commons.lang.SystemUtils;
 import org.junit.Assert;
@@ -76,6 +78,8 @@ import com.cloud.agent.api.BackupSnapshotCommand;
 import com.cloud.agent.api.CheckHealthCommand;
 import com.cloud.agent.api.CheckNetworkCommand;
 import com.cloud.agent.api.CheckOnHostCommand;
+import com.cloud.agent.api.CheckRouterAnswer;
+import com.cloud.agent.api.CheckRouterCommand;
 import com.cloud.agent.api.CheckVirtualMachineCommand;
 import com.cloud.agent.api.CleanupNetworkRulesCmd;
 import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
@@ -152,6 +156,7 @@ import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StorageLayer;
 import com.cloud.storage.StoragePool;
 import com.cloud.storage.Volume;
+import com.cloud.storage.resource.StorageSubsystemCommandHandler;
 import com.cloud.storage.template.Processor;
 import com.cloud.storage.template.Processor.FormatInfo;
 import com.cloud.storage.template.TemplateLocation;
@@ -4506,4 +4511,38 @@ public class LibvirtComputingResourceTest {
 
         verify(libvirtComputingResource, times(1)).getStoragePoolMgr();
     }
+
+    @Test
+    public void testNetworkElementCommand() {
+        final CheckRouterCommand command = new CheckRouterCommand();
+
+        final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class);
+        when(libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource);
+
+        when(virtRouterResource.executeRequest(command)).thenReturn(new CheckRouterAnswer(command,
"mock_resource"));
+
+        final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
+        assertNotNull(wrapper);
+
+        final Answer answer = wrapper.execute(command, libvirtComputingResource);
+        assertFalse(answer.getResult());
+    }
+
+    @Test
+    public void testStorageSubSystemCommand() {
+        final DiskTO disk = Mockito.mock(DiskTO.class);
+        final String vmName = "Test";
+        final AttachCommand command = new AttachCommand(disk, vmName);
+
+        final StorageSubsystemCommandHandler handler = Mockito.mock(StorageSubsystemCommandHandler.class);
+        when(libvirtComputingResource.getStorageHandler()).thenReturn(handler);
+
+        when(handler.handleStorageCommands(command)).thenReturn(new AttachAnswer(disk));
+
+        final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
+        assertNotNull(wrapper);
+
+        final Answer answer = wrapper.execute(command, libvirtComputingResource);
+        assertTrue(answer.getResult());
+    }
 }
\ No newline at end of file


Mime
View raw message