public static void copyMigrationOptions(MigrationOptions model, Cluster entity) { MigrationOptionsMapper.copyMigrationOptions(model, entity); if (model.isSetBandwidth()) { MigrationBandwidth bandwidth = model.getBandwidth(); if (bandwidth.getAssignmentMethod()!=null) { switch (bandwidth.getAssignmentMethod()) { case AUTO: entity.setMigrationBandwidthLimitType(MigrationBandwidthLimitType.AUTO); break; case HYPERVISOR_DEFAULT: entity.setMigrationBandwidthLimitType(MigrationBandwidthLimitType.VDSM_CONFIG); break; case CUSTOM: entity.setMigrationBandwidthLimitType(MigrationBandwidthLimitType.CUSTOM); entity.setCustomMigrationNetworkBandwidth(model.getBandwidth().getCustomValue()); } } } }
/** * Ensures that updating a group works as expected. */ @Test public void testUpdate() { String oldName = existingCluster.getName(); existingCluster.setName("This is the new name"); existingCluster.setVirtService(false); existingCluster.setGlusterService(true); existingCluster.setMigrationBandwidthLimitType(MigrationBandwidthLimitType.CUSTOM); existingCluster.setCustomMigrationNetworkBandwidth(20); dao.update(existingCluster); Cluster result = dao.get(existingCluster.getId()); assertCorrectCluster(result); result = dao.getByName(oldName); assertNull(result); }
@BeforeEach @Override public void setUp() throws Exception { super.setUp(); existingCluster = dao.get(FixturesTool.CLUSTER_RHEL6_ISCSI); groupWithNoRunningVms = dao.get(FixturesTool.CLUSTER_NO_RUNNING_VMS); newGroup = new Cluster(); newGroup.setName("New VDS Group"); newGroup.setCompatibilityVersion(Version.getLast()); newGroup.setVirtService(true); newGroup.setGlusterService(false); newGroup.setClusterPolicyId(existingCluster.getClusterPolicyId()); // set cluster policy name to allow equals method to succeed newGroup.setClusterPolicyName(clusterPolicyDao.get(existingCluster.getClusterPolicyId(), Collections.emptyMap()).getName()); newGroup.setClusterPolicyProperties(new LinkedHashMap<>()); newGroup.setDetectEmulatedMachine(true); newGroup.setEmulatedMachine("rhel6.4.0"); newGroup.setArchitecture(ArchitectureType.x86_64); newGroup.setGlusterCliBasedSchedulingOn(true); newGroup.setMigrationBandwidthLimitType(MigrationBandwidthLimitType.CUSTOM); newGroup.setCustomMigrationNetworkBandwidth(1000); newGroup.setMigrationPolicyId(Guid.newGuid()); newGroup.setMacPoolId(FixturesTool.DEFAULT_MAC_POOL_ID); newGroup.setFirewallType(FirewallType.FIREWALLD); newGroup.setLogMaxMemoryUsedThreshold(95); newGroup.setLogMaxMemoryUsedThresholdType(LogMaxMemoryUsedThresholdType.PERCENTAGE); newGroup.setVncEncryptionEnabled(true); }
cluster.setCustomMigrationNetworkBandwidth( MigrationBandwidthLimitType.CUSTOM.equals(model.getMigrationBandwidthLimitType().getSelectedItem()) ? model.getCustomMigrationNetworkBandwidth().getEntity()