/** * Check if a given security group has been rendered. * @param ruleGroups - the group of rules to be rendered. * @return true if rendered, false otherwise. */ public boolean isSecurityRuleGroupsAlreadyCached(SecurityRuleGroups ruleGroups) { Uuid ruleGroupsId = ruleGroups.getUuid(); return this.securityRuleGroupsStore.get(ruleGroupsId) != null; }
public void removeSecurityRuleGroupsFromCache(SecurityRuleGroups ruleGroups) { this.securityRuleGroupsStore.remove(ruleGroups.getUuid()); }
public void addRequestRemoveSecurityRuleGroups(SecurityRuleGroups ruleGroups) { Uuid ruleGroupsId = ruleGroups.getUuid(); SecurityRuleGroupsMappingInfo info = this.securityRuleGroupsStore.get(ruleGroupsId); if (info == null) { LOG.error("FABMGR: ERROR: removeSecurityRuleGroups: info is null"); return; } info.markDeleted(); }
/** * To mark a security group's render status. * @param ruleGroups - the group of rules to be rendered. */ public void markSecurityRuleGroupsAsRendered(SecurityRuleGroups ruleGroups) { Uuid ruleGroupsId = ruleGroups.getUuid(); this.securityRuleGroupsStore.get(ruleGroupsId).setServiceHasBeenRendered(true); }
/** * Check if a security group has been rendered. * @param ruleGroups - the group to be checked. * @return true if rendered. false otherwise. */ public boolean isSecurityRuleGroupsRendered(SecurityRuleGroups ruleGroups) { if (!this.isSecurityRuleGroupsAlreadyCached(ruleGroups)) { return false; } return this.securityRuleGroupsStore.get(ruleGroups.getUuid()).hasServiceBeenRendered(); }
/** * To cache an SecurityRuleGroups. * @param ruleGroups to be cached. */ public void cacheSecurityRuleGroups(SecurityRuleGroups ruleGroups) { if (!this.isSecurityRuleGroupsAlreadyCached(ruleGroups)) { this.securityRuleGroupsStore.put(ruleGroups.getUuid(), new SecurityRuleGroupsMappingInfo(ruleGroups)); } }
public void removeSecurityRuleGroupsFromLr(LogicalRouter lr, SecurityRuleGroups ruleGroups) { Uuid ruleGroupsId = ruleGroups.getUuid(); Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: removeSecurityRuleGroupsFromLr: info is null: {}", lrId.getValue()); return; } info.removeSecurityRuleGroups(ruleGroupsId); }
public void removeSecurityRuleGroupsFromLsw(LogicalSwitch lsw, SecurityRuleGroups ruleGroups) { Uuid ruleGroupsId = ruleGroups.getUuid(); Uuid lswId = lsw.getUuid(); LogicalSwitchMappingInfo info = this.lswStore.get(lswId); if (info == null) { LOG.error("FABMGR: ERROR: removeSecurityRuleGroupsFromLsw: info is null: {}", lswId.getValue()); return; } info.removeSecurityRuleGroups(ruleGroupsId); }
public void addSecurityRuleGroupsToLsw(LogicalSwitch lsw, SecurityRuleGroups ruleGroups) { Uuid ruleGroupsId = ruleGroups.getUuid(); Uuid lswId = lsw.getUuid(); LogicalSwitchMappingInfo info = this.lswStore.get(lswId); if (info == null) { LOG.error("FABMGR: ERROR: addSecurityRuleGroupsToLsw: info is null: {}", lswId.getValue()); return; } info.addSecurityRuleGroups(ruleGroupsId); }
public void addSecurityRuleGroupsToLr(LogicalRouter lr, SecurityRuleGroups ruleGroups) { Uuid ruleGroupsId = ruleGroups.getUuid(); Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: addSecurityRuleGroupsToLr: info is null: {}", lrId.getValue()); return; } info.addSecurityRuleGroups(ruleGroupsId); }
private void removeSecurityRuleGroupsFromFabric(Uuid tenantId, String fabricId, UserLogicalNetworkCache uln, NodeId nodeId, SecurityRuleGroups ruleGroups) { SecurityRuleGroupsMappingInfo ruleGroupsInfo = uln.findSecurityRuleGroupsFromRuleGroupsId(ruleGroups.getUuid()); if (ruleGroupsInfo == null) { LOG.error("FABMGR: ERROR: removeSecurityRuleGroupsFromFabric: ruleGroups not in cache: {}", ruleGroups.getUuid().getValue()); return; } if (!ruleGroupsInfo.hasServiceBeenRendered()) { LOG.error("FABMGR: ERROR: removeSecurityRuleGroupsFromFabric: securityRuleGroups has not been rendered: {}", ruleGroups.getUuid().getValue()); return; } /* * One SecurityRuleGroups may be mapped to multiple ACL rules. * So we need to delete ACL in a loop. */ List<String> aclNameList = ruleGroupsInfo.getRenderedAclNameList(); if (aclNameList == null || aclNameList.isEmpty()) { LOG.error("FABMGR: ERROR: removeSecurityRuleGroupsFromFabric: alcNameList is null or empty: {}", ruleGroups.getUuid().getValue()); return; } for (String aclName : aclNameList) { this.removeAclFromFabric(tenantId, fabricId, uln, nodeId, aclName); } }
private void updateRules(SecurityRuleGroups newData, SecurityRuleGroups oldData) { LOG.debug("FABMGR: Update SecurityRuleGroups event: {}", newData.getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleSecurityRuleGroupsUpdateEvent(newData); }
return false; if (!Objects.equals(_uuid, other.getUuid())) { return false;
public SecurityRuleGroupsBuilder(SecurityRuleGroups base) { if (base.getKey() == null) { this._key = new SecurityRuleGroupsKey( base.getUuid() ); this._uuid = base.getUuid(); } else { this._key = base.getKey(); this._uuid = _key.getUuid(); } this._description = base.getDescription(); this._name = base.getName(); this._ports = base.getPorts(); this._securityRuleGroup = base.getSecurityRuleGroup(); this._tenantId = base.getTenantId(); if (base instanceof SecurityRuleGroupsImpl) { SecurityRuleGroupsImpl impl = (SecurityRuleGroupsImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.logical.faas.security.rules.rev151013.security.rule.groups.attributes.security.rule.groups.container.SecurityRuleGroups> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.logical.faas.security.rules.rev151013.security.rule.groups.attributes.security.rule.groups.container.SecurityRuleGroups>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
if (dao instanceof SecurityRuleGroups) { LOG.debug("FABMGR: Create SecurityRuleGroups event: {}", ((SecurityRuleGroups) dao).getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleSecurityRuleGroupsCreateEvent((SecurityRuleGroups) dao); ((SecurityRuleGroups) old).getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleSecurityRuleGroupsRemoveEvent((SecurityRuleGroups) old);
LOG.error( "FABMGR: ERROR: handleSecurityRuleGroupsUpdateEvent: ruleGroups has already been rendered: {}", ruleGroups.getUuid().getValue()); return; } else {
if (updateAndMergeRefs) { SecurityRuleGroups dsSecurityGroups = readSecurityGroupsFromDs(newSecurityGroups.getTenantId(), newSecurityGroups.getUuid()); if (dsSecurityGroups != null) { SecurityRuleGroupsBuilder builder = new SecurityRuleGroupsBuilder(newSecurityGroups); t.put(logicalDatastoreType, UlnIidFactory.securityGroupsIid(updatedSecurityGroups.getTenantId(), updatedSecurityGroups.getUuid()), updatedSecurityGroups, true); if (submitToDs(t)) { LOG.debug("Wrote logical securityGroups {} to datastore.", updatedSecurityGroups.getUuid().getValue()); set.addAll(port.getSecurityRulesGroups()); if (!set.contains(updatedSecurityGroups.getUuid())) { set.add(updatedSecurityGroups.getUuid()); PortBuilder builder = new PortBuilder(port); builder.setSecurityRulesGroups(new ArrayList<>(set)); LOG.error("Failed to write logical securityGroups {} to datastore.", updatedSecurityGroups.getUuid() .getValue());
private void renderSecurityRuleGroups(Uuid tenantId, NodeId fabricId,UserLogicalNetworkCache uln, NodeId nodeId, SecurityRuleGroups ruleGroups) { /* * One SecurityRuleGroups contains a list SecurityRuleGroup. * One SecurityRuleGroup contains a list of SecurityRule. * One SecurityRule can be mapped to one ietf-acl. */ SecurityRuleGroupsMappingInfo ruleGroupsMappingInfo = uln.findSecurityRuleGroupsFromRuleGroupsId(ruleGroups.getUuid()); if (ruleGroupsMappingInfo == null) { LOG.error("FABMGR: ERROR: renderSecurityRuleGroups: ruleGroupsMappingInfo is null"); return; } List<SecurityRuleGroup> ruleGroupList = ruleGroups.getSecurityRuleGroup(); for (SecurityRuleGroup ruleGroup : ruleGroupList) { List<SecurityRule> ruleList = ruleGroup.getSecurityRule(); for (SecurityRule rule : ruleList) { String aclName = this.createAclFromSecurityRule(rule); this.renderSecurityRule(tenantId, fabricId, uln, nodeId, ruleGroupsMappingInfo, aclName); } } uln.markSecurityRuleGroupsAsRendered(ruleGroups); }
private static void removeSecurityGroupsFromDsIfExists(Uuid tenantId, Uuid securityGroupId, boolean updateExistingRefs) { Optional<SecurityRuleGroups> oldOption = removeIfExists(UlnIidFactory.securityGroupsIid(tenantId, securityGroupId)); /* * Make sure other logical network nodes links are updated as well */ if (oldOption.isPresent() && updateExistingRefs) { SecurityRuleGroups securityRuleGroups = oldOption.get(); if (securityRuleGroups.getPorts() != null) { for (Uuid portId : securityRuleGroups.getPorts()) { Port port = UlnDatastoreApi.readPortFromDs(securityRuleGroups.getTenantId(), portId); if (port != null && port.getSecurityRulesGroups() != null) { Set<Uuid> set = new HashSet<>(port.getSecurityRulesGroups()); if (set.remove(securityRuleGroups.getUuid())) { PortBuilder builder = new PortBuilder(port); builder.setSecurityRulesGroups(new ArrayList<>(set)); UlnDatastoreApi.submitPortToDs(builder.build(), false); } } } } } }
private void renderSecurityRuleGroupsOnPair(Uuid tenantId, UserLogicalNetworkCache uln, NodeId fabricId, NodeId nodeId, NodeId fabricId2, NodeId nodeId2, SecurityRuleGroups ruleGroups) { /* * One SecurityRuleGroups contains a list SecurityRuleGroup. * One SecurityRuleGroup contains a list of SecurityRule. * One SecurityRule can be mapped to one ietf-acl. */ SecurityRuleGroupsMappingInfo ruleGroupsMappingInfo = uln.findSecurityRuleGroupsFromRuleGroupsId(ruleGroups.getUuid()); if (ruleGroupsMappingInfo == null) { LOG.error("FABMGR: ERROR: renderSecurityRuleGroups: ruleGroupsMappingInfo is null"); return; } List<SecurityRuleGroup> ruleGroupList = ruleGroups.getSecurityRuleGroup(); for (SecurityRuleGroup ruleGroup : ruleGroupList) { List<SecurityRule> ruleList = ruleGroup.getSecurityRule(); for (SecurityRule rule : ruleList) { String aclName = this.createAclFromSecurityRule(rule); this.renderSecurityRule(tenantId, fabricId, uln, nodeId, ruleGroupsMappingInfo, aclName); this.renderSecurityRule(tenantId, fabricId2, uln, nodeId2, ruleGroupsMappingInfo, aclName); } } uln.markSecurityRuleGroupsAsRendered(ruleGroups); }