cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [6/7] git commit: updated refs/heads/master to 7e41747
Date Thu, 12 May 2016 15:08:00 GMT
CLOUDSTACK-8813: Notify listeners when a host has been added to a cluster, is about to be removed from a cluster, or has been removed from a cluster


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

Branch: refs/heads/master
Commit: dad9e5d86835ccdaa39a3c62047b7fce3a32de6d
Parents: bee2bdc
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Thu Aug 13 18:44:12 2015 -0600
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Wed May 11 08:02:46 2016 -0600

----------------------------------------------------------------------
 .../agent/api/CreateStoragePoolCommand.java     |    7 +-
 .../agent/api/ModifyStoragePoolAnswer.java      |   37 +-
 .../agent/api/ModifyStoragePoolCommand.java     |   46 +-
 .../cloud/agent/api/ModifyTargetsAnswer.java    |   23 +
 .../cloud/agent/api/ModifyTargetsCommand.java   |   57 +
 .../api/storage/DataStoreProviderManager.java   |    4 +
 .../api/storage/HypervisorHostListener.java     |    6 +
 .../api/storage/PrimaryDataStoreDriver.java     |   16 +-
 .../src/com/cloud/agent/AgentManager.java       |   10 +-
 .../src/com/cloud/agent/Listener.java           |   18 +
 .../com/cloud/agent/manager/AgentAttache.java   |    8 +-
 .../cloud/agent/manager/AgentManagerImpl.java   |   53 +-
 .../agent/manager/SynchronousListener.java      |   12 +
 .../com/cloud/vm/VirtualMachineManagerImpl.java |   12 +
 .../orchestration/NetworkOrchestrator.java      |   11 +
 .../datastore/db/PrimaryDataStoreDao.java       |    2 +
 .../datastore/db/PrimaryDataStoreDaoImpl.java   |    8 +
 .../test/DirectAgentManagerSimpleImpl.java      |    9 +-
 .../cloudstack/storage/RemoteHostEndPoint.java  |   12 +
 .../provider/DataStoreProviderManagerImpl.java  |    1 +
 .../datastore/provider/DefaultHostListener.java |   14 +
 .../discoverer/HypervServerDiscoverer.java      |   12 +
 .../ovm3/resources/Ovm3Discoverer.java          |   12 +
 .../com/cloud/resource/SimulatorDiscoverer.java |   12 +
 .../resource/SimulatorSecondaryDiscoverer.java  |   12 +
 .../vmware/manager/VmwareManagerImpl.java       |   12 +
 .../vmware/resource/VmwareResource.java         |   51 +-
 .../resource/VmwareStorageProcessor.java        |   78 +-
 .../discoverer/XcpServerDiscoverer.java         |   17 +-
 .../CitrixModifyStoragePoolCommandWrapper.java  |    5 +-
 .../network/manager/NuageVspManagerImpl.java    |   15 +
 .../provider/ElastistorHostListener.java        |   14 +
 .../datastore/provider/NexentaHostListener.java |   29 +-
 .../driver/SolidFirePrimaryDataStoreDriver.java |   27 +-
 .../SolidFirePrimaryDataStoreLifeCycle.java     |    6 +-
 ...olidFireSharedPrimaryDataStoreLifeCycle.java |   62 +-
 .../provider/SolidFireHostListener.java         |  230 ++-
 .../provider/SolidFireSharedHostListener.java   |  181 +-
 .../storage/datastore/util/SolidFireUtil.java   |  129 +-
 .../com/cloud/capacity/CapacityManagerImpl.java |   12 +
 .../cloud/capacity/ComputeCapacityListener.java |   12 +
 .../cloud/capacity/StorageCapacityListener.java |   12 +
 .../consoleproxy/ConsoleProxyListener.java      |   12 +
 .../deploy/DeploymentPlanningManagerImpl.java   |   12 +
 .../kvm/discoverer/LibvirtServerDiscoverer.java |   12 +
 .../cloud/network/NetworkUsageManagerImpl.java  |   12 +
 .../com/cloud/network/SshKeysDistriMonitor.java |   16 +-
 .../VirtualNetworkApplianceManagerImpl.java     |  229 +--
 .../network/security/SecurityGroupListener.java |   16 +-
 .../com/cloud/resource/ResourceManagerImpl.java |   59 +-
 .../storage/ImageStoreUploadMonitorImpl.java    |   12 +
 .../cloud/storage/LocalStoragePoolListener.java |   30 +-
 .../com/cloud/storage/StorageManagerImpl.java   |    2 +-
 .../storage/download/DownloadListener.java      |   18 +-
 .../storage/listener/StoragePoolMonitor.java    |   83 +-
 .../storage/listener/StorageSyncListener.java   |   12 +
 .../secondary/SecondaryStorageListener.java     |   12 +
 .../cloud/storage/upload/UploadListener.java    |   15 +-
 .../plugins/solidfire/TestAddRemoveHosts.py     |  710 ++++++++
 .../plugins/solidfire/TestSnapshots.py          | 1472 +++++++++++++++
 .../plugins/solidfire/TestVMSnapshots.py        |  862 +++++++++
 .../plugins/solidfire/TestVolumes.py            | 1676 ++++++++++++++++++
 ui/scripts/system.js                            |    7 +-
 63 files changed, 6210 insertions(+), 375 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/core/src/com/cloud/agent/api/CreateStoragePoolCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/CreateStoragePoolCommand.java b/core/src/com/cloud/agent/api/CreateStoragePoolCommand.java
index 90a5e39..52746fe 100644
--- a/core/src/com/cloud/agent/api/CreateStoragePoolCommand.java
+++ b/core/src/com/cloud/agent/api/CreateStoragePoolCommand.java
@@ -19,10 +19,10 @@
 
 package com.cloud.agent.api;
 
-import com.cloud.storage.StoragePool;
-
 import java.util.Map;
 
