Update DNS Servers on "Save settings"

"Nameservers" is called "DNS Servers" on the GUI. Update the
property if it has changed when the user hits Save settings
and confirms.

Had difficulties getting the DNS input fields to update the
interface.Nameservers array. The
"ng-blur="interface.Nameservers[$index] = dns" solution is from:
https://stackoverflow.com/questions/13714884/difficulty-with-ng-model-ng-repeat-and-inputs

Tested: Changed some DNS Servers on a Witherspoon.
Change-Id: Ib9c4be044d0725ac50e57e2733c3dc2ef8e29053
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/configuration/controllers/network-controller.js b/app/configuration/controllers/network-controller.js
index d5fdc00..4e8a7e0 100644
--- a/app/configuration/controllers/network-controller.js
+++ b/app/configuration/controllers/network-controller.js
@@ -55,6 +55,12 @@
           promises.push(setDHCPEnabled());
         }
 
+        // toString() is a cheap way to compare 2 string arrays
+        if ($scope.interface.Nameservers.toString() !=
+            $scope.old_interface.Nameservers.toString()) {
+          promises.push(setNameservers());
+        }
+
         // Set IPV4 IP Addresses, Netmask Prefix Lengths, and Gateways
         if (!$scope.interface.DHCPEnabled) {
           for (var i in $scope.interface.ipv4.values) {
@@ -164,6 +170,18 @@
                 });
       }
 
+      function setNameservers() {
+        return APIUtils
+            .setNameservers(
+                $scope.selectedInterface, $scope.interface.Nameservers)
+            .then(
+                function(data) {},
+                function(error) {
+                  console.log(JSON.stringify(error));
+                  $scope.set_network_error = 'DNS Servers';
+                });
+      }
+
       function setIPV4(index) {
         // The correct way to edit an IPV4 interface is to remove it and then
         // add a new one