use of org.onosproject.provider.lldp.impl.LinkDiscoveryFromDevice in project onos by opennetworkinglab.
the class ConfigLinkDiscoveryCommand method doExecute.
@Override
protected void doExecute() {
DeviceService deviceService = get(DeviceService.class);
NetworkConfigService netcfgService = get(NetworkConfigService.class);
DeviceId did = DeviceId.deviceId(device);
ConnectPoint cp = Optional.ofNullable(port).map(PortNumber::fromString).map(pn -> new ConnectPoint(did, pn)).orElse(null);
if (cp == null) {
// device config
if (!remove) {
if (deviceService.getDevice(did) == null) {
print("[WARN] configuring about unknown device %s", did);
}
LinkDiscoveryFromDevice cfg;
cfg = netcfgService.addConfig(did, LinkDiscoveryFromDevice.class);
cfg.enabled(enable);
cfg.apply();
} else {
netcfgService.removeConfig(did, LinkDiscoveryFromDevice.class);
}
} else {
// port config
if (!remove) {
if (deviceService.getPort(cp) == null) {
print("[WARN] configuring about unknown port %s", cp);
}
LinkDiscoveryFromPort cfg;
cfg = netcfgService.addConfig(cp, LinkDiscoveryFromPort.class);
cfg.enabled(enable);
cfg.apply();
} else {
netcfgService.removeConfig(cp, LinkDiscoveryFromPort.class);
}
}
}
Aggregations