Search in sources :

Example 1 with StorageDetails

use of com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails in project cloudstack by apache.

the class StoragePluginTest method testNFSStorageMountCreation.

@Test
public void testNFSStorageMountCreation() throws Ovm3ResourceException {
    con.setResult(results.simpleResponseWrapWrapper(NFSMOUNTRESPONSEXML));
    StorageDetails sd = sPt.storagePluginMountNFS(NFSHOST, NFSPATH, FSMNTUUID, NFSMNT);
    con.setResult(results.simpleResponseWrapWrapper(NFSMOUNTRESPONSEXML));
    NFSMNT = NFSMNT + "/" + FSMNTUUID;
    sd = sPt.storagePluginMountNFS(NFSHOST, NFSPATH, FSMNTUUID, NFSMNT);
    results.basicLongTest(Long.valueOf(sd.getSize()), 263166853120L);
    results.basicLongTest(Long.valueOf(sd.getFreeSize()), 259377299456L);
    results.basicStringTest(sd.getName(), "nfs:" + NFSPATH);
    results.basicStringTest(sd.getUuid(), FSPROPUUID);
    results.basicStringTest(sd.getDetailsRelationalUuid(), FSMNTUUID);
}
Also used : StorageDetails(com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails) Test(org.junit.Test)

Example 2 with StorageDetails

use of com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails in project cloudstack by apache.

the class Ovm3StoragePool method execute.

/**
 * Gets statistics for storage.
 *
 * @param cmd
 * @return
 */
public GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
    LOGGER.debug("Getting stats for: " + cmd.getStorageId());
    try {
        Linux host = new Linux(c);
        Linux.FileSystem fs = host.getFileSystemByUuid(cmd.getStorageId(), "nfs");
        StoragePlugin store = new StoragePlugin(c);
        String propUuid = store.deDash(cmd.getStorageId());
        String mntUuid = cmd.getStorageId();
        if (store == null || propUuid == null || mntUuid == null || fs == null) {
            String msg = "Null returned when retrieving stats for " + cmd.getStorageId();
            LOGGER.error(msg);
            return new GetStorageStatsAnswer(cmd, msg);
        }
        /* or is it mntUuid ish ? */
        StorageDetails sd = store.storagePluginGetFileSystemInfo(propUuid, mntUuid, fs.getHost(), fs.getDevice());
        /*
             * FIXME: cure me or kill me, this needs to trigger a reinit of
             * primary storage, actually the problem is more deeprooted, as when
             * the hypervisor reboots it looses partial context and needs to be
             * reinitiated.... actually a full configure round... how to trigger
             * that ?
             */
        if ("".equals(sd.getSize())) {
            String msg = "No size when retrieving stats for " + cmd.getStorageId();
            LOGGER.debug(msg);
            return new GetStorageStatsAnswer(cmd, msg);
        }
        long total = Long.parseLong(sd.getSize());
        long used = total - Long.parseLong(sd.getFreeSize());
        return new GetStorageStatsAnswer(cmd, total, used);
    } catch (Ovm3ResourceException e) {
        LOGGER.debug("GetStorageStatsCommand for " + cmd.getStorageId() + " failed", e);
        return new GetStorageStatsAnswer(cmd, e.getMessage());
    }
}
Also used : GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) Linux(com.cloud.hypervisor.ovm3.objects.Linux) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) StorageDetails(com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails) StoragePlugin(com.cloud.hypervisor.ovm3.objects.StoragePlugin)

Example 3 with StorageDetails

use of com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails in project cloudstack by apache.

the class Ovm3StoragePool method execute.

/**
 * Gets the details of a storage pool, size etc
 *
 * @param cmd
 * @return
 */
public Answer execute(ModifyStoragePoolCommand cmd) {
    StorageFilerTO pool = cmd.getPool();
    LOGGER.debug("modifying pool " + pool);
    try {
        if (config.getAgentInOvm3Cluster()) {
        // no native ovm cluster for now, I got to break it in horrible
        // ways
        }
        if (pool.getType() == StoragePoolType.NetworkFilesystem) {
            createRepo(pool);
            StoragePlugin store = new StoragePlugin(c);
            String propUuid = store.deDash(pool.getUuid());
            String mntUuid = pool.getUuid();
            String nfsHost = pool.getHost();
            String nfsPath = pool.getPath();
            StorageDetails ss = store.storagePluginGetFileSystemInfo(propUuid, mntUuid, nfsHost, nfsPath);
            Map<String, TemplateProp> tInfo = new HashMap<String, TemplateProp>();
            return new ModifyStoragePoolAnswer(cmd, Long.parseLong(ss.getSize()), Long.parseLong(ss.getFreeSize()), tInfo);
        } else if (pool.getType() == StoragePoolType.OCFS2) {
            createOCFS2Sr(pool);
        }
        return new Answer(cmd, false, "The pool type: " + pool.getType().name() + " is not supported.");
    } catch (Exception e) {
        LOGGER.debug("ModifyStoragePoolCommand failed", e);
        return new Answer(cmd, false, e.getMessage());
    }
}
Also used : TemplateProp(com.cloud.storage.template.TemplateProp) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) GetStorageStatsAnswer(com.cloud.agent.api.GetStorageStatsAnswer) Answer(com.cloud.agent.api.Answer) HashMap(java.util.HashMap) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) StorageDetails(com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails) StoragePlugin(com.cloud.hypervisor.ovm3.objects.StoragePlugin) ConfigurationException(javax.naming.ConfigurationException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)

Aggregations

StorageDetails (com.cloud.hypervisor.ovm3.objects.StoragePlugin.StorageDetails)3 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)2 Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)2 StoragePlugin (com.cloud.hypervisor.ovm3.objects.StoragePlugin)2 Answer (com.cloud.agent.api.Answer)1 ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)1 PrimaryStorageDownloadAnswer (com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer)1 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)1 Linux (com.cloud.hypervisor.ovm3.objects.Linux)1 TemplateProp (com.cloud.storage.template.TemplateProp)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 HashMap (java.util.HashMap)1 ConfigurationException (javax.naming.ConfigurationException)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1 Test (org.junit.Test)1