+import com.cloud.storage.StoragePool;
+
 public class CreateStoragePoolCommand extends ModifyStoragePoolCommand {
     public static final String DATASTORE_NAME = "datastoreName";
     public static final String IQN = "iqn";
@@ -32,9 +32,6 @@ public class CreateStoragePoolCommand extends ModifyStoragePoolCommand {
     private boolean _createDatastore;
     private Map<String, String> _details;
 
-    public CreateStoragePoolCommand() {
-    }
-
     public CreateStoragePoolCommand(boolean add, StoragePool pool) {
         super(add, pool);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/core/src/com/cloud/agent/api/ModifyStoragePoolAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ModifyStoragePoolAnswer.java b/core/src/com/cloud/agent/api/ModifyStoragePoolAnswer.java
index b92bb72..0e42d9a 100644
--- a/core/src/com/cloud/agent/api/ModifyStoragePoolAnswer.java
+++ b/core/src/com/cloud/agent/api/ModifyStoragePoolAnswer.java
@@ -24,44 +24,41 @@ import java.util.Map;
 import com.cloud.storage.template.TemplateProp;
 
 public class ModifyStoragePoolAnswer extends Answer {
-    StoragePoolInfo poolInfo;
-    Map<String, TemplateProp> templateInfo;
-    String localDatastoreName = null;
-
-    protected ModifyStoragePoolAnswer() {
-    }
+    private StoragePoolInfo _poolInfo;
+    private Map<String, TemplateProp> _templateInfo;
+    private String _localDatastoreName;
 
     public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, long capacityBytes, long availableBytes, Map<String, TemplateProp> tInfo) {
         super(cmd);
-        this.result = true;
-        this.poolInfo =
-            new StoragePoolInfo(null, cmd.getPool().getHost(), cmd.getPool().getPath(), cmd.getLocalPath(), cmd.getPool().getType(), capacityBytes, availableBytes);
 
-        this.templateInfo = tInfo;
-    }
+        result = true;
 
-    public StoragePoolInfo getPoolInfo() {
-        return poolInfo;
+        _poolInfo = new StoragePoolInfo(null, cmd.getPool().getHost(), cmd.getPool().getPath(), cmd.getLocalPath(), cmd.getPool().getType(), capacityBytes, availableBytes);
+
+        _templateInfo = tInfo;
     }
 
     public void setPoolInfo(StoragePoolInfo poolInfo) {
-        this.poolInfo = poolInfo;
+        _poolInfo = poolInfo;
     }
 
-    public Map<String, TemplateProp> getTemplateInfo() {
-        return templateInfo;
+    public StoragePoolInfo getPoolInfo() {
+        return _poolInfo;
     }
 
     public void setTemplateInfo(Map<String, TemplateProp> templateInfo) {
-        this.templateInfo = templateInfo;
+        _templateInfo = templateInfo;
     }
 
-    public String getLocalDatastoreName() {
-        return localDatastoreName;
+    public Map<String, TemplateProp> getTemplateInfo() {
+        return _templateInfo;
     }
 
     public void setLocalDatastoreName(String localDatastoreName) {
-        this.localDatastoreName = localDatastoreName;
+        _localDatastoreName = localDatastoreName;
     }
 
+    public String getLocalDatastoreName() {
+        return _localDatastoreName;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/core/src/com/cloud/agent/api/ModifyStoragePoolCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ModifyStoragePoolCommand.java b/core/src/com/cloud/agent/api/ModifyStoragePoolCommand.java
index 136eb09..9ec4a27 100644
--- a/core/src/com/cloud/agent/api/ModifyStoragePoolCommand.java
+++ b/core/src/com/cloud/agent/api/ModifyStoragePoolCommand.java
@@ -26,51 +26,49 @@ import com.cloud.agent.api.to.StorageFilerTO;
 import com.cloud.storage.StoragePool;
 
 public class ModifyStoragePoolCommand extends Command {
-
-    boolean add;
-    StorageFilerTO pool;
-    String localPath;
-    String[] options;
     public static final String LOCAL_PATH_PREFIX = "/mnt/";
 
-    public ModifyStoragePoolCommand() {
-
-    }
+    private boolean _add;
+    private StorageFilerTO _pool;
+    private String _localPath;
+    private String _storagePath;
 
     public ModifyStoragePoolCommand(boolean add, StoragePool pool, String localPath) {
-        this.add = add;
-        this.pool = new StorageFilerTO(pool);
-        this.localPath = localPath;
-
+        _add = add;
+        _pool = new StorageFilerTO(pool);
+        _localPath = localPath;
     }
 
     public ModifyStoragePoolCommand(boolean add, StoragePool pool) {
         this(add, pool, LOCAL_PATH_PREFIX + File.separator + UUID.nameUUIDFromBytes((pool.getHostAddress() + pool.getPath()).getBytes()));
     }
 
-    public StorageFilerTO getPool() {
-        return pool;
+    public boolean getAdd() {
+        return _add;
     }
 
     public void setPool(StoragePool pool) {
-        this.pool = new StorageFilerTO(pool);
+        _pool = new StorageFilerTO(pool);
     }
 
-    public boolean getAdd() {
-        return add;
+    public StorageFilerTO getPool() {
+        return _pool;
     }
 
-    @Override
-    public boolean executeInSequence() {
-        return false;
+    public String getLocalPath() {
+        return _localPath;
     }
 
-    public String getLocalPath() {
-        return localPath;
+    public void setStoragePath(String storagePath) {
+        _storagePath = storagePath;
     }
 
-    public void setOptions(String[] options) {
-        this.options = options;
+    public String getStoragePath() {
+        return _storagePath;
     }
 
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/core/src/com/cloud/agent/api/ModifyTargetsAnswer.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ModifyTargetsAnswer.java b/core/src/com/cloud/agent/api/ModifyTargetsAnswer.java
new file mode 100644
index 0000000..c192e4a
--- /dev/null
+++ b/core/src/com/cloud/agent/api/ModifyTargetsAnswer.java
@@ -0,0 +1,23 @@
+//
+// 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 ModifyTargetsAnswer extends Answer {
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/core/src/com/cloud/agent/api/ModifyTargetsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/ModifyTargetsCommand.java b/core/src/com/cloud/agent/api/ModifyTargetsCommand.java
new file mode 100644
index 0000000..721516b
--- /dev/null
+++ b/core/src/com/cloud/agent/api/ModifyTargetsCommand.java
@@ -0,0 +1,57 @@
+//
+// 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;
+
+import java.util.List;
+import java.util.Map;
+
+public class ModifyTargetsCommand extends Command {
+    public static final String IQN = "iqn";
+    public static final String STORAGE_HOST = "storageHost";
+    public static final String STORAGE_PORT = "storagePort";
+    public static final String CHAP_NAME = "chapName";
+    public static final String CHAP_SECRET = "chapSecret";
+    public static final String MUTUAL_CHAP_NAME = "mutualChapName";
+    public static final String MUTUAL_CHAP_SECRET = "mutualChapSecret";
+
+    private boolean _add;
+    private List<Map<String, String>> _targets;
+
+    public void setAdd(boolean add) {
+        _add = add;
+    }
+
+    public boolean getAdd() {
+        return _add;
+    }
+
+    public void setTargets(List<Map<String, String>> targets) {
+        _targets = targets;
+    }
+
+    public List<Map<String, String>> getTargets() {
+        return _targets;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
index d643d7f..e476d8f 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreProviderManager.java
@@ -18,6 +18,8 @@
  */
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
+import java.util.List;
+
 import com.cloud.storage.DataStoreProviderApiService;
 import com.cloud.utils.component.Manager;
 
@@ -29,4 +31,6 @@ public interface DataStoreProviderManager extends Manager, DataStoreProviderApiS
     DataStoreProvider getDefaultImageDataStoreProvider();
 
     DataStoreProvider getDefaultCacheDataStoreProvider();
+
+    List<DataStoreProvider> getProviders();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HypervisorHostListener.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HypervisorHostListener.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HypervisorHostListener.java
index 82ba8b6..d7e8522 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HypervisorHostListener.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/HypervisorHostListener.java
@@ -21,7 +21,13 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
 import com.cloud.exception.StorageConflictException;
 
 public interface HypervisorHostListener {
+    boolean hostAdded(long hostId);
+
     boolean hostConnect(long hostId, long poolId) throws StorageConflictException;
 
     boolean hostDisconnected(long hostId, long poolId);
+
+    boolean hostAboutToBeRemoved(long hostId);
+
+    boolean hostRemoved(long hostId, long clusterId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java
index 0c6bd93..e0c0d28 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreDriver.java
@@ -26,27 +26,27 @@ import com.cloud.storage.StoragePool;
 import com.cloud.storage.Volume;
 
 public interface PrimaryDataStoreDriver extends DataStoreDriver {
-    public ChapInfo getChapInfo(VolumeInfo volumeInfo);
+    ChapInfo getChapInfo(VolumeInfo volumeInfo);
 
-    public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore);
+    boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore);
 
-    public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
+    void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
 
     // intended for managed storage (cloud.storage_pool.managed = true)
     // if not managed, return volume.getSize()
-    public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool storagePool);
+    long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool storagePool);
 
     // intended for managed storage (cloud.storage_pool.managed = true)
     // if managed storage, return the total number of bytes currently in use for the storage pool in question
     // if not managed storage, return 0
-    public long getUsedBytes(StoragePool storagePool);
+    long getUsedBytes(StoragePool storagePool);
 
     // intended for managed storage (cloud.storage_pool.managed = true)
     // if managed storage, return the total number of IOPS currently in use for the storage pool in question
     // if not managed storage, return 0
-    public long getUsedIops(StoragePool storagePool);
+    long getUsedIops(StoragePool storagePool);
 
-    public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
+    void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
 
-    public void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback);
+    void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/components-api/src/com/cloud/agent/AgentManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/agent/AgentManager.java b/engine/components-api/src/com/cloud/agent/AgentManager.java
index e9e3249..244772d 100644
--- a/engine/components-api/src/com/cloud/agent/AgentManager.java
+++ b/engine/components-api/src/com/cloud/agent/AgentManager.java
@@ -42,7 +42,7 @@ public interface AgentManager {
         Add, Del, Contains,
     }
 
-    boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException;
+    boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance, boolean newHost) throws ConnectionException;
 
     /**
      * easy send method that returns null if there's any errors. It handles all exceptions.
@@ -131,8 +131,6 @@ public interface AgentManager {
 
     Answer sendTo(Long dcId, HypervisorType type, Command cmd);
 
-//    public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException;
-
     public boolean agentStatusTransitTo(HostVO host, Status.Event e, long msId);
 
     boolean isAgentAttached(long hostId);
@@ -146,4 +144,10 @@ public interface AgentManager {
     boolean reconnect(long hostId);
 
     void rescan();
+
+    void notifyMonitorsOfNewlyAddedHost(long hostId);
+
+    void notifyMonitorsOfHostAboutToBeRemoved(long hostId);
+
+    void notifyMonitorsOfRemovedHost(long hostId, long clusterId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/components-api/src/com/cloud/agent/Listener.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/agent/Listener.java b/engine/components-api/src/com/cloud/agent/Listener.java
index 242f90c..843a634 100644
--- a/engine/components-api/src/com/cloud/agent/Listener.java
+++ b/engine/components-api/src/com/cloud/agent/Listener.java
@@ -64,6 +64,12 @@ public interface Listener {
     AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd);
 
     /**
+     * This method is called by AgentManager when a host is added to a cluster.
+     * @param long the ID of the newly added host
+     */
+    void processHostAdded(long hostId);
+
+    /**
      * This method is called by AgentManager when an agent made a
      * connection to this server if the listener has
      * been registered for host events.
@@ -87,6 +93,18 @@ public interface Listener {
     boolean processDisconnect(long agentId, Status state);
 
     /**
+     * This method is called by AgentManager when a host is about to be removed from a cluster.
+     * @param long the ID of the host that's about to be removed
+     */
+    void processHostAboutToBeRemoved(long hostId);
+
+    /**
+     * This method is called by AgentManager when a host is removed from a cluster.
+     * @param long the ID of the newly removed host
+     */
+    void processHostRemoved(long hostId, long clusterId);
+
+    /**
      * If this Listener is passed to the send() method, this method
      * is called by AgentManager after processing an answer
      * from the agent.  Returning true means you're expecting more

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java
index 0acac3c..d5ec900 100644
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java
@@ -44,6 +44,7 @@ import com.cloud.agent.api.CleanupNetworkRulesCmd;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.MaintainCommand;
 import com.cloud.agent.api.MigrateCommand;
+import com.cloud.agent.api.ModifyTargetsCommand;
 import com.cloud.agent.api.PingTestCommand;
 import com.cloud.agent.api.PvlanSetupCommand;
 import com.cloud.agent.api.ReadyCommand;
@@ -109,11 +110,12 @@ public abstract class AgentAttache {
 
     protected AgentManagerImpl _agentMgr;
 
-    public final static String[] s_commandsAllowedInMaintenanceMode = new String[] {MaintainCommand.class.toString(), MigrateCommand.class.toString(),
+    public final static String[] s_commandsAllowedInMaintenanceMode = new String[] { MaintainCommand.class.toString(), MigrateCommand.class.toString(),
         StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(),
         ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(),
-        CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString()};
-    protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] {StartCommand.class.toString(), CreateCommand.class.toString()};
+        CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString(),
+        ModifyTargetsCommand.class.toString() };
+    protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] { StartCommand.class.toString(), CreateCommand.class.toString() };
     static {
         Arrays.sort(s_commandsAllowedInMaintenanceMode);
         Arrays.sort(s_commandsNotAllowedInConnectingMode);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
index 45a7dca..efd9eed 100644
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -538,6 +538,17 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
         }
     }
 
+    @Override
+    public void notifyMonitorsOfNewlyAddedHost(long hostId) {
+        for (final Pair<Integer, Listener> monitor : _hostMonitors) {
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Sending host added to listener: " + monitor.second().getClass().getSimpleName());
+            }
+
+            monitor.second().processHostAdded(hostId);
+        }
+    }
+
     protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, final StartupCommand[] cmd, final boolean forRebalance) throws ConnectionException {
         final long hostId = attache.getId();
         final HostVO host = _hostDao.findById(hostId);
@@ -1001,6 +1012,28 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
         return true;
     }
 
+    @Override
+    public void notifyMonitorsOfHostAboutToBeRemoved(long hostId) {
+        for (final Pair<Integer, Listener> monitor : _hostMonitors) {
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Sending host about to be removed to listener: " + monitor.second().getClass().getSimpleName());
+            }
+
+            monitor.second().processHostAboutToBeRemoved(hostId);
+        }
+    }
+
+    @Override
+    public void notifyMonitorsOfRemovedHost(long hostId, long clusterId) {
+        for (final Pair<Integer, Listener> monitor : _hostMonitors) {
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Sending host removed to listener: " + monitor.second().getClass().getSimpleName());
+            }
+
+            monitor.second().processHostRemoved(hostId, clusterId);
+        }
+    }
+
     public boolean executeUserRequest(final long hostId, final Event event) throws AgentUnavailableException {
         if (event == Event.AgentDisconnected) {
             if (s_logger.isDebugEnabled()) {
@@ -1464,7 +1497,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
     }
 
     @Override
-    public boolean handleDirectConnectAgent(final Host host, final StartupCommand[] cmds, final ServerResource resource, final boolean forRebalance) throws ConnectionException {
+    public boolean handleDirectConnectAgent(final Host host, final StartupCommand[] cmds, final ServerResource resource,
+            final boolean forRebalance, boolean newHost) throws ConnectionException {
         AgentAttache attache;
 
         attache = createAttacheForDirectConnect(host, resource);
@@ -1473,6 +1507,11 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
             answers[i] = new StartupAnswer(cmds[i], attache.getId(), PingInterval.value());
         }
         attache.process(answers);
+
+        if (newHost) {
+            notifyMonitorsOfNewlyAddedHost(host.getId());
+        }
+
         attache = notifyMonitorsOfConnection(attache, cmds, forRebalance);
 
         return attache != null;
@@ -1618,6 +1657,10 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
         }
 
         @Override
+        public void processHostAdded(long hostId) {
+        }
+
+        @Override
         public void processConnect(final Host host, final StartupCommand cmd, final boolean forRebalance) {
             if (host.getType().equals(Host.Type.TrafficMonitor) || host.getType().equals(Host.Type.SecondaryStorage)) {
                 return;
@@ -1634,6 +1677,14 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
         }
 
         @Override
+        public void processHostAboutToBeRemoved(long hostId) {
+        }
+
+        @Override
+        public void processHostRemoved(long hostId, long clusterId) {
+        }
+
+        @Override
         public boolean processTimeout(final long agentId, final long seq) {
             return true;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java b/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java
index 28c60c1..96d4077 100644
--- a/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/SynchronousListener.java
@@ -79,6 +79,18 @@ public class SynchronousListener implements Listener {
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
+    public void processHostAdded(long hostId) {
+    }
+
+    @Override
     public void processConnect(Host agent, StartupCommand cmd, boolean forRebalance) {
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/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 43228e8..9523b92 100644
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -2787,6 +2787,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
+    public void processHostAdded(long hostId) {
+    }
+
+    @Override
     public void processConnect(final Host agent, final StartupCommand cmd, final boolean forRebalance) throws ConnectionException {
         if (!(cmd instanceof StartupRoutingCommand)) {
             return;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index e427272..66185c6 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -3001,6 +3001,9 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         return null;
     }
 
+    public void processHostAdded(long hostId) {
+    }
+
     @Override
     public void processConnect(final Host host, final StartupCommand cmd, final boolean forRebalance) throws ConnectionException {
         if (!(cmd instanceof StartupRoutingCommand)) {
@@ -3089,6 +3092,14 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
     public boolean isRecurring() {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
index d265da1..32d1d79 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
@@ -64,6 +64,8 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
      */
     List<StoragePoolVO> findPoolByName(String name);
 
+    List<StoragePoolVO> findPoolsByProvider(String provider);
+
     /**
      * Find pools by the pod that matches the details.
      *

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
index fd617cc..c451e1d 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -79,6 +79,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
         AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
         AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
         AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ);
+        AllFieldSearch.and("storage_provider_name", AllFieldSearch.entity().getStorageProviderName(), Op.EQ);
         AllFieldSearch.done();
 
         DcPodSearch = createSearchBuilder();
@@ -129,6 +130,13 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
     }
 
     @Override
+    public List<StoragePoolVO> findPoolsByProvider(String provider) {
+        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
+        sc.setParameters("storage_provider_name", provider);
+        return listBy(sc);
+    }
+
+    @Override
     public StoragePoolVO findPoolByUUID(String uuid) {
         SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
         sc.setParameters("uuid", uuid);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java
index b34b697..0e4755e 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/DirectAgentManagerSimpleImpl.java
@@ -278,9 +278,16 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
     }
 
     @Override
-    public boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException {
+    public boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance, boolean newHost) throws ConnectionException {
         // TODO Auto-generated method stub
         return false;
     }
 
+    @Override
+    public void notifyMonitorsOfHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void notifyMonitorsOfRemovedHost(long hostId, long clusterId) {
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java b/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
index 1f59cc6..3bad62e 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/RemoteHostEndPoint.java
@@ -161,6 +161,10 @@ public class RemoteHostEndPoint implements EndPoint {
         }
 
         @Override
+        public void processHostAdded(long hostId) {
+        }
+
+        @Override
         public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
             // TODO Auto-generated method stub
 
@@ -173,6 +177,14 @@ public class RemoteHostEndPoint implements EndPoint {
         }
 
         @Override
+        public void processHostAboutToBeRemoved(long hostId) {
+        }
+
+        @Override
+        public void processHostRemoved(long hostId, long clusterId) {
+        }
+
+        @Override
         public boolean isRecurring() {
             // TODO Auto-generated method stub
             return false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
index 6e36514..98eeb6b 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
@@ -218,6 +218,7 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
         this.imageStoreProviderMgr = imageDataStoreProviderMgr;
     }
 
+    @Override
     public List<DataStoreProvider> getProviders() {
         return providers;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
index 89af076..64533d5 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
@@ -55,6 +55,11 @@ public class DefaultHostListener implements HypervisorHostListener {
     PrimaryDataStoreDao primaryStoreDao;
 
     @Override
+    public boolean hostAdded(long hostId) {
+        return true;
+    }
+
+    @Override
     public boolean hostConnect(long hostId, long poolId) throws StorageConflictException {
         StoragePool pool = (StoragePool)this.dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
         ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
@@ -109,4 +114,13 @@ public class DefaultHostListener implements HypervisorHostListener {
         return false;
     }
 
+    @Override
+    public boolean hostAboutToBeRemoved(long hostId) {
+        return true;
+    }
+
+    @Override
+    public boolean hostRemoved(long hostId, long clusterId) {
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
index fd8db4a..fd54d43 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
@@ -107,6 +107,10 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
     }
 
     @Override
+    public void processHostAdded(long hostId) {
+    }
+
+    @Override
     public final void processConnect(final Host agent, final StartupCommand cmd, final boolean forRebalance) throws ConnectionException {
         // Limit the commands we can process
         if (!(cmd instanceof StartupRoutingCommand)) {
@@ -177,6 +181,14 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
     public final boolean isRecurring() {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java
index 4743600..3f24527 100755
--- a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3Discoverer.java
@@ -338,6 +338,10 @@ public class Ovm3Discoverer extends DiscovererBase implements Discoverer,
         return null;
     }
 
+    @Override
+    public void processHostAdded(long hostId) {
+    }
+
     /* for reconnecting */
     @Override
     public void processConnect(Host host, StartupCommand cmd,
@@ -352,6 +356,14 @@ public class Ovm3Discoverer extends DiscovererBase implements Discoverer,
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
     public boolean isRecurring() {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
index 76eb1c0..c942c8f 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
@@ -246,6 +246,10 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
     }
 
     @Override
+    public void processHostAdded(long hostId) {
+    }
+
+    @Override
     public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
 
         /*if(forRebalance)
@@ -274,6 +278,14 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
     public boolean isRecurring() {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
index 6e75244..e09a5a9 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
@@ -141,6 +141,10 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
     }
 
     @Override
+    public void processHostAdded(long hostId) {
+    }
+
+    @Override
     public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
 
     }
@@ -156,6 +160,14 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
     public boolean processTimeout(long agentId, long seq) {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index f27e938..63124e1 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -842,6 +842,10 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
     }
 
     @Override
+    public void processHostAdded(long hostId) {
+    }
+
+    @Override
     public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) {
         if (cmd instanceof StartupCommand) {
             if (host.getHypervisorType() == HypervisorType.VMware) {
@@ -883,6 +887,14 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
     public boolean isRecurring() {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/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 14a73bb..82e7f65 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -148,6 +148,8 @@ import com.cloud.agent.api.MigrateWithStorageCommand;
 import com.cloud.agent.api.ModifySshKeysCommand;
 import com.cloud.agent.api.ModifyStoragePoolAnswer;
 import com.cloud.agent.api.ModifyStoragePoolCommand;
+import com.cloud.agent.api.ModifyTargetsAnswer;
+import com.cloud.agent.api.ModifyTargetsCommand;
 import com.cloud.agent.api.NetworkUsageAnswer;
 import com.cloud.agent.api.NetworkUsageCommand;
 import com.cloud.agent.api.PingCommand;
@@ -409,6 +411,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 answer = execute((DestroyCommand)cmd);
             } else if (clz == CreateStoragePoolCommand.class) {
                 return execute((CreateStoragePoolCommand)cmd);
+            } else if (clz == ModifyTargetsCommand.class) {
+                answer = execute((ModifyTargetsCommand)cmd);
             } else if (clz == ModifyStoragePoolCommand.class) {
                 answer = execute((ModifyStoragePoolCommand)cmd);
             } else if (clz == DeleteStoragePoolCommand.class) {
@@ -933,7 +937,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
              */
             // Fallback to E1000 if no specific nicAdapter is passed
             VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.E1000;
-            Map details = cmd.getDetails();
+            Map<String, String> details = cmd.getDetails();
             if (details != null) {
                 nicDeviceType = VirtualEthernetCardType.valueOf((String) details.get("nicAdapter"));
             }
@@ -3527,7 +3531,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
     private Answer execute(MigrateVolumeCommand cmd) {
         String volumePath = cmd.getVolumePath();
         StorageFilerTO poolTo = cmd.getPool();
-        Volume.Type volumeType = cmd.getVolumeType();
 
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing resource MigrateVolumeCommand: " + _gson.toJson(cmd));
@@ -3608,7 +3611,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             // Consolidate VM disks.
             // In case of a linked clone VM, if VM's disks are not consolidated,
             // further volume operations on the ROOT volume such as volume snapshot etc. will result in DB inconsistencies.
-            String apiVersion = HypervisorHostHelper.getVcenterApiVersion(vmMo.getContext());
             if (!vmMo.consolidateVmDisks()) {
                 s_logger.warn("VM disk consolidation failed after storage migration.");
             } else {
@@ -3677,6 +3679,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         return new Answer(cmd, true, "success");
     }
 
+    protected Answer execute(ModifyTargetsCommand cmd) {
+        VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
+
+        handleTargets(cmd.getAdd(), cmd.getTargets(), (HostMO)hyperHost);
+
+        return new ModifyTargetsAnswer();
+    }
+
     protected Answer execute(ModifyStoragePoolCommand cmd) {
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing resource ModifyStoragePoolCommand: " + _gson.toJson(cmd));
@@ -3690,34 +3700,53 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                 throw new Exception("Unsupported storage pool type " + pool.getType());
             }
 
-            ManagedObjectReference morDatastore = null;
-            morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
-            if (morDatastore == null)
-                morDatastore =
-                hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(), pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
+            ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
+
+            if (morDatastore == null) {
+                morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(), pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
+            }
 
             assert (morDatastore != null);
+
             DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary();
+
             long capacity = summary.getCapacity();
             long available = summary.getFreeSpace();
+
             Map<String, TemplateProp> tInfo = new HashMap<String, TemplateProp>();
             ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, capacity, available, tInfo);
+
             if (cmd.getAdd() && pool.getType() == StoragePoolType.VMFS) {
                 answer.setLocalDatastoreName(morDatastore.getValue());
             }
+
             return answer;
         } catch (Throwable e) {
             if (e instanceof RemoteException) {
                 s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+
                 invalidateServiceContext();
             }
 
             String msg = "ModifyStoragePoolCommand failed due to " + VmwareHelper.getExceptionMessage(e);
+
             s_logger.error(msg, e);
+
             return new Answer(cmd, false, msg);
         }
     }
 
+    private void handleTargets(boolean add, List<Map<String, String>> targets, HostMO host) {
+        if (targets != null && targets.size() > 0) {
+            try {
+                _storageProcessor.handleTargetsForHost(add, targets, host);
+            }
+            catch (Exception ex) {
+                s_logger.warn(ex.getMessage());
+            }
+        }
+    }
+
     protected Answer execute(DeleteStoragePoolCommand cmd) {
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing resource DeleteStoragePoolCommand: " + _gson.toJson(cmd));
@@ -4701,12 +4730,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         }
     }
 
-    private boolean isVmInCluster(String vmName) throws Exception {
-        VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
-
-        return hyperHost.findVmOnPeerHyperHost(vmName) != null;
-    }
-
     protected OptionValue[] configureVnc(OptionValue[] optionsToMerge, VmwareHypervisorHost hyperHost, String vmName, String vncPassword, String keyboardLayout)
             throws Exception {
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
index 310313a..21f79f9 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
@@ -71,6 +71,7 @@ import org.apache.cloudstack.storage.to.VolumeObjectTO;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
+import com.cloud.agent.api.ModifyTargetsCommand;
 import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
 import com.cloud.agent.api.to.DiskTO;
@@ -1911,14 +1912,77 @@ public class VmwareStorageProcessor implements StorageProcessor {
         return (int)(bytes / (1024L * 1024L));
     }
 
-    private void addRemoveInternetScsiTargetsToAllHosts(VmwareContext context, final boolean add, final List<HostInternetScsiHbaStaticTarget> lstTargets,
-            List<Pair<ManagedObjectReference, String>> lstHosts) throws Exception {
-        ExecutorService executorService = Executors.newFixedThreadPool(lstHosts.size());
+    public void handleTargetsForHost(boolean add, List<Map<String, String>> targets, HostMO host) throws Exception {
+        List<HostInternetScsiHbaStaticTarget> lstTargets = new ArrayList<HostInternetScsiHbaStaticTarget>();
 
-        final List<Exception> exceptions = new ArrayList<Exception>();
+        for (Map<String, String> mapTarget : targets) {
+            HostInternetScsiHbaStaticTarget target = new HostInternetScsiHbaStaticTarget();
 
-        for (Pair<ManagedObjectReference, String> hostPair : lstHosts) {
+            String targetAddress = mapTarget.get(ModifyTargetsCommand.STORAGE_HOST);
+            Integer targetPort = Integer.parseInt(mapTarget.get(ModifyTargetsCommand.STORAGE_PORT));
+            String iScsiName = trimIqn(mapTarget.get(ModifyTargetsCommand.IQN));
+
+            target.setAddress(targetAddress);
+            target.setPort(targetPort);
+            target.setIScsiName(iScsiName);
+
+            String chapName = mapTarget.get(ModifyTargetsCommand.CHAP_NAME);
+            String chapSecret = mapTarget.get(ModifyTargetsCommand.CHAP_SECRET);
+
+            if (StringUtils.isNotBlank(chapName) && StringUtils.isNotBlank(chapSecret)) {
+                HostInternetScsiHbaAuthenticationProperties auth = new HostInternetScsiHbaAuthenticationProperties();
+
+                String strAuthType = "chapRequired";
+
+                auth.setChapAuthEnabled(true);
+                auth.setChapInherited(false);
+                auth.setChapAuthenticationType(strAuthType);
+                auth.setChapName(chapName);
+                auth.setChapSecret(chapSecret);
+
+                String mutualChapName = mapTarget.get(ModifyTargetsCommand.MUTUAL_CHAP_NAME);
+                String mutualChapSecret = mapTarget.get(ModifyTargetsCommand.MUTUAL_CHAP_SECRET);
+
+                if (StringUtils.isNotBlank(mutualChapName) && StringUtils.isNotBlank(mutualChapSecret)) {
+                    auth.setMutualChapInherited(false);
+                    auth.setMutualChapAuthenticationType(strAuthType);
+                    auth.setMutualChapName(mutualChapName);
+                    auth.setMutualChapSecret(mutualChapSecret);
+                }
+
+                target.setAuthenticationProperties(auth);
+            }
+
+            lstTargets.add(target);
+        }
+
+        List<HostMO> hosts = new ArrayList<>();
+
+        hosts.add(host);
+
+        addRemoveInternetScsiTargetsToAllHosts(add, lstTargets, hosts);
+    }
+
+    private void addRemoveInternetScsiTargetsToAllHosts(VmwareContext context, final boolean add, final List<HostInternetScsiHbaStaticTarget> targets,
+            List<Pair<ManagedObjectReference, String>> hostPairs) throws Exception {
+        List<HostMO> hosts = new ArrayList<>();
+
+        for (Pair<ManagedObjectReference, String> hostPair : hostPairs) {
             HostMO host = new HostMO(context, hostPair.first());
+
+            hosts.add(host);
+        }
+
+        addRemoveInternetScsiTargetsToAllHosts(add, targets, hosts);
+    }
+
+    private void addRemoveInternetScsiTargetsToAllHosts(final boolean add, final List<HostInternetScsiHbaStaticTarget> targets,
+            List<HostMO> hosts) throws Exception {
+        ExecutorService executorService = Executors.newFixedThreadPool(hosts.size());
+
+        final List<Exception> exceptions = new ArrayList<Exception>();
+
+        for (HostMO host : hosts) {
             HostStorageSystemMO hostStorageSystem = host.getHostStorageSystemMO();
 
             boolean iScsiHbaConfigured = false;
@@ -1938,9 +2002,9 @@ public class VmwareStorageProcessor implements StorageProcessor {
                         public void run() {
                             try {
                                 if (add) {
-                                    hss.addInternetScsiStaticTargets(iScsiHbaDevice, lstTargets);
+                                    hss.addInternetScsiStaticTargets(iScsiHbaDevice, targets);
                                 } else {
-                                    hss.removeInternetScsiStaticTargets(iScsiHbaDevice, lstTargets);
+                                    hss.removeInternetScsiStaticTargets(iScsiHbaDevice, targets);
                                 }
 
                                 hss.rescanHba(iScsiHbaDevice);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java
index 63c4485..4416c20 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java
@@ -113,16 +113,15 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
     protected String _guestNic;
     protected boolean _setupMultipath;
     protected String _instance;
-    private String xs620snapshothotfix = "Xenserver-Vdi-Copy-HotFix";
 
     @Inject
     protected AlertManager _alertMgr;
     @Inject
     protected AgentManager _agentMgr;
     @Inject
-    VMTemplateDao _tmpltDao;
+    private VMTemplateDao _tmpltDao;
     @Inject
-    HostPodDao _podDao;
+    private HostPodDao _podDao;
 
     protected XcpServerDiscoverer() {
     }
@@ -543,6 +542,10 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
     }
 
     @Override
+    public void processHostAdded(long hostId) {
+    }
+
+    @Override
     public void processConnect(com.cloud.host.Host agent, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
         if (!(cmd instanceof StartupRoutingCommand)) {
             return;
@@ -630,6 +633,14 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
     }
 
     @Override
+    public void processHostAboutToBeRemoved(long hostId) {
+    }
+
+    @Override
+    public void processHostRemoved(long hostId, long clusterId) {
+    }
+
+    @Override
     public boolean processTimeout(long agentId, long seq) {
         return false;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixModifyStoragePoolCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixModifyStoragePoolCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixModifyStoragePoolCommandWrapper.java
index 67d456f..4c7136e 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixModifyStoragePoolCommandWrapper.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixModifyStoragePoolCommandWrapper.java
@@ -49,7 +49,8 @@ public final class CitrixModifyStoragePoolCommandWrapper extends CommandWrapper<
         final boolean add = command.getAdd();
         if (add) {
             try {
-                final SR sr = citrixResourceBase.getStorageRepository(conn, pool.getUuid());
+                final String srName = command.getStoragePath() != null ? command.getStoragePath() : pool.getUuid();
+                final SR sr = citrixResourceBase.getStorageRepository(conn, srName);
                 citrixResourceBase.setupHeartbeatSr(conn, sr, false);
                 final long capacity = sr.getPhysicalSize(conn);
                 final long available = capacity - sr.getPhysicalUtilisation(conn);
@@ -81,7 +82,7 @@ public final class CitrixModifyStoragePoolCommandWrapper extends CommandWrapper<
                 if (result == null || !result.split("#")[1].equals("0")) {
                     throw new CloudRuntimeException("Unable to remove heartbeat file entry for SR " + srUuid + " due to " + result);
                 }
-                return new Answer(command, true, "seccuss");
+                return new Answer(command, true, "success");
             } catch (final XenAPIException e) {
                 final String msg = "ModifyStoragePoolCommand remove XenAPIException:" + e.toString() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: "
                         + pool.getHost() + pool.getPath();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
index 16fd11d..f38a9c7 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
@@ -736,6 +736,11 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
             }
 
             @Override
+            public void processHostAdded(long hostId) {
+
+            }
+
+            @Override
             public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
 
             }
@@ -746,6 +751,16 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
             }
 
             @Override
+            public void processHostAboutToBeRemoved(long hostId) {
+
+            }
+
+            @Override
+            public void processHostRemoved(long hostId, long clusterId) {
+
+            }
+
+            @Override
             public boolean isRecurring() {
                 return false;
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/provider/ElastistorHostListener.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/provider/ElastistorHostListener.java b/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/provider/ElastistorHostListener.java
index c2624ea..b40e60e 100644
--- a/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/provider/ElastistorHostListener.java
+++ b/plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/provider/ElastistorHostListener.java
@@ -77,6 +77,11 @@ public class ElastistorHostListener implements HypervisorHostListener {
     HostDao  _hostDao;
 
     @Override
+    public boolean hostAdded(long hostId) {
+        return true;
+    }
+
+    @Override
     public boolean hostConnect(long hostId, long poolId) {
         StoragePool pool = (StoragePool) this.dataStoreMgr.getDataStore(poolId, DataStoreRole.Primary);
 
@@ -126,4 +131,13 @@ public class ElastistorHostListener implements HypervisorHostListener {
         return false;
     }
 
+    @Override
+    public boolean hostAboutToBeRemoved(long hostId) {
+        return true;
+    }
+
+    @Override
+    public boolean hostRemoved(long hostId, long clusterId) {
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/provider/NexentaHostListener.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/provider/NexentaHostListener.java b/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/provider/NexentaHostListener.java
index 9503252..5fe7599 100644
--- a/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/provider/NexentaHostListener.java
+++ b/plugins/storage/volume/nexenta/src/org/apache/cloudstack/storage/datastore/provider/NexentaHostListener.java
@@ -23,13 +23,40 @@ import org.apache.log4j.Logger;
 import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
 
 public class NexentaHostListener implements HypervisorHostListener {
-    private static final Logger logger = Logger.getLogger(NexentaHostListener.class);
+    private static final Logger s_logger = Logger.getLogger(NexentaHostListener.class);
 
+    @Override
+    public boolean hostAdded(long hostId) {
+        s_logger.trace("hostAdded(long) invoked");
+
+        return true;
+    }
+
+    @Override
     public boolean hostConnect(long hostId, long poolId) {
+        s_logger.trace("hostConnect(long, long) invoked");
+
         return true;
     }
 
+    @Override
     public boolean hostDisconnected(long hostId, long poolId) {
+        s_logger.trace("hostDisconnected(long, long) invoked");
+
+        return true;
+    }
+
+    @Override
+    public boolean hostAboutToBeRemoved(long hostId) {
+        s_logger.trace("hostAboutToBeRemoved(long) invoked");
+
+        return true;
+    }
+
+    @Override
+    public boolean hostRemoved(long hostId, long clusterId) {
+        s_logger.trace("hostRemoved(long) invoked");
+
         return true;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
index 61e199c..5f647db 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
@@ -76,7 +76,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
 
 public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
     private static final Logger s_logger = Logger.getLogger(SolidFirePrimaryDataStoreDriver.class);
-    private static final int s_lockTimeInSeconds = 300;
     private static final int s_lowestHypervisorSnapshotReserve = 10;
 
     @Inject private AccountDao _accountDao;
@@ -141,8 +140,12 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
 
         GlobalLock lock = GlobalLock.getInternLock(cluster.getUuid());
 
-        if (!lock.lock(s_lockTimeInSeconds)) {
-            s_logger.debug("Couldn't lock the DB (in grantAccess) on the following string: " + cluster.getUuid());
+        if (!lock.lock(SolidFireUtil.s_lockTimeInSeconds)) {
+            String errMsg = "Couldn't lock the DB (in grantAccess) on the following string: " + cluster.getUuid();
+
+            s_logger.debug(errMsg);
+
+            throw new CloudRuntimeException(errMsg);
         }
 
         try {
@@ -161,10 +164,9 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
             if (vagId != null) {
                 SolidFireUtil.SolidFireVag sfVag = SolidFireUtil.getSolidFireVag(sfConnection, Long.parseLong(vagId));
 
-                String[] hostIqns = SolidFireUtil.getNewHostIqns(sfVag.getInitiators(), SolidFireUtil.getIqnsFromHosts(hosts));
                 long[] volumeIds = SolidFireUtil.getNewVolumeIds(sfVag.getVolumeIds(), sfVolumeId, true);
 
-                SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), hostIqns, volumeIds);
+                SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), sfVag.getInitiators(), volumeIds);
             }
             else {
                 SolidFireUtil.placeVolumeInVolumeAccessGroup(sfConnection, sfVolumeId, storagePoolId, cluster.getUuid(), hosts, _clusterDetailsDao);
@@ -196,8 +198,12 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
 
         GlobalLock lock = GlobalLock.getInternLock(cluster.getUuid());
 
-        if (!lock.lock(s_lockTimeInSeconds)) {
-            s_logger.debug("Couldn't lock the DB (in revokeAccess) on the following string: " + cluster.getUuid());
+        if (!lock.lock(SolidFireUtil.s_lockTimeInSeconds)) {
+            String errMsg = "Couldn't lock the DB (in revokeAccess) on the following string: " + cluster.getUuid();
+
+            s_logger.debug(errMsg);
+
+            throw new CloudRuntimeException(errMsg);
         }
 
         try {
@@ -206,16 +212,13 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
             String vagId = clusterDetail != null ? clusterDetail.getValue() : null;
 
             if (vagId != null) {
-                List<HostVO> hosts = _hostDao.findByClusterId(clusterId);
-
                 SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao);
 
                 SolidFireUtil.SolidFireVag sfVag = SolidFireUtil.getSolidFireVag(sfConnection, Long.parseLong(vagId));
 
-                String[] hostIqns = SolidFireUtil.getNewHostIqns(sfVag.getInitiators(), SolidFireUtil.getIqnsFromHosts(hosts));
                 long[] volumeIds = SolidFireUtil.getNewVolumeIds(sfVag.getVolumeIds(), sfVolumeId, false);
 
-                SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), hostIqns, volumeIds);
+                SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), sfVag.getInitiators(), volumeIds);
             }
         }
         finally {
@@ -701,7 +704,7 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
     }
 
     @Override
-    public void revertSnapshot(SnapshotInfo snapshot, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback) {
+    public void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback) {
         throw new UnsupportedOperationException("Reverting not supported. Create a template or volume based on the snapshot instead.");
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java
index 4b38f22..f89c97a 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFirePrimaryDataStoreLifeCycle.java
@@ -136,7 +136,7 @@ public class SolidFirePrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeC
                 lClusterDefaultMinIops = Long.parseLong(clusterDefaultMinIops);
             }
         } catch (NumberFormatException ex) {
-            s_logger.warn("Cannot parse the setting of " + SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS +
+            s_logger.warn("Cannot parse the setting " + SolidFireUtil.CLUSTER_DEFAULT_MIN_IOPS +
                           ", using default value: " + lClusterDefaultMinIops +
                           ". Exception: " + ex);
         }
@@ -148,7 +148,7 @@ public class SolidFirePrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeC
                 lClusterDefaultMaxIops = Long.parseLong(clusterDefaultMaxIops);
             }
         } catch (NumberFormatException ex) {
-            s_logger.warn("Cannot parse the setting of " + SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS +
+            s_logger.warn("Cannot parse the setting " + SolidFireUtil.CLUSTER_DEFAULT_MAX_IOPS +
                           ", using default value: " + lClusterDefaultMaxIops +
                           ". Exception: " + ex);
         }
@@ -160,7 +160,7 @@ public class SolidFirePrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeC
                 fClusterDefaultBurstIopsPercentOfMaxIops = Float.parseFloat(clusterDefaultBurstIopsPercentOfMaxIops);
             }
         } catch (NumberFormatException ex) {
-            s_logger.warn("Cannot parse the setting of " + SolidFireUtil.CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS +
+            s_logger.warn("Cannot parse the setting " + SolidFireUtil.CLUSTER_DEFAULT_BURST_IOPS_PERCENT_OF_MAX_IOPS +
                           ", using default value: " + fClusterDefaultBurstIopsPercentOfMaxIops +
                           ". Exception: " + ex);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dad9e5d8/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java
index 7cb6900..6921e4f 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/lifecycle/SolidFireSharedPrimaryDataStoreLifeCycle.java
@@ -70,6 +70,7 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountDetailsDao;
 import com.cloud.user.AccountVO;
 import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStoreLifeCycle {
@@ -178,8 +179,7 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
                 lMinIops = Long.parseLong(minIops);
             }
         } catch (Exception ex) {
-            s_logger.info("[ignored]"
-                    + "error getting minimals iops: " + ex.getLocalizedMessage());
+            s_logger.info("[ignored] error getting Min IOPS: " + ex.getLocalizedMessage());
         }
 
         try {
@@ -189,8 +189,7 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
                 lMaxIops = Long.parseLong(maxIops);
             }
         } catch (Exception ex) {
-            s_logger.info("[ignored]"
-                    + "error getting maximal iops: " + ex.getLocalizedMessage());
+            s_logger.info("[ignored] error getting Max IOPS: " + ex.getLocalizedMessage());
         }
 
         try {
@@ -200,8 +199,7 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
                 lBurstIops = Long.parseLong(burstIops);
             }
         } catch (Exception ex) {
-            s_logger.info("[ignored]"
-                    + "error getting iops bursts: " + ex.getLocalizedMessage());
+            s_logger.info("[ignored] error getting Burst IOPS: " + ex.getLocalizedMessage());
         }
 
         if (lMinIops > lMaxIops) {
@@ -255,14 +253,27 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
             parameters.setPath(iqn);
         }
 
-        // this adds a row in the cloud.storage_pool table for this SolidFire volume
-        DataStore dataStore = _primaryDataStoreHelper.createPrimaryDataStore(parameters);
+        ClusterVO cluster = _clusterDao.findById(clusterId);
+
+        GlobalLock lock = GlobalLock.getInternLock(cluster.getUuid());
+
+        if (!lock.lock(SolidFireUtil.s_lockTimeInSeconds)) {
+            String errMsg = "Couldn't lock the DB on the following string: " + cluster.getUuid();
+
+            s_logger.debug(errMsg);
+
+            throw new CloudRuntimeException(errMsg);
+        }
+
+        DataStore dataStore = null;
 
-        // now that we have a DataStore (we need the id from the DataStore instance), we can create a Volume Access Group, if need be, and
-        // place the newly created volume in the Volume Access Group
         try {
+            // this adds a row in the cloud.storage_pool table for this SolidFire volume
+            dataStore = _primaryDataStoreHelper.createPrimaryDataStore(parameters);
+
+            // now that we have a DataStore (we need the id from the DataStore instance), we can create a Volume Access Group, if need be, and
+            // place the newly created volume in the Volume Access Group
             List<HostVO> hosts = _hostDao.findByClusterId(clusterId);
-            ClusterVO cluster = _clusterDao.findById(clusterId);
 
             SolidFireUtil.placeVolumeInVolumeAccessGroup(sfConnection, sfVolume.getId(), dataStore.getId(), cluster.getUuid(), hosts, _clusterDetailsDao);
 
@@ -275,6 +286,10 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
 
             throw new CloudRuntimeException(ex.getMessage());
         }
+        finally {
+            lock.unlock();
+            lock.releaseRef();
+        }
 
         return dataStore;
     }
@@ -546,7 +561,25 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
         }
 
         if (clusterId != null) {
-            removeVolumeFromVag(storagePool.getId(), clusterId);
+            ClusterVO cluster = _clusterDao.findById(clusterId);
+
+            GlobalLock lock = GlobalLock.getInternLock(cluster.getUuid());
+
+            if (!lock.lock(SolidFireUtil.s_lockTimeInSeconds)) {
+                String errMsg = "Couldn't lock the DB on the following string: " + cluster.getUuid();
+
+                s_logger.debug(errMsg);
+
+                throw new CloudRuntimeException(errMsg);
+            }
+
+            try {
+                removeVolumeFromVag(storagePool.getId(), clusterId);
+            }
+            finally {
+                lock.unlock();
+                lock.releaseRef();
+            }
         }
 
         deleteSolidFireVolume(storagePool.getId());
@@ -561,16 +594,13 @@ public class SolidFireSharedPrimaryDataStoreLifeCycle implements PrimaryDataStor
         String vagId = clusterDetail != null ? clusterDetail.getValue() : null;
 
         if (vagId != null) {
-            List<HostVO> hosts = _hostDao.findByClusterId(clusterId);
-
             SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao);
 
             SolidFireUtil.SolidFireVag sfVag = SolidFireUtil.getSolidFireVag(sfConnection, Long.parseLong(vagId));
 
-            String[] hostIqns = SolidFireUtil.getNewHostIqns(sfVag.getInitiators(), SolidFireUtil.getIqnsFromHosts(hosts));
             long[] volumeIds = SolidFireUtil.getNewVolumeIds(sfVag.getVolumeIds(), sfVolumeId, false);
 
-            SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), hostIqns, volumeIds);
+            SolidFireUtil.modifySolidFireVag(sfConnection, sfVag.getId(), sfVag.getInitiators(), volumeIds);
         }
     }
 


Mime
View raw message