use of com.cloud.agent.api.CreateStoragePoolCommand in project cloudstack by apache.
the class SolidFireSharedPrimaryDataStoreLifeCycle method createStoragePool.
private boolean createStoragePool(HostVO host, StoragePool storagePool) {
long hostId = host.getId();
HypervisorType hypervisorType = host.getHypervisorType();
CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, storagePool);
if (HypervisorType.VMware.equals(hypervisorType)) {
cmd.setCreateDatastore(true);
Map<String, String> details = new HashMap<>();
StoragePoolDetailVO storagePoolDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.DATASTORE_NAME);
details.put(CreateStoragePoolCommand.DATASTORE_NAME, storagePoolDetail.getValue());
storagePoolDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.IQN);
details.put(CreateStoragePoolCommand.IQN, storagePoolDetail.getValue());
storagePoolDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_VIP);
details.put(CreateStoragePoolCommand.STORAGE_HOST, storagePoolDetail.getValue());
storagePoolDetail = storagePoolDetailsDao.findDetail(storagePool.getId(), SolidFireUtil.STORAGE_PORT);
details.put(CreateStoragePoolCommand.STORAGE_PORT, storagePoolDetail.getValue());
cmd.setDetails(details);
}
Answer answer = agentMgr.easySend(hostId, cmd);
if (answer != null && answer.getResult()) {
return true;
} else {
primaryDataStoreDao.expunge(storagePool.getId());
final String msg;
if (answer != null) {
msg = "Cannot create storage pool through host '" + hostId + "' due to the following: " + answer.getDetails();
} else {
msg = "Cannot create storage pool through host '" + hostId + "' due to CreateStoragePoolCommand returns null";
}
LOGGER.warn(msg);
throw new CloudRuntimeException(msg);
}
}
use of com.cloud.agent.api.CreateStoragePoolCommand in project cosmic by MissionCriticalCloud.
the class CloudStackPrimaryDataStoreLifeCycleImpl method createStoragePool.
protected boolean createStoragePool(final long hostId, final StoragePool pool) {
s_logger.debug("creating pool " + pool.getName() + " on host " + hostId);
if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem && pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi && pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2 && pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB && pool.getPoolType() != StoragePoolType.Gluster) {
s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType());
return false;
}
final CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
final Answer answer = agentMgr.easySend(hostId, cmd);
if (answer != null && answer.getResult()) {
return true;
} else {
primaryDataStoreDao.expunge(pool.getId());
String msg = "";
if (answer != null) {
msg = "Can not create storage pool through host " + hostId + " due to " + answer.getDetails();
s_logger.warn(msg);
} else {
msg = "Can not create storage pool through host " + hostId + " due to CreateStoragePoolCommand returns null";
s_logger.warn(msg);
}
throw new CloudRuntimeException(msg);
}
}
use of com.cloud.agent.api.CreateStoragePoolCommand in project cosmic by MissionCriticalCloud.
the class NotAValidCommand method testCreateStoragePoolCommand.
@Test
public void testCreateStoragePoolCommand() {
final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
final XsHost xsHost = Mockito.mock(XsHost.class);
final CreateStoragePoolCommand createStorageCommand = new CreateStoragePoolCommand(false, poolVO);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(citrixResourceBase.getHost()).thenReturn(xsHost);
final Answer answer = wrapper.execute(createStorageCommand, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
Aggregations