@Test public void deleteVmGroupThrowsException() throws Exception { vmGroupMockInitializationOnExceptionThrown(); VmInputs vmInputs = getVmInputs(); when(vimPortMock.reconfigureComputeResourceTask(any(ManagedObjectReference.class), any(ClusterConfigSpecEx.class), any(Boolean.class))) .thenThrow(new RuntimeFaultFaultMsg(CLUSTER_CONFIGURATION_FAILED, new RuntimeFault())); thrownException.expectMessage(CLUSTER_CONFIGURATION_FAILED); clusterComputeResourceService.deleteVmGroup(httpInputsMock, vmInputs); }
public Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), vmInputs.getClusterName()); ClusterVmGroup clusterVmGroup = new ClusterVmGroup(); clusterVmGroup.setName(vmInputs.getVmGroupName()); ClusterGroupSpec clusterGroupSpec = new ClusterGroupSpec(); clusterGroupSpec.setInfo(clusterVmGroup); clusterGroupSpec.setOperation(ArrayUpdateOperation.REMOVE); clusterGroupSpec.setRemoveKey(vmInputs.getVmGroupName()); return reconfigureClusterGroup(vmInputs, connectionResources, clusterMor, clusterGroupSpec); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } }
ClusterComputeResourceService { public Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), vmInputs.getClusterName()); ClusterVmGroup clusterVmGroup = new ClusterVmGroup(); clusterVmGroup.setName(vmInputs.getVmGroupName()); ClusterGroupSpec clusterGroupSpec = new ClusterGroupSpec(); clusterGroupSpec.setInfo(clusterVmGroup); clusterGroupSpec.setOperation(ArrayUpdateOperation.REMOVE); clusterGroupSpec.setRemoveKey(vmInputs.getVmGroupName()); return reconfigureClusterGroup(vmInputs, connectionResources, clusterMor, clusterGroupSpec); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } } }
ClusterComputeResourceService { public Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), vmInputs.getClusterName()); ClusterVmGroup clusterVmGroup = new ClusterVmGroup(); clusterVmGroup.setName(vmInputs.getVmGroupName()); ClusterGroupSpec clusterGroupSpec = new ClusterGroupSpec(); clusterGroupSpec.setInfo(clusterVmGroup); clusterGroupSpec.setOperation(ArrayUpdateOperation.REMOVE); clusterGroupSpec.setRemoveKey(vmInputs.getVmGroupName()); return reconfigureClusterGroup(vmInputs, connectionResources, clusterMor, clusterGroupSpec); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } }  }
ClusterComputeResourceService { public Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), vmInputs.getClusterName()); ClusterVmGroup clusterVmGroup = new ClusterVmGroup(); clusterVmGroup.setName(vmInputs.getVmGroupName()); ClusterGroupSpec clusterGroupSpec = new ClusterGroupSpec(); clusterGroupSpec.setInfo(clusterVmGroup); clusterGroupSpec.setOperation(ArrayUpdateOperation.REMOVE); clusterGroupSpec.setRemoveKey(vmInputs.getVmGroupName()); return reconfigureClusterGroup(vmInputs, connectionResources, clusterMor, clusterGroupSpec); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } }  Map<String, String> updateOrAddVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs, final String restartPriority); String getVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs); Map<String, String> createVmGroup(HttpInputs httpInputs, VmInputs vmInputs, List<String> vmNameList); Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs); String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz); Map<String, String> createHostGroup(HttpInputs httpInputs, VmInputs vmInputs, List<String> hostNameList); Map<String, String> deleteHostGroup(HttpInputs httpInputs, VmInputs vmInputs); Map<String, String> createAffinityRule(HttpInputs httpInputs, VmInputs vmInputs,
                                                  String affineHostGroupName, String antiAffineHostGroupName); Map<String, String> deleteClusterRule(HttpInputs httpInputs, VmInputs vmInputs); }
ClusterComputeResourceService { public Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), vmInputs.getClusterName()); ClusterVmGroup clusterVmGroup = new ClusterVmGroup(); clusterVmGroup.setName(vmInputs.getVmGroupName()); ClusterGroupSpec clusterGroupSpec = new ClusterGroupSpec(); clusterGroupSpec.setInfo(clusterVmGroup); clusterGroupSpec.setOperation(ArrayUpdateOperation.REMOVE); clusterGroupSpec.setRemoveKey(vmInputs.getVmGroupName()); return reconfigureClusterGroup(vmInputs, connectionResources, clusterMor, clusterGroupSpec); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } }  Map<String, String> updateOrAddVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs, final String restartPriority); String getVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs); Map<String, String> createVmGroup(HttpInputs httpInputs, VmInputs vmInputs, List<String> vmNameList); Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs); String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz); Map<String, String> createHostGroup(HttpInputs httpInputs, VmInputs vmInputs, List<String> hostNameList); Map<String, String> deleteHostGroup(HttpInputs httpInputs, VmInputs vmInputs); Map<String, String> createAffinityRule(HttpInputs httpInputs, VmInputs vmInputs,
                                                  String affineHostGroupName, String antiAffineHostGroupName); Map<String, String> deleteClusterRule(HttpInputs httpInputs, VmInputs vmInputs);  }