use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class CreateNullHost method doExecute.
@Override
protected void doExecute() {
NullProviders service = get(NullProviders.class);
NetworkConfigService cfgService = get(NetworkConfigService.class);
TopologySimulator simulator = service.currentSimulator();
if (!validateSimulator(simulator) || !validateLocType(locType)) {
return;
}
CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
HostId id = sim.nextHostId();
Set<HostLocation> locations;
try {
locations = getLocations(sim, deviceNames);
} catch (NoLocationException e) {
error("\u001B[1;31mHost not created - no location (free port) available on %s\u001B[0m", e.getMessage());
return;
}
Set<IpAddress> ips = getIps(hostIps);
BasicHostConfig cfg = cfgService.addConfig(id, BasicHostConfig.class);
setUiCoordinates(cfg, locType, latOrY, longOrX);
Tools.delay(10);
sim.createHost(id, locations, ips);
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class CreateNullHosts method doExecute.
@Override
protected void doExecute() {
NullProviders service = get(NullProviders.class);
NetworkConfigService cfgService = get(NetworkConfigService.class);
TopologySimulator simulator = service.currentSimulator();
if (!validateSimulator(simulator)) {
return;
}
CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
List<ConnectPoint> points = findAvailablePorts(sim.deviceId(deviceName));
String pattern = hostIpPattern.replace("*", "%d");
double yStep = rowGap / hostsPerRow;
double y = gridY;
double x = gridX - (colGap * (hostsPerRow - 1)) / 2;
for (int h = 0; h < hostCount; h++) {
HostLocation location = new HostLocation(points.get(h), System.currentTimeMillis());
IpAddress ip = IpAddress.valueOf(String.format(pattern, h));
HostId id = sim.nextHostId();
if (gridY != NONE) {
BasicHostConfig cfg = cfgService.addConfig(id, BasicHostConfig.class);
setUiCoordinates(cfg, GRID, y, x);
if (((h + 1) % hostsPerRow) == 0) {
x = gridX - (colGap * (hostsPerRow - 1)) / 2;
} else {
x += colGap;
y += yStep;
}
}
Tools.delay(10);
sim.createHost(id, location, ip);
}
}
use of org.onosproject.net.config.NetworkConfigService in project up4 by omec-project.
the class ConfigPscEncap method doExecute.
@Override
protected void doExecute() throws Exception {
if (enable == null) {
return;
}
NetworkConfigService netCfgService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(APP_NAME);
Up4Config config = netCfgService.getConfig(appId, Up4Config.class);
if (config == null) {
print("No UP4 netcfg has been pushed yet");
return;
}
config.setPscEncap(enable);
netCfgService.applyConfig(appId, Up4Config.class, config.node());
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class ProtectionEndpointIntentInstaller method apply.
@Override
public void apply(IntentOperationContext<ProtectionEndpointIntent> context) {
Optional<IntentData> toUninstall = context.toUninstall();
Optional<IntentData> toInstall = context.toInstall();
List<ProtectionEndpointIntent> uninstallIntents = context.intentsToUninstall();
List<ProtectionEndpointIntent> installIntents = context.intentsToInstall();
if (!toInstall.isPresent() && !toUninstall.isPresent()) {
intentInstallCoordinator.intentInstallSuccess(context);
return;
}
if (toUninstall.isPresent()) {
IntentData intentData = toUninstall.get();
trackerService.removeTrackedResources(intentData.key(), intentData.intent().resources());
uninstallIntents.forEach(installable -> trackerService.removeTrackedResources(intentData.intent().key(), installable.resources()));
}
if (toInstall.isPresent()) {
IntentData intentData = toInstall.get();
trackerService.addTrackedResources(intentData.key(), intentData.intent().resources());
installIntents.forEach(installable -> trackerService.addTrackedResources(intentData.key(), installable.resources()));
}
List<Stage> stages = new ArrayList<>();
stages.add(new Stage(uninstallIntents.stream().map(i -> Pair.of(i, REMOVE)).collect(Collectors.toList())));
stages.add(new Stage(installIntents.stream().map(i -> Pair.of(i, ADD)).collect(Collectors.toList())));
for (Stage stage : stages) {
log.debug("applying Stage {}", stage);
try {
// wait for stage completion
stage.apply();
stage.listeners().forEach(networkConfigService::removeListener);
} catch (IntentException e) {
log.error("Stage {} failed, reason: {}", stage, e.toString());
intentInstallCoordinator.intentInstallFailed(context);
return;
}
}
// All stage success
intentInstallCoordinator.intentInstallSuccess(context);
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class AnnotateHostCommand method doExecute.
@Override
protected void doExecute() {
NetworkConfigService netcfgService = get(NetworkConfigService.class);
HostId hostId = HostId.hostId(uri);
if (key == null) {
print("[ERROR] Annotation key not specified.");
return;
}
HostAnnotationConfig cfg = netcfgService.getConfig(hostId, HostAnnotationConfig.class);
if (cfg == null) {
cfg = new HostAnnotationConfig(hostId);
}
if (removeCfg) {
// remove config about entry
cfg.annotation(key);
} else {
// add request config
cfg.annotation(key, value);
}
netcfgService.applyConfig(hostId, HostAnnotationConfig.class, cfg.node());
}
Aggregations