Search in sources :

Example 1 with PlatformIpPoolsResponse

use of com.sequenceiq.cloudbreak.api.model.PlatformIpPoolsResponse 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());
}
Also used : Optional(org.testng.annotations.Optional) PlatformResourceRequestJson(com.sequenceiq.cloudbreak.api.model.PlatformResourceRequestJson) Assert(org.testng.Assert) PlatformIpPoolsResponse(com.sequenceiq.cloudbreak.api.model.PlatformIpPoolsResponse) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Parameters(org.testng.annotations.Parameters) Set(java.util.Set) Test(org.testng.annotations.Test) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) IpPoolJson(com.sequenceiq.cloudbreak.api.model.IpPoolJson) StringUtils(org.springframework.util.StringUtils) IntegrationTestContext(com.sequenceiq.it.IntegrationTestContext) PlatformIpPoolsResponse(com.sequenceiq.cloudbreak.api.model.PlatformIpPoolsResponse) IpPoolJson(com.sequenceiq.cloudbreak.api.model.IpPoolJson) PlatformResourceRequestJson(com.sequenceiq.cloudbreak.api.model.PlatformResourceRequestJson) Parameters(org.testng.annotations.Parameters) AbstractCloudbreakIntegrationTest(com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest) Test(org.testng.annotations.Test)

Example 2 with PlatformIpPoolsResponse

use of com.sequenceiq.cloudbreak.api.model.PlatformIpPoolsResponse in project cloudbreak by hortonworks.

the class CloudIpPoolsToPlatformIpPoolsResponseConverter method convert.

@Override
public PlatformIpPoolsResponse convert(CloudIpPools source) {
    Map<String, Set<IpPoolJson>> result = new HashMap<>();
    for (Entry<String, Set<CloudIpPool>> entry : source.getCloudIpPools().entrySet()) {
        Set<IpPoolJson> ipPoolJsonSet = new HashSet<>();
        for (CloudIpPool ipPool : entry.getValue()) {
            IpPoolJson actual = new IpPoolJson(ipPool.getName(), ipPool.getId(), ipPool.getProperties());
            ipPoolJsonSet.add(actual);
        }
        result.put(entry.getKey(), ipPoolJsonSet);
    }
    return new PlatformIpPoolsResponse(result);
}
Also used : PlatformIpPoolsResponse(com.sequenceiq.cloudbreak.api.model.PlatformIpPoolsResponse) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) CloudIpPool(com.sequenceiq.cloudbreak.cloud.model.CloudIpPool) IpPoolJson(com.sequenceiq.cloudbreak.api.model.IpPoolJson) HashSet(java.util.HashSet)

Aggregations

IpPoolJson (com.sequenceiq.cloudbreak.api.model.IpPoolJson)2 PlatformIpPoolsResponse (com.sequenceiq.cloudbreak.api.model.PlatformIpPoolsResponse)2 Set (java.util.Set)2 PlatformResourceRequestJson (com.sequenceiq.cloudbreak.api.model.PlatformResourceRequestJson)1 CloudIpPool (com.sequenceiq.cloudbreak.cloud.model.CloudIpPool)1 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)1 AbstractCloudbreakIntegrationTest (com.sequenceiq.it.cloudbreak.AbstractCloudbreakIntegrationTest)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 StringUtils (org.springframework.util.StringUtils)1 Assert (org.testng.Assert)1 Optional (org.testng.annotations.Optional)1 Parameters (org.testng.annotations.Parameters)1 Test (org.testng.annotations.Test)1