use of org.onosproject.net.config.basics.HostAnnotationConfig in project onos by opennetworkinglab.
the class HostAnnotationOperator method combine.
@Override
public HostDescription combine(HostId hostId, HostDescription descr, Optional<Config> prevConfig) {
HostAnnotationConfig cfg = lookupConfig(hostId);
if (cfg == null) {
return descr;
}
Map<String, String> annotations = cfg.annotations();
Builder builder = DefaultAnnotations.builder();
builder.putAll(descr.annotations());
if (prevConfig.isPresent()) {
HostAnnotationConfig prevHostAnnotationConfig = (HostAnnotationConfig) prevConfig.get();
for (String key : prevHostAnnotationConfig.annotations().keySet()) {
if (!annotations.containsKey(key)) {
builder.remove(key);
}
}
}
builder.putAll(annotations);
return DefaultHostDescription.copyReplacingAnnotation(descr, builder.build());
}
use of org.onosproject.net.config.basics.HostAnnotationConfig 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