use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class DefaultInstanceGroupProviderTest method createDefaultTemplateTestVolumeEncryptionAddedWhenAzureAndEncryptionAtHostEnabled.
@Test
void createDefaultTemplateTestVolumeEncryptionAddedWhenAzureAndEncryptionAtHostEnabled() {
when(entitlementService.isAzureEncryptionAtHostEnabled(ACCOUNT_ID)).thenReturn(Boolean.TRUE);
Template result = underTest.createDefaultTemplate(CloudPlatform.AZURE, ACCOUNT_ID, "dummyDiskEncryptionSet", null, null);
assertThat(result).isNotNull();
Json attributes = result.getAttributes();
assertThat(attributes).isNotNull();
assertThat(attributes.<Object>getValue(AzureInstanceTemplate.DISK_ENCRYPTION_SET_ID)).isEqualTo("dummyDiskEncryptionSet");
assertThat(attributes.<Object>getValue(AzureInstanceTemplate.MANAGED_DISK_ENCRYPTION_WITH_CUSTOM_KEY_ENABLED)).isEqualTo(Boolean.TRUE);
assertThat(attributes.<Object>getValue(AzureInstanceTemplate.ENCRYPTION_AT_HOST_ENABLED)).isEqualTo(Boolean.TRUE);
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class DefaultInstanceGroupProviderTest method createDefaultNetworkWithAwsAttributesShouldReturnWithNetworkAttributes.
@Test
void createDefaultNetworkWithAwsAttributesShouldReturnWithNetworkAttributes() {
Json json = new Json(Map.of(NetworkConstants.SUBNET_IDS, Set.of("id")));
NetworkRequest network = new NetworkRequest();
AwsNetworkParameters awsNetworkParameters = new AwsNetworkParameters();
awsNetworkParameters.setSubnetId("id");
network.setAws(awsNetworkParameters);
InstanceGroupNetwork defaultNetwork = underTest.createDefaultNetwork(CloudPlatform.AWS, network);
assertThat(defaultNetwork.getAttributes()).isEqualTo(json);
}
use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class ServiceProviderCredentialAdapter method mergeCloudProviderParameters.
private boolean mergeCloudProviderParameters(Credential credential, CloudCredential cloudCredentialResponse, Set<String> skippedKeys, boolean overrideParameters) {
Json attributes = new Json(credential.getAttributes());
Map<String, Object> newAttributes = attributes.getMap();
boolean newAttributesAdded = false;
for (Entry<String, Object> cloudParam : cloudCredentialResponse.getParameters().entrySet()) {
if (!skippedKeys.contains(cloudParam.getKey()) && cloudParam.getValue() != null) {
if (overrideParameters || newAttributes.get(cloudParam.getKey()) == null) {
newAttributes.put(cloudParam.getKey(), cloudParam.getValue());
newAttributesAdded = true;
}
}
}
if (newAttributesAdded) {
credential.setAttributes(new Json(newAttributes).getValue());
}
return newAttributesAdded;
}
use of com.sequenceiq.cloudbreak.common.json.Json 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.cloudbreak.common.json.Json in project cloudbreak by hortonworks.
the class CredentialV1RequestToCredentialConverter method convertAttributes.
private void convertAttributes(CredentialRequest source, Credential credential) {
CredentialAttributes credentialAttributes = new CredentialAttributes();
doIfNotNull(source.getAws(), param -> credentialAttributes.setAws(awsConverter.convert(param)));
doIfNotNull(source.getAzure(), param -> credentialAttributes.setAzure(azureConverter.convert(param)));
doIfNotNull(source.getGcp(), param -> credentialAttributes.setGcp(gcpConverter.convert(param)));
doIfNotNull(source.getMock(), param -> credentialAttributes.setMock(mockConverter.convert(param)));
doIfNotNull(source.getYarn(), param -> credentialAttributes.setYarn(yarnConverter.convert(param)));
credential.setAttributes(new Json(credentialAttributes).getValue());
}
Aggregations