This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 86fcb142383c4bb5742225eb8352a41734fe787f Merge: 4f8b88b 1efe6e2 Author: Rohit Yadav <[email protected]> AuthorDate: Thu Sep 24 12:20:29 2020 +0530 Merge remote-tracking branch 'origin/4.14' Signed-off-by: Rohit Yadav <[email protected]> api/src/main/java/com/cloud/network/Networks.java | 49 +++++++++++---- .../com/cloud/agent/manager/AgentManagerImpl.java | 9 ++- .../engine/orchestration/NetworkOrchestrator.java | 23 ++++++- .../orchestration/NetworkOrchestratorTest.java | 73 ++++++++++++++++++++++ .../cloudstack/agent/lb/IndirectAgentLB.java | 2 +- .../hypervisor/vmware/resource/VmwareResource.java | 4 +- .../agent/lb/IndirectAgentLBServiceImpl.java | 5 +- .../com/cloud/hypervisor/vmware/mo/ClusterMO.java | 7 ++- .../com/cloud/hypervisor/vmware/mo/HostMO.java | 41 +++++++++++- .../hypervisor/vmware/mo/VmwareHypervisorHost.java | 2 +- 10 files changed, 187 insertions(+), 28 deletions(-) diff --cc engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java index 3f1b506,6bfc3de..f69f54c --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java @@@ -1091,9 -1094,9 +1096,9 @@@ public class AgentManagerImpl extends M final HostVO host = _resourceMgr.createHostVOForConnectedAgent(startup); if (host != null) { - ready = new ReadyCommand(host.getDataCenterId(), host.getId()); + ready = new ReadyCommand(host.getDataCenterId(), host.getId(), NumbersUtil.enableHumanReadableSizes); - if (!indirectAgentLB.compareManagementServerList(host.getId(), host.getDataCenterId(), agentMSHostList)) { + if (!indirectAgentLB.compareManagementServerList(host.getId(), host.getDataCenterId(), agentMSHostList, lbAlgorithm)) { final List<String> newMSList = indirectAgentLB.getManagementServerList(host.getId(), host.getDataCenterId(), null); ready.setMsHostList(newMSList); ready.setLbAlgorithm(indirectAgentLB.getLBAlgorithmName()); diff --cc engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index 892f771,804775a..e12dca0 --- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@@ -2513,14 -2465,8 +2513,14 @@@ public class NetworkOrchestrator extend //Logical router's UUID provided as VLAN_ID userNetwork.setVlanIdAsUUID(vlanIdFinal); //Set transient field } else { - uri = BroadcastDomainType.fromString(vlanIdFinal); + uri = encodeVlanIdIntoBroadcastUri(vlanIdFinal, pNtwk); } + + if (_networksDao.listByPhysicalNetworkPvlan(physicalNetworkId, uri.toString()).size() > 0) { + throw new InvalidParameterValueException("Network with vlan " + vlanIdFinal + + " already exists or overlaps with other network pvlans in zone " + zoneId); + } + userNetwork.setBroadcastUri(uri); if (!vlanIdFinal.equalsIgnoreCase(Vlan.UNTAGGED)) { userNetwork.setBroadcastDomainType(BroadcastDomainType.Vlan); diff --cc engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java index e68ac5c,ed5265c..ff0a6fa --- a/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java +++ b/engine/orchestration/src/test/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java @@@ -464,23 -467,74 +467,93 @@@ public class NetworkOrchestratorTest ex } @Test + public void testDontReleaseNicWhenPreserveNicsSettingEnabled() { + VirtualMachineProfile vm = mock(VirtualMachineProfile.class); + NicVO nic = mock(NicVO.class); + NetworkVO network = mock(NetworkVO.class); + + when(vm.getType()).thenReturn(Type.User); + when(network.getGuruName()).thenReturn(guruName); + when(testOrchastrator._networksDao.findById(nic.getNetworkId())).thenReturn(network); + + Long nicId = 1L; + when(nic.getId()).thenReturn(nicId); + when(vm.getParameter(VirtualMachineProfile.Param.PreserveNics)).thenReturn(true); + + testOrchastrator.removeNic(vm, nic); + + verify(nic, never()).setState(Nic.State.Deallocating); + verify(testOrchastrator._nicDao, never()).remove(nicId); + } + + public void encodeVlanIdIntoBroadcastUriTestVxlan() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("123", "VXLAN", "vxlan", "vxlan://123"); + } + + @Test + public void encodeVlanIdIntoBroadcastUriTestVlan() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("123", "VLAN", "vlan", "vlan://123"); + } + + @Test + public void encodeVlanIdIntoBroadcastUriTestEmpty() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("123", "", "vlan", "vlan://123"); + } + + @Test + public void encodeVlanIdIntoBroadcastUriTestNull() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("123", null, "vlan", "vlan://123"); + } + + @Test(expected = CloudRuntimeException.class) + public void encodeVlanIdIntoBroadcastUriTestEmptyVlanId() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("", "vxlan", "vlan", "vlan://123"); + } + + @Test(expected = CloudRuntimeException.class) + public void encodeVlanIdIntoBroadcastUriTestNullVlanId() { + encodeVlanIdIntoBroadcastUriPrepareAndTest(null, "vlan", "vlan", "vlan://123"); + } + + @Test(expected = CloudRuntimeException.class) + public void encodeVlanIdIntoBroadcastUriTestBlankVlanId() { + encodeVlanIdIntoBroadcastUriPrepareAndTest(" ", "vlan", "vlan", "vlan://123"); + } + + @Test + public void encodeVlanIdIntoBroadcastUriTestNullVlanIdWithSchema() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("vlan://123", "vlan", "vlan", "vlan://123"); + } + + @Test + public void encodeVlanIdIntoBroadcastUriTestNullVlanIdWithSchemaIsolationVxlan() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("vlan://123", "vxlan", "vlan", "vlan://123"); + } + + @Test + public void encodeVlanIdIntoBroadcastUriTestNullVxlanIdWithSchema() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("vxlan://123", "vxlan", "vxlan", "vxlan://123"); + } + + @Test + public void encodeVlanIdIntoBroadcastUriTestNullVxlanIdWithSchemaIsolationVlan() { + encodeVlanIdIntoBroadcastUriPrepareAndTest("vxlan://123", "vlan", "vxlan", "vxlan://123"); + } + + @Test(expected = InvalidParameterValueException.class) + public void encodeVlanIdIntoBroadcastUriTestNullNetwork() { + URI resultUri = testOrchastrator.encodeVlanIdIntoBroadcastUri("vxlan://123", null); + } + + private void encodeVlanIdIntoBroadcastUriPrepareAndTest(String vlanId, String isolationMethod, String expectedIsolation, String expectedUri) { + PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(); + List<String> isolationMethods = new ArrayList<>(); + isolationMethods.add(isolationMethod); + physicalNetwork.setIsolationMethods(isolationMethods); + + URI resultUri = testOrchastrator.encodeVlanIdIntoBroadcastUri(vlanId, physicalNetwork); + + Assert.assertEquals(expectedIsolation, resultUri.getScheme()); + Assert.assertEquals(expectedUri, resultUri.toString()); + } }
