Search in sources :

Example 26 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class ReviewCommand method doExecute.

@Override
protected void doExecute() {
    ApplicationAdminService applicationAdminService = get(ApplicationAdminService.class);
    ApplicationId appId = applicationAdminService.getId(name);
    if (appId == null) {
        print("No such application: %s", name);
        return;
    }
    Application app = applicationAdminService.getApplication(appId);
    SecurityAdminService smService = SecurityUtil.getSecurityService();
    if (smService == null) {
        print("Security Mode is disabled");
        return;
    }
    if (accept == null) {
        smService.review(appId);
        printPolicy(smService, app);
    } else if ("accept".equals(accept.trim())) {
        smService.acceptPolicy(appId);
        printPolicy(smService, app);
    } else {
        print("Unknown command");
    }
}
Also used : SecurityAdminService(org.onosproject.security.SecurityAdminService) ApplicationId(org.onosproject.core.ApplicationId) Application(org.onosproject.core.Application) ApplicationAdminService(org.onosproject.app.ApplicationAdminService)

Example 27 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class SimpleApplicationStore method remove.

@Override
public void remove(ApplicationId appId) {
    Application app = apps.remove(appId);
    if (app != null) {
        states.remove(appId);
        delegate.notify(new ApplicationEvent(APP_UNINSTALLED, app));
        purgeApplication(app.id().name());
    }
}
Also used : ApplicationEvent(org.onosproject.app.ApplicationEvent) Application(org.onosproject.core.Application) DefaultApplication(org.onosproject.core.DefaultApplication)

Example 28 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class SimpleApplicationStoreTest method deactivate.

@Test
public void deactivate() {
    Application app = createTestApp();
    store.deactivate(app.id());
    assertEquals("incorrect app count", 1, store.getApplications().size());
    assertEquals("incorrect app state", INSTALLED, store.getState(app.id()));
    assertEquals("incorrect event type", APP_DEACTIVATED, delegate.event.type());
    assertEquals("incorrect event app", app, delegate.event.subject());
}
Also used : Application(org.onosproject.core.Application) Test(org.junit.Test)

Example 29 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class ApplicationsListCommand method doExecute.

@Override
protected void doExecute() {
    ApplicationService service = get(ApplicationService.class);
    List<Application> apps = newArrayList(service.getApplications());
    if (sortByName) {
        apps.sort(Comparator.comparing(app -> app.id().name()));
    } else {
        Collections.sort(apps, Comparators.APP_COMPARATOR);
    }
    if (outputJson()) {
        print("%s", json(service, apps));
    } else {
        for (Application app : apps) {
            boolean isActive = service.getState(app.id()) == ACTIVE;
            if (activeOnly && isActive || !activeOnly) {
                if (shortOnly) {
                    String shortDescription = app.title().equals(app.id().name()) ? app.description().replaceAll("[\\r\\n]", " ").replaceAll(" +", " ") : app.title();
                    print(SHORT_FMT, isActive ? "*" : " ", app.id().id(), app.id().name(), app.version(), shortDescription);
                } else {
                    print(FMT, isActive ? "*" : " ", app.id().id(), app.id().name(), app.version(), app.origin(), app.category(), app.description(), app.features(), app.featuresRepo().map(URI::toString).orElse(""), app.requiredApps(), app.permissions(), app.url());
                }
            }
        }
    }
}
Also used : Comparators(org.onosproject.utils.Comparators) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ApplicationService(org.onosproject.app.ApplicationService) Command(org.apache.karaf.shell.api.action.Command) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ACTIVE(org.onosproject.app.ApplicationState.ACTIVE) Service(org.apache.karaf.shell.api.action.lifecycle.Service) JsonNode(com.fasterxml.jackson.databind.JsonNode) URI(java.net.URI) Comparator(java.util.Comparator) Option(org.apache.karaf.shell.api.action.Option) Collections(java.util.Collections) Application(org.onosproject.core.Application) Application(org.onosproject.core.Application) URI(java.net.URI) ApplicationService(org.onosproject.app.ApplicationService)

Example 30 with Application

use of org.onosproject.core.Application in project onos by opennetworkinglab.

the class ApplicationsListCommand method json.

private JsonNode json(ApplicationService service, List<Application> apps) {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode result = mapper.createArrayNode();
    for (Application app : apps) {
        boolean isActive = service.getState(app.id()) == ACTIVE;
        if (activeOnly && isActive || !activeOnly) {
            result.add(jsonForEntity(app, Application.class));
        }
    }
    return result;
}
Also used : ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Application(org.onosproject.core.Application) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Application (org.onosproject.core.Application)32 DefaultApplication (org.onosproject.core.DefaultApplication)12 Test (org.junit.Test)8 List (java.util.List)6 ApplicationAdminService (org.onosproject.app.ApplicationAdminService)6 ApplicationEvent (org.onosproject.app.ApplicationEvent)6 ApplicationId (org.onosproject.core.ApplicationId)6 IOException (java.io.IOException)4 Lists (com.google.common.collect.Lists)3 InputStream (java.io.InputStream)3 Collectors (java.util.stream.Collectors)3 Service (org.apache.karaf.shell.api.action.lifecycle.Service)3 ApplicationService (org.onosproject.app.ApplicationService)3 ApplicationState (org.onosproject.app.ApplicationState)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 Charsets (com.google.common.base.Charsets)2 MoreObjects (com.google.common.base.MoreObjects)2 Preconditions (com.google.common.base.Preconditions)2 Throwables (com.google.common.base.Throwables)2