/** * Check if a logical router already has a cache entry. * @param lr - the logical router object. * @return true if found */ public boolean isLrAlreadyCached(LogicalRouter lr) { return this.lrStore.get(lr.getUuid()) != null; }
public void removeLrFromCache(LogicalRouter lr) { this.lrStore.remove(lr.getUuid()); }
public LogicalRouterMappingInfo getLrMappingInfo(LogicalRouter lr) { return this.lrStore.get(lr.getUuid()); }
public void addRequestRemoveLr(LogicalRouter lr) { Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: removeLr: info is null"); return; } info.markDeleted(); }
public void addGatewayIpToLr(LogicalRouter lr, IpAddress gatewayIp) { Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: addLrLswEdgeToLr: info is null: {}", lrId.getValue()); return; } info.addGatewayIp(gatewayIp); }
/** * To cache an LogicalRouter. * @param lr to be cached. */ public void cacheLr(LogicalRouter lr) { if (!this.isLrAlreadyCached(lr)) { this.lrStore.put(lr.getUuid(), new LogicalRouterMappingInfo(lr)); } }
/** * Check if an logical router has been rendered. * @param lr - the logical router to be checked. * @param fabricId - the target fabric * @return true if rendered, false otherwise. */ public boolean isLrRendered(LogicalRouter lr, NodeId fabricId) { if (!this.isLrAlreadyCached(lr)) { return false; } return this.lrStore.get(lr.getUuid()).hasServiceBeenRenderedOnFabric(fabricId); }
public void addLrLswEdgeToLr(LogicalRouter lr, Edge edge) { Uuid edgeId = edge.getUuid(); Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: addLrLswEdgeToLr: info is null: {}", lrId.getValue()); return; } info.addLrLswEdge(edgeId); }
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 removePortFromLr(LogicalRouter lr, Port port) { Uuid portId = port.getUuid(); Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: removePortFromLr: info is null: {}", lrId.getValue()); return; } info.removePort(portId); }
public void removeLrLswEdgeFromLr(LogicalRouter lr, Edge edge) { Uuid edgeId = edge.getUuid(); Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: removeLrLswEdgeFromLr: info is null: {}", lrId.getValue()); return; } info.removeLrLswEdge(edgeId); }
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 addPortToLr(LogicalRouter lr, Port port) { Uuid portId = port.getUuid(); Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: addPortToLr: info is null: {}", lrId.getValue()); return; } info.addPort(portId); }
private void doLogicalRouterRemove(Uuid tenantId, UserLogicalNetworkCache uln, LogicalRouter lr) { LogicalRouterMappingInfo lrInfo = uln.findLrFromLrId(lr.getUuid()); if (lrInfo == null) { LOG.error("FABMGR: ERROR: doLogicalRouterRemove: lr not in cache: {}", lr.getUuid().getValue()); return; } if (!lrInfo.hasServiceBeenRendered()) { LOG.error("FABMGR: ERROR: doLogicalRouterRemove: lr has not been rendered: {}", lr.getUuid().getValue()); return; } int numOfRuleGroups = lrInfo.getSecurityRuleGroupsListSize(); if (numOfRuleGroups > 0) { LOG.trace("FABMGR: doLogicalRouterRemove: numOfRuleGroups={}", numOfRuleGroups); return; } int numOfLrLswEdges = lrInfo.getLrLswEdgeListSize(); if (numOfLrLswEdges > 0) { LOG.trace("FABMGR: doLogicalRouterRemove: numOfLrLswEdges={}", numOfLrLswEdges); return; } /* * All the dependencies of this LR are deleted(There are may still be undeleted * logical ports on the LR, but they can be removed together with * this LR). So we can go ahead to remove this LR. */ for (Map.Entry<String, RenderedRouter> entry : lrInfo.getRenderedRouters().entrySet()) { this.removeLrFromFabric(tenantId, entry.getKey(),uln, entry.getValue().getRouterID()); } uln.removeLrFromCache(lr); }
public void executeEvent(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) { // Create for (DataObject dao : change.getCreatedData().values()) { if (dao instanceof LogicalRouter) { LOG.debug("FABMGR: Create Logical Router event: {}", ((LogicalRouter) dao).getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleLrCreateEvent((LogicalRouter) dao); } } // Update Map<InstanceIdentifier<?>, DataObject> dao = change.getUpdatedData(); for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dao.entrySet()) { if (entry.getValue() instanceof LogicalRouter) { LOG.debug("FABMGR: Update Logical Router event: {}", ((LogicalRouter) entry.getValue()).getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleLrUpdateEvent((LogicalRouter) entry.getValue()); } } // Remove for (InstanceIdentifier<?> iid : change.getRemovedPaths()) { DataObject old = change.getOriginalData().get(iid); if (old == null) { continue; } if (old instanceof LogicalRouter) { LOG.debug("FABMGR: Remove Logical Router event: {}", ((LogicalRouter) old).getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleLrRemoveEvent((LogicalRouter) old); } } }
public synchronized void handleLrUpdateEvent(LogicalRouter lr) { Uuid tenantId = lr.getTenantId(); if (this.isUlnAlreadyInCache(tenantId) == false) { LOG.error("FABMGR: ERROR: handleLrUpdateEvent: this is update; ULN is supposed to be in cache: {}", tenantId.getValue()); return; } UserLogicalNetworkCache uln = this.ulnStore.get(tenantId); if (uln == null) { LOG.error("FABMGR: ERROR: handleLrUpdateEvent: uln is null"); return; } if (!uln.isLrAlreadyCached(lr)) { LOG.error("FABMGR: ERROR: handleLrUpdateEvent: lr should have been cached"); // fall through. Treat this case as create event } else { if (uln.getLrStore().get(lr.getUuid()).hasServiceBeenRendered()) { LOG.error("FABMGR: ERROR: handleLrUpdateEvent: lr has already been rendered: {}", lr.getUuid().getValue()); return; } else { uln.removeLrFromCache(lr); } } /* * Now we can treat update event as a new create event. */ this.handleLrCreateEvent(lr); }
public static CreateLneLayer3Input createLneLayer3Input(Uuid tenantId, NodeId fabricId, LogicalRouter lr) { CreateLneLayer3InputBuilder builder = new CreateLneLayer3InputBuilder(); builder.setTenantId(new TenantId(tenantId.getValue())); builder.setLrUuid(UlnUtil.convertToYangUuid(lr.getUuid())); builder.setName(UlnUtil.convertToYangUuid(lr.getUuid()).getValue()); builder.setVfabricId(fabricId); return builder.build(); }
private NodeId renderLogicalRouter( Uuid tenantId, String fabricId, UserLogicalNetworkCache uln, LogicalRouterMappingInfo lr) { NodeId rr ; if ((rr = uln.getRenderedRouterOnFabirc(fabricId)) == null) { rr = fmgr.createLneLayer3(UlnUtil.convertToYangUuid(tenantId), fabricId,uln); uln.addRenderedRouterOnFabric(fabricId, rr); } RenderedRouter renderedLr = new RenderedRouter(fabricId, rr); uln.getLrStore().get(lr.getLr().getUuid()).addRenderedRouter(renderedLr); return rr; }
private void renderExternalGW ( Uuid tenantId, UserLogicalNetworkCache uln, LogicalRouterMappingInfo lr ) { if (lr.getLr().isPublic() && !uln.isHasExternalGateway()) { // TODO // the prefix and tag should all come from admin provisioning, // so does the tag. we hard code it for now. Random rand = new Random(); int accessTag = rand.nextInt(EXT_ACCESS_TAG_RANGE) + EXT_ACCESS_TAG_START; IpAddress pubip = this.getPubIP(lr.getLr(), uln); if (pubip == null) { System.out.println(lr.getLr().getUuid()); return; } this.fmgr.setupExternalGW( UlnUtil.convertToYangUuid(tenantId), uln, lr, pubip, new IpPrefix(new Ipv4Prefix(pubip.getIpv4Address().getValue() + "/24")), accessTag); uln.setHasExternalGateway(true); } }
private boolean isEdgeConnectingTheLRToALSW(LogicalRouterMappingInfo lr, EdgeMappingInfo edge) { if (this.findEdgeType(edge) == LogicalEdgeType.LR_LSW) { PortMappingInfo lrPort = this.findLrPortOnEdge(edge); Uuid lrId = lr.getLr().getUuid(); if (lrPort != null && lrPort.getPort().getLocationId().equals(lrId)) { PortMappingInfo otherPort = this.findOtherPortInEdge(edge, lrPort.getPort().getUuid()); if (otherPort != null && otherPort.getPort().getLocationType() == LocationType.SwitchType) { return true; } else { LOG.error("FABMGR: ERROR: findLrLswEdge: otherPort is not LSW type: {}", otherPort.getPort().getLocationType().toString()); } } } return false; }