private InterfaceAclImpl(InterfaceAclBuilder base) { this._allowedAddressPairs = base.getAllowedAddressPairs(); this._securityGroups = base.getSecurityGroups(); this._portSecurityEnabled = base.isPortSecurityEnabled(); }
public InterfaceAclBuilder(InterfaceAcl base) { this._allowedAddressPairs = base.getAllowedAddressPairs(); this._securityGroups = base.getSecurityGroups(); this._portSecurityEnabled = base.isPortSecurityEnabled(); }
public SecurityRuleAttrBuilder(SecurityRuleAttr base) { this._direction = base.getDirection(); this._remoteGroupId = base.getRemoteGroupId(); }
/** * Gets the acl allowed address pairs. * * @param macAddress the mac address * @param ipAddress the ip address * @return the acl allowed address pairs */ protected static AllowedAddressPairs getAclAllowedAddressPairs(MacAddress macAddress, org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress ipAddress) { AllowedAddressPairsBuilder aclAllowedAdressPairBuilder = new AllowedAddressPairsBuilder(); aclAllowedAdressPairBuilder.setMacAddress(macAddress); if (ipAddress != null && ipAddress.getValue() != null) { if (ipAddress.getIpPrefix() != null) { aclAllowedAdressPairBuilder.setIpAddress(new IpPrefixOrAddress(ipAddress.getIpPrefix())); } else { aclAllowedAdressPairBuilder.setIpAddress(new IpPrefixOrAddress(ipAddress.getIpAddress())); } } return aclAllowedAdressPairBuilder.build(); }
private static boolean isIPv4Address(AllowedAddressPairs aap) { IpPrefixOrAddress ipPrefixOrAddress = aap.getIpAddress(); IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix(); if (ipPrefix != null) { if (ipPrefix.getIpv4Prefix() != null) { return true; } } else { IpAddress ipAddress = ipPrefixOrAddress.getIpAddress(); if (ipAddress.getIpv4Address() != null) { return true; } } return false; }
public static List<AllowedAddressPairs> getPortAllowedAddresses(Interface port) { if (port == null) { LOG.error("Port is Null"); return null; } InterfaceAcl aclInPort = port.getAugmentation(InterfaceAcl.class); if (aclInPort == null) { LOG.error("getSecurityGroupInPortList: no security group associated to Interface port: {}", port.getName()); return null; } return aclInPort.getAllowedAddressPairs(); }
/** * Checks whether port security is enabled for the port. * @param port the port. * @return the list of security groups. */ public static List<Uuid> getInterfaceAcls(Interface port) { if (port == null) { LOG.error("Port is Null"); return null; } InterfaceAcl aclInPort = port.getAugmentation(InterfaceAcl.class); if (aclInPort == null) { LOG.error("getSecurityGroupInPortList: no security group associated}", port.getName()); return null; } return aclInPort.getSecurityGroups(); }
private SecurityRuleAttrImpl(SecurityRuleAttrBuilder base) { this._direction = base.getDirection(); this._remoteGroupId = base.getRemoteGroupId(); }
public static IpPrefixOrAddress getDefaultInstance(String defaultValue) { try { IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(defaultValue); return new IpPrefixOrAddress(ipPrefix); } catch (IllegalArgumentException e) { LOG.debug("{} is not of IpPrefix type; checking whether it's a IpAddress type", defaultValue); IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(defaultValue); return new IpPrefixOrAddress(ipAddress); } } }
private void updateRemoteAclCache(List<Ace> aceList, String aclName, AclServiceManager.Action action) { if (null == aceList) { return; } for (Ace ace : aceList) { SecurityRuleAttr aceAttributes = ace.getAugmentation(SecurityRuleAttr.class); if (aceAttributes != null && aceAttributes.getRemoteGroupId() != null) { if (action == AclServiceManager.Action.ADD) { AclDataUtil.addRemoteAclId(aceAttributes.getRemoteGroupId(), new Uuid(aclName)); } else { AclDataUtil.removeRemoteAclId(aceAttributes.getRemoteGroupId(), new Uuid(aclName)); } } } }
@Override protected void add(InstanceIdentifier<Interface> key, Interface port) { InterfaceAcl aclInPort = port.getAugmentation(InterfaceAcl.class); if (aclInPort != null && aclInPort.isPortSecurityEnabled()) { addAclInterfaceToCache(port.getName(), aclInPort); } }
/** * Populate interface acl builder. * * @param interfaceAclBuilder the interface acl builder * @param port the port */ protected static void populateInterfaceAclBuilder(InterfaceAclBuilder interfaceAclBuilder, Port port) { // Handle security group enabled List<Uuid> securityGroups = port.getSecurityGroups(); if (securityGroups != null) { interfaceAclBuilder.setSecurityGroups(securityGroups); } List<AllowedAddressPairs> aclAllowedAddressPairs = NeutronvpnUtils.getAllowedAddressPairsForAclService( port.getMacAddress(), port.getFixedIps()); // Update the allowed address pair with the IPv6 LLA that is auto configured on the port. aclAllowedAddressPairs.add(NeutronvpnUtils.updateIPv6LinkLocalAddressForAclService(port.getMacAddress())); List<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.AllowedAddressPairs> portAllowedAddressPairs = port.getAllowedAddressPairs(); if (portAllowedAddressPairs != null) { aclAllowedAddressPairs.addAll(NeutronvpnUtils.getAllowedAddressPairsForAclService(portAllowedAddressPairs)); } interfaceAclBuilder.setAllowedAddressPairs(aclAllowedAddressPairs); }
public org.opendaylight.yangtools.yang.binding.YangModuleInfo getModuleInfo() { return $YangModuleInfoImpl.getInstance(); } }
public InterfaceAcl build() { return new InterfaceAclImpl(this); }
public SecurityRuleAttr build() { return new SecurityRuleAttrImpl(this); }
/** * Constructor provided only for using in JMX. Don't use it for * construction new object of this union type. */ @ConstructorProperties("value") public IpPrefixOrAddress(char[] _value) { java.lang.String defVal = new java.lang.String(_value); IpPrefixOrAddress defInst = IpPrefixOrAddressBuilder.getDefaultInstance(defVal); this._ipPrefix = defInst._ipPrefix; this._ipAddress = defInst._ipAddress; this._value = _value == null ? null : _value.clone(); } /**
private AclInterface updateAclInterfaceInCache(String interfaceId, InterfaceAcl aclInPortAfter) { AclInterface aclInterface = AclInterfaceCacheUtil.getAclInterfaceFromCache(interfaceId); if (aclInterface != null) { boolean portSecurityEnabled = aclInPortAfter.isPortSecurityEnabled(); aclInterface.setPortSecurityEnabled(portSecurityEnabled); if (portSecurityEnabled) { aclInterface.setSecurityGroups(aclInPortAfter.getSecurityGroups()); aclInterface.setAllowedAddressPairs(aclInPortAfter.getAllowedAddressPairs()); } } else { // Control should not come here LOG.error("Unable to find Acl Interface details for {}", interfaceId); } return aclInterface; }
@Override public boolean equals(java.lang.Object obj) { if (this == obj) { return true; } if (!(obj instanceof DataObject)) { return false; } if (!org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr.class.equals(((DataObject)obj).getImplementedInterface())) { return false; } org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr other = (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr)obj; if (!Objects.equals(_direction, other.getDirection())) { return false; } if (!Objects.equals(_remoteGroupId, other.getRemoteGroupId())) { return false; } return true; }
private AclInterface addAclInterfaceToCache(String interfaceId, InterfaceAcl aclInPort) { AclInterface aclInterface = new AclInterface(); aclInterface.setInterfaceId(interfaceId); aclInterface.setPortSecurityEnabled(aclInPort.isPortSecurityEnabled()); aclInterface.setSecurityGroups(aclInPort.getSecurityGroups()); aclInterface.setAllowedAddressPairs(aclInPort.getAllowedAddressPairs()); AclInterfaceCacheUtil.addAclInterfaceToCache(interfaceId, aclInterface); return aclInterface; }
private AclInterface getOldAclInterfaceObject(AclInterface aclInterface, InterfaceAcl aclInPortBefore) { AclInterface oldAclInterface = new AclInterface(); if (aclInPortBefore == null) { oldAclInterface.setPortSecurityEnabled(false); } else { oldAclInterface.setInterfaceId(aclInterface.getInterfaceId()); oldAclInterface.setDpId(aclInterface.getDpId()); oldAclInterface.setLPortTag(aclInterface.getLPortTag()); oldAclInterface.setPortSecurityEnabled(aclInPortBefore.isPortSecurityEnabled()); oldAclInterface.setAllowedAddressPairs(aclInPortBefore.getAllowedAddressPairs()); oldAclInterface.setSecurityGroups(aclInPortBefore.getSecurityGroups()); } return oldAclInterface; }