예제 #1
0
  /** Ensures that the right object is returned. */
  @Test
  public void testGet() {
    VdsDynamic result = dao.get(existingVds.getId());

    assertNotNull(result);
    assertEquals(existingVds.getId(), result.getId());
  }
예제 #2
0
 @Test
 public void testUpdateHostExternalStatus() {
   VdsDynamic before = dao.get(existingVds.getId());
   before.setExternalStatus(ExternalStatus.Error);
   dao.updateExternalStatus(before.getId(), before.getExternalStatus());
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before.getExternalStatus(), after.getExternalStatus());
 }
예제 #3
0
 @Test
 public void testUpdateStatus() {
   VdsDynamic before = dao.get(existingVds.getId());
   before.setStatus(VDSStatus.Down);
   dao.updateStatus(before.getId(), before.getStatus());
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before, after);
 }
예제 #4
0
 @Test
 public void testUpdateAvailableUpdates() {
   VdsDynamic before = dao.get(existingVds.getId());
   assertFalse(before.isUpdateAvailable());
   before.setUpdateAvailable(true);
   dao.updateUpdateAvailable(before.getId(), before.isUpdateAvailable());
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before.isUpdateAvailable(), after.isUpdateAvailable());
 }
예제 #5
0
 @Test
 public void testGlusterVersion() {
   RpmVersion glusterVersion = new RpmVersion("glusterfs-3.4.0.34.1u2rhs-1.el6rhs");
   VdsDynamic before = dao.get(existingVds.getId());
   before.setGlusterVersion(glusterVersion);
   dao.update(before);
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(glusterVersion, after.getGlusterVersion());
 }
예제 #6
0
 @Test
 public void testUpdateLibrbdVersion() {
   RpmVersion librbdVersion = new RpmVersion("librbd1-0.80.9-1.fc21.x86_64_updated");
   VdsDynamic before = dao.get(existingVds.getId());
   assertNotEquals(librbdVersion, before.getLibrbdVersion());
   before.setLibrbdVersion(librbdVersion);
   dao.update(before);
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(librbdVersion, after.getLibrbdVersion());
 }
예제 #7
0
 @Test
 public void testUpdateNetConfigDirty() {
   VdsDynamic before = dao.get(existingVds.getId());
   Boolean netConfigDirty = before.getNetConfigDirty();
   netConfigDirty = Boolean.FALSE.equals(netConfigDirty);
   before.setNetConfigDirty(netConfigDirty);
   dao.updateNetConfigDirty(before.getId(), netConfigDirty);
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before, after);
 }
예제 #8
0
 private void checkKdumpIntegrationStatus() {
   VdsStatic vdsSt = getParameters().getVdsStaticData();
   if (vdsSt.isPmEnabled() && vdsSt.isPmKdumpDetection()) {
     VdsDynamic vdsDyn = getDbFacade().getVdsDynamicDao().get(vdsSt.getId());
     if (vdsDyn != null && vdsDyn.getKdumpStatus() != KdumpStatus.ENABLED) {
       auditLogDirector.log(
           new AuditLogableBase(vdsSt.getId()),
           AuditLogType.KDUMP_DETECTION_NOT_CONFIGURED_ON_VDS);
     }
   }
 }
예제 #9
0
  /** Ensures removing a VDS instance works. */
  @Test
  public void testRemove() {
    dao.remove(existingVds.getId());
    statisticsDao.remove(existingVds.getId());
    staticDao.remove(existingVds.getId());

    VdsStatic resultStatic = staticDao.get(existingVds.getId());
    assertNull(resultStatic);
    VdsDynamic resultDynamic = dao.get(existingVds.getId());
    assertNull(resultDynamic);
  }
예제 #10
0
 @Test
 public void testUpdateStatusAndReasons() {
   VdsDynamic before = dao.get(existingVds.getId());
   before.setStatus(RandomUtils.instance().nextEnum(VDSStatus.class));
   before.setNonOperationalReason(RandomUtils.instance().nextEnum(NonOperationalReason.class));
   before.setMaintenanceReason(RandomUtils.instance().nextString(50));
   dao.updateStatusAndReasons(before);
   VdsDynamic after = dao.get(existingVds.getId());
   assertEquals(before, after);
   assertEquals(before.getStatus(), after.getStatus());
   assertEquals(before.getNonOperationalReason(), after.getNonOperationalReason());
   assertEquals(before.getMaintenanceReason(), after.getMaintenanceReason());
 }
