use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class AwsIDBrokerObjectStorageValidator method validateObjectStorage.
public ValidationResult validateObjectStorage(AmazonIdentityManagementClient iam, SpiFileSystem spiFileSystem, String logsLocationBase, String backupLocationBase, ValidationResultBuilder resultBuilder) {
List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems();
for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) {
CloudS3View cloudFileSystem = (CloudS3View) cloudFileSystemView;
String instanceProfileArn = cloudFileSystem.getInstanceProfile();
InstanceProfile instanceProfile = awsIamService.getInstanceProfile(iam, instanceProfileArn, cloudFileSystem.getCloudIdentityType(), resultBuilder);
if (instanceProfile != null) {
CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType();
if (CloudIdentityType.ID_BROKER.equals(cloudIdentityType)) {
validateIDBroker(iam, instanceProfile, cloudFileSystem, resultBuilder);
} else if (CloudIdentityType.LOG.equals(cloudIdentityType)) {
validateLog(iam, instanceProfile, cloudFileSystem, logsLocationBase, backupLocationBase, resultBuilder);
}
}
}
return resultBuilder.build();
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class GcpInstanceResourceBuilder method build.
@Override
public List<CloudResource> build(GcpContext context, CloudInstance cloudInstance, long privateId, AuthenticatedContext auth, Group group, List<CloudResource> buildableResource, CloudStack cloudStack) throws Exception {
InstanceTemplate template = group.getReferenceInstanceTemplate();
String projectId = context.getProjectId();
String location = cloudInstance.getAvailabilityZone();
Compute compute = context.getCompute();
List<CloudResource> computeResources = context.getComputeResources(privateId);
List<AttachedDisk> listOfDisks = new ArrayList<>();
listOfDisks.addAll(getBootDiskList(computeResources, projectId, cloudInstance.getAvailabilityZone()));
listOfDisks.addAll(getAttachedDisks(computeResources, projectId));
listOfDisks.forEach(disk -> customGcpDiskEncryptionService.addEncryptionKeyToDisk(template, disk));
Instance instance = new Instance();
instance.setMachineType(String.format("https://www.googleapis.com/compute/v1/projects/%s/zones/%s/machineTypes/%s", projectId, location, template.getFlavor()));
instance.setDescription(description());
instance.setName(buildableResource.get(0).getName());
Optional<CloudFileSystemView> cloudFileSystemView = group.getIdentity();
if (cloudFileSystemView.isPresent()) {
CloudGcsView gcsView = (CloudGcsView) cloudFileSystemView.get();
ServiceAccount serviceAccount = new ServiceAccount();
serviceAccount.setEmail(gcsView.getServiceAccountEmail());
serviceAccount.setScopes(Arrays.asList(GCP_CLOUD_STORAGE_RW_SCOPE));
instance.setServiceAccounts(Arrays.asList(serviceAccount));
}
// For FreeIPA hosts set the hostname during creation to avoid Google Network Manager overriding it with internal hostnames
if (cloudStack.getParameters() != null && cloudStack.getParameters().getOrDefault(CLOUD_STACK_TYPE_PARAMETER, "").equals(FREEIPA_STACK_TYPE)) {
String hostname = getHostname(group, privateId);
if (hostname != null) {
instance.setHostname(hostname);
}
}
instance.setCanIpForward(Boolean.TRUE);
instance.setNetworkInterfaces(getNetworkInterface(context, computeResources, group, cloudStack, cloudInstance));
instance.setDisks(listOfDisks);
instance.setServiceAccounts(extractServiceAccounts(group));
Scheduling scheduling = new Scheduling();
boolean preemptible = false;
if (template.getParameter(PREEMPTIBLE, Boolean.class) != null) {
preemptible = template.getParameter(PREEMPTIBLE, Boolean.class);
}
scheduling.setPreemptible(preemptible);
instance.setScheduling(scheduling);
configureTagsOnInstance(auth, group, instance);
configureLabelsOnInstance(cloudStack, instance);
Metadata metadata = new Metadata();
metadata.setItems(new ArrayList<>());
Items sshMetaData = new Items();
sshMetaData.setKey("ssh-keys");
sshMetaData.setValue(getPublicKey(group.getPublicKey(), group.getLoginUserName()));
Items blockProjectWideSsh = new Items();
blockProjectWideSsh.setKey("block-project-ssh-keys");
blockProjectWideSsh.setValue("TRUE");
Items startupScript = new Items();
startupScript.setKey("startup-script");
startupScript.setValue(cloudStack.getImage().getUserDataByType(group.getType()));
metadata.getItems().add(sshMetaData);
metadata.getItems().add(startupScript);
metadata.getItems().add(blockProjectWideSsh);
instance.setMetadata(metadata);
Insert insert = compute.instances().insert(projectId, cloudInstance.getAvailabilityZone(), instance);
insert.setPrettyPrint(Boolean.TRUE);
try {
Operation operation = insert.execute();
verifyOperation(operation, buildableResource);
updateDiskSetWithInstanceName(auth, computeResources, instance);
assignToExistingInstanceGroup(context, group, instance, buildableResource);
return singletonList(createOperationAwareCloudResource(buildableResource.get(0), operation));
} catch (GoogleJsonResponseException e) {
throw new GcpResourceException(checkException(e), resourceType(), buildableResource.get(0).getName());
}
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class StackToCloudStackConverterTest method testBuildFileSystemViewSameGCPEmail.
@Test
public void testBuildFileSystemViewSameGCPEmail() throws Exception {
Telemetry telemetry = mock(Telemetry.class);
Backup backup = mock(Backup.class);
Logging logging = mock(Logging.class);
GcsCloudStorageV1Parameters gcsLogging = new GcsCloudStorageV1Parameters();
gcsLogging.setServiceAccountEmail("myaccount@myprojectid.iam.gserviceaccount.com");
GcsCloudStorageV1Parameters gcsBackup = new GcsCloudStorageV1Parameters();
gcsBackup.setServiceAccountEmail("myaccount@myprojectid.iam.gserviceaccount.com");
when(stack.getTelemetry()).thenReturn(telemetry);
when(telemetry.getLogging()).thenReturn(logging);
when(stack.getBackup()).thenReturn(backup);
when(backup.getGcs()).thenReturn(gcsBackup);
when(logging.getGcs()).thenReturn(gcsLogging);
Optional<CloudFileSystemView> fileSystemView = underTest.buildFileSystemView(stack);
assertEquals(Optional.empty(), fileSystemView);
}
Aggregations