@Test public void testBuildClusterForNonExistingBlueprint() { when(client.doesBlueprintExist("id")).thenReturn(false); String result = clusterCommands.buildCluster(new Blueprint("id")); verify(client).doesBlueprintExist("id"); assertEquals("Not a valid blueprint id", result); }
@CliCommand(value = "cluster build", help = "Starts to build a cluster") public String buildCluster( @CliOption(key = "blueprint", mandatory = true, help = "Id of the blueprint, use 'blueprints' command to see the list") Blueprint id) { String message; String blueprint = id.getName(); if (client.doesBlueprintExist(blueprint)) { context.setFocus(blueprint, FocusType.CLUSTER_BUILD); context.setHint(Hints.ASSIGN_HOSTS); message = String.format("%s\n%s", renderSingleMap(client.getHostNames(), "HOSTNAME", "STATE"), renderMultiValueMap(client.getBlueprintMap(blueprint), "HOSTGROUP", "COMPONENT")); createNewHostGroups(); } else { message = "Not a valid blueprint id"; } return message; }
ClusterCommands implements CommandMarker { @CliCommand(value = "cluster build", help = "Starts to build a cluster") public String buildCluster( @CliOption(key = "blueprint", mandatory = true, help = "Id of the blueprint, use 'blueprints' command to see the list") Blueprint id) { String message; String blueprint = id.getName(); if (client.doesBlueprintExist(blueprint)) { context.setFocus(blueprint, FocusType.CLUSTER_BUILD); context.setHint(Hints.ASSIGN_HOSTS); message = String.format("%s\n%s", renderSingleMap(client.getHostNames(), "HOSTNAME", "STATE"), renderMultiValueMap(client.getBlueprintMap(blueprint), "HOSTGROUP", "COMPONENT")); createNewHostGroups(); } else { message = "Not a valid blueprint id"; } return message; } }
ClusterCommands implements CommandMarker { @CliCommand(value = "cluster build", help = "Starts to build a cluster") public String buildCluster( @CliOption(key = "blueprint", mandatory = true, help = "Id of the blueprint, use 'blueprints' command to see the list") Blueprint id) { String message; String blueprint = id.getName(); if (client.doesBlueprintExist(blueprint)) { context.setFocus(blueprint, FocusType.CLUSTER_BUILD); context.setHint(Hints.ASSIGN_HOSTS); message = String.format("%s\n%s", renderSingleMap(client.getHostNames(), "HOSTNAME", "STATE"), renderMultiValueMap(client.getBlueprintMap(blueprint), "HOSTGROUP", "COMPONENT")); createNewHostGroups(); } else { message = "Not a valid blueprint id"; } return message; } @Autowired  ClusterCommands(AmbariClient client, AmbariContext context, FlashService flashService); }
ClusterCommands implements CommandMarker { @CliCommand(value = "cluster build", help = "Starts to build a cluster") public String buildCluster( @CliOption(key = "blueprint", mandatory = true, help = "Id of the blueprint, use 'blueprints' command to see the list") Blueprint id) { String message; String blueprint = id.getName(); if (client.doesBlueprintExist(blueprint)) { context.setFocus(blueprint, FocusType.CLUSTER_BUILD); context.setHint(Hints.ASSIGN_HOSTS); message = String.format("%s\n%s", renderSingleMap(client.getHostNames(), "HOSTNAME", "STATE"), renderMultiValueMap(client.getBlueprintMap(blueprint), "HOSTGROUP", "COMPONENT")); createNewHostGroups(); } else { message = "Not a valid blueprint id"; } return message; } @Autowired  ClusterCommands(AmbariClient client, AmbariContext context, FlashService flashService); @CliAvailabilityIndicator("cluster build") boolean isClusterBuildCommandAvailable(); @CliCommand(value = "cluster build", help = "Starts to build a cluster") String buildCluster(
    @CliOption(key = "blueprint", mandatory = true, help = "Id of the blueprint, use 'blueprints' command to see the list") Blueprint id); @CliAvailabilityIndicator("cluster assign") boolean isAssignCommandAvailable(); @CliCommand(value = "cluster assign", help = "Assign host to host group") String assign(
    @CliOption(key = "host", mandatory = true, help = "Fully qualified host name") Host host,
    @CliOption(key = "hostGroup", mandatory = true, help = "Host group which to assign the host") String group); @CliAvailabilityIndicator(value = "cluster autoAssign") boolean isClusterAutoAssignAvailable(); @CliCommand(value = "cluster autoAssign", help = "Automatically assigns hosts to different host groups base on the provided strategy") String autoAssign(); @CliAvailabilityIndicator("cluster preview") boolean isClusterPreviewCommandAvailable(); @CliCommand(value = "cluster preview", help = "Shows the currently assigned hosts") String showAssignments(); @CliAvailabilityIndicator("cluster create") boolean isCreateClusterCommandAvailable(); @CliCommand(value = "cluster create", help = "Create a cluster based on current blueprint and assigned hosts") String createCluster(
    @CliOption(key = "exitOnFinish", mandatory = false, help = "Quits the shell when the cluster creation finishes") Boolean exit); @CliAvailabilityIndicator("cluster delete") boolean isDeleteClusterCommandAvailable(); @CliCommand(value = "cluster delete", help = "Delete the cluster") String deleteCluster(); @CliAvailabilityIndicator(value = "cluster reset") boolean isClusterResetCommandAvailable(); @CliCommand(value = "cluster reset", help = "Clears the host - host group assignments") void reset(); }
