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(); } }
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(); } }
Rule.createBuilder(RuleDirection.INGRESS, securityGroup.getId()) .ethertype(RuleEthertype.IPV6) .portRangeMax(90) .portRangeMin(80) .protocol(RuleProtocol.TCP)
RuleDirection.INGRESS, "a7734e61-b545-452d-a3cd-0189cbd9747a") .portRangeMin(80) .portRangeMax(80) .ethertype(RuleEthertype.IPV4) .protocol(RuleProtocol.TCP)
.ethertype(RuleEthertype.IPV4) .portRangeMin(ipPermission.getFromPort()) .portRangeMax(ipPermission.getToPort()) .remoteIpPrefix(cidr) .build()); .ethertype(RuleEthertype.IPV4) .portRangeMin(ipPermission.getFromPort()) .portRangeMax(ipPermission.getToPort()) .remoteGroupId(groupId) .build());
.ethertype(RuleEthertype.IPV4) .portRangeMin(ipPermission.getFromPort()) .portRangeMax(ipPermission.getToPort()) .remoteIpPrefix(cidr) .build()); .ethertype(RuleEthertype.IPV4) .portRangeMin(ipPermission.getFromPort()) .portRangeMax(ipPermission.getToPort()) .remoteGroupId(groupId) .build());