Search in sources :

Example 11 with ModifyStoragePoolAnswer

use of com.cloud.agent.api.ModifyStoragePoolAnswer in project CloudStack-archive by CloudStack-extras.

the class MockStorageManagerImpl method ModifyStoragePool.

@Override
public ModifyStoragePoolAnswer ModifyStoragePool(ModifyStoragePoolCommand cmd) {
    StorageFilerTO sf = cmd.getPool();
    MockStoragePoolVO storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
    if (storagePool == null) {
        storagePool = new MockStoragePoolVO();
        storagePool.setUuid(sf.getUuid());
        storagePool.setMountPoint("/mnt/" + sf.getUuid() + File.separator);
        Long size = DEFAULT_HOST_STORAGE_SIZE;
        String path = sf.getPath();
        int index = path.lastIndexOf("/");
        if (index != -1) {
            path = path.substring(index + 1);
            if (path != null) {
                String[] values = path.split("=");
                if (values.length > 1 && values[0].equalsIgnoreCase("size")) {
                    size = Long.parseLong(values[1]);
                }
            }
        }
        storagePool.setCapacity(size);
        storagePool.setStorageType(sf.getType());
        storagePool = _mockStoragePoolDao.persist(storagePool);
    }
    return new ModifyStoragePoolAnswer(cmd, storagePool.getCapacity(), 0, new HashMap<String, TemplateInfo>());
}
Also used : TemplateInfo(com.cloud.storage.template.TemplateInfo) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) MockStoragePoolVO(com.cloud.simulator.MockStoragePoolVO) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO)

Example 12 with ModifyStoragePoolAnswer

use of com.cloud.agent.api.ModifyStoragePoolAnswer in project CloudStack-archive by CloudStack-extras.

the class MockStorageManagerImpl method CreateStoragePool.

@Override
public Answer CreateStoragePool(CreateStoragePoolCommand cmd) {
    StorageFilerTO sf = cmd.getPool();
    MockStoragePoolVO storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
    if (storagePool == null) {
        storagePool = new MockStoragePoolVO();
        storagePool.setUuid(sf.getUuid());
        storagePool.setMountPoint("/mnt/" + sf.getUuid() + File.separator);
        Long size = DEFAULT_HOST_STORAGE_SIZE;
        String path = sf.getPath();
        int index = path.lastIndexOf("/");
        if (index != -1) {
            path = path.substring(index + 1);
            if (path != null) {
                String[] values = path.split("=");
                if (values.length > 1 && values[0].equalsIgnoreCase("size")) {
                    size = Long.parseLong(values[1]);
                }
            }
        }
        storagePool.setCapacity(size);
        storagePool.setStorageType(sf.getType());
        storagePool = _mockStoragePoolDao.persist(storagePool);
    }
    return new ModifyStoragePoolAnswer(cmd, storagePool.getCapacity(), 0, new HashMap<String, TemplateInfo>());
}
Also used : TemplateInfo(com.cloud.storage.template.TemplateInfo) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) MockStoragePoolVO(com.cloud.simulator.MockStoragePoolVO) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO)

Example 13 with ModifyStoragePoolAnswer

use of com.cloud.agent.api.ModifyStoragePoolAnswer in project cloudstack by apache.

the class MockStorageManagerImpl method ModifyStoragePool.

@Override
public ModifyStoragePoolAnswer ModifyStoragePool(ModifyStoragePoolCommand cmd) {
    StorageFilerTO sf = cmd.getPool();
    TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
    MockStoragePoolVO storagePool = null;
    try {
        txn.start();
        storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
        if (storagePool == null) {
            storagePool = new MockStoragePoolVO();
            storagePool.setUuid(sf.getUuid());
            storagePool.setMountPoint("/mnt/" + sf.getUuid());
            Long size = DEFAULT_HOST_STORAGE_SIZE;
            String path = sf.getPath();
            int index = path.lastIndexOf("/");
            if (index != -1) {
                path = path.substring(index + 1);
                if (path != null) {
                    String[] values = path.split("=");
                    if (values.length > 1 && values[0].equalsIgnoreCase("size")) {
                        size = Long.parseLong(values[1]);
                    }
                }
            }
            storagePool.setCapacity(size);
            storagePool.setStorageType(sf.getType());
            storagePool = _mockStoragePoolDao.persist(storagePool);
        }
        txn.commit();
    } catch (Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("Error when modifying storage pool " + cmd.getPool().getPath(), ex);
    } finally {
        txn.close();
        txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
        txn.close();
    }
    return new ModifyStoragePoolAnswer(cmd, storagePool.getCapacity(), storagePool.getCapacity(), new HashMap<String, TemplateProp>());
}
Also used : TemplateProp(com.cloud.storage.template.TemplateProp) TransactionLegacy(com.cloud.utils.db.TransactionLegacy) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) MockStoragePoolVO(com.cloud.simulator.MockStoragePoolVO) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) URISyntaxException(java.net.URISyntaxException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 14 with ModifyStoragePoolAnswer

use of com.cloud.agent.api.ModifyStoragePoolAnswer in project cloudstack by apache.

the class LibvirtModifyStoragePoolCommandWrapper method execute.

@Override
public Answer execute(final ModifyStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) {
    final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
    final KVMStoragePool storagepool = storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), command.getPool().getUserInfo(), command.getPool().getType());
    if (storagepool == null) {
        return new Answer(command, false, " Failed to create storage pool");
    }
    final Map<String, TemplateProp> tInfo = new HashMap<String, TemplateProp>();
    final ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(command, storagepool.getCapacity(), storagepool.getAvailable(), tInfo);
    return answer;
}
Also used : TemplateProp(com.cloud.storage.template.TemplateProp) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) Answer(com.cloud.agent.api.Answer) KVMStoragePoolManager(com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager) KVMStoragePool(com.cloud.hypervisor.kvm.storage.KVMStoragePool) HashMap(java.util.HashMap) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer)