ClusterCommands implements CommandMarker { @CliCommand(value = "cluster build", help = "Starts to build a cluster") public String buildCluster( @CliOption(key = "blueprint", mandatory = true, help = "Id of the blueprint, use 'blueprints' command to see the list") Blueprint id) { String message; String blueprint = id.getName(); if (client.doesBlueprintExist(blueprint)) { context.setFocus(blueprint, FocusType.CLUSTER_BUILD); context.setHint(Hints.ASSIGN_HOSTS); message = String.format("%s\n%s", renderSingleMap(client.getHostNames(), "HOSTNAME", "STATE"), renderMultiValueMap(client.getBlueprintMap(blueprint), "HOSTGROUP", "COMPONENT")); createNewHostGroups(); } else { message = "Not a valid blueprint id"; } return message; } @Autowired  ClusterCommands(AmbariClient client, AmbariContext context, FlashService flashService); @CliAvailabilityIndicator("cluster build") boolean isClusterBuildCommandAvailable(); @CliCommand(value = "cluster build", help = "Starts to build a cluster") String buildCluster(
    @CliOption(key = "blueprint", mandatory = true, help = "Id of the blueprint, use 'blueprints' command to see the list") Blueprint id); @CliAvailabilityIndicator("cluster assign") boolean isAssignCommandAvailable(); @CliCommand(value = "cluster assign", help = "Assign host to host group") String assign(
    @CliOption(key = "host", mandatory = true, help = "Fully qualified host name") Host host,
    @CliOption(key = "hostGroup", mandatory = true, help = "Host group which to assign the host") String group); @CliAvailabilityIndicator(value = "cluster autoAssign") boolean isClusterAutoAssignAvailable(); @CliCommand(value = "cluster autoAssign", help = "Automatically assigns hosts to different host groups base on the provided strategy") String autoAssign(); @CliAvailabilityIndicator("cluster preview") boolean isClusterPreviewCommandAvailable(); @CliCommand(value = "cluster preview", help = "Shows the currently assigned hosts") String showAssignments(); @CliAvailabilityIndicator("cluster create") boolean isCreateClusterCommandAvailable(); @CliCommand(value = "cluster create", help = "Create a cluster based on current blueprint and assigned hosts") String createCluster(
    @CliOption(key = "exitOnFinish", mandatory = false, help = "Quits the shell when the cluster creation finishes") Boolean exit); @CliAvailabilityIndicator("cluster delete") boolean isDeleteClusterCommandAvailable(); @CliCommand(value = "cluster delete", help = "Delete the cluster") String deleteCluster(); @CliAvailabilityIndicator(value = "cluster reset") boolean isClusterResetCommandAvailable(); @CliCommand(value = "cluster reset", help = "Clears the host - host group assignments") void reset();  }