use of org.onosproject.net.intent.WorkPartitionService in project onos by opennetworkinglab.
the class IntentsListCommand method doExecute.
@Override
protected void doExecute() {
service = get(IntentService.class);
workPartitionService = get(WorkPartitionService.class);
if (workPartitionService == null) {
return;
}
contentFilter = new StringFilter(filter, StringFilter.Strategy.AND);
Iterable<Intent> intents;
if (pending) {
intents = service.getPending();
} else {
intents = service.getIntents();
}
// Remove intents
if (remove != null && !remove.isEmpty()) {
filter.add(remove);
contentFilter = new StringFilter(filter, StringFilter.Strategy.AND);
IntentRemoveCommand intentRemoveCmd = new IntentRemoveCommand();
if (!remove.isEmpty()) {
intentRemoveCmd.purgeIntentsInteractive(filterIntents(service));
}
return;
}
// Show detailed intents
if (!intentIds.isEmpty()) {
IntentDetailsCommand intentDetailsCmd = new IntentDetailsCommand();
intentDetailsCmd.detailIntents(intentIds);
return;
}
// Show brief intents
if (intentsSummary || miniSummary) {
Map<String, IntentSummary> summarized = summarize(intents);
if (outputJson()) {
ObjectNode summaries = mapper().createObjectNode();
summarized.forEach((n, s) -> summaries.set(uncapitalize(n), s.json(mapper())));
print("%s", summaries);
} else if (miniSummary) {
StringBuilder builder = new StringBuilder();
builder.append(summarized.remove("All").miniSummary());
summarized.values().forEach(s -> builder.append(s.miniSummary()));
print("%s", builder.toString());
} else {
StringBuilder builder = new StringBuilder();
builder.append(SUMMARY_TITLES);
builder.append('\n').append(SEPARATOR);
builder.append(summarized.remove("All").summary());
summarized.values().forEach(s -> builder.append(s.summary()));
print("%s", builder.toString());
}
return;
}
// JSON or default output
if (outputJson()) {
print("%s", json(intents));
} else {
for (Intent intent : intents) {
IntentState state = service.getIntentState(intent.key());
StringBuilder intentFormat = fullFormat(intent, state);
StringBuilder detailsIntentFormat = detailsFormat(intent, state);
String formatted = intentFormat.append(detailsIntentFormat).toString();
if (contentFilter.filter(formatted)) {
print("%s\n", formatted);
}
}
}
}
use of org.onosproject.net.intent.WorkPartitionService in project onos by opennetworkinglab.
the class IntentsDiagnosisCommand method buildServiceRefs.
private ServiceRefs buildServiceRefs() {
IntentService intentsService = get(IntentService.class);
if (intentsService == null) {
return null;
}
DeviceService deviceService = get(DeviceService.class);
if (deviceService == null) {
return null;
}
FlowStatisticService flowStatsService = get(FlowStatisticService.class);
if (flowStatsService == null) {
return null;
}
FlowRuleService flowService = get(FlowRuleService.class);
if (flowService == null) {
return null;
}
WorkPartitionService workPartitionService = get(WorkPartitionService.class);
if (workPartitionService == null) {
return null;
}
ObjectiveTrackerService objectiveTrackerService = get(ObjectiveTrackerService.class);
if (objectiveTrackerService == null) {
return null;
}
return new ServiceRefs(intentsService, deviceService, flowService, workPartitionService, objectiveTrackerService);
}
use of org.onosproject.net.intent.WorkPartitionService in project onos by opennetworkinglab.
the class VirtualNetworkIntentManagerTest method setUp.
@Before
public void setUp() throws Exception {
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
intentStore = new SimpleVirtualIntentStore();
coreService = new VirtualNetworkIntentManagerTest.TestCoreService();
MockIdGenerator.cleanBind();
TestUtils.setField(virtualNetworkManagerStore, "coreService", coreService);
TestUtils.setField(virtualNetworkManagerStore, "storageService", new TestStorageService());
virtualNetworkManagerStore.activate();
manager = new VirtualNetworkManager();
manager.store = virtualNetworkManagerStore;
NetTestTools.injectEventDispatcher(manager, new TestEventDispatcher());
intentService.addListener(listener);
// Register a compiler and an installer both setup for success.
intentExtensionService = intentService;
intentExtensionService.registerCompiler(VirtualNetworkIntent.class, compiler);
created = new Semaphore(0, true);
withdrawn = new Semaphore(0, true);
purged = new Semaphore(0, true);
workPartitionService = new WorkPartitionServiceAdapter();
testDirectory = new TestServiceDirectory().add(VirtualNetworkStore.class, virtualNetworkManagerStore).add(IntentService.class, intentService).add(WorkPartitionService.class, workPartitionService);
TestUtils.setField(manager, "serviceDirectory", testDirectory);
manager.activate();
}
Aggregations