Committed by
Gerrit Code Review
ONOS-3356 Fixed NPE when processing configuration of a non-existent device.
Change-Id: I00369a67c406634b2ee7d379cad6e0fc41842388
Showing
3 changed files
with
18 additions
and
3 deletions
... | @@ -51,7 +51,7 @@ public final class BasicDeviceOperator implements ConfigOperator { | ... | @@ -51,7 +51,7 @@ public final class BasicDeviceOperator implements ConfigOperator { |
51 | * @return DeviceDescription based on both sources | 51 | * @return DeviceDescription based on both sources |
52 | */ | 52 | */ |
53 | public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) { | 53 | public static DeviceDescription combine(BasicDeviceConfig bdc, DeviceDescription descr) { |
54 | - if (bdc == null) { | 54 | + if (bdc == null || descr == null) { |
55 | return descr; | 55 | return descr; |
56 | } | 56 | } |
57 | 57 | ... | ... |
... | @@ -740,7 +740,7 @@ public class DeviceManager | ... | @@ -740,7 +740,7 @@ public class DeviceManager |
740 | Device dev = getDevice(did); | 740 | Device dev = getDevice(did); |
741 | DeviceDescription desc = (dev == null) ? null : BasicDeviceOperator.descriptionOf(dev); | 741 | DeviceDescription desc = (dev == null) ? null : BasicDeviceOperator.descriptionOf(dev); |
742 | desc = BasicDeviceOperator.combine(cfg, desc); | 742 | desc = BasicDeviceOperator.combine(cfg, desc); |
743 | - if (getProvider(did) != null) { | 743 | + if (desc != null && getProvider(did) != null) { |
744 | de = store.createOrUpdateDevice(getProvider(did).id(), did, desc); | 744 | de = store.createOrUpdateDevice(getProvider(did).id(), did, desc); |
745 | } | 745 | } |
746 | } | 746 | } |
... | @@ -754,7 +754,7 @@ public class DeviceManager | ... | @@ -754,7 +754,7 @@ public class DeviceManager |
754 | OpticalPortConfig opc = networkConfigService.getConfig(cpt, OpticalPortConfig.class); | 754 | OpticalPortConfig opc = networkConfigService.getConfig(cpt, OpticalPortConfig.class); |
755 | PortDescription desc = OpticalPortOperator.descriptionOf(dpt); | 755 | PortDescription desc = OpticalPortOperator.descriptionOf(dpt); |
756 | desc = OpticalPortOperator.combine(opc, desc); | 756 | desc = OpticalPortOperator.combine(opc, desc); |
757 | - if (getProvider(did) != null) { | 757 | + if (desc != null && getProvider(did) != null) { |
758 | de = store.updatePortStatus(getProvider(did).id(), did, desc); | 758 | de = store.updatePortStatus(getProvider(did).id(), did, desc); |
759 | } | 759 | } |
760 | } | 760 | } | ... | ... |
tools/test/bin/onos-netcfg
0 → 100755
1 | +#!/bin/bash | ||
2 | +# ----------------------------------------------------------------------------- | ||
3 | +# ONOS network configuration uploader. | ||
4 | +# ----------------------------------------------------------------------------- | ||
5 | + | ||
6 | +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | ||
7 | +. $ONOS_ROOT/tools/build/envDefaults | ||
8 | + | ||
9 | +node="${1:-$OCI}" | ||
10 | +file="${2:-$ONOS_ROOT/tools/test/topos/oe-linear-3.json}" | ||
11 | +url="${3}" | ||
12 | + | ||
13 | +curl -sS --fail -L --user $ONOS_WEB_USER:$ONOS_WEB_PASS \ | ||
14 | + -X POST -H 'Content-Type:application/json' \ | ||
15 | + http://$node:8181/onos/v1/network/configuration/${url} -d@$file |
-
Please register or login to post a comment