incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [23/50] [abbrv] Move KVM related code into plugins/hypervisor/kvm, a new jar file is created: cloud-kvm.jar
Date Tue, 31 Jul 2012 20:40:02 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/agent/src/com/cloud/agent/storage/KVMStoragePoolManager.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/storage/KVMStoragePoolManager.java b/agent/src/com/cloud/agent/storage/KVMStoragePoolManager.java
deleted file mode 100644
index a82318d..0000000
--- a/agent/src/com/cloud/agent/storage/KVMStoragePoolManager.java
+++ /dev/null
@@ -1,109 +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.agent.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.storage.Storage.StoragePoolType;
-import com.cloud.storage.StorageLayer;
-
-public class KVMStoragePoolManager {
-    private StorageAdaptor _storageAdaptor;
-    private KVMHAMonitor _haMonitor;
-    private final Map<String, Object> _storagePools = new ConcurrentHashMap<String, Object>();
-
-    private void addStoragePool(String uuid) {
-        synchronized (_storagePools) {
-            if (!_storagePools.containsKey(uuid)) {
-                _storagePools.put(uuid, new Object());
-            }
-        }
-    }
-
-    public KVMStoragePoolManager(StorageLayer storagelayer, KVMHAMonitor monitor) {
-        this._storageAdaptor = new LibvirtStorageAdaptor(storagelayer);
-        this._haMonitor = monitor;
-    }
-
-    public KVMStoragePool getStoragePool(String uuid) {
-        return this._storageAdaptor.getStoragePool(uuid);
-    }
-
-    public KVMStoragePool getStoragePoolByURI(String uri) {
-        return this._storageAdaptor.getStoragePoolByUri(uri);
-    }
-
-    public KVMStoragePool createStoragePool(String name, String host, int port, String path,
-                                            String userInfo, StoragePoolType type) {
-        KVMStoragePool pool = this._storageAdaptor.createStoragePool(name,
-                                host, port, path, userInfo, type);
-        if (type == StoragePoolType.NetworkFilesystem) {
-            KVMHABase.NfsStoragePool nfspool = new KVMHABase.NfsStoragePool(
-                    pool.getUuid(), host, path, pool.getLocalPath(),
-                    PoolType.PrimaryStorage);
-            _haMonitor.addStoragePool(nfspool);
-        }
-        addStoragePool(pool.getUuid());
-        return pool;
-    }
-
-    public boolean deleteStoragePool(String uuid) {
-        _haMonitor.removeStoragePool(uuid);
-        this._storageAdaptor.deleteStoragePool(uuid);
-        _storagePools.remove(uuid);
-        return true;
-    }
-
-    public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template, String name,
-                                                    KVMStoragePool destPool) {
-        if (destPool.getType() == StoragePoolType.RBD) {
-            return this._storageAdaptor.createDiskFromTemplate(template, name,
-                    KVMPhysicalDisk.PhysicalDiskFormat.RAW, template.getSize(), destPool);
-        } else {
-            return this._storageAdaptor.createDiskFromTemplate(template, name,
-                    KVMPhysicalDisk.PhysicalDiskFormat.QCOW2,
-            template.getSize(), destPool);
-        }
-    }
-
-    public KVMPhysicalDisk createTemplateFromDisk(KVMPhysicalDisk disk,
-            String name, PhysicalDiskFormat format, long size,
-            KVMStoragePool destPool) {
-        return this._storageAdaptor.createTemplateFromDisk(disk, name, format,
-                size, destPool);
-    }
-
-    public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
-            KVMStoragePool destPool) {
-        return this._storageAdaptor.copyPhysicalDisk(disk, name, destPool);
-    }
-
-    public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot,
-            String snapshotName, String name, KVMStoragePool destPool) {
-        return this._storageAdaptor.createDiskFromSnapshot(snapshot,
-                snapshotName, name, destPool);
-    }
-
-    public KVMPhysicalDisk getPhysicalDiskFromUrl(String url) {
-        return this._storageAdaptor.getPhysicalDiskFromURI(url);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/agent/src/com/cloud/agent/storage/KVMVirtualDisk.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/storage/KVMVirtualDisk.java b/agent/src/com/cloud/agent/storage/KVMVirtualDisk.java
deleted file mode 100644
index c454b12..0000000
--- a/agent/src/com/cloud/agent/storage/KVMVirtualDisk.java
+++ /dev/null
@@ -1,21 +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.agent.storage;
-
-public class KVMVirtualDisk {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/agent/src/com/cloud/agent/storage/LibvirtStorageAdaptor.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/storage/LibvirtStorageAdaptor.java b/agent/src/com/cloud/agent/storage/LibvirtStorageAdaptor.java
deleted file mode 100644
index da000aa..0000000
--- a/agent/src/com/cloud/agent/storage/LibvirtStorageAdaptor.java
+++ /dev/null
@@ -1,901 +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.agent.storage;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import org.apache.log4j.Logger;
-import org.apache.commons.codec.binary.Base64;
-import org.libvirt.Connect;
-import org.libvirt.LibvirtException;
-import org.libvirt.Secret;
-import org.libvirt.StoragePool;
-import org.libvirt.StoragePoolInfo;
-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.exception.InternalErrorException;
-import com.cloud.storage.Storage.StoragePoolType;
-import com.cloud.storage.StorageLayer;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.script.OutputInterpreter;
-import com.cloud.utils.script.Script;
-
-public class LibvirtStorageAdaptor implements StorageAdaptor {
-    private static final Logger s_logger = Logger
-            .getLogger(LibvirtStorageAdaptor.class);
-    private StorageLayer _storageLayer;
-    private String _mountPoint = "/mnt";
-    private String _manageSnapshotPath;
-
-    public LibvirtStorageAdaptor(StorageLayer storage) {
-        _storageLayer = storage;
-        _manageSnapshotPath = Script.findScript("scripts/storage/qcow2/",
-                "managesnapshot.sh");
-    }
-
-    @Override
-    public boolean createFolder(String uuid, String path) {
-        String mountPoint = _mountPoint + File.separator + uuid;
-        File f = new File(mountPoint + path);
-        if (!f.exists()) {
-            f.mkdirs();
-        }
-        return true;
-    }
-
-    public StorageVol getVolume(StoragePool pool, String volName) {
-        StorageVol vol = null;
-
-        try {
-            vol = pool.storageVolLookupByName(volName);
-        } catch (LibvirtException e) {
-
-        }
-        if (vol == null) {
-            storagePoolRefresh(pool);
-            try {
-                vol = pool.storageVolLookupByName(volName);
-            } catch (LibvirtException e) {
-                throw new CloudRuntimeException(e.toString());
-            }
-        }
-        return vol;
-    }
-
-    public StorageVol createVolume(Connect conn, StoragePool pool, String uuid,
-            long size, volFormat format) throws LibvirtException {
-        LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID
-                .randomUUID().toString(), size, format, null, null);
-        s_logger.debug(volDef.toString());
-        return pool.storageVolCreateXML(volDef.toString(), 0);
-    }
-
-    public StoragePool getStoragePoolbyURI(Connect conn, URI uri)
-            throws LibvirtException {
-        String sourcePath;
-        String uuid;
-        String sourceHost = "";
-        String protocal;
-        if (uri.getScheme().equalsIgnoreCase("local")) {
-            sourcePath = _mountPoint + File.separator
-                    + uri.toString().replace("local:///", "");
-            sourcePath = sourcePath.replace("//", "/");
-            uuid = UUID.nameUUIDFromBytes(new String(sourcePath).getBytes())
-                    .toString();
-            protocal = "DIR";
-        } else {
-            sourcePath = uri.getPath();
-            sourcePath = sourcePath.replace("//", "/");
-            sourceHost = uri.getHost();
-            uuid = UUID.nameUUIDFromBytes(
-                    new String(sourceHost + sourcePath).getBytes()).toString();
-            protocal = "NFS";
-        }
-
-        String targetPath = _mountPoint + File.separator + uuid;
-        StoragePool sp = null;
-        try {
-            sp = conn.storagePoolLookupByUUIDString(uuid);
-        } catch (LibvirtException e) {
-        }
-
-        if (sp == null) {
-            try {
-                LibvirtStoragePoolDef spd = null;
-                if (protocal.equalsIgnoreCase("NFS")) {
-                    _storageLayer.mkdir(targetPath);
-                    spd = new LibvirtStoragePoolDef(poolType.NETFS, uuid, uuid,
-                            sourceHost, sourcePath, targetPath);
-                    s_logger.debug(spd.toString());
-                    // addStoragePool(uuid);
-
-                } else if (protocal.equalsIgnoreCase("DIR")) {
-                    _storageLayer.mkdir(targetPath);
-                    spd = new LibvirtStoragePoolDef(poolType.DIR, uuid, uuid,
-                            null, null, sourcePath);
-                }
-
-                synchronized (getStoragePool(uuid)) {
-                    sp = conn.storagePoolDefineXML(spd.toString(), 0);
-                    if (sp == null) {
-                        s_logger.debug("Failed to define storage pool");
-                        return null;
-                    }
-                    sp.create(0);
-                }
-
-                return sp;
-            } catch (LibvirtException e) {
-                try {
-                    if (sp != null) {
-                        sp.undefine();
-                        sp.free();
-                    }
-                } catch (LibvirtException l) {
-
-                }
-                throw e;
-            }
-        } else {
-            StoragePoolInfo spi = sp.getInfo();
-            if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
-                sp.create(0);
-            }
-            return sp;
-        }
-    }
-
-    public void storagePoolRefresh(StoragePool pool) {
-        try {
-            synchronized (getStoragePool(pool.getUUIDString())) {
-                pool.refresh(0);
-            }
-        } catch (LibvirtException e) {
-
-        }
-    }
-
-    private StoragePool createNfsStoragePool(Connect conn, String uuid,
-            String host, String path) {
-        String targetPath = _mountPoint + File.separator + uuid;
-        LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.NETFS,
-                uuid, uuid, host, path, targetPath);
-        _storageLayer.mkdir(targetPath);
-        StoragePool sp = null;
-        try {
-            s_logger.debug(spd.toString());
-            sp = conn.storagePoolDefineXML(spd.toString(), 0);
-            sp.create(0);
-            return sp;
-        } catch (LibvirtException e) {
-            s_logger.debug(e.toString());
-            if (sp != null) {
-                try {
-                    sp.undefine();
-                    sp.free();
-                } catch (LibvirtException l) {
-                    s_logger.debug("Failed to define nfs storage pool with: "
-                            + l.toString());
-                }
-            }
-            return null;
-        }
-    }
-
-    private StoragePool CreateSharedStoragePool(Connect conn, String uuid,
-            String host, String path) {
-        String mountPoint = path;
-        if (!_storageLayer.exists(mountPoint)) {
-            return null;
-        }
-        LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.DIR,
-                uuid, uuid, host, path, path);
-        StoragePool sp = null;
-        try {
-            s_logger.debug(spd.toString());
-            sp = conn.storagePoolDefineXML(spd.toString(), 0);
-            sp.create(0);
-
-            return sp;
-        } catch (LibvirtException e) {
-            s_logger.debug(e.toString());
-            if (sp != null) {
-                try {
-                    sp.undefine();
-                    sp.free();
-                } catch (LibvirtException l) {
-                    s_logger.debug("Failed to define shared mount point storage pool with: "
-                            + l.toString());
-                }
-            }
-            return null;
-        }
-    }
-
-    private StoragePool createCLVMStoragePool(Connect conn, String uuid,
-            String host, String path) {
-
-        String volgroupPath = "/dev/" + path;
-        String volgroupName = path;
-        volgroupName = volgroupName.replaceFirst("/", "");
-
-        LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.LOGICAL,
-                volgroupName, uuid, host, volgroupPath, volgroupPath);
-        StoragePool sp = null;
-        try {
-            s_logger.debug(spd.toString());
-            sp = conn.storagePoolDefineXML(spd.toString(), 0);
-            sp.create(0);
-            return sp;
-        } catch (LibvirtException e) {
-            s_logger.debug(e.toString());
-            if (sp != null) {
-                try {
-                    sp.undefine();
-                    sp.free();
-                } catch (LibvirtException l) {
-                    s_logger.debug("Failed to define clvm storage pool with: "
-                            + l.toString());
-                }
-            }
-            return null;
-        }
-
-    }
-
-    private StoragePool createRBDStoragePool(Connect conn, String uuid,
-        String host, int port, String userInfo, String path) {
-
-        LibvirtStoragePoolDef spd;
-        StoragePool sp = null;
-
-        String[] userInfoTemp = userInfo.split(":");
-        if (userInfoTemp.length == 2) {
-            s_logger.debug("libvirt secret information found. id: " + userInfoTemp[0] + " secret: " + userInfoTemp[1]);
-            LibvirtSecretDef sd = new LibvirtSecretDef(usage.CEPH, uuid);
-
-            Secret s = null;
-
-            sd.setCephName(userInfoTemp[0]);
-
-            try {
-                s_logger.debug(sd.toString());
-                s = conn.secretDefineXML(sd.toString());
-                s.setValue(Base64.decodeBase64(userInfoTemp[1]));
-            } catch (LibvirtException e) {
-                s_logger.debug(e.toString());
-                if (s != null) {
-                    try {
-                        s.undefine();
-                        s.free();
-                    } catch (LibvirtException l) {
-                        s_logger.debug("Failed to define secret with: " + l.toString());
-                        }
-                    }
-            }
-            spd = new LibvirtStoragePoolDef(poolType.RBD, uuid, uuid, host, port, path, userInfoTemp[0], authType.CEPH, uuid);
-        } else {
-            spd = new LibvirtStoragePoolDef(poolType.RBD, uuid, uuid, host, port, path, "");
-        }
-
-        try {
-            s_logger.debug(spd.toString());
-            sp = conn.storagePoolDefineXML(spd.toString(), 0);
-            sp.create(0);
-            return sp;
-        } catch (LibvirtException e) {
-            s_logger.debug(e.toString());
-            if (sp != null) {
-                try {
-                    sp.undefine();
-                    sp.free();
-                } catch (LibvirtException l) {
-                    s_logger.debug("Failed to define RBD storage pool with: " + l.toString());
-                }
-            }
-            return null;
-        }
-    }
-
-    public StorageVol copyVolume(StoragePool destPool,
-            LibvirtStorageVolumeDef destVol, StorageVol srcVol, int timeout)
-            throws LibvirtException {
-        StorageVol vol = destPool.storageVolCreateXML(destVol.toString(), 0);
-        String srcPath = srcVol.getKey();
-        String destPath = vol.getKey();
-        Script.runSimpleBashScript("cp " + srcPath + " " + destPath, timeout);
-        return vol;
-    }
-
-    public boolean copyVolume(String srcPath, String destPath,
-            String volumeName, int timeout) throws InternalErrorException {
-        _storageLayer.mkdirs(destPath);
-        if (!_storageLayer.exists(srcPath)) {
-            throw new InternalErrorException("volume:" + srcPath
-                    + " is not exits");
-        }
-        String result = Script.runSimpleBashScript("cp " + srcPath + " "
-                + destPath + File.separator + volumeName, timeout);
-        if (result != null) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
-    public LibvirtStoragePoolDef getStoragePoolDef(Connect conn,
-            StoragePool pool) throws LibvirtException {
-        String poolDefXML = pool.getXMLDesc(0);
-        LibvirtStoragePoolXMLParser parser = new LibvirtStoragePoolXMLParser();
-        return parser.parseStoragePoolXML(poolDefXML);
-    }
-
-    public LibvirtStorageVolumeDef getStorageVolumeDef(Connect conn,
-            StorageVol vol) throws LibvirtException {
-        String volDefXML = vol.getXMLDesc(0);
-        LibvirtStorageVolumeXMLParser parser = new LibvirtStorageVolumeXMLParser();
-        return parser.parseStorageVolumeXML(volDefXML);
-    }
-
-    public StorageVol getVolumeFromURI(Connect conn, String volPath)
-            throws LibvirtException, URISyntaxException {
-        int index = volPath.lastIndexOf("/");
-        URI volDir = null;
-        StoragePool sp = null;
-        StorageVol vol = null;
-        try {
-            volDir = new URI(volPath.substring(0, index));
-            String volName = volPath.substring(index + 1);
-            sp = getStoragePoolbyURI(conn, volDir);
-            vol = sp.storageVolLookupByName(volName);
-            return vol;
-        } catch (LibvirtException e) {
-            s_logger.debug("Faild to get vol path: " + e.toString());
-            throw e;
-        } finally {
-            try {
-                if (sp != null) {
-                    sp.free();
-                }
-            } catch (LibvirtException e) {
-
-            }
-        }
-    }
-
-    public StoragePool createFileBasedStoragePool(Connect conn,
-            String localStoragePath, String uuid) {
-        if (!(_storageLayer.exists(localStoragePath) && _storageLayer
-                .isDirectory(localStoragePath))) {
-            return null;
-        }
-
-        File path = new File(localStoragePath);
-        if (!(path.canWrite() && path.canRead() && path.canExecute())) {
-            return null;
-        }
-
-        StoragePool pool = null;
-
-        try {
-            pool = conn.storagePoolLookupByUUIDString(uuid);
-        } catch (LibvirtException e) {
-
-        }
-
-        if (pool == null) {
-            LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.DIR,
-                    uuid, uuid, null, null, localStoragePath);
-            try {
-                pool = conn.storagePoolDefineXML(spd.toString(), 0);
-                pool.create(0);
-            } catch (LibvirtException e) {
-                if (pool != null) {
-                    try {
-                        pool.destroy();
-                        pool.undefine();
-                    } catch (LibvirtException e1) {
-                    }
-                    pool = null;
-                }
-                throw new CloudRuntimeException(e.toString());
-            }
-        }
-
-        try {
-            StoragePoolInfo spi = pool.getInfo();
-            if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
-                pool.create(0);
-            }
-
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-
-        return pool;
-    }
-
-    private void getStats(LibvirtStoragePool pool) {
-        Script statsScript = new Script("/bin/bash", s_logger);
-        statsScript.add("-c");
-        statsScript.add("stats=$(df --total " + pool.getLocalPath()
-                + " |grep total|awk '{print $2,$3}');echo $stats");
-        final OutputInterpreter.OneLineParser statsParser = new OutputInterpreter.OneLineParser();
-        String result = statsScript.execute(statsParser);
-        if (result == null) {
-            String stats = statsParser.getLine();
-            if (stats != null && !stats.isEmpty()) {
-                String sizes[] = stats.trim().split(" ");
-                if (sizes.length == 2) {
-                    pool.setCapacity(Long.parseLong(sizes[0]) * 1024);
-                    pool.setUsed(Long.parseLong(sizes[1]) * 1024);
-                }
-            }
-        }
-    }
-
-    @Override
-    public KVMStoragePool getStoragePool(String uuid) {
-        StoragePool storage = null;
-        try {
-            Connect conn = LibvirtConnection.getConnection();
-            storage = conn.storagePoolLookupByUUIDString(uuid);
-
-            if (storage.getInfo().state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
-                storage.create(0);
-            }
-            LibvirtStoragePoolDef spd = getStoragePoolDef(conn, storage);
-            StoragePoolType type = null;
-            if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.NETFS
-                    || spd.getPoolType() == LibvirtStoragePoolDef.poolType.DIR) {
-                type = StoragePoolType.Filesystem;
-            } else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.RBD) {
-                type = StoragePoolType.RBD;
-            }
-
-            LibvirtStoragePool pool = new LibvirtStoragePool(uuid, storage.getName(),
-                                                            type, this, storage);
-
-            if (pool.getType() != StoragePoolType.RBD) {
-                pool.setLocalPath(spd.getTargetPath());
-            } else {
-                pool.setLocalPath("");
-                pool.setSourceHost(spd.getSourceHost());
-                pool.setSourcePort(spd.getSourcePort());
-                pool.setSourceDir(spd.getSourceDir());
-                String authUsername = spd.getAuthUserName();
-                if (authUsername != null) {
-                    Secret secret = conn.secretLookupByUUIDString(spd.getSecretUUID());
-                    String secretValue = new String(Base64.encodeBase64(secret.getByteValue()));
-                    pool.setAuthUsername(authUsername);
-                    pool.setAuthSecret(secretValue);
-                }
-            }
-
-            if (pool.getType() == StoragePoolType.RBD) {
-                pool.setCapacity(storage.getInfo().capacity);
-                pool.setUsed(storage.getInfo().allocation);
-            } else {
-                getStats(pool);
-            }
-
-            return pool;
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-    }
-
-    @Override
-    public KVMPhysicalDisk getPhysicalDisk(String volumeUuid,
-            KVMStoragePool pool) {
-        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
-
-        try {
-            StorageVol vol = this.getVolume(libvirtPool.getPool(), volumeUuid);
-            KVMPhysicalDisk disk;
-            LibvirtStorageVolumeDef voldef = getStorageVolumeDef(libvirtPool
-                    .getPool().getConnect(), vol);
-            disk = new KVMPhysicalDisk(vol.getPath(), vol.getName(), pool);
-            disk.setSize(vol.getInfo().allocation);
-            disk.setVirtualSize(vol.getInfo().capacity);
-            if (voldef.getFormat() == null) {
-                disk.setFormat(pool.getDefaultFormat());
-            } else if (pool.getType() == StoragePoolType.RBD) {
-                disk.setFormat(KVMPhysicalDisk.PhysicalDiskFormat.RAW);
-            } else if (voldef.getFormat() == LibvirtStorageVolumeDef.volFormat.QCOW2) {
-                disk.setFormat(KVMPhysicalDisk.PhysicalDiskFormat.QCOW2);
-            } else if (voldef.getFormat() == LibvirtStorageVolumeDef.volFormat.RAW) {
-                disk.setFormat(KVMPhysicalDisk.PhysicalDiskFormat.RAW);
-            }
-            return disk;
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-
-    }
-
-    @Override
-    public KVMStoragePool createStoragePool(String name, String host, int port,
-                                            String path, String userInfo, StoragePoolType type) {
-        StoragePool sp = null;
-        Connect conn = null;
-        try {
-            conn = LibvirtConnection.getConnection();
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-
-        try {
-            sp = conn.storagePoolLookupByUUIDString(name);
-            if (sp.getInfo().state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
-                sp.undefine();
-                sp = null;
-            }
-        } catch (LibvirtException e) {
-
-        }
-
-        if (sp == null) {
-            if (type == StoragePoolType.NetworkFilesystem) {
-                sp = createNfsStoragePool(conn, name, host, path);
-            } else if (type == StoragePoolType.SharedMountPoint
-                    || type == StoragePoolType.Filesystem) {
-                sp = CreateSharedStoragePool(conn, name, host, path);
-            } else if (type == StoragePoolType.RBD) {
-                sp = createRBDStoragePool(conn, name, host, port, userInfo, path);
-            }
-        }
-
-        try {
-            StoragePoolInfo spi = sp.getInfo();
-            if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
-                sp.create(0);
-            }
-
-            LibvirtStoragePoolDef spd = getStoragePoolDef(conn, sp);
-            LibvirtStoragePool pool = new LibvirtStoragePool(name,
-                    sp.getName(), type, this, sp);
-
-            if (pool.getType() != StoragePoolType.RBD) {
-                pool.setLocalPath(spd.getTargetPath());
-            } else {
-                pool.setLocalPath("");
-            }
-
-            if (pool.getType() == StoragePoolType.RBD) {
-                pool.setCapacity(sp.getInfo().capacity);
-                pool.setUsed(sp.getInfo().allocation);
-            } else {
-                getStats(pool);
-            }
-            return pool;
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-    }
-
-    @Override
-    public boolean deleteStoragePool(String uuid) {
-        Connect conn = null;
-        try {
-            conn = LibvirtConnection.getConnection();
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-
-        StoragePool sp = null;
-        Secret s = null;
-
-        try {
-            sp = conn.storagePoolLookupByUUIDString(uuid);
-        } catch (LibvirtException e) {
-            return true;
-        }
-
-        /*
-         * Some storage pools, like RBD also have 'secret' information stored in libvirt
-         * Destroy them if they exist
-        */
-        try {
-            s = conn.secretLookupByUUIDString(uuid);
-        } catch (LibvirtException e) {
-        }
-
-        try {
-            sp.destroy();
-            sp.undefine();
-            sp.free();
-            if (s != null) {
-                s.undefine();
-                s.free();
-            }
-            return true;
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-    }
-
-    @Override
-    public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool,
-            PhysicalDiskFormat format, long size) {
-        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
-        StoragePool virtPool = libvirtPool.getPool();
-        LibvirtStorageVolumeDef.volFormat libvirtformat = null;
-
-        if (pool.getType() == StoragePoolType.RBD) {
-            format = PhysicalDiskFormat.RAW;
-        }
-
-        if (format == PhysicalDiskFormat.QCOW2) {
-            libvirtformat = LibvirtStorageVolumeDef.volFormat.QCOW2;
-        } else if (format == PhysicalDiskFormat.RAW) {
-            libvirtformat = LibvirtStorageVolumeDef.volFormat.RAW;
-        }
-
-        LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(name,
-                size, libvirtformat, null, null);
-        s_logger.debug(volDef.toString());
-        try {
-            StorageVol vol = virtPool.storageVolCreateXML(volDef.toString(), 0);
-            KVMPhysicalDisk disk = new KVMPhysicalDisk(vol.getPath(),
-                    vol.getName(), pool);
-            disk.setFormat(format);
-            disk.setSize(vol.getInfo().allocation);
-            disk.setVirtualSize(vol.getInfo().capacity);
-            return disk;
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-    }
-
-    @Override
-    public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool) {
-        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
-        try {
-            StorageVol vol = this.getVolume(libvirtPool.getPool(), uuid);
-            vol.delete(0);
-            vol.free();
-            return true;
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-    }
-
-    @Override
-    public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
-            String name, PhysicalDiskFormat format, long size, KVMStoragePool destPool) {
-
-        String newUuid = UUID.randomUUID().toString();
-        KVMStoragePool srcPool = template.getPool();
-        KVMPhysicalDisk disk = null;
-
-        /*
-            With RBD you can't run qemu-img convert with an existing RBD image as destination
-            qemu-img will exit with the error that the destination already exists.
-            So for RBD we don't create the image, but let qemu-img do that for us.
-
-            We then create a KVMPhysicalDisk object that we can return
-        */
-
-        if (destPool.getType() != StoragePoolType.RBD) {
-            disk = destPool.createPhysicalDisk(newUuid, format, template.getVirtualSize());
-
-            Script.runSimpleBashScript("qemu-img create -f "
-                    + template.getFormat() + " -b  " + template.getPath() + " "
-                    + disk.getPath());
-        } else {
-            disk = new KVMPhysicalDisk(destPool.getSourceDir() + "/" + newUuid, newUuid, destPool);
-            disk.setFormat(format);
-            disk.setSize(template.getVirtualSize());
-            disk.setVirtualSize(disk.getSize());
-
-            if (srcPool.getType() != StoragePoolType.RBD) {
-                Script.runSimpleBashScript("qemu-img convert"
-                        + " -f " + template.getFormat()
-                        + " -O " + format
-                        + " " + template.getPath()
-                        + " " + KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(),
-                                                destPool.getSourcePort(),
-                                                destPool.getAuthUserName(),
-                                                destPool.getAuthSecret(),
-                                                disk.getPath()));
-            } else {
-                template.setFormat(PhysicalDiskFormat.RAW);
-                Script.runSimpleBashScript("qemu-img convert"
-                        + " -f " + template.getFormat()
-                        + " -O " + format
-                        + " " + KVMPhysicalDisk.RBDStringBuilder(srcPool.getSourceHost(),
-                                                srcPool.getSourcePort(),
-                                                srcPool.getAuthUserName(),
-                                                srcPool.getAuthSecret(),
-                                                template.getPath())
-                        + " " + KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(),
-                                                destPool.getSourcePort(),
-                                                destPool.getAuthUserName(),
-                                                destPool.getAuthSecret(),
-                                                disk.getPath()));
-            }
-        }
-        return disk;
-    }
-
-    @Override
-    public KVMPhysicalDisk createTemplateFromDisk(KVMPhysicalDisk disk,
-            String name, PhysicalDiskFormat format, long size,
-            KVMStoragePool destPool) {
-        return null;
-    }
-
-    @Override
-    public List<KVMPhysicalDisk> listPhysicalDisks(String storagePoolUuid,
-            KVMStoragePool pool) {
-        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
-        StoragePool virtPool = libvirtPool.getPool();
-        List<KVMPhysicalDisk> disks = new ArrayList<KVMPhysicalDisk>();
-        try {
-            String[] vols = virtPool.listVolumes();
-            for (String volName : vols) {
-                KVMPhysicalDisk disk = this.getPhysicalDisk(volName, pool);
-                disks.add(disk);
-            }
-            return disks;
-        } catch (LibvirtException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-    }
-
-    @Override
-    public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
-            KVMStoragePool destPool) {
-
-        /*
-            With RBD you can't run qemu-img convert with an existing RBD image as destination
-            qemu-img will exit with the error that the destination already exists.
-            So for RBD we don't create the image, but let qemu-img do that for us.
-
-            We then create a KVMPhysicalDisk object that we can return
-        */
-
-        KVMPhysicalDisk newDisk;
-        if (destPool.getType() != StoragePoolType.RBD) {
-            newDisk = destPool.createPhysicalDisk(name, disk.getVirtualSize());
-        } else {
-            newDisk = new KVMPhysicalDisk(destPool.getSourceDir() + "/" + name, name, destPool);
-            newDisk.setFormat(PhysicalDiskFormat.RAW);
-            newDisk.setSize(disk.getVirtualSize());
-            newDisk.setVirtualSize(disk.getSize());
-        }
-
-        KVMStoragePool srcPool = disk.getPool();
-        String destPath = newDisk.getPath();
-        String sourcePath = disk.getPath();
-        PhysicalDiskFormat sourceFormat = disk.getFormat();
-        PhysicalDiskFormat destFormat = newDisk.getFormat();
-
-        if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() != StoragePoolType.RBD)) {
-            Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
-                + " -O " + destFormat
-                + " " + sourcePath
-                + " " + destPath);
-        } else if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() == StoragePoolType.RBD))  {
-            Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
-                    + " -O " + destFormat
-                    + " " + sourcePath
-                    + " " + KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(),
-                                                destPool.getSourcePort(),
-                                                destPool.getAuthUserName(),
-                                                destPool.getAuthSecret(),
-                                                destPath));
-        } else {
-            Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat
-                    + " -O " + destFormat
-                    + " " + KVMPhysicalDisk.RBDStringBuilder(srcPool.getSourceHost(),
-                                                srcPool.getSourcePort(),
-                                                srcPool.getAuthUserName(),
-                                                srcPool.getAuthSecret(),
-                                                sourcePath)
-                    + " " + KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(),
-                                                destPool.getSourcePort(),
-                                                destPool.getAuthUserName(),
-                                                destPool.getAuthSecret(),
-                                                destPath));
-        }
-
-        return newDisk;
-    }
-
-    @Override
-    public KVMStoragePool getStoragePoolByUri(String uri) {
-        URI storageUri = null;
-
-        try {
-            storageUri = new URI(uri);
-        } catch (URISyntaxException e) {
-            throw new CloudRuntimeException(e.toString());
-        }
-
-        String sourcePath = null;
-        String uuid = null;
-        String sourceHost = "";
-        StoragePoolType protocal = null;
-        if (storageUri.getScheme().equalsIgnoreCase("nfs")) {
-            sourcePath = storageUri.getPath();
-            sourcePath = sourcePath.replace("//", "/");
-            sourceHost = storageUri.getHost();
-            uuid = UUID.randomUUID().toString();
-            protocal = StoragePoolType.NetworkFilesystem;
-        }
-
-            return createStoragePool(uuid, sourceHost, 0, sourcePath, "", protocal);
-    }
-
-    @Override
-    public KVMPhysicalDisk getPhysicalDiskFromURI(String uri) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot,
-            String snapshotName, String name, KVMStoragePool destPool) {
-        return null;
-    }
-
-    @Override
-    public boolean refresh(KVMStoragePool pool) {
-        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
-        StoragePool virtPool = libvirtPool.getPool();
-        try {
-            virtPool.refresh(0);
-        } catch (LibvirtException e) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public boolean deleteStoragePool(KVMStoragePool pool) {
-        LibvirtStoragePool libvirtPool = (LibvirtStoragePool) pool;
-        StoragePool virtPool = libvirtPool.getPool();
-        try {
-            virtPool.destroy();
-            virtPool.undefine();
-            virtPool.free();
-        } catch (LibvirtException e) {
-            return false;
-        }
-
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/agent/src/com/cloud/agent/storage/LibvirtStoragePool.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/storage/LibvirtStoragePool.java b/agent/src/com/cloud/agent/storage/LibvirtStoragePool.java
deleted file mode 100644
index 943b8b2..0000000
--- a/agent/src/com/cloud/agent/storage/LibvirtStoragePool.java
+++ /dev/null
@@ -1,208 +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.agent.storage;
-
-import java.util.List;
-
-import org.libvirt.StoragePool;
-
-import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
-import com.cloud.storage.Storage.StoragePoolType;
-
-public class LibvirtStoragePool implements KVMStoragePool {
-    protected String uuid;
-    protected String uri;
-    protected long capacity;
-    protected long used;
-    protected String name;
-    protected String localPath;
-    protected PhysicalDiskFormat defaultFormat;
-    protected StoragePoolType type;
-    protected StorageAdaptor _storageAdaptor;
-    protected StoragePool _pool;
-    protected String authUsername;
-    protected String authSecret;
-    protected String sourceHost;
-    protected int sourcePort;
-    protected String sourceDir;
-
-    public LibvirtStoragePool(String uuid, String name, StoragePoolType type,
-            StorageAdaptor adaptor, StoragePool pool) {
-        this.uuid = uuid;
-        this.name = name;
-        this.type = type;
-        this._storageAdaptor = adaptor;
-        this.capacity = 0;
-        this.used = 0;
-        this._pool = pool;
-
-    }
-
-    public void setCapacity(long capacity) {
-        this.capacity = capacity;
-    }
-
-    @Override
-    public long getCapacity() {
-        return this.capacity;
-    }
-
-    public void setUsed(long used) {
-        this.used = used;
-    }
-
-    @Override
-    public long getUsed() {
-        return this.used;
-    }
-
-    public StoragePoolType getStoragePoolType() {
-        return this.type;
-    }
-
-    public String getName() {
-        return this.name;
-    }
-
-    public String getUuid() {
-        return this.uuid;
-    }
-
-    public String uri() {
-        return this.uri;
-    }
-
-    @Override
-    public PhysicalDiskFormat getDefaultFormat() {
-        return PhysicalDiskFormat.QCOW2;
-    }
-
-    @Override
-    public KVMPhysicalDisk createPhysicalDisk(String name,
-            PhysicalDiskFormat format, long size) {
-        return this._storageAdaptor
-                .createPhysicalDisk(name, this, format, size);
-    }
-
-    @Override
-    public KVMPhysicalDisk createPhysicalDisk(String name, long size) {
-        return this._storageAdaptor.createPhysicalDisk(name, this,
-                this.getDefaultFormat(), size);
-    }
-
-    @Override
-    public KVMPhysicalDisk getPhysicalDisk(String volumeUuid) {
-        return this._storageAdaptor.getPhysicalDisk(volumeUuid, this);
-    }
-
-    @Override
-    public boolean deletePhysicalDisk(String uuid) {
-        return this._storageAdaptor.deletePhysicalDisk(uuid, this);
-    }
-
-    @Override
-    public List<KVMPhysicalDisk> listPhysicalDisks() {
-        return this._storageAdaptor.listPhysicalDisks(this.uuid, this);
-    }
-
-    @Override
-    public boolean refresh() {
-        return this._storageAdaptor.refresh(this);
-    }
-
-    @Override
-    public boolean isExternalSnapshot() {
-        if (this.type == StoragePoolType.Filesystem) {
-            return false;
-        }
-
-        return true;
-    }
-
-    @Override
-    public String getLocalPath() {
-        return this.localPath;
-    }
-
-    public void setLocalPath(String localPath) {
-        this.localPath = localPath;
-    }
-
-    @Override
-    public String getAuthUserName() {
-        return this.authUsername;
-    }
-
-    public void setAuthUsername(String authUsername) {
-        this.authUsername = authUsername;
-    }
-
-    @Override
-    public String getAuthSecret() {
-        return this.authSecret;
-    }
-
-    public void setAuthSecret(String authSecret) {
-        this.authSecret = authSecret;
-    }
-
-    @Override
-    public String getSourceHost() {
-        return this.sourceHost;
-    }
-
-    public void setSourceHost(String host) {
-        this.sourceHost = host;
-    }
-
-    @Override
-    public int getSourcePort() {
-        return this.sourcePort;
-    }
-
-    public void setSourcePort(int port) {
-        this.sourcePort = port;
-    }
-
-    @Override
-    public String getSourceDir() {
-        return this.sourceDir;
-    }
-
-    public void setSourceDir(String dir) {
-        this.sourceDir = dir;
-    }
-
-    @Override
-    public StoragePoolType getType() {
-        return this.type;
-    }
-
-    public StoragePool getPool() {
-        return this._pool;
-    }
-
-    @Override
-    public boolean delete() {
-        return this._storageAdaptor.deleteStoragePool(this);
-    }
-
-    @Override
-    public boolean createFolder(String path) {
-        return this._storageAdaptor.createFolder(this.uuid, path);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/agent/src/com/cloud/agent/storage/StorageAdaptor.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/storage/StorageAdaptor.java b/agent/src/com/cloud/agent/storage/StorageAdaptor.java
deleted file mode 100644
index 8238677..0000000
--- a/agent/src/com/cloud/agent/storage/StorageAdaptor.java
+++ /dev/null
@@ -1,70 +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.agent.storage;
-
-import java.util.List;
-
-import org.libvirt.StoragePool;
-
-import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
-import com.cloud.storage.Storage.StoragePoolType;
-
-public interface StorageAdaptor {
-
-    public KVMStoragePool getStoragePool(String uuid);
-
-    public KVMPhysicalDisk getPhysicalDisk(String volumeUuid,
-            KVMStoragePool pool);
-
-    public KVMStoragePool createStoragePool(String name, String host, int port,
-            String path, String userInfo, StoragePoolType type);
-
-    public boolean deleteStoragePool(String uuid);
-
-    public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool,
-            PhysicalDiskFormat format, long size);
-
-    public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool);
-
-    public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
-            String name, PhysicalDiskFormat format, long size,
-            KVMStoragePool destPool);
-
-    public KVMPhysicalDisk createTemplateFromDisk(KVMPhysicalDisk disk,
-            String name, PhysicalDiskFormat format, long size,
-            KVMStoragePool destPool);
-
-    public List<KVMPhysicalDisk> listPhysicalDisks(String storagePoolUuid,
-            KVMStoragePool pool);
-
-    public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
-            KVMStoragePool destPools);
-
-    public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot,
-            String snapshotName, String name, KVMStoragePool destPool);
-
-    public KVMStoragePool getStoragePoolByUri(String uri);
-
-    public KVMPhysicalDisk getPhysicalDiskFromURI(String uri);
-
-    public boolean refresh(KVMStoragePool pool);
-
-    public boolean deleteStoragePool(KVMStoragePool pool);
-
-    public boolean createFolder(String uuid, String path);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/build/build-cloud-plugins.xml
----------------------------------------------------------------------
diff --git a/build/build-cloud-plugins.xml b/build/build-cloud-plugins.xml
index c16474d..a7a1f39 100755
--- a/build/build-cloud-plugins.xml
+++ b/build/build-cloud-plugins.xml
@@ -198,9 +198,14 @@
 
   <!-- ===================== Hypervisors ========================= -->
 
