Thomas Vachuska
Committed by Gerrit Code Review

ONOS-3356 Fixed NPE when processing configuration of a non-existent device.

Change-Id: I00369a67c406634b2ee7d379cad6e0fc41842388
......@@ -51,7 +51,7 @@ public final class BasicDeviceOperator implements ConfigOperator {
* @return DeviceDescription based on both sources
*/
public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) {
if (bdc == null) {
if (bdc == null || descr == null) {
return descr;
}
......
......@@ -740,7 +740,7 @@ public class DeviceManager
Device dev = getDevice(did);
DeviceDescription desc = (dev == null) ? null : BasicDeviceOperator.descriptionOf(dev);
desc = BasicDeviceOperator.combine(cfg, desc);
if (getProvider(did) != null) {
if (desc != null && getProvider(did) != null) {
de = store.createOrUpdateDevice(getProvider(did).id(), did, desc);
}
}
......@@ -754,7 +754,7 @@ public class DeviceManager
OpticalPortConfig opc = networkConfigService.getConfig(cpt, OpticalPortConfig.class);
PortDescription desc = OpticalPortOperator.descriptionOf(dpt);
desc = OpticalPortOperator.combine(opc, desc);
if (getProvider(did) != null) {
if (desc != null && getProvider(did) != null) {
de = store.updatePortStatus(getProvider(did).id(), did, desc);
}
}
......
#!/bin/bash
# -----------------------------------------------------------------------------
# ONOS network configuration uploader.
# -----------------------------------------------------------------------------
[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
. $ONOS_ROOT/tools/build/envDefaults
node="${1:-$OCI}"
file="${2:-$ONOS_ROOT/tools/test/topos/oe-linear-3.json}"
url="${3}"
curl -sS --fail -L --user $ONOS_WEB_USER:$ONOS_WEB_PASS \
-X POST -H 'Content-Type:application/json' \
http://$node:8181/onos/v1/network/configuration/${url} -d@$file