public SecurityRuleGroups build() { return new SecurityRuleGroupsImpl(this); }
/** * 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 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 SecurityRuleGroupsImpl(SecurityRuleGroupsBuilder 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(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.logical.faas.security.rules.rev151013.security.rule.groups.attributes.security.rule.groups.container.SecurityRuleGroups>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.logical.faas.security.rules.rev151013.security.rule.groups.attributes.security.rule.groups.container.SecurityRuleGroups>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.logical.faas.security.rules.rev151013.security.rule.groups.attributes.security.rule.groups.container.SecurityRuleGroups>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.logical.faas.security.rules.rev151013.security.rule.groups.attributes.security.rule.groups.container.SecurityRuleGroups>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
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); builder.setPorts(new ArrayList<>(set)); UlnDatastoreApi.submitSecurityGroupsToDs(builder.build(), false);
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 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(); }
public static InstanceIdentifier<SecurityRuleGroups> securityGroupsIid(Uuid tenantId, Uuid securityGroupId) { return InstanceIdentifier.builder(TenantLogicalNetworks.class) .child(TenantLogicalNetwork.class, new TenantLogicalNetworkKey(tenantId)) .child(SecurityRuleGroupsContainer.class) .child(SecurityRuleGroups.class, new SecurityRuleGroupsKey(securityGroupId)) .build(); }
public SecurityRuleGroupsBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.logical.faas.security.rules.rev151013.security.rule.groups.attributes.security.rule.groups.container.SecurityRuleGroups>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.faas.logical.faas.security.rules.rev151013.security.rule.groups.attributes.security.rule.groups.container.SecurityRuleGroups> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
public void removeSecurityRuleGroupsFromCache(SecurityRuleGroups ruleGroups) { this.securityRuleGroupsStore.remove(ruleGroups.getUuid()); }
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(); }
/** * 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); }
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 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)); } }
/** * 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(); }
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 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); }
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); }
private void updateRules(SecurityRuleGroups newData, SecurityRuleGroups oldData) { LOG.debug("FABMGR: Update SecurityRuleGroups event: {}", newData.getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleSecurityRuleGroupsUpdateEvent(newData); }