private Name getPortName(FlowCapableNodeConnector fcnc) { if (fcnc == null || fcnc.getName() == null) { return null; } return new Name(fcnc.getName()); }
private static @Nonnull ForwardingContext createL3ContextFromRouter( Router router) { Name l3ContextName = null; if (!Strings.isNullOrEmpty(router.getName())) { l3ContextName = new Name(router.getName()); } return new ForwardingContextBuilder().setContextId(new ContextId(router.getUuid().getValue())) .setContextType(MappingUtils.L3_CONTEXT) .setName(new Name(l3ContextName.getValue())) .build(); }
@Deprecated private static @Nonnull L3Context createL3CtxFromRouter(Router router) { Name l3ContextName = null; if (!Strings.isNullOrEmpty(router.getName())) { l3ContextName = new Name(router.getName()); } return new L3ContextBuilder().setId(new L3ContextId(router.getUuid().getValue())) .setName(l3ContextName) .setDescription(new Description(MappingUtils.NEUTRON_ROUTER + router.getUuid().getValue())) .build(); }
@Deprecated public static Subnet createTenantSubnet( org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet subnet, IpAddress virtualRouterIp) { org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder subnetBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder(); subnetBuilder.setId(new SubnetId(subnet.getUuid().getValue())); subnetBuilder.setParent(new ContextId(subnet.getNetworkId().getValue())); if (!Strings.isNullOrEmpty(subnet.getName())) { try { subnetBuilder.setName(new Name(subnet.getName())); } catch (Exception e) { LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", subnet.getName(), subnet.getUuid().getValue()); LOG.debug("Name exception", e); } } subnetBuilder.setIpPrefix(subnet.getCidr()); subnetBuilder.setVirtualRouterIp(virtualRouterIp); return subnetBuilder.build(); }
@Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); // create and write endpointgroups boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Integer sgtValue = sgtInfo.getSgt().getValue(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgtValue, sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtName); final InstanceIdentifier<EndpointGroup> epgPath = IidFactory.endpointGroupIid(tenantId, epgId); final EndpointGroup epg = new EndpointGroupBuilder() .setId(epgId) .setDescription(new Description("imported from ISE for sgt=" + sgtValue)) .setName(new Name(sgtName.replaceAll(" ", "_") + "--" + sgtValue)) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epgPath, epg, createParent); createParent = false; } return wTx.submit(); } }
@Override public void onCreated(Router router, Neutron neutron) { LOG.trace("created router - {}", router); ContextId routerl3ContextId = new ContextId(router.getUuid().getValue()); TenantId tenantId = new TenantId(router.getTenantId().getValue()); InstanceIdentifier<ForwardingContext> routerL3CtxIid = L2L3IidFactory.l3ContextIid(tenantId, routerl3ContextId); ForwardingContextBuilder fwdCtxBuilder = new ForwardingContextBuilder(); Name routerName = null; if (!Strings.isNullOrEmpty(router.getName())) { try { routerName = new Name(router.getName()); fwdCtxBuilder.setName(routerName); } catch (Exception e) { LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", router.getName(), router.getUuid().getValue()); LOG.debug("Name exception", e); } } ForwardingContext routerl3Context = fwdCtxBuilder.setContextId(routerl3ContextId) .setContextType(MappingUtils.L3_CONTEXT) .build(); WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.CONFIGURATION, routerL3CtxIid, routerl3Context, true); createTenantL3Context(new L3ContextId(routerl3ContextId), tenantId, routerName, wTx); DataStoreHelper.submitToDs(wTx); }
public boolean addNeutronSecurityGroup(SecurityGroup secGroup, ReadWriteTransaction rwTx) { TenantId tId = new TenantId(secGroup.getTenantId().getValue()); EndpointGroupId epgId = new EndpointGroupId(secGroup.getUuid().getValue()); if (epgId.getValue().equals(MappingUtils.EIG_UUID.getValue())) { ExternalImplicitGroup eig = new ExternalImplicitGroupBuilder().setId(epgId).build(); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.externalImplicitGroupIid(tId, epgId), eig, true); } EndpointGroupBuilder epgBuilder = new EndpointGroupBuilder().setId(epgId); if (!Strings.isNullOrEmpty(secGroup.getName())) { try { epgBuilder.setName(new Name(secGroup.getName())); } catch (Exception e) { LOG.info("Name '{}' of Neutron Security-group '{}' is ignored.", secGroup.getName(), secGroup.getUuid().getValue()); LOG.debug("Name exception", e); } } epgBuilder.setIntraGroupPolicy(IntraGroupPolicy.RequireContract); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tId, epgId), epgBuilder.build(), true); return true; }
public static NetworkDomain createSubnet( org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet subnet, IpAddress virtualRouterIp) { SubnetBuilder sb = new SubnetBuilder(); sb.setIpPrefix(subnet.getCidr()); sb.setVirtualRouterIp(virtualRouterIp); NetworkDomainBuilder ndb = new NetworkDomainBuilder(); if (!Strings.isNullOrEmpty(subnet.getName())) { try { ndb.setName(new Name(subnet.getName())); } catch (Exception e) { LOG.info("Name '{}' of Neutron Subnet '{}' is ignored.", subnet.getName(), subnet.getUuid().getValue()); LOG.debug("Name exception", e); } } ndb.setNetworkDomainId(new NetworkDomainId(subnet.getUuid().getValue())); ndb.setNetworkDomainType(MappingUtils.SUBNET); ndb.setParent(MappingUtils.createParent(new NetworkDomainId(subnet.getNetworkId().getValue()), L2FloodDomain.class)); ndb.addAugmentation(SubnetAugmentForwarding.class, new SubnetAugmentForwardingBuilder().setSubnet(sb.build()) .build()); return ndb.build(); }
@Deprecated private void createTenantNetworkDomains(Network network, TenantId tenantId, ReadWriteTransaction rwTx) { Name name; L3ContextBuilder l3CtxBuilder = new L3ContextBuilder(); L2FloodDomainBuilder l2FdBuilder = new L2FloodDomainBuilder(); L2BridgeDomainBuilder l2BdBuilder = new L2BridgeDomainBuilder(); if (!Strings.isNullOrEmpty(network.getName())) { try { name = new Name(network.getName()); l3CtxBuilder.setName(name); l2FdBuilder.setName(name); l2BdBuilder.setName(name); } catch (Exception e) { name = null; LOG.info("Name of Neutron Network '{}' is ignored.", network.getName()); LOG.debug("Name exception", e); } } L2FloodDomainId l2FdId = new L2FloodDomainId(network.getUuid().getValue()); L3ContextId l3ContextId = new L3ContextId(l2FdId); L3Context l3Context = l3CtxBuilder.setId(l3ContextId).build(); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l3ContextIid(tenantId, l3Context.getId()), l3Context, true); L2BridgeDomainId l2BdId = new L2BridgeDomainId(l2FdId); L2BridgeDomain l2Bd = l2BdBuilder.setId(l2BdId).setParent(l3Context.getId()).build(); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l2BridgeDomainIid(tenantId, l2BdId), l2Bd, true); L2FloodDomain l2Fd = l2FdBuilder.setId(l2FdId).setParent(l2BdId).build(); rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.l2FloodDomainIid(tenantId, l2FdId), l2Fd, true); }
if (!Strings.isNullOrEmpty(network.getName())) { try { name = new Name(network.getName()); fwdCtxBuilder.setName(name); } catch (Exception e) {