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>());
}
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>());
}
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>());
}
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;
}
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>());
}
Aggregations