Search in sources :

Example 1 with ClouderaManagerDto

use of com.sequenceiq.mock.clouderamanager.ClouderaManagerDto in project cloudbreak by hortonworks.

the class CmdRunSaltResponse method run.

@Override
public Object run(String mockUuid, Map<String, List<String>> params) throws Exception {
    List<String> targets = params.get("tgt");
    List<String> args = params.get("arg");
    String host = !CollectionUtils.isEmpty(targets) ? targets.get(0) : "";
    Map<String, JsonNode> result = new HashMap<>();
    String s = "(cd /srv/salt/disk;CLOUD_PLATFORM='MOCK' ATTACHED_VOLUME_NAME_LIST='' ATTACHED_VOLUME_SERIAL_LIST='' ./find-device-and-format.sh)";
    if (!CollectionUtils.isEmpty(args) && args.contains(s)) {
        result.put(host, new TextNode("a750be52-fc65-11e8-8eb2-f2801f1b9fd1"));
    } else if (!CollectionUtils.isEmpty(args) && args.contains("cat /etc/fstab")) {
        result.put(host, new TextNode("UUID=a750be52-fc65-11e8-8eb2-f2801f1b9fd1 /hadoopfs/fs1        ext4          noatime          0      2"));
    } else if (!CollectionUtils.isEmpty(args) && args.contains("salt-bootstrap version")) {
        ClouderaManagerDto cmDto = clouderaManagerStoreService.read(mockUuid);
        addDataToAllHost(cmDto, result, "3000.8");
    } else if (!CollectionUtils.isEmpty(args) && args.contains("cat /var/lib/cloudera-scm-agent/active_parcels.json | jq -r '.CDH'")) {
        ClouderaManagerDto cmDto = clouderaManagerStoreService.read(mockUuid);
        addDataToAllHost(cmDto, result, cmDto.getClusterTemplate().getCdhVersion());
    }
    ApplyResponse response = new ApplyResponse();
    response.setResult(List.of(result));
    return response;
}
Also used : ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) HashMap(java.util.HashMap) JsonNode(com.fasterxml.jackson.databind.JsonNode) TextNode(com.fasterxml.jackson.databind.node.TextNode) ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)

Example 2 with ClouderaManagerDto

use of com.sequenceiq.mock.clouderamanager.ClouderaManagerDto in project cloudbreak by hortonworks.

the class ExternalUserMappingsResourceOperation method updateExternalUserMapping.

public ResponseEntity<ApiExternalUserMapping> updateExternalUserMapping(String mockUuid, String uuid, @Valid ApiExternalUserMapping body) {
    ClouderaManagerDto dto = clouderaManagerStoreService.read(mockUuid);
    ApiExternalUserMapping user = getUser(dto, uuid);
    user.setAuthRoles(body.getAuthRoles());
    return responseCreatorComponent.exec(body);
}
Also used : ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) ApiExternalUserMapping(com.sequenceiq.mock.swagger.model.ApiExternalUserMapping)

Example 3 with ClouderaManagerDto

use of com.sequenceiq.mock.clouderamanager.ClouderaManagerDto in project cloudbreak by hortonworks.

the class ExternalUserMappingsResourceOperation method createExternalUserMappings.

public ResponseEntity<ApiExternalUserMappingList> createExternalUserMappings(String mockUuid, @Valid ApiExternalUserMappingList body) {
    ClouderaManagerDto dto = clouderaManagerStoreService.read(mockUuid);
    List<ApiExternalUserMapping> items = body.getItems();
    items.forEach(u -> u.uuid(UUID.randomUUID().toString()));
    dto.getExternalUsers().addAll(items);
    return responseCreatorComponent.exec(body);
}
Also used : ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) ApiExternalUserMapping(com.sequenceiq.mock.swagger.model.ApiExternalUserMapping)

Example 4 with ClouderaManagerDto

use of com.sequenceiq.mock.clouderamanager.ClouderaManagerDto in project cloudbreak by hortonworks.