Example 15 with ModifyStoragePoolAnswer

use of com.cloud.agent.api.ModifyStoragePoolAnswer in project cloudstack by apache.

the class MockStorageManagerImpl method CreateStoragePool.

@Override
public Answer CreateStoragePool(CreateStoragePoolCommand cmd) {
    StorageFilerTO sf = cmd.getPool();
    TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
    MockStoragePoolVO storagePool = null;
    try {
        txn.start();
        storagePool = _mockStoragePoolDao.findByUuid(sf.getUuid());
        if (storagePool == null) {
            storagePool = new MockStoragePoolVO();
            storagePool.setUuid(sf.getUuid());
            storagePool.setMountPoint("/mnt/" + sf.getUuid());
            Long size = DEFAULT_HOST_STORAGE_SIZE;
            String path = sf.getPath();
            int index = path.lastIndexOf("/");
            if (index != -1) {
                path = path.substring(index + 1);
                if (path != null) {
                    String[] values = path.split("=");
                    if (values.length > 1 && values[0].equalsIgnoreCase("size")) {
                        size = Long.parseLong(values[1]);
                    }
                }
            }
            storagePool.setCapacity(size);
            storagePool.setStorageType(sf.getType());
            storagePool = _mockStoragePoolDao.persist(storagePool);
        }
        txn.commit();
    } catch (Exception ex) {
        txn.rollback();
        throw new CloudRuntimeException("Error when creating storage pool " + cmd.getPool().getPath(), ex);
    } finally {
        txn.close();
        txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
        txn.close();
    }
    return new ModifyStoragePoolAnswer(cmd, storagePool.getCapacity(), 0, new HashMap<String, TemplateProp>());
}
Also used : TemplateProp(com.cloud.storage.template.TemplateProp) TransactionLegacy(com.cloud.utils.db.TransactionLegacy) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ModifyStoragePoolAnswer(com.cloud.agent.api.ModifyStoragePoolAnswer) MockStoragePoolVO(com.cloud.simulator.MockStoragePoolVO) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO) URISyntaxException(java.net.URISyntaxException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

ModifyStoragePoolAnswer (com.cloud.agent.api.ModifyStoragePoolAnswer)16 Answer (com.cloud.agent.api.Answer)11 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)10 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)8 TemplateProp (com.cloud.storage.template.TemplateProp)7 HashMap (java.util.HashMap)6 GetStorageStatsAnswer (com.cloud.agent.api.GetStorageStatsAnswer)5 PrimaryStorageDownloadAnswer (com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer)5 ConfigurationException (javax.naming.ConfigurationException)5 CheckVirtualMachineAnswer (com.cloud.agent.api.CheckVirtualMachineAnswer)4 GetHostStatsAnswer (com.cloud.agent.api.GetHostStatsAnswer)4 GetVmStatsAnswer (com.cloud.agent.api.GetVmStatsAnswer)4 ReadyAnswer (com.cloud.agent.api.ReadyAnswer)4 RebootAnswer (com.cloud.agent.api.RebootAnswer)4 StartAnswer (com.cloud.agent.api.StartAnswer)4 StopAnswer (com.cloud.agent.api.StopAnswer)4 MockStoragePoolVO (com.cloud.simulator.MockStoragePoolVO)4 TemplateInfo (com.cloud.storage.template.TemplateInfo)4 CheckHealthAnswer (com.cloud.agent.api.CheckHealthAnswer)3 CheckNetworkAnswer (com.cloud.agent.api.CheckNetworkAnswer)3