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;
}
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);
}
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);
}
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));
}
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"));
}
Aggregations