Fix to allow Switch configuration modification(Description and Tier) in non-default... 80/780/1
authorPramila Singh <pramisin@cisco.com>
Fri, 2 Aug 2013 22:35:56 +0000 (15:35 -0700)
committerPramila Singh <pramisin@cisco.com>
Fri, 2 Aug 2013 22:56:22 +0000 (15:56 -0700)
Change-Id: Id431dc31cfb43a0fb840c456e0d73935f82dfdeb
Signed-off-by: Pramila Singh <pramisin@cisco.com>
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java
opendaylight/web/devices/src/main/resources/js/page.js

index 5d10620..a91edb0 100644 (file)
@@ -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<String, Property> propMapCurr = nodeProps.get(node);
-        Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
         if (propMapCurr == null) {
             return new Status(StatusCode.SUCCESS);
         }
+        Map<String, Property> propMap = new HashMap<String, Property>(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<String, SwitchConfig>(
                 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<String, Property>(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);
         }
 
index e6a785f..ca1dd97 100644 (file)
@@ -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()) {
index ce59238..38df045 100644 (file)
@@ -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);