-  <target name="compile-hypervisors" depends="compile-ovm, compile-xen, compile-vmware" description="Compile all hypervisors"/>
-  <target name="build-hypervisors" depends="build-ovm, build-xen, build-vmware" description="Builds all hypervisors"/>
+  <target name="compile-hypervisors" depends="compile-kvm, compile-ovm, compile-xen, compile-vmware" description="Compile all hypervisors"/>
+  <target name="build-hypervisors" depends="build-kvm, build-ovm, build-xen, build-vmware" description="Builds all hypervisors"/>
 
+  <target name="compile-kvm" depends="-init, compile-core, compile-agent" description="Compile KVM">
+  	<ant antfile="${base.dir}/plugins/hypervisors/kvm/build.xml" target="build"/>
+  </target>
+  <target name="build-kvm" depends="compile-kvm" />
+  
   <target name="compile-ovm" depends="-init, compile-server" description="Compile OVM">
   	<ant antfile="${base.dir}/plugins/hypervisors/ovm/build.xml" target="build"/>
   </target>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/build/package.xml
----------------------------------------------------------------------
diff --git a/build/package.xml b/build/package.xml
index 30dde94..a2768b6 100755
--- a/build/package.xml
+++ b/build/package.xml
@@ -82,7 +82,6 @@
         <include name="cloud-commons-collections-3.2.1.jar" />
         <include name="cloud-commons-codec-1.4.jar" />
         <include name="cloud-commons-pool-1.4.jar" />
