public static PortFlow extractPortFlow(final NeutronSecurityRule securityRule, final List<String> endPointgroups) { Integer portMin = securityRule.getSecurityRulePortMin(); Integer portMax = securityRule.getSecurityRulePortMax(); String etherType = securityRule.getSecurityRuleEthertype(); String protocol = securityRule.getSecurityRuleProtocol(); String direction = securityRule.getSecurityRuleDirection(); final PortFlow portFlow = new PortFlow(portMax, portMin, protocol, etherType, direction, endPointgroups); portFlow.validate(); return portFlow; } }
public SecurityRuleAddedImpl(SecurityRule secRule) { Date date= new Date(); timeStamp = new Timestamp(date.getTime()); securityRule = new NeutronSecurityRule(); securityRule.setSecurityRuleID(secRule.getUuid().getValue()); securityRule.setSecurityGroupID(secRule.getSecurityGroupId().getValue()); securityRule.setSecurityTenantID(secRule.getTenantId().getValue()); if (secRule.getDirection() != null) { securityRule.setSecurityRuleDirection(secRule.getDirection().getSimpleName()); } if (secRule.getProtocol() != null) { securityRule.setSecurityRuleProtocol(String.valueOf(secRule.getProtocol().getValue())); } if (secRule.getEthertype() != null) { securityRule.setSecurityRuleEthertype(secRule.getEthertype().getSimpleName()); } if (secRule.getRemoteIpPrefix() != null) { securityRule.setSecurityRuleRemoteIpPrefix(String.valueOf(secRule.getRemoteIpPrefix().getValue())); } if (secRule.getPortRangeMin() != null) { securityRule.setSecurityRulePortMin(secRule.getPortRangeMin()); } if (secRule.getPortRangeMax() != null) { securityRule.setSecurityRulePortMax(secRule.getPortRangeMax()); } }
if (securityRule.getSecurityRuleDirection().compareTo("DirectionEgress") == 0) { if (securityRule.getSecurityRuleRemoteIpPrefix() != null) { toString = securityRule.getSecurityRuleRemoteIpPrefix(); if(toString.contains("0.0.0.0")) { toString = "any"; else if (securityRule.getSecurityRuleDirection().compareTo("DirectionIngress") == 0) { if (securityRule.getSecurityRuleRemoteIpPrefix() != null) { fromString = securityRule.getSecurityRuleRemoteIpPrefix(); if(fromString.contains("0.0.0.0")) { fromString = "any";
@Override public void handleEvent(NicNotification event) { if (SecurityRuleAdded.class.isInstance(event)) { //Translate Security rules into intents SecurityRuleAdded securityRuleAdded = (SecurityRuleAdded) event; securityRule = securityRuleAdded.getSecurityRule(); Intent intent = createIntent(); ruleToIntentMap.put(securityRule.getSecurityRuleID(), intent.getId()); addIntentToMDSAL(intent, FlowAction.ADD_FLOW); } else if (SecurityRuleDeleted.class.isInstance(event)) { SecurityRuleDeleted securityRuleDeleted = (SecurityRuleDeleted) event; securityRule = (NeutronSecurityRule) securityRuleDeleted.getSecurityRule(); Uuid uuid = ruleToIntentMap.get(securityRule.getSecurityRuleID()); removeIntent(uuid); } else if(SecurityRuleUpdated.class.isInstance(event)) { //TODO: } }
public SecurityRuleDeletedImpl(SecurityRule secRule) { Date date= new Date(); timeStamp = new Timestamp(date.getTime()); securityRule = new NeutronSecurityRule(); securityRule.setSecurityRuleID(secRule.getUuid().getValue()); securityRule.setSecurityGroupID(secRule.getSecurityGroupId().getValue()); securityRule.setSecurityTenantID(secRule.getTenantId().getValue()); if (secRule.getDirection() != null) { securityRule.setSecurityRuleDirection(secRule.getDirection().getSimpleName()); } if (secRule.getProtocol() != null) { securityRule.setSecurityRuleProtocol(String.valueOf(secRule.getProtocol().getValue())); } if (secRule.getEthertype() != null) { securityRule.setSecurityRuleEthertype(secRule.getEthertype().getSimpleName()); } if (secRule.getRemoteIpPrefix() != null) { securityRule.setSecurityRuleRemoteIpPrefix(String.valueOf(secRule.getRemoteIpPrefix().getValue())); } if (secRule.getPortRangeMin() != null) { securityRule.setSecurityRulePortMin(secRule.getPortRangeMin()); } if (secRule.getPortRangeMax() != null) { securityRule.setSecurityRulePortMax(secRule.getPortRangeMax()); } } @Override
public SecurityRuleUpdatedImpl(SecurityRule secRule) { Date date= new Date(); timeStamp = new Timestamp(date.getTime()); securityRule = new NeutronSecurityRule(); securityRule.setSecurityRuleID(secRule.getUuid().getValue()); securityRule.setSecurityGroupID(secRule.getSecurityGroupId().getValue()); securityRule.setSecurityTenantID(secRule.getTenantId().getValue()); if (secRule.getDirection() != null) { securityRule.setSecurityRuleDirection(secRule.getDirection().getSimpleName()); } if (secRule.getProtocol() != null) { securityRule.setSecurityRuleProtocol(String.valueOf(secRule.getProtocol().getValue())); } if (secRule.getEthertype() != null) { securityRule.setSecurityRuleEthertype(secRule.getEthertype().getSimpleName()); } if (secRule.getRemoteIpPrefix() != null) { securityRule.setSecurityRuleRemoteIpPrefix(String.valueOf(secRule.getRemoteIpPrefix().getValue())); } if (secRule.getPortRangeMin() != null) { securityRule.setSecurityRulePortMin(secRule.getPortRangeMin()); } if (secRule.getPortRangeMax() != null) { securityRule.setSecurityRulePortMax(secRule.getPortRangeMax()); } } @Override