use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.
the class ListCfgCmdTest method testCreateSuccess.
@Test
public void testCreateSuccess() {
final Configuration cfg = Mockito.mock(Configuration.class);
listCfgsByCmd._mgr = mgr;
listCfgsByCmd._responseGenerator = responseGenerator;
final List<Configuration> configList = new ArrayList<>();
configList.add(cfg);
final Pair<List<? extends Configuration>, Integer> result = new Pair<>(configList, 1);
try {
Mockito.when(mgr.searchForConfigurations(listCfgsByCmd)).thenReturn(result);
} catch (final Exception e) {
Assert.fail("Received exception when success expected " + e.getMessage());
}
final ConfigurationResponse cfgResponse = new ConfigurationResponse();
cfgResponse.setName("Test case");
Mockito.when(responseGenerator.createConfigurationResponse(cfg)).thenReturn(cfgResponse);
listCfgsByCmd.execute();
Mockito.verify(responseGenerator).createConfigurationResponse(cfg);
final ListResponse<ConfigurationResponse> actualResponse = (ListResponse<ConfigurationResponse>) listCfgsByCmd.getResponseObject();
Assert.assertEquals(cfgResponse, actualResponse.getResponses().get(0));
}
use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.
the class VirtualMachineManagerImpl method orchestrateReconfigure.
@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateReconfigure(final VmWorkReconfigure work) throws Exception {
final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId());
if (vm == null) {
s_logger.info("Unable to find vm " + work.getVmId());
}
assert vm != null;
final ServiceOffering newServiceOffering = _offeringDao.findById(vm.getId(), work.getNewServiceOfferingId());
reConfigureVm(vm.getUuid(), newServiceOffering, work.isSameHost());
return new Pair<>(JobInfo.Status.SUCCEEDED, null);
}
use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.
the class VirtualMachineManagerImpl method orchestrateAddVmToNetwork.
@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateAddVmToNetwork(final VmWorkAddVmToNetwork work) throws Exception {
final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId());
if (vm == null) {
s_logger.info("Unable to find vm " + work.getVmId());
}
assert vm != null;
final Network network = _networkDao.findById(work.getNetworkId());
final NicProfile nic = orchestrateAddVmToNetwork(vm, network, work.getRequestedNicProfile());
return new Pair<>(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(nic));
}
use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.
the class VirtualMachineManagerImpl method orchestrateStorageMigration.
@ReflectionUse
private Pair<JobInfo.Status, String> orchestrateStorageMigration(final VmWorkStorageMigration work) throws Exception {
final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId());
if (vm == null) {
s_logger.info("Unable to find vm " + work.getVmId());
}
assert vm != null;
final StoragePool pool = (PrimaryDataStoreInfo) dataStoreMgr.getPrimaryDataStore(work.getDestStoragePoolId());
orchestrateStorageMigration(vm.getUuid(), pool);
return new Pair<>(JobInfo.Status.SUCCEEDED, null);
}
use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.
the class GenericDaoBase method setField.
@DB()
protected void setField(final Object entity, final ResultSet rs, final ResultSetMetaData meta, final int index) throws SQLException {
Attribute attr = _allColumns.get(new Pair<>(meta.getTableName(index), meta.getColumnName(index)));
if (attr == null) {
// work around for mysql bug to return original table name instead of view name in db view case
final Table tbl = entity.getClass().getSuperclass().getAnnotation(Table.class);
if (tbl != null) {
attr = _allColumns.get(new Pair<>(tbl.name(), meta.getColumnLabel(index)));
}
}
assert (attr != null) : "How come I can't find " + meta.getCatalogName(index) + "." + meta.getColumnName(index);
setField(entity, attr.field, rs, index);
}
Aggregations