-        <include name="libvirt-0.4.8.jar" />
         <include name="cloud-jna.jar" />
         <include name="cloud-cglib.jar" />
         <include name="jetty-6.1.26.jar" />
@@ -93,6 +92,7 @@
         <include name="${utils.jar}" />
         <include name="${core.jar}" />
         <include name="${api.jar}" />
+        <include name="${kvm.jar}" />
       </zipfileset>
 
       <zipfileset dir="${agent.dist.dir}" filemode="770">
@@ -112,7 +112,7 @@
   </target>
 
 
-  <target name="package-agent" depends="-init-package, package-oss-systemvm,  build-systemvm-patch, package-agent-common">
+  <target name="package-agent" depends="-init-package, package-oss-systemvm,  build-systemvm-patch, package-agent-common, build-kvm">
     <zip destfile="${dist.dir}/agent.zip" duplicate="preserve" update="true">
       <zipfileset dir="${dist.dir}" prefix="vms">
         <include name="patch.tgz" />
@@ -291,6 +291,17 @@
     </zip>
   </target>
 
+  <target name="package-kvm" depends="package-agent">
+    <zip destfile="${dist.dir}/agent.zip" update="true">
+    	<zipfileset dir="${jar.dir}">
+    	   <include name="cloud-kvm.jar"/>
+    	</zipfileset>
+    	<zipfileset dir="${deps.dir}">
+    	   <include name="libvirt-0.4.8.jar"/>
+    	</zipfileset>
+    </zip>
+  </target>
+	
   <target name="clean-zip">
     <delete dir="${dist.dir}">
       <include name="*.zip" />

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/cloud.spec
----------------------------------------------------------------------
diff --git a/cloud.spec b/cloud.spec
index 63a7e8a..fcfa740 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)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/core/src/com/cloud/hypervisor/kvm/resource/KvmDummyResourceBase.java
----------------------------------------------------------------------
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 d49780f..0000000
--- 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<String, String>(), new HashMap<String, VmState>());
-		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<String, Object> 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;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/debian/cloud-agent-libs.install
----------------------------------------------------------------------
diff --git a/debian/cloud-agent-libs.install b/debian/cloud-agent-libs.install
index 538f068..4cc5336 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

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/plugins/hypervisors/kvm/.classpath
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/.classpath b/plugins/hypervisors/kvm/.classpath
new file mode 100644
index 0000000..9e6fddb
--- /dev/null
+++ b/plugins/hypervisors/kvm/.classpath
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/agent"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/api"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/core"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/plugins/hypervisors/kvm/.project
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/.project b/plugins/hypervisors/kvm/.project
new file mode 100755
index 0000000..4a89b9e
--- /dev/null
+++ b/plugins/hypervisors/kvm/.project
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>KVM</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.python.pydev.PyDevBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.python.pydev.pythonNature</nature>
+	</natures>
+</projectDescription>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/plugins/hypervisors/kvm/.pydevproject
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/.pydevproject b/plugins/hypervisors/kvm/.pydevproject
new file mode 100644
index 0000000..a9cca03
--- /dev/null
+++ b/plugins/hypervisors/kvm/.pydevproject
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
+</pydev_project>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7a0a9231/plugins/hypervisors/kvm/build.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/build.xml b/plugins/hypervisors/kvm/build.xml
new file mode 100755
index 0000000..60e6653
--- /dev/null
+++ b/plugins/hypervisors/kvm/build.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+
+<project name="Cloud Stack KVM" default="help" basedir=".">
+  <description>
+		Cloud Stack ant build file
+    </description>
+
+  <dirname property="kvm.base.dir" file="${ant.file.Cloud Stack KVM}/"/>
+  <!-- This directory must be set -->
+  <property name="top.dir" location="${kvm.base.dir}/../../.."/>
+  <property name="build.dir" location="${top.dir}/build"/>
+	
+	<echo message="build.dir=${build.dir}; top.dir=${top.dir}; kvm.base.dir=${kvm.base.dir}"/>
+
+  <!-- Import anything that the user wants to set-->
+  <!-- Import properties files and environment variables here -->
+
+  <property environment="env" />
+
+  <condition property="build-cloud.properties.file" value="${build.dir}/override/build-cloud.properties" else="${build.dir}/build-cloud.properties">
+    <available file="${build.dir}/override/build-cloud.properties" />
+  </condition>
+
+  <condition property="cloud.properties.file" value="${build.dir}/override/cloud.properties" else="${build.dir}/cloud.properties">
+    <available file="${build.dir}/override/cloud.properties" />
+  </condition>
+
+  <condition property="override.file" value="${build.dir}/override/replace.properties" else="${build.dir}/replace.properties">
+    <available file="${build.dir}/override/replace.properties" />
+  </condition>
+
+  <echo message="Using build parameters from ${build-cloud.properties.file}" />
+  <property file="${build-cloud.properties.file}" />
+
+  <echo message="Using company info from ${cloud.properties.file}" />
+  <property file="${cloud.properties.file}" />
+
+  <echo message="Using override file from ${override.file}" />
+  <property file="${override.file}" />
+
+  <property file="${build.dir}/build.number" />
+
+  <!-- In case these didn't get defined in the build-cloud.properties -->
+  <property name="branding.name" value="default" />
+  <property name="deprecation" value="off" />
+  <property name="target.compat.version" value="1.6" />
+  <property name="source.compat.version" value="1.6" />
+  <property name="debug" value="true" />
+  <property name="debuglevel" value="lines,source"/>
+
+  <echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
+  <!-- directories for build and distribution -->
+  <property name="target.dir" location="${top.dir}/target" />
+  <property name="classes.dir" location="${target.dir}/classes" />
+  <property name="jar.dir" location="${target.dir}/jar" />
+  <property name="dep.cache.dir" location="${target.dir}/dep-cache" />
+  <property name="build.log" location="${target.dir}/ant_verbose.txt" />
+
+  <property name="deps.dir" location="${top.dir}/deps" />
+  
+  <property name="kvm.jar" value="cloud-kvm.jar" />
+  <property name="scripts.target.dir" location="${target.dir}/scripts"/>
+  <property name="kvm.scripts.dir" location="${base.dir}/plugins/hypervisors/kvm/scripts" />
+	
+  <import file="${build.dir}/build-common.xml"/>
+
+  <echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
+	
+  <!-- This section needs to be replaced by some kind of dependency library-->
+  <path id="deps.classpath">
+    <!--filelist files="${deps.classpath}" /-->
+    <fileset dir="${deps.dir}" erroronmissingdir="false">
+      <include name="*.jar" />
+    </fileset>
+  </path>
+	
+  <path id="cloudstack.classpath">
+  	<fileset dir="${jar.dir}">
+  	  <include name="*.jar"/>
+    </fileset>
+  </path>
+	
+  <path id="kvm.classpath">
+	<path refid="deps.classpath"/>
+  	<path refid="cloudstack.classpath"/>
+  </path>
+	
+  <!-- This section needs to be replaced by some kind of dependency library-->
+
+  <target name="deploy-kvm" >
+      <copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts">
+          <fileset dir="${kvm.scripts.dir}">
+              <include name="**/*"/>
+          </fileset>
+      </copy>
+  </target>
+
+  <target name="init" description="Initialize binaries directory">
+  	<mkdir dir="${classes.dir}/${kvm.jar}"/>
+  	<mkdir dir="${jar.dir}"/>
+  </target>
+	
+  <target name="compile-kvm" depends="init" description="Compiles Xen ">
+    <compile-java jar.name="${kvm.jar}" top.dir="${kvm.base.dir}" classpath="kvm.classpath" />
+  </target>
+	
+  <target name="help" description="help">
+    <echo level="info" message="This is the build file for kvmserver"/>
+    <echo level="info" message="You can do a build by doing ant build or clean by ant clean" />
+  </target>
+
+  <target name="clean-kvm">
+    <delete dir="${classes.dir}/${kvm.jar}"/>
+  </target>
+	
+  <target name="build" depends="compile-kvm"/>
+
+  <target name="clean" depends="clean-kvm"/>
+  
+</project>


Mime
View raw message