Java 类com.vmware.vim25.ClusterConfigInfoEx 实例源码

项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void listVmGroupsSuccess() throws Exception {
    commonMockInitializations();
    List<ClusterGroupInfo> clusterGroupInfoList = new ArrayList<>();
    ClusterVmGroup clusterVmGroup1 = new ClusterVmGroup();
    ClusterVmGroup clusterVmGroup2 = new ClusterVmGroup();
    clusterVmGroup1.setName("abc");
    clusterVmGroup2.setName("def");
    clusterGroupInfoList.add(clusterVmGroup1);
    clusterGroupInfoList.add(clusterVmGroup2);
    clusterGroupInfoList.add(new ClusterHostGroup());
    clusterGroupInfoList.add(new ClusterHostGroup());
    clusterGroupInfoList.add(new ClusterHostGroup());
    ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx();
    clusterConfigInfoEx.getGroup().addAll(clusterGroupInfoList);
    doReturn(clusterConfigInfoEx).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    whenNew(ArrayList.class).withNoArguments().thenReturn(vmGroupNameListSpy);

    String result = clusterComputeResourceServiceSpy.listGroups(httpInputsMock, "Cluster1", ",", ClusterVmGroup.class);

    verify(vmGroupNameListSpy, times(2)).add(any(String.class));
    assertNotNull(result);
    assertEquals("abc,def", result);
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void listHostGroupsSuccess() throws Exception {
    commonMockInitializations();
    List<ClusterGroupInfo> clusterGroupInfoList = new ArrayList<>();
    clusterGroupInfoList.add(new ClusterVmGroup());
    clusterGroupInfoList.add(new ClusterVmGroup());
    ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx();
    clusterConfigInfoEx.getGroup().addAll(clusterGroupInfoList);
    doReturn(clusterConfigInfoEx).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    whenNew(ArrayList.class).withNoArguments().thenReturn(hostGroupNameListSpy);

    String result = clusterComputeResourceServiceSpy.listGroups(httpInputsMock, "Cluster1", ",", ClusterHostGroup.class);

    verify(hostGroupNameListSpy, never()).add(any(String.class));
    assertNotNull(result);
    assertTrue(StringUtilities.isEmpty(result));
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void createAffinityRuleSuccess() throws Exception {
    commonMockInitializations();
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(false).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    doReturn(clusterVmHostRuleInfoMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_VM_HOST_RULE_INFO,
            any(ClusterConfigInfoEx.class), any(VmInputs.class), any(String.class), any(String.class));
    whenNew(ResponseHelper.class).withArguments(any(ConnectionResources.class), any(ManagedObjectReference.class))
            .thenReturn(getResponseHelper(connectionResourcesMock, taskMock, true));

    Map<String, String> resultMap = clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "affineHostGroupName", "");

    commonVerifications();
    assertionsSuccess(resultMap);
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void createAffinityRuleFailure() throws Exception {
    commonMockInitializations();
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(false).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    doReturn(clusterVmHostRuleInfoMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_VM_HOST_RULE_INFO,
            any(ClusterConfigInfoEx.class), any(VmInputs.class), any(String.class), any(String.class));
    whenNew(ResponseHelper.class).withArguments(any(ConnectionResources.class), any(ManagedObjectReference.class))
            .thenReturn(getResponseHelper(connectionResourcesMock, taskMock, false));

    Map<String, String> resultMap = clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "affineHostGroupName", "");

    commonVerifications();
    assertionsFailure(resultMap);
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void createAffinityRuleVmGroupNotFoundException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(false).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    whenNew(ClusterVmHostRuleInfo.class).withNoArguments().thenReturn(clusterVmHostRuleInfoMock);
    doReturn(clusterVmHostRuleInfoMock).when(clusterComputeResourceServiceSpy, ADD_AFFINE_GROUP_TO_RULE,
            any(ClusterVmHostRuleInfo.class), any(ClusterConfigInfoEx.class), any(String.class));
    doThrow(new RuntimeFaultFaultMsg(VM_GROUP_DOES_NOT_EXIST, new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, EXISTS_GROUP,
                    any(ClusterConfigInfoEx.class), any(String.class), any(Class.class));
    thrownException.expectMessage(VM_GROUP_DOES_NOT_EXIST);

    clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "affineHostGroupName", "");
}
项目:photon-model    文件:ComputeResourceOverlay.java   
public boolean isDrsEnabled() {
    ComputeResourceConfigInfo cfg = ((ComputeResourceConfigInfo) getOrFail(
            VimPath.res_configurationEx));

    if (cfg instanceof ClusterConfigInfoEx) {
        ClusterDrsConfigInfo drsConfig = ((ClusterConfigInfoEx) cfg).getDrsConfig();
        return drsConfig == null || drsConfig.isEnabled();
    } else {
        return false;
    }
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void listVmGroupsThrowsException() throws Exception {
    List<ClusterGroupInfo> clusterGroupInfoList = new ArrayList<>();
    ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx();
    clusterConfigInfoEx.getGroup().addAll(clusterGroupInfoList);
    doThrow(new RuntimeFaultFaultMsg(String.format(ErrorMessages.ANOTHER_FAILURE_MSG, "Cluster1"), new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
                    any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    thrownException.expectMessage(String.format(ErrorMessages.ANOTHER_FAILURE_MSG, "Cluster1"));

    clusterComputeResourceServiceSpy.listGroups(httpInputsMock, "Cluster1", "", ClusterVmGroup.class);
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void getVmOverrideWithNoVmInformationAndNoConfigurationsSuccess() throws Exception {
    commonMockInitializations();
    ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx();
    doReturn(clusterConfigInfoEx).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));

    String result = clusterComputeResourceServiceSpy.getVmOverride(httpInputsMock, getVmInputs());

    assertNotNull(result);
    assertEquals(new JsonArray().toString(), result);
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void getVmOverrideWithVmInformationAndNoConfigurationsSuccess() throws Exception {
    commonVmMockInitializations();
    VmInputs vmInputs = new VmInputs.VmInputsBuilder()
            .withVirtualMachineId(VM_ID_VALUE)
            .build();
    ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx();
    doReturn(clusterConfigInfoEx).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));

    String result = clusterComputeResourceServiceSpy.getVmOverride(httpInputsMock, vmInputs);

    assertNotNull(result);
    assertEquals("unknown configuration", result);
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void listHostGroupsThrowsException() throws Exception {
    List<ClusterGroupInfo> clusterGroupInfoList = new ArrayList<>();
    ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx();
    clusterConfigInfoEx.getGroup().addAll(clusterGroupInfoList);
    doThrow(new RuntimeFaultFaultMsg(String.format(ErrorMessages.ANOTHER_FAILURE_MSG, "Cluster1"), new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
                    any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    thrownException.expectMessage(String.format(ErrorMessages.ANOTHER_FAILURE_MSG, "Cluster1"));

    clusterComputeResourceServiceSpy.listGroups(httpInputsMock, "Cluster1", "", ClusterHostGroup.class);
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void createAffinityRuleThrowsRuleAlreadyExistsException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx();
    doReturn(clusterConfigInfoEx).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doThrow(new RuntimeFaultFaultMsg(String.format(RULE_ALREADY_EXISTS, vmInputs.getRuleName()), new RuntimeFault())).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    thrownException.expectMessage(String.format(RULE_ALREADY_EXISTS, vmInputs.getRuleName()));

    clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "affineHostGroupName", "");
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void createAffinityRuleThrowsAffineHostGroupNotFoundException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(false).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    doThrow(new RuntimeFaultFaultMsg(AFFINE_HOST_GROUP_DOES_NOT_EXIST, new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, ADD_AFFINE_GROUP_TO_RULE,
                    any(ClusterVmHostRuleInfo.class), any(ClusterConfigInfoEx.class), any(String.class));
    thrownException.expectMessage(AFFINE_HOST_GROUP_DOES_NOT_EXIST);

    clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "affineHostGroupName", "");
}
项目:cs-actions    文件:ClusterComputeResourceServiceTest.java   
@Test
public void createAffinityRuleThrowsAntiAffineHostGroupNotFoundException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(false).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    doThrow(new RuntimeFaultFaultMsg(ANTI_AFFINE_HOST_GROUP_DOES_NOT_EXIST, new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, ADD_ANTI_AFFINE_GROUP_TO_RULE,
                    any(ClusterVmHostRuleInfo.class), any(ClusterConfigInfoEx.class), any(String.class));
    thrownException.expectMessage(ANTI_AFFINE_HOST_GROUP_DOES_NOT_EXIST);

    clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "", "antiAffineHostGroup");
}
项目:cloudstack    文件:ClusterMO.java   
@Override
public ClusterDasConfigInfo getDasConfig() throws Exception {
    ClusterConfigInfoEx configInfo = getClusterConfigInfo();
    if (configInfo != null) {
        // Note getDynamicProperty() with "configurationEx.dasConfig" does not work here because of that dasConfig is a property in subclass
        return configInfo.getDasConfig();
    }

    return null;
}
项目:cloudstack    文件:ClusterMO.java   
private String getRestartPriorityForVM(VirtualMachineMO vmMo) throws Exception {
    if (vmMo == null) {
        s_logger.debug("Failed to get restart priority for VM, invalid VM object reference");
        return null;
    }

    ManagedObjectReference vmMor = vmMo.getMor();
    if (vmMor == null || !vmMor.getType().equals("VirtualMachine")) {
        s_logger.debug("Failed to get restart priority for VM: " + vmMo.getName() + ", invalid VM object reference");
        return null;
    }

    ClusterConfigInfoEx configInfo = getClusterConfigInfo();
    if (configInfo == null) {
        s_logger.debug("Failed to get restart priority for VM: " + vmMo.getName() + ", no cluster config information");
        return null;
    }

    List<ClusterDasVmConfigInfo> dasVmConfig = configInfo.getDasVmConfig();
    for (int dasVmConfigIndex = 0; dasVmConfigIndex < dasVmConfig.size(); dasVmConfigIndex++) {
        ClusterDasVmConfigInfo dasVmConfigInfo = dasVmConfig.get(dasVmConfigIndex);
        if (dasVmConfigInfo != null && dasVmConfigInfo.getKey().getValue().equals(vmMor.getValue())) {
            DasVmPriority dasVmPriority = dasVmConfigInfo.getRestartPriority();
            if (dasVmPriority != null) {
                return dasVmPriority.value();
            } else {
                //VM uses cluster restart priority when DasVmPriority for the VM is null.
                return ClusterDasVmSettingsRestartPriority.CLUSTER_RESTART_PRIORITY.value();
            }
        }
    }

    s_logger.debug("VM: " + vmMo.getName() + " uses default restart priority in the cluster: " + getName());
    return null;
}
项目:cloudstack    文件:ClusterMO.java   
private ClusterConfigInfoEx getClusterConfigInfo() throws Exception {
    ClusterConfigInfoEx configInfo = (ClusterConfigInfoEx)_context.getVimClient().getDynamicProperty(_mor, "configurationEx");
    return configInfo;
}