@Test public void testCreateAffinityRuleHostGroupsNotProvidedException() throws Exception { Map<String, String> resultMap = createAffinityRule.createAffinityRule("", "", "", "", "", "", "", "", "", "", "", "", null); verify(clusterComputeResourceServiceMock, never()).createAffinityRule(any(HttpInputs.class), any(VmInputs.class), any(String.class), any(String.class)); assertNotNull(resultMap); assertEquals(-1, Integer.parseInt(resultMap.get(OutputNames.RETURN_CODE))); assertEquals(PROVIDE_AFFINE_OR_ANTI_AFFINE_HOST_GROUP, resultMap.get(OutputNames.RETURN_RESULT)); }
@Action(name = "Create Affinity Rule", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createAffinityRule(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = CLUSTER_NAME, required = true) String clusterName, @Param(value = RULE_NAME, required = true) String ruleName, @Param(value = AFFINE_HOST_GROUP_NAME) String affineHostGroupName, @Param(value = ANTI_AFFINE_HOST_GROUP_NAME) String antiAffineHostGroupName, @Param(value = VM_GROUP_NAME, required = true) String vmGroupName, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { InputUtils.checkMutuallyExclusiveInputs(affineHostGroupName, antiAffineHostGroupName, PROVIDE_AFFINE_OR_ANTI_AFFINE_HOST_GROUP); final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withVmGroupName(vmGroupName) .withRuleName(ruleName) .build(); return new ClusterComputeResourceService().createAffinityRule(httpInputs, vmInputs, affineHostGroupName, antiAffineHostGroupName); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }
CreateAffinityRule { @Action(name = "Create Affinity Rule", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createAffinityRule(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = CLUSTER_NAME, required = true) String clusterName, @Param(value = RULE_NAME, required = true) String ruleName, @Param(value = AFFINE_HOST_GROUP_NAME) String affineHostGroupName, @Param(value = ANTI_AFFINE_HOST_GROUP_NAME) String antiAffineHostGroupName, @Param(value = VM_GROUP_NAME, required = true) String vmGroupName, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { InputUtils.checkMutuallyExclusiveInputs(affineHostGroupName, antiAffineHostGroupName, PROVIDE_AFFINE_OR_ANTI_AFFINE_HOST_GROUP); final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withVmGroupName(vmGroupName) .withRuleName(ruleName) .build(); return new ClusterComputeResourceService().createAffinityRule(httpInputs, vmInputs, affineHostGroupName, antiAffineHostGroupName); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } } }
CreateAffinityRule { @Action(name = "Create Affinity Rule", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createAffinityRule(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = CLUSTER_NAME, required = true) String clusterName, @Param(value = RULE_NAME, required = true) String ruleName, @Param(value = AFFINE_HOST_GROUP_NAME) String affineHostGroupName, @Param(value = ANTI_AFFINE_HOST_GROUP_NAME) String antiAffineHostGroupName, @Param(value = VM_GROUP_NAME, required = true) String vmGroupName, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { InputUtils.checkMutuallyExclusiveInputs(affineHostGroupName, antiAffineHostGroupName, PROVIDE_AFFINE_OR_ANTI_AFFINE_HOST_GROUP); final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withVmGroupName(vmGroupName) .withRuleName(ruleName) .build(); return new ClusterComputeResourceService().createAffinityRule(httpInputs, vmInputs, affineHostGroupName, antiAffineHostGroupName); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  }
CreateAffinityRule { @Action(name = "Create Affinity Rule", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createAffinityRule(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = CLUSTER_NAME, required = true) String clusterName, @Param(value = RULE_NAME, required = true) String ruleName, @Param(value = AFFINE_HOST_GROUP_NAME) String affineHostGroupName, @Param(value = ANTI_AFFINE_HOST_GROUP_NAME) String antiAffineHostGroupName, @Param(value = VM_GROUP_NAME, required = true) String vmGroupName, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { InputUtils.checkMutuallyExclusiveInputs(affineHostGroupName, antiAffineHostGroupName, PROVIDE_AFFINE_OR_ANTI_AFFINE_HOST_GROUP); final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withVmGroupName(vmGroupName) .withRuleName(ruleName) .build(); return new ClusterComputeResourceService().createAffinityRule(httpInputs, vmInputs, affineHostGroupName, antiAffineHostGroupName); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  @Action(name = "Create Affinity Rule", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) Map<String, String> createAffinityRule(@Param(value = HOST, required = true) String host,
                                                  @Param(value = PORT) String port,
                                                  @Param(value = PROTOCOL) String protocol,
                                                  @Param(value = USERNAME, required = true) String username,
                                                  @Param(value = PASSWORD, encrypted = true) String password,
                                                  @Param(value = TRUST_EVERYONE) String trustEveryone,
                                                  @Param(value = CLOSE_SESSION) String closeSession,
                                                  @Param(value = CLUSTER_NAME, required = true) String clusterName,
                                                  @Param(value = RULE_NAME, required = true) String ruleName,
                                                  @Param(value = AFFINE_HOST_GROUP_NAME) String affineHostGroupName,
                                                  @Param(value = ANTI_AFFINE_HOST_GROUP_NAME) String antiAffineHostGroupName,
                                                  @Param(value = VM_GROUP_NAME, required = true) String vmGroupName,
                                                  @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject); }
CreateAffinityRule { @Action(name = "Create Affinity Rule", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createAffinityRule(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = CLUSTER_NAME, required = true) String clusterName, @Param(value = RULE_NAME, required = true) String ruleName, @Param(value = AFFINE_HOST_GROUP_NAME) String affineHostGroupName, @Param(value = ANTI_AFFINE_HOST_GROUP_NAME) String antiAffineHostGroupName, @Param(value = VM_GROUP_NAME, required = true) String vmGroupName, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { InputUtils.checkMutuallyExclusiveInputs(affineHostGroupName, antiAffineHostGroupName, PROVIDE_AFFINE_OR_ANTI_AFFINE_HOST_GROUP); final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withVmGroupName(vmGroupName) .withRuleName(ruleName) .build(); return new ClusterComputeResourceService().createAffinityRule(httpInputs, vmInputs, affineHostGroupName, antiAffineHostGroupName); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  @Action(name = "Create Affinity Rule", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) Map<String, String> createAffinityRule(@Param(value = HOST, required = true) String host,
                                                  @Param(value = PORT) String port,
                                                  @Param(value = PROTOCOL) String protocol,
                                                  @Param(value = USERNAME, required = true) String username,
                                                  @Param(value = PASSWORD, encrypted = true) String password,
                                                  @Param(value = TRUST_EVERYONE) String trustEveryone,
                                                  @Param(value = CLOSE_SESSION) String closeSession,
                                                  @Param(value = CLUSTER_NAME, required = true) String clusterName,
                                                  @Param(value = RULE_NAME, required = true) String ruleName,
                                                  @Param(value = AFFINE_HOST_GROUP_NAME) String affineHostGroupName,
                                                  @Param(value = ANTI_AFFINE_HOST_GROUP_NAME) String antiAffineHostGroupName,
                                                  @Param(value = VM_GROUP_NAME, required = true) String vmGroupName,
                                                  @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject);  }