// Find the public address, although the OpenStack firewall may be blocking it
publicAddress = machine.getNetworkPoint().getBestAddress(NetworkPoint.forPublicInternet());
if (cloudBehaviours.supportsSecurityGroups()) {
Server server = machine.getServer();
SecurityGroup securityGroup = openstackHelpers.getMachineSecurityGroup(openstackComputeClient, server);
securityGroup = openstackComputeClient.root().securityGroups().securityGroup(securityGroup.getId()).show();
SecurityGroupRule matchingRule = findMatchingRule(securityGroup);
if (OpsContext.isConfigure()) {
if (matchingRule == null) {
CreateSecurityGroupRuleRequest rule = new CreateSecurityGroupRuleRequest();
rule.setCidr("0.0.0.0/0");
rule.setIpProtocol("tcp");
rule.setFromPort(model.publicPort);
rule.setToPort(model.publicPort);
rule.setParentGroupId(securityGroup.getId());
openstackComputeClient.root().securityGroupRules().create(rule);
}
}