the class AuthRolesResourceOperation method readAuthRolesMetadata.

public ResponseEntity<ApiAuthRoleMetadataList> readAuthRolesMetadata(String mockUuid, @Valid String view) {
    ClouderaManagerDto dto = clouderaManagerStoreService.read(mockUuid);
    List<ApiAuthRoleMetadata> collect = dto.getUsers().stream().flatMap(u -> u.getAuthRoles().stream()).map(r -> new ApiAuthRoleMetadata().role("ROLE_ADMIN").uuid(r.getUuid()).displayName(r.getDisplayName())).collect(Collectors.toList());
    return responseCreatorComponent.exec(new ApiAuthRoleMetadataList().items(collect));
}
Also used : Inject(javax.inject.Inject) Valid(javax.validation.Valid) List(java.util.List) ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) ClouderaManagerStoreService(com.sequenceiq.mock.clouderamanager.ClouderaManagerStoreService) ResponseCreatorComponent(com.sequenceiq.mock.clouderamanager.ResponseCreatorComponent) ApiAuthRoleMetadataList(com.sequenceiq.mock.swagger.model.ApiAuthRoleMetadataList) ResponseEntity(org.springframework.http.ResponseEntity) Controller(org.springframework.stereotype.Controller) ApiAuthRoleMetadata(com.sequenceiq.mock.swagger.model.ApiAuthRoleMetadata) Collectors(java.util.stream.Collectors) ApiAuthRoleMetadataList(com.sequenceiq.mock.swagger.model.ApiAuthRoleMetadataList) ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) ApiAuthRoleMetadata(com.sequenceiq.mock.swagger.model.ApiAuthRoleMetadata)

Example 5 with ClouderaManagerDto

use of com.sequenceiq.mock.clouderamanager.ClouderaManagerDto in project cloudbreak by hortonworks.

the class ClusterResourceOperation method stopCommand.

public ResponseEntity<ApiCommand> stopCommand(String mockUuid, String clusterName) {
    ClouderaManagerDto read = clouderaManagerStoreService.read(mockUuid);
    Map<String, ApiServiceState> newStates = new HashMap<>();
    read.getServiceStates().forEach((service, apiServiceState) -> newStates.put(service, ApiServiceState.STOPPED));
    read.setServiceStates(newStates);
    read.setStatus(ApiServiceState.STOPPED);
    return responseCreatorComponent.exec(new ApiCommand().id(CommandId.CLUSTER_STOP).active(Boolean.TRUE).name("Stop"));
}
Also used : ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) ApiCommand(com.sequenceiq.mock.swagger.model.ApiCommand) ApiServiceState(com.sequenceiq.mock.swagger.model.ApiServiceState) HashMap(java.util.HashMap)

Aggregations

ClouderaManagerDto (com.sequenceiq.mock.clouderamanager.ClouderaManagerDto)8 HashMap (java.util.HashMap)4 ClouderaManagerStoreService (com.sequenceiq.mock.clouderamanager.ClouderaManagerStoreService)2 ApiCommand (com.sequenceiq.mock.swagger.model.ApiCommand)2 ApiExternalUserMapping (com.sequenceiq.mock.swagger.model.ApiExternalUserMapping)2 ApiServiceState (com.sequenceiq.mock.swagger.model.ApiServiceState)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Inject (javax.inject.Inject)2 ResponseEntity (org.springframework.http.ResponseEntity)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 Gson (com.google.gson.Gson)1 ApplyResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)1 PackageVersionResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.PackageVersionResponse)1 CheckedSupplier (com.sequenceiq.cloudbreak.util.CheckedSupplier)1 CmProfile (com.sequenceiq.mock.clouderamanager.CmProfile)1 ResponseCreatorComponent (com.sequenceiq.mock.clouderamanager.ResponseCreatorComponent)1 MockResponse (com.sequenceiq.mock.spi.MockResponse)1