use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class CredentialToCredentialV1ResponseConverter method convert.
public Credential convert(ExtendedCloudCredential source) {
if (source == null) {
return null;
}
Credential credential = new Credential();
credential.setName(source.getName());
credential.setDescription(source.getDescription());
credential.setCloudPlatform(source.getCloudPlatform());
credential.setCreator(source.getUserCrn());
credential.setAccountId(source.getAccountId());
Map<String, Object> attributes = source.getParameters() == null ? new HashMap<>() : source.getParameters();
credential.setAttributes(new Json(attributes).getValue());
return credential;
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class CredentialToCredentialV1ResponseConverter method convert.
public Credential convert(CredentialRequest source) {
if (source == null) {
return null;
}
Credential credential = new Credential();
credential.setName(Strings.isNullOrEmpty(source.getName()) ? UUID.randomUUID().toString() : source.getName());
credential.setDescription(source.getDescription());
credential.setCloudPlatform(source.getCloudPlatform());
credential.setVerificationStatusText(source.getVerificationStatusText());
credential.setVerifyPermissions(source.isVerifyPermissions());
convertAttributes(source, credential);
if (source.getAws() != null) {
credential.setGovCloud(source.getAws().getGovCloud());
}
return credential;
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class CloudNetworkService method fetchCloudNetwork.
private Map<String, CloudSubnet> fetchCloudNetwork(Set<Region> regions, Credential credential, String cloudPlatform, NetworkDto network, Map<String, String> filter, Set<String> subnetIds) {
String regionName = regions.iterator().next().getName();
PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest();
platformResourceRequest.setCredential(credential);
platformResourceRequest.setCloudPlatform(cloudPlatform);
platformResourceRequest.setRegion(regionName);
platformResourceRequest.setFilters(filter);
LOGGER.debug("About to fetch networks from cloud provider ({})...", cloudPlatform);
CloudNetworks cloudNetworks = platformParameterService.getCloudNetworks(platformResourceRequest);
Set<CloudNetwork> cloudNetworkSet = cloudNetworks.getCloudNetworkResponses().get(regionName);
return cloudNetworkSet.stream().flatMap(it -> it.getSubnetsMeta().stream()).filter(sn -> isNetworkIdMatches(subnetIds, sn, cloudPlatform) || isNetworkNameMatches(subnetIds, sn, cloudPlatform)).collect(toMap(getNetworkIdentifier(cloudPlatform), Function.identity()));
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class PlatformParameterServiceTest method getPlatformResourceRequestSetPlatformFromCredential.
@Test
void getPlatformResourceRequestSetPlatformFromCredential() {
final Credential credential = new Credential();
String platformFromCredential = "anotherVariant";
credential.setCloudPlatform(platformFromCredential);
when(credentialService.getOptionalByCrnForAccountId(eq(CREDENTIAL_CRN), eq(ACCOUNT_ID), eq(ENVIRONMENT))).thenReturn(Optional.of(credential));
when(credentialService.extractCredential(any(), any())).thenReturn(credential);
PlatformResourceRequest result = platformParameterServiceUnderTest.getPlatformResourceRequest(ACCOUNT_ID, null, CREDENTIAL_CRN, null, EMPTY, null);
assertEquals(platformFromCredential, result.getCloudPlatform());
assertEquals(platformFromCredential, result.getPlatformVariant());
assertEquals(null, result.getRegion());
assertEquals(null, result.getAvailabilityZone());
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class PlatformParameterServiceTest method getPlatformResourceRequestSetPlatformFromArgument.
@Test
void getPlatformResourceRequestSetPlatformFromArgument() {
final Credential credential = new Credential();
String platformFromCredential = "anotherVariant";
credential.setCloudPlatform(platformFromCredential);
when(credentialService.getOptionalByCrnForAccountId(eq(CREDENTIAL_CRN), eq(ACCOUNT_ID), eq(ENVIRONMENT))).thenReturn(Optional.of(credential));
when(credentialService.extractCredential(any(), any())).thenReturn(credential);
PlatformResourceRequest result = platformParameterServiceUnderTest.getPlatformResourceRequest(ACCOUNT_ID, null, CREDENTIAL_CRN, REGION, PLATFORM_VARIANT, AVAILIBILTY_ZONE);
assertEquals(platformFromCredential, result.getCloudPlatform());
assertEquals(null, result.getPlatformVariant());
assertEquals(REGION, result.getRegion());
assertEquals(AVAILIBILTY_ZONE, result.getAvailabilityZone());
}
Aggregations