use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class VplsIntentUtility method buildUniIntents.
/**
* Builds unicast Intents for a VPLS.
*
* @param vplsData the VPLS
* @param hosts the hosts of the VPLS
* @param appId application ID for Intents
* @return unicast Intents for the VPLS
*/
public static Set<Intent> buildUniIntents(VplsData vplsData, Set<Host> hosts, ApplicationId appId) {
Set<Interface> interfaces = vplsData.interfaces();
if (interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<Intent> uniIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(VplsIntentUtility::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
Key key = buildKey(PREFIX_UNICAST, hostFcp.connectPoint(), vplsData.name(), host.mac(), appId);
Intent uniIntent = buildUniIntent(key, appId, srcFcps, hostFcp, host, vplsData.encapsulationType(), resourceGroup);
uniIntents.add(uniIntent);
});
return uniIntents;
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class TunnelBorrowCommand method doExecute.
@Override
protected void doExecute() {
Collection<Tunnel> tunnelSet = null;
Tunnel.Type trueType = null;
TunnelService service = get(TunnelService.class);
ApplicationId appId = new DefaultApplicationId(1, consumerId);
ProviderId producerName = new ProviderId("default", "org.onosproject.provider.tunnel.default");
if (!isNull(src) && !isNull(dst) && !isNull(type)) {
TunnelEndPoint srcPoint = null;
TunnelEndPoint dstPoint = null;
if ("MPLS".equals(type)) {
trueType = Tunnel.Type.MPLS;
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("VXLAN".equals(type)) {
trueType = Tunnel.Type.VXLAN;
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("GRE".equals(type)) {
trueType = Tunnel.Type.GRE;
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("VLAN".equals(type)) {
trueType = Tunnel.Type.VLAN;
String[] srcArray = src.split("-");
String[] dstArray = dst.split("-");
srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, null, OpticalLogicId.logicId(0), true);
dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, null, OpticalLogicId.logicId(0), true);
} else if ("ODUK".equals(type)) {
trueType = Tunnel.Type.ODUK;
String[] srcArray = src.split("-");
String[] dstArray = dst.split("-");
srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
} else if ("OCH".equals(type)) {
trueType = Tunnel.Type.OCH;
String[] srcArray = src.split("-");
String[] dstArray = dst.split("-");
srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, OpticalTunnelEndPoint.Type.TIMESLOT, OpticalLogicId.logicId(0), true);
dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.TIMESLOT, OpticalLogicId.logicId(0), true);
} else {
print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
return;
}
tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint, trueType);
}
if (!isNull(tunnelId)) {
TunnelId id = TunnelId.valueOf(tunnelId);
Tunnel tunnel = service.borrowTunnel(appId, id);
tunnelSet = new HashSet<Tunnel>();
tunnelSet.add(tunnel);
}
if (!isNull(tunnelName)) {
TunnelName name = TunnelName.tunnelName(tunnelName);
tunnelSet = service.borrowTunnel(appId, name);
}
for (Tunnel tunnel : tunnelSet) {
print(FMT, tunnel.src(), tunnel.dst(), tunnel.type(), tunnel.state(), tunnel.providerId(), tunnel.tunnelName(), tunnel.groupId());
}
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class InstallCoordinatorTest method createTestIntent.
/**
* Creates a test Intent.
*
* @return the test Intent.
*/
private PointToPointIntent createTestIntent() {
FilteredConnectPoint ingress = new FilteredConnectPoint(ConnectPoint.deviceConnectPoint("s1/1"));
FilteredConnectPoint egress = new FilteredConnectPoint(ConnectPoint.deviceConnectPoint("s1/2"));
ApplicationId appId = TestApplicationId.create("test App");
return PointToPointIntent.builder().filteredIngressPoint(ingress).filteredEgressPoint(egress).appId(appId).key(Key.of("Test key", appId)).build();
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class IntentRemoveCommand method removeIntent.
/**
* Removes the intents passed as argument, assuming these
* belong to the application's ID provided (if any) and
* contain a key string.
*
* If an application ID is provided, it will be used to further
* filter the intents to be removed.
*
* @param intents list of intents to remove
* @param applicationIdString application ID to filter intents
* @param keyString string to filter intents
* @param purgeAfterRemove states whether the intents should be also purged
* @param sync states whether the cli should wait for the operation to finish
* before returning
*/
private void removeIntent(Iterable<Intent> intents, String applicationIdString, String keyString, boolean purgeAfterRemove, boolean sync) {
IntentService intentService = get(IntentService.class);
CoreService coreService = get(CoreService.class);
this.applicationIdString = applicationIdString;
this.keyString = keyString;
this.purgeAfterRemove = purgeAfterRemove;
this.sync = sync;
if (purgeAfterRemove || sync) {
print("Using \"sync\" to remove/purge intents - this may take a while...");
print("Check \"summary\" to see remove/purge progress.");
}
ApplicationId appId = appId();
if (!isNullOrEmpty(applicationIdString)) {
appId = coreService.getAppId(applicationIdString);
if (appId == null) {
print("Cannot find application Id %s", applicationIdString);
return;
}
}
if (isNullOrEmpty(keyString)) {
removeIntentsByAppId(intentService, intents, appId);
} else {
final Key key;
if (keyString.startsWith("0x")) {
// The intent uses a LongKey
keyString = keyString.replaceFirst("0x", "");
key = Key.of(new BigInteger(keyString, 16).longValue(), appId);
} else {
// The intent uses a StringKey
key = Key.of(keyString, appId);
}
Intent intent = intentService.getIntent(key);
if (intent != null) {
removeIntent(intentService, intent);
}
}
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class ApplicationIdListCommand method json.
// ApplicationId
private JsonNode json(List<ApplicationId> ids) {
ObjectMapper mapper = new ObjectMapper();
ArrayNode result = mapper.createArrayNode();
for (ApplicationId id : ids) {
result.add(mapper.createObjectNode().put("id", id.id()).put("name", id.name()));
}
return result;
}
Aggregations