Set Hostname on "Save settings"

Set the Hostname field when the user selects "Save settings"
and accepts the popup. Before Hostname was readonly.

Tested: Set the Hostname on a Witherspoon
Change-Id: I9de840ee9d52ec4a9ae1fd69d4ea27f62b0baf17
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/configuration/controllers/network-controller.html b/app/configuration/controllers/network-controller.html
index 968f8a2..e9b819c 100644
--- a/app/configuration/controllers/network-controller.html
+++ b/app/configuration/controllers/network-controller.html
@@ -10,7 +10,7 @@
 			<fieldset>
 				<div class="column small-12 large-3">
 					<label for="net-config__mac">Hostname</label>
-					<input id="net-config__mac" type="text" readonly value="{{hostname}}"/>
+					<input id="net-config__mac" type="text" ng-model="hostname"/>
 				</div>
 				<div class="column small-12 large-3">
 					<label for="netinterface-select">Network interface</label>
diff --git a/app/configuration/controllers/network-controller.js b/app/configuration/controllers/network-controller.js
index 5fe1594..31b482c 100644
--- a/app/configuration/controllers/network-controller.js
+++ b/app/configuration/controllers/network-controller.js
@@ -39,6 +39,8 @@
         // changed before setting
         promises.push(setMACAddress());
         promises.push(setDefaultGateway());
+        promises.push(setHostname());
+
         $q.all(promises).finally(function() {
           if (!$scope.set_network_error) {
             $scope.set_network_success = true;
@@ -68,6 +70,17 @@
                   $scope.set_network_error = 'Default Gateway';
                 });
       }
+
+      function setHostname() {
+        return APIUtils.setHostname($scope.hostname)
+            .then(
+                function(data) {},
+                function(error) {
+                  console.log(JSON.stringify(error));
+                  $scope.set_network_error = 'Hostname';
+                });
+      }
+
       $scope.refresh = function() {
         $route.reload();
       };