diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties
index 9b5d36ed9b2..5e3c8db0660 100644
--- a/agent/conf/agent.properties
+++ b/agent/conf/agent.properties
@@ -18,7 +18,7 @@
# Sample configuration file for CloudStack agent
#resource= the java class, which agent load to execute
-resource=com.cloud.agent.resource.computing.LibvirtComputingResource
+resource=com.cloud.hypervisor.kvm.resource.LibvirtComputingResource
#workers= number of threads running in agent
workers=5
diff --git a/agent/scripts/run.sh b/agent/scripts/run.sh
index 55543fe6b69..1fa427539fd 100755
--- a/agent/scripts/run.sh
+++ b/agent/scripts/run.sh
@@ -17,4 +17,4 @@
# under the License.
#run.sh runs the agent client.
-java $1 -Xms128M -Xmx384M -cp cglib-nodep-2.2.jar:trilead-ssh2-build213.jar:cloud-api.jar:cloud-core-extras.jar:cloud-utils.jar:cloud-agent.jar:cloud-console-proxy.jar:cloud-console-common.jar:freemarker.jar:log4j-1.2.15.jar:ws-commons-util-1.0.2.jar:xmlrpc-client-3.1.3.jar:cloud-core.jar:xmlrpc-common-3.1.3.jar:javaee-api-5.0-1.jar:gson-1.3.jar:commons-httpclient-3.1.jar:commons-logging-1.1.1.jar:commons-codec-1.4.jar:commons-collections-3.2.1.jar:commons-pool-1.4.jar:apache-log4j-extras-1.0.jar:libvirt-0.4.5.jar:jna.jar:.:/etc/cloud:./conf com.cloud.agent.AgentShell
+java $1 -Xms128M -Xmx384M -cp cglib-nodep-2.2.jar:trilead-ssh2-build213.jar:cloud-api.jar:cloud-core-extras.jar:cloud-utils.jar:cloud-agent.jar:cloud-console-proxy.jar:cloud-console-common.jar:freemarker.jar:log4j-1.2.15.jar:ws-commons-util-1.0.2.jar:xmlrpc-client-3.1.3.jar:cloud-core.jar:xmlrpc-common-3.1.3.jar:javaee-api-5.0-1.jar:gson-1.3.jar:commons-httpclient-3.1.jar:commons-logging-1.1.1.jar:commons-codec-1.4.jar:commons-collections-3.2.1.jar:commons-pool-1.4.jar:apache-log4j-extras-1.0.jar:libvirt-0.4.5.jar:jna.jar:.:/etc/cloud:./*:/usr/share/java/*:./conf com.cloud.agent.AgentShell
diff --git a/build/build-cloud-plugins.xml b/build/build-cloud-plugins.xml
index c16474d3fbf..a7a1f39aad3 100755
--- a/build/build-cloud-plugins.xml
+++ b/build/build-cloud-plugins.xml
@@ -198,9 +198,14 @@
-
-
+
+
+
+
+
+
+
diff --git a/build/package.xml b/build/package.xml
index 30dde943acc..a2768b63325 100755
--- a/build/package.xml
+++ b/build/package.xml
@@ -82,7 +82,6 @@
-
@@ -93,6 +92,7 @@
+
@@ -112,7 +112,7 @@
-
+
@@ -291,6 +291,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cloud.spec b/cloud.spec
index 63a7e8aae71..fcfa7409b20 100644
--- a/cloud.spec
+++ b/cloud.spec
@@ -532,6 +532,7 @@ fi
%files agent-libs
%defattr(0644,root,root,0755)
%{_javadir}/%{name}-agent.jar
+%{_javadir}/%{name}-kvm.jar
%files agent
%defattr(0644,root,root,0755)
diff --git a/core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java b/core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java
deleted file mode 100644
index d49780f60bb..00000000000
--- a/core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// 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;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.naming.ConfigurationException;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.PingCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.agent.api.StartupRoutingCommand.VmState;
-import com.cloud.host.Host.Type;
-import com.cloud.hypervisor.Hypervisor;
-import com.cloud.resource.ServerResource;
-import com.cloud.resource.ServerResourceBase;
-import com.cloud.vm.VirtualMachine.State;
-
-public class KvmDummyResourceBase extends ServerResourceBase implements ServerResource {
- private String _zoneId;
- private String _podId;
- private String _clusterId;
- private String _guid;
- private String _agentIp;
- @Override
- public Type getType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public StartupCommand[] initialize() {
- StartupRoutingCommand cmd = new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.KVM, new HashMap(), new HashMap());
- cmd.setDataCenter(_zoneId);
- cmd.setPod(_podId);
- cmd.setCluster(_clusterId);
- cmd.setGuid(_guid);
- cmd.setName(_agentIp);
- cmd.setPrivateIpAddress(_agentIp);
- cmd.setStorageIpAddress(_agentIp);
- cmd.setVersion(KvmDummyResourceBase.class.getPackage().getImplementationVersion());
- return new StartupCommand[] { cmd };
- }
-
- @Override
- public PingCommand getCurrentStatus(long id) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Answer executeRequest(Command cmd) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected String getDefaultScriptsDir() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean configure(final String name, final Map params) throws ConfigurationException {
- _zoneId = (String)params.get("zone");
- _podId = (String)params.get("pod");
- _clusterId = (String)params.get("cluster");
- _guid = (String)params.get("guid");
- _agentIp = (String)params.get("agentIp");
- return true;
- }
-}
diff --git a/debian/cloud-agent-libs.install b/debian/cloud-agent-libs.install
index 538f0686fac..4cc533697ea 100644
--- a/debian/cloud-agent-libs.install
+++ b/debian/cloud-agent-libs.install
@@ -1 +1,2 @@
/usr/share/java/cloud-agent.jar
+/usr/share/java/cloud-kvm.jar
diff --git a/plugins/hypervisors/kvm/.classpath b/plugins/hypervisors/kvm/.classpath
new file mode 100644
index 00000000000..9e6fddb7e90
--- /dev/null
+++ b/plugins/hypervisors/kvm/.classpath
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/hypervisors/kvm/.project b/plugins/hypervisors/kvm/.project
new file mode 100755
index 00000000000..4a89b9efafc
--- /dev/null
+++ b/plugins/hypervisors/kvm/.project
@@ -0,0 +1,23 @@
+
+
+ KVM
+
+
+
+
+
+ org.python.pydev.PyDevBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.python.pydev.pythonNature
+
+
diff --git a/plugins/hypervisors/kvm/.pydevproject b/plugins/hypervisors/kvm/.pydevproject
new file mode 100644
index 00000000000..a9cca037b33
--- /dev/null
+++ b/plugins/hypervisors/kvm/.pydevproject
@@ -0,0 +1,7 @@
+
+
+
+
+Default
+python 2.7
+
diff --git a/plugins/hypervisors/kvm/build.xml b/plugins/hypervisors/kvm/build.xml
new file mode 100755
index 00000000000..60e66534212
--- /dev/null
+++ b/plugins/hypervisors/kvm/build.xml
@@ -0,0 +1,137 @@
+
+
+
+
+
+
+ Cloud Stack ant build file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/agent/src/com/cloud/agent/resource/computing/FakeComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/FakeComputingResource.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/FakeComputingResource.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/FakeComputingResource.java
index abfa4787a51..83f69768495 100644
--- a/agent/src/com/cloud/agent/resource/computing/FakeComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/FakeComputingResource.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.io.File;
import java.io.FileInputStream;
@@ -97,7 +97,6 @@ import com.cloud.resource.ServerResourceBase;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Volume;
-import com.cloud.storage.VolumeVO;
import com.cloud.storage.template.TemplateInfo;
import com.cloud.utils.PropertiesUtil;
import com.cloud.utils.exception.CloudRuntimeException;
diff --git a/agent/src/com/cloud/agent/resource/computing/KVMGuestOsMapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMGuestOsMapper.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/KVMGuestOsMapper.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMGuestOsMapper.java
index 22f3935c59c..e3615ad9dfd 100644
--- a/agent/src/com/cloud/agent/resource/computing/KVMGuestOsMapper.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMGuestOsMapper.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.util.HashMap;
import java.util.Map;
diff --git a/agent/src/com/cloud/agent/resource/computing/KVMHABase.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/KVMHABase.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java
index ed29a627468..2cb60d74907 100644
--- a/agent/src/com/cloud/agent/resource/computing/KVMHABase.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.io.File;
import java.util.concurrent.Callable;
@@ -23,7 +23,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import org.libvirt.Connect;
import org.libvirt.LibvirtException;
import org.libvirt.StoragePool;
import org.libvirt.StoragePoolInfo;
diff --git a/agent/src/com/cloud/agent/resource/computing/KVMHAChecker.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java
similarity index 97%
rename from agent/src/com/cloud/agent/resource/computing/KVMHAChecker.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java
index f5b8a32bcee..68deca0d464 100644
--- a/agent/src/com/cloud/agent/resource/computing/KVMHAChecker.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java
@@ -14,14 +14,13 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import org.apache.log4j.Logger;
-import org.libvirt.Connect;
import com.cloud.utils.script.OutputInterpreter;
import com.cloud.utils.script.Script;
diff --git a/agent/src/com/cloud/agent/resource/computing/KVMHAMonitor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
similarity index 98%
rename from agent/src/com/cloud/agent/resource/computing/KVMHAMonitor.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
index 09d5c83928f..c4e121b8ae8 100644
--- a/agent/src/com/cloud/agent/resource/computing/KVMHAMonitor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHAMonitor.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.util.ArrayList;
import java.util.List;
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtCapXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtCapXMLParser.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtCapXMLParser.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtCapXMLParser.java
index 4c5fa29485c..704af23b703 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtCapXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtCapXMLParser.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index a4854bec394..ea12b986b0a 100755
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.io.BufferedReader;
import java.io.File;
@@ -153,26 +153,26 @@ import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.agent.api.to.VolumeTO;
-import com.cloud.agent.resource.computing.KVMHABase.NfsStoragePool;
-import com.cloud.agent.resource.computing.LibvirtVMDef.ConsoleDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.DevicesDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.DiskDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.DiskDef.diskProtocol;
-import com.cloud.agent.resource.computing.LibvirtVMDef.FeaturesDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.GraphicDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.GuestDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.GuestResourceDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.InputDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef.hostNicType;
-import com.cloud.agent.resource.computing.LibvirtVMDef.SerialDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.TermPolicy;
-import com.cloud.agent.resource.computing.LibvirtVMDef.ClockDef;
+import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ConsoleDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DevicesDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef.diskProtocol;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.FeaturesDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GraphicDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.GuestResourceDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InputDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.hostNicType;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ClockDef;
import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
-import com.cloud.agent.storage.KVMPhysicalDisk;
-import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
-import com.cloud.agent.storage.KVMStoragePool;
-import com.cloud.agent.storage.KVMStoragePoolManager;
+import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
+import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
+import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
+import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager;
import com.cloud.dc.Vlan;
import com.cloud.exception.InternalErrorException;
import com.cloud.host.Host.Type;
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtConnection.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java
similarity index 97%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtConnection.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java
index d3a231871bb..981d343004d 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtConnection.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtConnection.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import org.apache.log4j.Logger;
import org.libvirt.Connect;
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtDomainXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
similarity index 96%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtDomainXMLParser.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
index 62155349b66..55fbfaa4fdc 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtDomainXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
@@ -14,14 +14,12 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -32,13 +30,12 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import com.cloud.agent.resource.computing.LibvirtVMDef.DiskDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef.nicModel;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.nicModel;
/**
* @author chiradeep
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtNetworkDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtNetworkDef.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtNetworkDef.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtNetworkDef.java
index 7f757dec967..6df3bd1e962 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtNetworkDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtNetworkDef.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.util.ArrayList;
import java.util.List;
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtSecretDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtSecretDef.java
similarity index 98%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtSecretDef.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtSecretDef.java
index f7e10c38ddf..454dbf31cf5 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtSecretDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtSecretDef.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
public class LibvirtSecretDef {
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtStoragePoolDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtStoragePoolDef.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java
index 9c285284563..e181ceac5a3 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtStoragePoolDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
public class LibvirtStoragePoolDef {
public enum poolType {
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtStoragePoolXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtStoragePoolXMLParser.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java
index cff4c2b74aa..a349d5edf8c 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtStoragePoolXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeDef.java
similarity index 98%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeDef.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeDef.java
index ef8e22e6008..d5cd91a954c 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeDef.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
public class LibvirtStorageVolumeDef {
public enum volFormat {
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeXMLParser.java
similarity index 98%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeXMLParser.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeXMLParser.java
index 163ca2b19db..3a4d94bdc58 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeXMLParser.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
similarity index 99%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtVMDef.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
index 3b07bcd16b7..998f39372a9 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtVMDef.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java
@@ -14,10 +14,9 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtXMLParser.java
similarity index 97%
rename from agent/src/com/cloud/agent/resource/computing/LibvirtXMLParser.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtXMLParser.java
index b73ea0f0c3f..3a614037d85 100644
--- a/agent/src/com/cloud/agent/resource/computing/LibvirtXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtXMLParser.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.resource.computing;
+package com.cloud.hypervisor.kvm.resource;
import java.io.IOException;
import java.io.StringReader;
diff --git a/agent/src/com/cloud/agent/storage/KVMPhysicalDisk.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java
similarity index 98%
rename from agent/src/com/cloud/agent/storage/KVMPhysicalDisk.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java
index cb790d94620..08f51a494fa 100644
--- a/agent/src/com/cloud/agent/storage/KVMPhysicalDisk.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.storage;
+package com.cloud.hypervisor.kvm.storage;
public class KVMPhysicalDisk {
private String path;
diff --git a/agent/src/com/cloud/agent/storage/KVMStoragePool.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
similarity index 93%
rename from agent/src/com/cloud/agent/storage/KVMStoragePool.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
index f1192ede940..5437e7c69b0 100644
--- a/agent/src/com/cloud/agent/storage/KVMStoragePool.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
@@ -14,11 +14,11 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.storage;
+package com.cloud.hypervisor.kvm.storage;
import java.util.List;
-import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
+import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
public interface KVMStoragePool {
diff --git a/agent/src/com/cloud/agent/storage/KVMStoragePoolManager.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
similarity index 93%
rename from agent/src/com/cloud/agent/storage/KVMStoragePoolManager.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
index a82318d2c2d..491f7724ea3 100644
--- a/agent/src/com/cloud/agent/storage/KVMStoragePoolManager.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
@@ -14,15 +14,15 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.storage;
+package com.cloud.hypervisor.kvm.storage;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import com.cloud.agent.resource.computing.KVMHABase;
-import com.cloud.agent.resource.computing.KVMHABase.PoolType;
-import com.cloud.agent.resource.computing.KVMHAMonitor;
-import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
+import com.cloud.hypervisor.kvm.resource.KVMHABase;
+import com.cloud.hypervisor.kvm.resource.KVMHABase.PoolType;
+import com.cloud.hypervisor.kvm.resource.KVMHAMonitor;
+import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StorageLayer;
diff --git a/agent/src/com/cloud/agent/storage/KVMVirtualDisk.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMVirtualDisk.java
similarity index 95%
rename from agent/src/com/cloud/agent/storage/KVMVirtualDisk.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMVirtualDisk.java
index c454b12f853..d773cf4650b 100644
--- a/agent/src/com/cloud/agent/storage/KVMVirtualDisk.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMVirtualDisk.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.storage;
+package com.cloud.hypervisor.kvm.storage;
public class KVMVirtualDisk {
diff --git a/agent/src/com/cloud/agent/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
similarity index 97%
rename from agent/src/com/cloud/agent/storage/LibvirtStorageAdaptor.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index da000aaff19..90003f9cc2b 100644
--- a/agent/src/com/cloud/agent/storage/LibvirtStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -14,7 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.storage;
+package com.cloud.hypervisor.kvm.storage;
import java.io.File;
import java.net.URI;
@@ -33,17 +33,17 @@ import org.libvirt.StorageVol;
import org.libvirt.StoragePoolInfo.StoragePoolState;
import com.cloud.agent.api.ManageSnapshotCommand;
-import com.cloud.agent.resource.computing.LibvirtConnection;
-import com.cloud.agent.resource.computing.LibvirtSecretDef;
-import com.cloud.agent.resource.computing.LibvirtSecretDef.usage;
-import com.cloud.agent.resource.computing.LibvirtStoragePoolDef;
-import com.cloud.agent.resource.computing.LibvirtStoragePoolXMLParser;
-import com.cloud.agent.resource.computing.LibvirtStorageVolumeDef;
-import com.cloud.agent.resource.computing.LibvirtStoragePoolDef.poolType;
-import com.cloud.agent.resource.computing.LibvirtStoragePoolDef.authType;
-import com.cloud.agent.resource.computing.LibvirtStorageVolumeDef.volFormat;
-import com.cloud.agent.resource.computing.LibvirtStorageVolumeXMLParser;
-import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
+import com.cloud.hypervisor.kvm.resource.LibvirtConnection;
+import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtSecretDef.usage;
+import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolXMLParser;
+import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef;
+import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.poolType;
+import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.authType;
+import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef.volFormat;
+import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeXMLParser;
+import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.exception.InternalErrorException;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StorageLayer;
diff --git a/agent/src/com/cloud/agent/storage/LibvirtStoragePool.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java
similarity index 97%
rename from agent/src/com/cloud/agent/storage/LibvirtStoragePool.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java
index 943b8b268fd..bc428e1273c 100644
--- a/agent/src/com/cloud/agent/storage/LibvirtStoragePool.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java
@@ -14,13 +14,13 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.storage;
+package com.cloud.hypervisor.kvm.storage;
import java.util.List;
import org.libvirt.StoragePool;
-import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
+import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
public class LibvirtStoragePool implements KVMStoragePool {
diff --git a/agent/src/com/cloud/agent/storage/StorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java
similarity index 94%
rename from agent/src/com/cloud/agent/storage/StorageAdaptor.java
rename to plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java
index 82386772ba4..be6c5c0bda2 100644
--- a/agent/src/com/cloud/agent/storage/StorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java
@@ -14,13 +14,11 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.agent.storage;
+package com.cloud.hypervisor.kvm.storage;
import java.util.List;
-import org.libvirt.StoragePool;
-
-import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
+import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
import com.cloud.storage.Storage.StoragePoolType;
public interface StorageAdaptor {
diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
index 844c8b9c59f..9fb90274558 100755
--- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -88,7 +88,7 @@ import com.cloud.host.dao.HostDao;
import com.cloud.host.dao.HostTagsDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorGuruManager;
-import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
+import com.cloud.hypervisor.kvm.discover.KvmDummyResourceBase;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.resource.Discoverer;
import com.cloud.resource.ResourceManager;
diff --git a/server/src/com/cloud/baremetal/BareMetalResourceBase.java b/server/src/com/cloud/baremetal/BareMetalResourceBase.java
index 24f80026bbf..8c14ccecf2e 100755
--- a/server/src/com/cloud/baremetal/BareMetalResourceBase.java
+++ b/server/src/com/cloud/baremetal/BareMetalResourceBase.java
@@ -56,7 +56,6 @@ import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.api.ApiConstants;
import com.cloud.host.Host.Type;
import com.cloud.hypervisor.Hypervisor;
-import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
import com.cloud.resource.ServerResource;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.OutputInterpreter;
diff --git a/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java b/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java
deleted file mode 100755
index fa47a20c307..00000000000
--- a/server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java
+++ /dev/null
@@ -1,400 +0,0 @@
-// 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.discoverer;
-
-import java.net.InetAddress;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.Listener;
-import com.cloud.agent.api.AgentControlAnswer;
-import com.cloud.agent.api.AgentControlCommand;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.ShutdownCommand;
-import com.cloud.agent.api.StartupCommand;
-import com.cloud.agent.api.StartupRoutingCommand;
-import com.cloud.configuration.Config;
-import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.dc.ClusterVO;
-import com.cloud.dc.dao.ClusterDao;
-import com.cloud.exception.AgentUnavailableException;
-import com.cloud.exception.DiscoveredWithErrorException;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.exception.OperationTimedoutException;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.host.Status;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
-import com.cloud.network.NetworkManager;
-import com.cloud.network.PhysicalNetworkSetupInfo;
-import com.cloud.network.PhysicalNetworkVO;
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.resource.Discoverer;
-import com.cloud.resource.DiscovererBase;
-import com.cloud.resource.ResourceManager;
-import com.cloud.resource.ResourceStateAdapter;
-import com.cloud.resource.ServerResource;
-import com.cloud.resource.UnableDeleteHostException;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.component.Inject;
-import com.cloud.utils.script.Script;
-import com.cloud.utils.ssh.SSHCmdHelper;
-import com.trilead.ssh2.ChannelCondition;
-import com.trilead.ssh2.SCPClient;
-import com.trilead.ssh2.Session;
-
-@Local(value=Discoverer.class)
-public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
- Listener, ResourceStateAdapter {
- private static final Logger s_logger = Logger.getLogger(KvmServerDiscoverer.class);
- private String _setupAgentPath;
- private ConfigurationDao _configDao;
- private String _hostIp;
- private int _waitTime = 5; /*wait for 5 minutes*/
- private String _kvmPrivateNic;
- private String _kvmPublicNic;
- private String _kvmGuestNic;
- @Inject HostDao _hostDao = null;
- @Inject ClusterDao _clusterDao;
- @Inject ResourceManager _resourceMgr;
- @Inject AgentManager _agentMgr;
- @Inject NetworkManager _networkMgr;
-
- @Override
- public boolean processAnswers(long agentId, long seq, Answer[] answers) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean processCommands(long agentId, long seq, Command[] commands) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public AgentControlAnswer processControlCommand(long agentId,
- AgentControlCommand cmd) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) {
- }
-
- @Override
- public boolean processDisconnect(long agentId, Status state) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isRecurring() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public int getTimeout() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public boolean processTimeout(long agentId, long seq) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Map extends ServerResource, Map> find(long dcId,
- Long podId, Long clusterId, URI uri, String username,
- String password, List hostTags) throws DiscoveryException {
-
- ClusterVO cluster = _clusterDao.findById(clusterId);
- if(cluster == null || cluster.getHypervisorType() != HypervisorType.KVM) {
- if(s_logger.isInfoEnabled())
- s_logger.info("invalid cluster id or cluster is not for KVM hypervisors");
- return null;
- }
-
- Map> resources = new HashMap>();
- Map details = new HashMap();
- if (!uri.getScheme().equals("http")) {
- String msg = "urlString is not http so we're not taking care of the discovery for this: " + uri;
- s_logger.debug(msg);
- return null;
- }
- com.trilead.ssh2.Connection sshConnection = null;
- String agentIp = null;
- try {
-
- String hostname = uri.getHost();
- InetAddress ia = InetAddress.getByName(hostname);
- agentIp = ia.getHostAddress();
- String guid = UUID.nameUUIDFromBytes(agentIp.getBytes()).toString();
- String guidWithTail = guid + "-LibvirtComputingResource";/*tail added by agent.java*/
- if (_resourceMgr.findHostByGuid(guidWithTail) != null) {
- s_logger.debug("Skipping " + agentIp + " because " + guidWithTail + " is already in the database.");
- return null;
- }
-
- sshConnection = new com.trilead.ssh2.Connection(agentIp, 22);
-
- sshConnection.connect(null, 60000, 60000);
- if (!sshConnection.authenticateWithPassword(username, password)) {
- s_logger.debug("Failed to authenticate");
- throw new DiscoveredWithErrorException("Authentication error");
- }
-
- if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "lsmod|grep kvm", 3)) {
- s_logger.debug("It's not a KVM enabled machine");
- return null;
- }
-
- List netInfos = _networkMgr.getPhysicalNetworkInfo(dcId, HypervisorType.KVM);
- String kvmPrivateNic = _kvmPrivateNic;
- String kvmPublicNic = _kvmPublicNic;
- String kvmGuestNic = _kvmGuestNic;
-
- for (PhysicalNetworkSetupInfo info : netInfos) {
- if (info.getPrivateNetworkName() != null) {
- kvmPrivateNic = info.getPrivateNetworkName();
- }
- if (info.getPublicNetworkName() != null) {
- kvmPublicNic = info.getPublicNetworkName();
- }
- if (info.getGuestNetworkName() != null) {
- kvmGuestNic = info.getGuestNetworkName();
- }
- }
-
- String parameters = " -m " + _hostIp + " -z " + dcId + " -p " + podId + " -c " + clusterId + " -g " + guid + " -a";
-
- if (kvmPublicNic != null) {
- parameters += " --pubNic=" + kvmPublicNic;
- }
-
- if (kvmPrivateNic != null) {
- parameters += " --prvNic=" + kvmPrivateNic;
- }
-
- if (kvmGuestNic != null) {
- parameters += " --guestNic=" + kvmGuestNic;
- }
-
- SSHCmdHelper.sshExecuteCmd(sshConnection, "cloud-setup-agent " + parameters, 3);
-
- KvmDummyResourceBase kvmResource = new KvmDummyResourceBase();
- Map params = new HashMap();
-
- params.put("zone", Long.toString(dcId));
- params.put("pod", Long.toString(podId));
- params.put("cluster", Long.toString(clusterId));
- params.put("guid", guid);
- params.put("agentIp", agentIp);
- kvmResource.configure("kvm agent", params);
- resources.put(kvmResource, details);
-
- HostVO connectedHost = waitForHostConnect(dcId, podId, clusterId, guidWithTail);
- if (connectedHost == null)
- return null;
-
- details.put("guid", guidWithTail);
-
- // place a place holder guid derived from cluster ID
- if (cluster.getGuid() == null) {
- cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
- _clusterDao.update(clusterId, cluster);
- }
-
- //save user name and password
- _hostDao.loadDetails(connectedHost);
- Map hostDetails = connectedHost.getDetails();
- hostDetails.put("password", password);
- hostDetails.put("username", username);
- _hostDao.saveDetails(connectedHost);
- return resources;
- } catch (DiscoveredWithErrorException e){
- throw e;
- }catch (Exception e) {
- String msg = " can't setup agent, due to " + e.toString() + " - " + e.getMessage();
- s_logger.warn(msg);
- } finally {
- if (sshConnection != null)
- sshConnection.close();
- }
-
- return null;
- }
-
- private HostVO waitForHostConnect(long dcId, long podId, long clusterId, String guid) {
- for (int i = 0; i < _waitTime *2; i++) {
- List hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, clusterId, podId, dcId);
- for (HostVO host : hosts) {
- if (host.getGuid().equalsIgnoreCase(guid)) {
- return host;
- }
- }
- try {
- Thread.sleep(30000);
- } catch (InterruptedException e) {
- s_logger.debug("Failed to sleep: " + e.toString());
- }
- }
- s_logger.debug("Timeout, to wait for the host connecting to mgt svr, assuming it is failed");
- List hosts = _resourceMgr.findHostByGuid(dcId, guid);
- if (hosts.size() == 1) {
- return hosts.get(0);
- } else {
- return null;
- }
- }
-
- @Override
- public boolean configure(String name, Map params) throws ConfigurationException {
- ComponentLocator locator = ComponentLocator.getCurrentLocator();
- _configDao = locator.getDao(ConfigurationDao.class);
- _setupAgentPath = Script.findScript(getPatchPath(), "setup_agent.sh");
- _kvmPrivateNic = _configDao.getValue(Config.KvmPrivateNetwork.key());
- if (_kvmPrivateNic == null) {
- _kvmPrivateNic = "cloudbr0";
- }
-
- _kvmPublicNic = _configDao.getValue(Config.KvmPublicNetwork.key());
- if (_kvmPublicNic == null) {
- _kvmPublicNic = _kvmPrivateNic;
- }
-
- _kvmGuestNic = _configDao.getValue(Config.KvmGuestNetwork.key());
- if (_kvmGuestNic == null) {
- _kvmGuestNic = _kvmPrivateNic;
- }
-
- if (_setupAgentPath == null) {
- throw new ConfigurationException("Can't find setup_agent.sh");
- }
- _hostIp = _configDao.getValue("host");
- if (_hostIp == null) {
- throw new ConfigurationException("Can't get host IP");
- }
- _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
- return true;
- }
-
- protected String getPatchPath() {
- return "scripts/vm/hypervisor/kvm/";
- }
-
- @Override
- public void postDiscovery(List hosts, long msId)
- throws DiscoveryException {
- // TODO Auto-generated method stub
- }
-
- public Hypervisor.HypervisorType getHypervisorType() {
- return Hypervisor.HypervisorType.KVM;
- }
-
- @Override
- public boolean matchHypervisor(String hypervisor) {
- // for backwards compatibility, if not supplied, always let to try it
- if(hypervisor == null)
- return true;
-
- return Hypervisor.HypervisorType.KVM.toString().equalsIgnoreCase(hypervisor);
- }
-
- @Override
- public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
- StartupCommand firstCmd = cmd[0];
- if (!(firstCmd instanceof StartupRoutingCommand)) {
- return null;
- }
-
- StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
- if (ssCmd.getHypervisorType() != HypervisorType.KVM) {
- return null;
- }
-
- /* KVM requires host are the same in cluster */
- ClusterVO clusterVO = _clusterDao.findById(host.getClusterId());
- List hostsInCluster = _resourceMgr.listAllHostsInCluster(clusterVO.getId());
- if (!hostsInCluster.isEmpty()) {
- HostVO oneHost = hostsInCluster.get(0);
- _hostDao.loadDetails(oneHost);
- String hostOsInCluster = oneHost.getDetail("Host.OS");
- String hostOs = ssCmd.getHostDetails().get("Host.OS");
- if (!hostOsInCluster.equalsIgnoreCase(hostOs)) {
- throw new IllegalArgumentException("Can't add host: " + firstCmd.getPrivateIpAddress() + " with hostOS: " + hostOs + " into a cluster,"
- + "in which there are " + hostOsInCluster + " hosts added");
- }
- }
-
- _hostDao.loadDetails(host);
-
- return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.KVM, host.getDetails(), null);
- }
-
- @Override
- public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map details,
- List hostTags) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
- if (host.getType() != Host.Type.Routing || host.getHypervisorType() != HypervisorType.KVM) {
- return null;
- }
-
- _resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
- try {
- ShutdownCommand cmd = new ShutdownCommand(ShutdownCommand.DeleteHost, null);
- _agentMgr.send(host.getId(), cmd);
- } catch (AgentUnavailableException e) {
- s_logger.warn("Sending ShutdownCommand failed: ", e);
- } catch (OperationTimedoutException e) {
- s_logger.warn("Sending ShutdownCommand failed: ", e);
- }
-
- return new DeleteHostAnswer(true);
- }
-
- @Override
- public boolean stop() {
- _resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
- return super.stop();
- }
-
-
-}
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 347346203e3..7f00da989c4 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -98,7 +98,7 @@ import com.cloud.host.dao.HostDetailsDao;
import com.cloud.host.dao.HostTagsDao;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
+import com.cloud.hypervisor.kvm.discover.KvmDummyResourceBase;
import com.cloud.network.IPAddressVO;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.org.Cluster;