From 18a0612ed336b6499956fb15e65da295cb4b899d Mon Sep 17 00:00:00 2001 From: Pramila Singh Date: Fri, 2 Aug 2013 15:35:56 -0700 Subject: [PATCH] Fix to allow Switch configuration modification(Description and Tier) in non-default container Change-Id: Id431dc31cfb43a0fb840c456e0d73935f82dfdeb Signed-off-by: Pramila Singh --- .../switchmanager/internal/SwitchManagerImpl.java | 14 ++++++++++---- .../controller/devices/web/Devices.java | 6 ++++-- .../web/devices/src/main/resources/js/page.js | 7 +++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java index 5d10620c44..a91edb0c25 100644 --- a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java +++ b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java @@ -702,7 +702,7 @@ CommandProvider { if (mode != null) { if (isDefaultContainer) { if (!mode.isValid()) { - return new Status(StatusCode.NOTACCEPTABLE, "Invalid Forwarding Mode Value."); + return new Status(StatusCode.BADREQUEST, "Invalid Forwarding Mode Value."); } } else { return new Status(StatusCode.NOTACCEPTABLE, @@ -744,10 +744,10 @@ CommandProvider { } Node node = Node.fromString(nodeId); Map propMapCurr = nodeProps.get(node); - Map propMap = new HashMap(propMapCurr); if (propMapCurr == null) { return new Status(StatusCode.SUCCESS); } + Map propMap = new HashMap(propMapCurr); if (!prevNodeProperties.isEmpty()) { for (String prop : prevNodeProperties.keySet()) { if (!updateProperties.containsKey(prop)) { @@ -820,7 +820,6 @@ CommandProvider { spanConfigList), spanFileName); retS = objWriter.write(new ConcurrentHashMap( nodeConfigList), switchConfigFileName); - if (retS.equals(retP)) { if (retS.isSuccess()) { return retS; @@ -936,7 +935,6 @@ CommandProvider { } else { result = nodeProps.replace(node, propMapCurr, propMap); } - if (!result) { log.debug("Cluster conflict: Conflict while adding the node properties. Node: {} Properties: {}", node.getID(), props); @@ -981,7 +979,15 @@ CommandProvider { : new HashMap(propMapCurr); // copy node properties from plugin + String nodeId = node.toString(); for (Property prop : props) { + if (nodeConfigList != null) { + SwitchConfig conf = nodeConfigList.get(nodeId); + if (conf != null && (conf.getNodeProperties() != null) + && conf.getNodeProperties().containsKey(prop.getName())) { + continue; + } + } propMap.put(prop.getName(), prop); } diff --git a/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java index e6a785f586..ca1dd97137 100644 --- a/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java +++ b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java @@ -236,8 +236,10 @@ public class Devices implements IDaylightWeb { nodeProperties.put(desc.getName(), desc); Property nodeTier = new Tier(Integer.parseInt(tier)); nodeProperties.put(nodeTier.getName(), nodeTier); - Property mode = new ForwardingMode(Integer.parseInt(operationMode)); - nodeProperties.put(mode.getName(), mode); + if (containerName.equals(GlobalConstants.DEFAULT.toString())) { + Property mode = new ForwardingMode(Integer.parseInt(operationMode)); + nodeProperties.put(mode.getName(), mode); + } SwitchConfig cfg = new SwitchConfig(nodeId, nodeProperties); Status result = switchManager.updateNodeConfig(cfg); if (!result.isSuccess()) { diff --git a/opendaylight/web/devices/src/main/resources/js/page.js b/opendaylight/web/devices/src/main/resources/js/page.js index ce59238be6..38df045526 100644 --- a/opendaylight/web/devices/src/main/resources/js/page.js +++ b/opendaylight/web/devices/src/main/resources/js/page.js @@ -110,14 +110,14 @@ one.f.switchmanager.nodesLearnt = { var h3; var footer = []; var $body = one.f.switchmanager.nodesLearnt.modal.body.updateNode(nodeId, evt.target.switchDetails, tiers); - if ( (one.main.registry == undefined || one.main.registry.container == 'default') && evt.target.privilege == 'WRITE'){ + if (evt.target.privilege == 'WRITE'){ h3 = "Update Node Information"; footer = one.f.switchmanager.nodesLearnt.modal.footer.updateNode(); } else { //disable node edit $body.find('*').attr('disabled', 'disabled'); h3 = 'Node Information'; } - + var $modal = one.lib.modal.spawn(one.f.switchmanager.nodesLearnt.id.modal.modal, h3, "", footer); // bind save button $('#' + one.f.switchmanager.nodesLearnt.id.modal.save, $modal).click(function() { @@ -167,6 +167,9 @@ one.f.switchmanager.nodesLearnt = { var $select = one.lib.form.select.create( ["Allow reactive forwarding", "Proactive forwarding only"]); $select.attr('id', one.f.switchmanager.nodesLearnt.id.modal.form.operationMode); + if ((one.main.registry != undefined) && (one.main.registry.container != 'default')) { + $select.attr("disabled", true); + } $select.val(switchDetails["mode"]); $fieldset.append($label).append($select); $form.append($fieldset); -- 2.36.6