예제 #11
0
  /** Ensures saving a VDS instance works. */
  @Test
  public void testSave() {
    staticDao.save(newStaticVds);
    newDynamicVds.setId(newStaticVds.getId());
    newDynamicVds.setUpdateAvailable(true);
    dao.save(newDynamicVds);

    VdsStatic staticResult = staticDao.get(newStaticVds.getId());
    VdsDynamic dynamicResult = dao.get(newDynamicVds.getId());

    assertNotNull(staticResult);
    assertEquals(newStaticVds, staticResult);
    assertNotNull(dynamicResult);
    assertEquals(newDynamicVds, dynamicResult);
    assertEquals(newDynamicVds.isUpdateAvailable(), dynamicResult.isUpdateAvailable());
  }
예제 #12
0
 protected VDS getEntity(int index) {
   VDS vds = setUpEntityExpectations(control.createMock(VDS.class), index);
   VdsStatic vdsStatic = control.createMock(VdsStatic.class);
   expect(vdsStatic.getId()).andReturn(GUIDS[2]).anyTimes();
   expect(vds.getStaticData()).andReturn(vdsStatic).anyTimes();
   return vds;
 }
  @Test
  public void testGetAllCpuStatisticsByVdsId() {
    List<CpuStatistics> result =
        vdsCpuStatisticsDao.getAllCpuStatisticsByVdsId(existingVds.getId());

    assertNotNull(result);
    assertEquals(2, result.size());
  }
  @Test
  public void testMassUpdateCpuStatistics() {
    List<CpuStatistics> result =
        vdsCpuStatisticsDao.getAllCpuStatisticsByVdsId(existingVds.getId());
    assertNotNull(result);
    assertEquals(2, result.size());
    assertEquals(20, result.get(0).getCpuUsagePercent());
    assertEquals(20, result.get(1).getCpuUsagePercent());

    result.get(0).setCpuUsagePercent(30);
    result.get(1).setCpuUsagePercent(30);
    vdsCpuStatisticsDao.massUpdateCpuStatistics(result, existingVds.getId());

    result = vdsCpuStatisticsDao.getAllCpuStatisticsByVdsId(existingVds.getId());
    assertNotNull(result);
    assertEquals(2, result.size());
    assertEquals(30, result.get(0).getCpuUsagePercent());
    assertEquals(30, result.get(1).getCpuUsagePercent());
  }
 @Override
 public void save(VdsStatic vds) {
   Guid id = vds.getId();
   if (Guid.isNullOrEmpty(id)) {
     id = Guid.newGuid();
     vds.setId(id);
   }
   new SimpleJdbcCall(jdbcTemplate)
       .withProcedureName("InsertVdsStatic")
       .execute(getInsertOrUpdateParams(vds));
 }
 private MapSqlParameterSource getInsertOrUpdateParams(final VdsStatic vds) {
   return getCustomMapSqlParameterSource()
       .addValue("host_name", vds.getHostName())
       .addValue("free_text_comment", vds.getComment())
       .addValue("ip", vds.getManagementIp())
       .addValue("vds_unique_id", vds.getUniqueID())
       .addValue("port", vds.getPort())
       .addValue("protocol", vds.getProtocol())
       .addValue("vds_group_id", vds.getVdsGroupId())
       .addValue("vds_id", vds.getId())
       .addValue("vds_name", vds.getName())
       .addValue("server_SSL_enabled", vds.isServerSslEnabled())
       .addValue("vds_type", vds.getVdsType())
       .addValue("vds_strength", vds.getVdsStrength())
       .addValue("pm_type", vds.getPmType())
       .addValue("pm_user", vds.getPmUser())
       .addValue("pm_password", DbFacadeUtils.encryptPassword(vds.getPmPassword()))
       .addValue("pm_port", vds.getPmPort())
       .addValue("pm_options", vds.getPmOptions())
       .addValue("pm_enabled", vds.isPmEnabled())
       .addValue("pm_proxy_preferences", vds.getPmProxyPreferences())
       .addValue("pm_secondary_ip", vds.getPmSecondaryIp())
       .addValue("pm_secondary_type", vds.getPmSecondaryType())
       .addValue("pm_secondary_user", vds.getPmSecondaryUser())
       .addValue(
           "pm_secondary_password", DbFacadeUtils.encryptPassword(vds.getPmSecondaryPassword()))
       .addValue("pm_secondary_port", vds.getPmSecondaryPort())
       .addValue("pm_secondary_options", vds.getPmSecondaryOptions())
       .addValue("pm_secondary_concurrent", vds.isPmSecondaryConcurrent())
       .addValue("pm_detect_kdump", vds.isPmKdumpDetection())
       .addValue("otp_validity", vds.getOtpValidity())
       .addValue("vds_spm_priority", vds.getVdsSpmPriority())
       .addValue("console_address", vds.getConsoleAddress())
       .addValue("sshKeyFingerprint", vds.getSshKeyFingerprint())
       .addValue("ssh_port", vds.getSshPort())
       .addValue("ssh_username", vds.getSshUsername())
       .addValue("disable_auto_pm", vds.isDisablePowerManagementPolicy());
 }