use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class ControlPlaneRedirectManager method processRouterConfig.
/**
* Sets up the router interfaces if router config is available.
*/
private void processRouterConfig() {
ApplicationId routingAppId = coreService.registerApplication(RoutingService.ROUTER_APP_ID);
Set<RoutersConfig.Router> routerConfigs = RoutingConfiguration.getRouterConfigurations(networkConfigService, routingAppId);
for (RoutersConfig.Router router : routerConfigs) {
DeviceId deviceId = router.controlPlaneConnectPoint().deviceId();
routers.compute(deviceId, (d, r) -> {
if (r == null) {
return createRouter(RouterInfo.from(router));
} else {
r.changeConfiguration(RouterInfo.from(router), forceUnprovision);
return r;
}
});
}
for (DeviceId deviceId : routers.keySet()) {
if (!configExists(deviceId, routerConfigs)) {
Router router = routers.remove(deviceId);
router.cleanup();
}
}
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class AddSpeakerCommand method doExecute.
@Override
protected void doExecute() {
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.addConfig(appId, BgpConfig.class);
if (name != null) {
BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
if (speaker != null) {
log.debug("Speaker already exists: {}", name);
return;
}
}
if (vlanId == null || vlanId.isEmpty()) {
vlanIdObj = VlanId.NONE;
} else {
vlanIdObj = VlanId.vlanId(Short.valueOf(vlanId));
}
addSpeakerToConf(config);
configService.applyConfig(appId, BgpConfig.class, config.node());
print(SPEAKER_ADD_SUCCESS);
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class BgpSpeakersListCommand method doExecute.
@Override
protected void doExecute() {
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.getConfig(appId, BgpConfig.class);
if (config == null) {
print("No speakers configured");
return;
}
List<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Lists.newArrayList(config.bgpSpeakers());
Collections.sort(bgpSpeakers, SPEAKERS_COMPARATOR);
if (config.bgpSpeakers().isEmpty()) {
print("No speakers configured");
} else {
bgpSpeakers.forEach(s -> {
if (s.name().isPresent()) {
print(NAME_FORMAT, s.name().get(), s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
} else {
print(FORMAT, s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
}
});
}
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class RemoveSpeakerCommand method doExecute.
@Override
protected void doExecute() {
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.getConfig(appId, BgpConfig.class);
if (config == null || config.bgpSpeakers().isEmpty()) {
print(NO_CONFIGURATION);
return;
}
BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
if (speaker == null) {
print(SPEAKER_NOT_FOUND, name);
return;
} else {
if (!speaker.peers().isEmpty()) {
// Removal not allowed when peer connections exist.
print(PEERS_EXIST, name);
return;
}
}
removeSpeakerFromConf(config);
configService.applyConfig(appId, BgpConfig.class, config.node());
print(SPEAKER_REMOVE_SUCCESS);
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class DistributedApplicationStore method loadFromDisk.
private Application loadFromDisk(String appName) {
pendingApps.add(appName);
for (int i = 0; i < MAX_LOAD_RETRIES; i++) {
try {
// Directly return if app already exists
ApplicationId appId = getId(appName);
if (appId != null) {
Application application = getApplication(appId);
if (application != null) {
pendingApps.remove(appName);
return application;
}
}
ApplicationDescription appDesc = getApplicationDescription(appName);
Optional<String> loop = appDesc.requiredApps().stream().filter(app -> pendingApps.contains(app)).findAny();
if (loop.isPresent()) {
log.error("Circular app dependency detected: {} -> {}", pendingApps, loop.get());
pendingApps.remove(appName);
return null;
}
boolean success = appDesc.requiredApps().stream().noneMatch(requiredApp -> loadFromDisk(requiredApp) == null);
pendingApps.remove(appName);
if (success) {
return create(appDesc, false);
} else {
log.error("Unable to load dependencies for application {}", appName);
return null;
}
} catch (Exception e) {
log.warn("Unable to load application {} from disk: {}; retrying", appName, Throwables.getRootCause(e).getMessage());
log.debug("Full error details:", e);
// FIXME: This is a deliberate hack; fix in Falcon
randomDelay(RETRY_DELAY_MS);
}
}
pendingApps.remove(appName);
log.error("Unable to load application {}", appName);
return null;
}
Aggregations