use of org.onosproject.core.CoreService in project fabric-tna by stratum.
the class FabricUpfProgrammable method setupBehaviour.
@Override
protected boolean setupBehaviour(String opName) {
/* Always setup internally the behavior to refresh
the internal references: client, controller, etc*/
if (!super.setupBehaviour(opName)) {
return false;
}
// Already initialized.
if (appId != null) {
return true;
}
if (!computeHardwareResourceSizes()) {
// error message will be printed by computeHardwareResourceSizes()
return false;
}
flowRuleService = handler().get(FlowRuleService.class);
meterService = handler().get(MeterService.class);
packetService = handler().get(PacketService.class);
slicingService = handler().get(SlicingService.class);
upfTranslator = new FabricUpfTranslator();
final CoreService coreService = handler().get(CoreService.class);
appId = coreService.getAppId(Constants.APP_NAME_UPF);
if (appId == null) {
log.warn("Application ID is null. Cannot initialize behaviour.");
return false;
}
var capabilities = new FabricCapabilities(pipeconf);
if (!capabilities.supportUpf()) {
log.warn("Pipeconf {} on {} does not support UPF capabilities, " + "cannot perform {}", pipeconf.id(), deviceId, opName);
return false;
}
return true;
}
use of org.onosproject.core.CoreService in project fabric-tna by stratum.
the class FabricIntProgrammable method setupBehaviour.
private boolean setupBehaviour() {
deviceId = this.data().deviceId();
flowRuleService = handler().get(FlowRuleService.class);
groupService = handler().get(GroupService.class);
cfgService = handler().get(NetworkConfigService.class);
hostService = handler().get(HostService.class);
final CoreService coreService = handler().get(CoreService.class);
appId = coreService.getAppId(Constants.APP_NAME);
if (appId == null) {
log.warn("Application ID is null. Cannot initialize behaviour.");
return false;
}
return true;
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class VirtualFlowsListCommand method printFlows.
/**
* Prints flows.
*
* @param d the device
* @param flows the set of flows for that device
* @param coreService core system service
*/
protected void printFlows(Device d, List<FlowEntry> flows, CoreService coreService) {
List<FlowEntry> filteredFlows = flows.stream().filter(f -> contentFilter.filter(f)).collect(Collectors.toList());
boolean empty = filteredFlows == null || filteredFlows.isEmpty();
print("deviceId=%s, flowRuleCount=%d", d.id(), empty ? 0 : filteredFlows.size());
if (empty || countOnly) {
return;
}
for (FlowEntry f : filteredFlows) {
if (shortOutput) {
print(SHORT_FORMAT, f.state(), f.bytes(), f.packets(), f.tableId(), f.priority(), f.selector().criteria(), printTreatment(f.treatment()));
} else {
ApplicationId appId = coreService.getAppId(f.appId());
print(LONG_FORMAT, Long.toHexString(f.id().value()), f.state(), f.bytes(), f.packets(), f.life(), f.liveType(), f.priority(), f.tableId(), appId != null ? appId.name() : "<none>", f.selector().criteria(), f.treatment());
}
}
}
use of org.onosproject.core.CoreService in project onos by opennetworkinglab.
the class VirtualNetworkIntentRemoveCommand method doExecute.
@Override
protected void doExecute() {
VirtualNetworkService service = get(VirtualNetworkService.class);
IntentService intentService = service.get(NetworkId.networkId(networkId), IntentService.class);
CoreService coreService = get(CoreService.class);
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)) {
for (Intent intent : intentService.getIntents()) {
if (intent.appId().equals(appId)) {
removeIntent(intentService, intent);
}
}
} 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);
} else {
print("Intent not found!");
}
}
}
use of org.onosproject.core.CoreService 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);
}
}
}
Aggregations