use of com.cloud.storage.template.TemplateInfo in project CloudStack-archive by CloudStack-extras.
the class LibvirtComputingResource method execute.
protected Answer execute(ModifyStoragePoolCommand cmd) {
KVMStoragePool storagepool = _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPath(), cmd.getPool().getType());
if (storagepool == null) {
return new Answer(cmd, false, " Failed to create storage pool");
}
Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, storagepool.getCapacity(), storagepool.getUsed(), tInfo);
return answer;
}
use of com.cloud.storage.template.TemplateInfo in project CloudStack-archive by CloudStack-extras.
the class MockStorageManagerImpl method ListTemplates.
@Override
public Answer ListTemplates(ListTemplateCommand cmd) {
MockSecStorageVO storage = _mockSecStorageDao.findByUrl(cmd.getSecUrl());
if (storage == null) {
return new Answer(cmd, false, "Failed to get secondary storage");
}
List<MockVolumeVO> templates = _mockVolumeDao.findByStorageIdAndType(storage.getId(), MockVolumeType.TEMPLATE);
Map<String, TemplateInfo> templateInfos = new HashMap<String, TemplateInfo>();
for (MockVolumeVO template : templates) {
templateInfos.put(template.getName(), new TemplateInfo(template.getName(), template.getPath().replaceAll(storage.getMountPoint(), ""), template.getSize(), template.getSize(), true, false));
}
return new ListTemplateAnswer(cmd.getSecUrl(), templateInfos);
}
use of com.cloud.storage.template.TemplateInfo in project CloudStack-archive by CloudStack-extras.
the class FakeComputingResource method execute.
private Answer execute(ModifyStoragePoolCommand cmd) {
long capacity = getConfiguredProperty("local.storage.capacity", 10000000000L);
long used = 10000000L;
long available = capacity - used;
if (cmd.getAdd()) {
ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, capacity, used, new HashMap<String, TemplateInfo>());
if (s_logger.isInfoEnabled())
s_logger.info("Sending ModifyStoragePoolCommand answer with capacity: " + capacity + ", used: " + used + ", available: " + available);
return answer;
} else {
if (s_logger.isInfoEnabled())
s_logger.info("ModifyNetfsStoragePoolCmd is not add command, cmd: " + cmd.toString());
return new Answer(cmd);
}
}
use of com.cloud.storage.template.TemplateInfo in project CloudStack-archive by CloudStack-extras.
the class AgentRoutingResource method initializeLocalSR.
private StartupStorageCommand initializeLocalSR() {
Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
StoragePoolInfo poolInfo = _simMgr.getLocalStorage(hostGuid);
StartupStorageCommand cmd = new StartupStorageCommand(poolInfo.getHostPath(), poolInfo.getPoolType(), poolInfo.getCapacityBytes(), tInfo);
cmd.setPoolInfo(poolInfo);
cmd.setGuid(agentHost.getGuid());
cmd.setResourceType(StorageResourceType.STORAGE_POOL);
return cmd;
}
use of com.cloud.storage.template.TemplateInfo 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>());
}
Aggregations