Search in sources :

Example 1 with SecurityGroupRequest

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

the class SecurityGroupV2RequestToSecurityGroupRequestConverter method convert.

@Override
public SecurityGroupRequest convert(SecurityGroupV2Request source) {
    SecurityGroupRequest entity = new SecurityGroupRequest();
    entity.setName(missingResourceNameGenerator.generateName(APIResourceType.SECURITY_GROUP));
    entity.setSecurityGroupId(source.getSecurityGroupId());
    if (source.getSecurityRules() != null) {
        entity.setSecurityRules(source.getSecurityRules());
    }
    return entity;
}
Also used : SecurityGroupRequest(com.sequenceiq.cloudbreak.api.model.SecurityGroupRequest)

Example 2 with SecurityGroupRequest

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

the class SecurityGroupCreationTest method testSecurityGroupCreation.

@Test
@Parameters({ "name", "ports", "provider" })
public void testSecurityGroupCreation(@Optional("it-restricted-ambari") String name, @Optional("22,443,9443,8080") String ports, @Optional("MOCK") String provider) {
    // GIVEN
    // WHEN
    SecurityGroupRequest securityGroupRequest = new SecurityGroupRequest();
    securityGroupRequest.setDescription("Security group created by IT");
    securityGroupRequest.setName(name);
    SecurityRuleRequest securityRuleRequest = new SecurityRuleRequest("");
    securityRuleRequest.setProtocol("tcp");
    securityRuleRequest.setSubnet("0.0.0.0/0");
    securityRuleRequest.setPorts(ports);
    securityGroupRequest.setSecurityRules(Collections.singletonList(securityRuleRequest));
    securityGroupRequest.setCloudPlatform(provider);
    String id = getCloudbreakClient().securityGroupEndpoint().postPrivate(securityGroupRequest).getId().toString();
    // THEN
    Assert.assertNotNull(id);
    getItContext().putContextParam(CloudbreakITContextConstants.SECURITY_GROUP_ID, id, true);
}
Also used : SecurityGroupRequest(com.sequenceiq.cloudbreak.api.model.SecurityGroupRequest) SecurityRuleRequest(com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

SecurityGroupRequest (com.sequenceiq.cloudbreak.api.model.SecurityGroupRequest)2 SecurityRuleRequest (com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest)1 Parameters (org.testng.annotations.Parameters)1 Test (org.testng.annotations.Test)1