.ethertype(RuleEthertype.IPV6) .portRangeMax(90) .portRangeMin(80) .protocol(RuleProtocol.TCP) .build());
.portRangeMin(80) .portRangeMax(80) .ethertype(RuleEthertype.IPV4) .protocol(RuleProtocol.TCP) .remoteGroupId("85cc3048-abc3-43cc-89b3-377341426ac5") .build();
private SecurityGroup createSecurityGroupFrom(final org.jclouds.openstack.neutron.v2.domain.SecurityGroup group, Location location, Set<Integer> ports) { SecurityGroup securityGroup = neutronSecurityGroupToSecurityGroup.create(location).apply(group); logger.debug("<< created securityGroup(%s)", securityGroup); SecurityGroupApi securityGroupApi = getNeutronSecurityGroupApi(location.getId()); try { for (int inboundPort : ports) { logger.debug(">> authorizing securityGroup(%s) permission to 0.0.0.0/0 on port %d", securityGroup, inboundPort); securityGroupApi.create( Rule.CreateRule.createBuilder(RuleDirection.INGRESS, RegionAndId.fromSlashEncoded(securityGroup.getId()).getId()).protocol(RuleProtocol.TCP) .portRangeMin(inboundPort).portRangeMax(inboundPort).remoteIpPrefix("0.0.0.0/0").build()); logger.debug("<< authorized securityGroup(%s) permission to 0.0.0.0/0 on port %d", securityGroup, inboundPort); } return securityGroup; } catch (IllegalStateException e) { logger.trace("<< trying to find securityGroup(%s): %s", group, e.getMessage()); return securityGroupApi.listSecurityGroups().concat() .filter(new Predicate<org.jclouds.openstack.neutron.v2.domain.SecurityGroup>() { @Override public boolean apply(@Nullable org.jclouds.openstack.neutron.v2.domain.SecurityGroup input) { return input.getName().equals(group.getName()); } }).transform(neutronSecurityGroupToSecurityGroup.create(location)).first().orNull(); } }
for (String cidr : ipPermission.getCidrBlocks()) { securityGroupApi.create(Rule.CreateRule.createBuilder(RuleDirection.INGRESS, group.getProviderId()) .protocol(RuleProtocol.fromValue(ipPermission.getIpProtocol().name())) .ethertype(RuleEthertype.IPV4) .portRangeMin(ipPermission.getFromPort()) .portRangeMax(ipPermission.getToPort()) .remoteIpPrefix(cidr) .build()); String groupId = regionAndId.getId(); securityGroupApi.create(Rule.CreateRule.createBuilder(RuleDirection.INGRESS, groupId) .protocol(RuleProtocol.fromValue(ipPermission.getIpProtocol().name())) .ethertype(RuleEthertype.IPV4) .portRangeMin(ipPermission.getFromPort()) .portRangeMax(ipPermission.getToPort()) .remoteGroupId(groupId) .build());
for (String cidr : ipPermission.getCidrBlocks()) { securityGroupApi.create(Rule.CreateRule.createBuilder(RuleDirection.INGRESS, group.getProviderId()) .protocol(RuleProtocol.fromValue(ipPermission.getIpProtocol().name())) .ethertype(RuleEthertype.IPV4) .portRangeMin(ipPermission.getFromPort()) .portRangeMax(ipPermission.getToPort()) .remoteIpPrefix(cidr) .build()); String groupId = regionAndId.getId(); securityGroupApi.create(Rule.CreateRule.createBuilder(RuleDirection.INGRESS, groupId) .protocol(RuleProtocol.fromValue(ipPermission.getIpProtocol().name())) .ethertype(RuleEthertype.IPV4) .portRangeMin(ipPermission.getFromPort()) .portRangeMax(ipPermission.getToPort()) .remoteGroupId(groupId) .build());
private SecurityGroup createSecurityGroupFrom(final org.jclouds.openstack.neutron.v2.domain.SecurityGroup group, Location location, Set<Integer> ports) { SecurityGroup securityGroup = neutronSecurityGroupToSecurityGroup.create(location).apply(group); logger.debug("<< created securityGroup(%s)", securityGroup); SecurityGroupApi securityGroupApi = getNeutronSecurityGroupApi(location.getId()); try { for (int inboundPort : ports) { logger.debug(">> authorizing securityGroup(%s) permission to 0.0.0.0/0 on port %d", securityGroup, inboundPort); securityGroupApi.create( Rule.CreateRule.createBuilder(RuleDirection.INGRESS, RegionAndId.fromSlashEncoded(securityGroup.getId()).getId()).protocol(RuleProtocol.TCP) .portRangeMin(inboundPort).portRangeMax(inboundPort).remoteIpPrefix("0.0.0.0/0").build()); logger.debug("<< authorized securityGroup(%s) permission to 0.0.0.0/0 on port %d", securityGroup, inboundPort); } return securityGroup; } catch (IllegalStateException e) { logger.trace("<< trying to find securityGroup(%s): %s", group, e.getMessage()); return securityGroupApi.listSecurityGroups().concat() .filter(new Predicate<org.jclouds.openstack.neutron.v2.domain.SecurityGroup>() { @Override public boolean apply(@Nullable org.jclouds.openstack.neutron.v2.domain.SecurityGroup input) { return input.getName().equals(group.getName()); } }).transform(neutronSecurityGroupToSecurityGroup.create(location)).first().orNull(); } }
/** * @return the Builder for creating a new SecurityGroupRule */ public static CreateBuilder createBuilder(RuleDirection direction, String securityGroupId) { return new CreateBuilder(direction, securityGroupId); }
/** * @return the Builder for creating a new SecurityGroupRule */ public static CreateBuilder createBuilder(RuleDirection direction, String securityGroupId) { return new CreateBuilder(direction, securityGroupId); }