use of com.sequenceiq.cloudbreak.api.model.PlatformResourceRequestJson in project cloudbreak by hortonworks.
the class IpPoolSelectionTest method testIpPoolSelection.
@Test
@Parameters({ "credentialName", "region", "availabilityZone", "poolName" })
public void testIpPoolSelection(@Optional("") String credentialName, @Optional("") String region, @Optional("") String availabilityZone, String poolName) {
// GIVEN
IntegrationTestContext itContext = getItContext();
credentialName = StringUtils.hasText(credentialName) ? credentialName : itContext.getContextParam(CloudbreakV2Constants.CREDENTIAL_NAME);
region = StringUtils.hasText(region) ? region : itContext.getContextParam(CloudbreakV2Constants.REGION);
availabilityZone = StringUtils.hasText(availabilityZone) ? availabilityZone : itContext.getContextParam(CloudbreakV2Constants.AVAILABILTYZONE);
PlatformResourceRequestJson resourceRequestJson = new PlatformResourceRequestJson();
resourceRequestJson.setCredentialName(credentialName);
resourceRequestJson.setRegion(region);
resourceRequestJson.setAvailabilityZone(availabilityZone);
// WHEN
PlatformIpPoolsResponse response = getCloudbreakClient().connectorV1Endpoint().getIpPoolsCredentialId(resourceRequestJson);
// THEN
Set<IpPoolJson> ipPools = response.getIppools().get(availabilityZone);
Assert.assertNotNull(ipPools, "ippools cannot be null for " + region);
java.util.Optional<IpPoolJson> selected = ipPools.stream().filter(rk -> rk.getName().equals(poolName)).findFirst();
Assert.assertTrue(selected.isPresent(), "the ippool list doesn't contain [" + poolName + ']');
getItContext().putContextParam(CloudbreakV2Constants.OPENSTACK_FLOATING_POOL, selected.get().getId());
}
use of com.sequenceiq.cloudbreak.api.model.PlatformResourceRequestJson in project cloudbreak by hortonworks.
the class ExistingSshKeySelectionTest method testSshKeySelection.
@Test
@Parameters({ "credentialName", "region", "availabilityZone", "selectedKeyName" })
public void testSshKeySelection(@Optional("") String credentialName, @Optional("") String region, @Optional("") String availabilityZone, String selectedKeyName) {
// GIVEN
IntegrationTestContext itContext = getItContext();
credentialName = StringUtils.hasText(credentialName) ? credentialName : itContext.getContextParam(CloudbreakV2Constants.CREDENTIAL_NAME);
region = StringUtils.hasText(region) ? region : itContext.getContextParam(CloudbreakV2Constants.REGION);
availabilityZone = StringUtils.hasText(availabilityZone) ? availabilityZone : itContext.getContextParam(CloudbreakV2Constants.AVAILABILTYZONE);
PlatformResourceRequestJson resourceRequestJson = new PlatformResourceRequestJson();
resourceRequestJson.setCredentialName(credentialName);
resourceRequestJson.setRegion(region);
resourceRequestJson.setAvailabilityZone(availabilityZone);
// WHEN
PlatformSshKeysResponse response = getCloudbreakClient().connectorV1Endpoint().getCloudSshKeys(resourceRequestJson);
// THEN
Set<PlatformSshKeyResponse> regionKeys = response.getSshKeys().get(region);
Assert.assertNotNull(regionKeys, "keys cannot be null for " + region);
java.util.Optional<PlatformSshKeyResponse> selected = regionKeys.stream().filter(rk -> rk.getName().equals(selectedKeyName)).findFirst();
Assert.assertTrue(selected.isPresent(), "the sshkey list doesn't contain [" + selectedKeyName + ']');
getItContext().putContextParam(CloudbreakV2Constants.SSH_PUBLICKEY_ID, selected.get().getName());
}
Aggregations