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()); } } }
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); } } } } } }
/** * 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; }
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); }
public synchronized void handleSecurityRuleGroupsUpdateEvent(SecurityRuleGroups ruleGroups) { Uuid tenantId = ruleGroups.getTenantId(); if (this.isUlnAlreadyInCache(tenantId) == false) { LOG.error( LOG.error( "FABMGR: ERROR: handleSecurityRuleGroupsUpdateEvent: ruleGroups has already been rendered: {}", ruleGroups.getUuid().getValue()); return; } else {
SecurityRuleGroupsMappingInfo info = entry.getValue(); sb.append("ruleId=" + entry.getKey().getValue()); List<Uuid> ports = info.getSecurityRuleGroups().getPorts(); sb.append(", portId=" + (ports == null || ports.isEmpty() ? "null" : ports.get(0).getValue())); List<String> aclNameList = info.getRenderedAclNameList();
public synchronized void handleSecurityRuleGroupsRemoveEvent(SecurityRuleGroups ruleGroups) { Uuid tenantId = ruleGroups.getTenantId(); UserLogicalNetworkCache uln = this.ulnStore.get(tenantId); if (uln == null) { LOG.error("FABMGR: ERROR: handleSecurityRuleGroupsRemoveEvent: uln is null"); return; } if (!uln.isSecurityRuleGroupsAlreadyCached(ruleGroups)) { LOG.error("FABMGR: ERROR: handleSecurityRuleGroupsRemoveEvent: ruleGroups not in cache"); return; } uln.addRequestRemoveSecurityRuleGroups(ruleGroups); /* * Notify worker thread to start work */ this.workerThreadLock.release(); }
SecurityRuleGroups dsSecurityGroups = readSecurityGroupsFromDs(newSecurityGroups.getTenantId(), newSecurityGroups.getUuid()); if (dsSecurityGroups != null) { SecurityRuleGroupsBuilder builder = new SecurityRuleGroupsBuilder(newSecurityGroups); builder.setPorts(merge(dsSecurityGroups.getPorts(), newSecurityGroups.getPorts())); updatedSecurityGroups = builder.build(); UlnIidFactory.securityGroupsIid(updatedSecurityGroups.getTenantId(), updatedSecurityGroups.getUuid()), updatedSecurityGroups, true); if (submitToDs(t)) { LOG.debug("Wrote logical securityGroups {} to datastore.", updatedSecurityGroups.getUuid().getValue()); if (updatedSecurityGroups.getPorts() != null && updateAndMergeRefs) { for (Uuid portId : updatedSecurityGroups.getPorts()) { Port port = UlnDatastoreApi.readPortFromDs(updatedSecurityGroups.getTenantId(), portId); if (port != null) { Set<Uuid> set = new HashSet<>(); 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());
public void removeSecurityRuleGroupsFromCache(SecurityRuleGroups ruleGroups) { this.securityRuleGroupsStore.remove(ruleGroups.getUuid()); }
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); }
for (Uuid sId : port.getSecurityRulesGroups()) { SecurityRuleGroups secGrps = UlnDatastoreApi.readSecurityGroupsFromDs(tenantId, sId); if (secGrps != null && secGrps.getPorts() != null) { Set<Uuid> set = new HashSet<>(secGrps.getPorts()); if (set.remove(port.getUuid())) { SecurityRuleGroupsBuilder builder = new SecurityRuleGroupsBuilder(secGrps);
public synchronized void handleSecurityRuleGroupsCreateEvent(SecurityRuleGroups ruleGroups) { Uuid tenantId = ruleGroups.getTenantId(); this.createUlnCacheIfNotExist(tenantId); UserLogicalNetworkCache uln = this.ulnStore.get(tenantId); if (uln == null) { LOG.error("FABMGR: ERROR: handleSecurityRuleGroupsCreateEvent: uln is null"); return; } if (uln.isSecurityRuleGroupsAlreadyCached(ruleGroups) == true) { LOG.error("FABMGR: ERROR: handleSecurityRuleGroupsCreateEvent: ruleGroups already exist"); return; } uln.cacheSecurityRuleGroups(ruleGroups); this.workerThreadLock.release(); }
if (!Objects.equals(_description, other.getDescription())) { return false; if (!Objects.equals(_key, other.getKey())) { return false; if (!Objects.equals(_name, other.getName())) { return false; if (!Objects.equals(_ports, other.getPorts())) { return false; if (!Objects.equals(_securityRuleGroup, other.getSecurityRuleGroup())) { return false; if (!Objects.equals(_tenantId, other.getTenantId())) { return false; if (!Objects.equals(_uuid, other.getUuid())) { return false; if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { return false;
/** * 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); }
List<Uuid> portList = ruleGroups.getPorts(); if (portList == null) {
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(); }
List<Uuid> portList = ruleGroups.getPorts(); if (portList == null) {
/** * 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)); } }