You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2013/12/27 10:08:41 UTC

git commit: updated refs/heads/master to 84bf5b3

Updated Branches:
  refs/heads/master 8b151c98c -> 84bf5b3e5


added support to run hyperv agent on 0.0.0.0 and startuprouting command will discover the ip details and send in response


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/84bf5b3e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/84bf5b3e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/84bf5b3e

Branch: refs/heads/master
Commit: 84bf5b3e55e509651025693869118ea05b331766
Parents: 8b151c9
Author: Rajesh Battala <ra...@citrix.com>
Authored: Thu Dec 5 14:46:20 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Dec 27 14:43:25 2013 +0530

----------------------------------------------------------------------
 .../ServerResource/HypervResource/App.config    |  6 ++---
 .../HypervResource/HypervResourceController.cs  | 28 +++++++++++++-------
 2 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84bf5b3e/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
index 1bf17d4..0e75ef9 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
@@ -24,7 +24,7 @@
         <value>8</value>
       </setting>
       <setting name="private_ip_address" serializeAs="String">
-        <value>10.1.1.1</value>
+        <value>0.0.0.0</value>
       </setting>
       <setting name="type" serializeAs="String">
         <value>Routing</value>
@@ -45,13 +45,13 @@
         <value>34359738368</value>
       </setting>
       <setting name="host" serializeAs="String">
-        <value>camldonall01.citrite.net</value>
+        <value>0.0.0.0</value>
       </setting>
       <setting name="pod" serializeAs="String">
         <value>1</value>
       </setting>
       <setting name="gateway_ip_address" serializeAs="String">
-        <value>10.70.176.1</value>
+        <value>0.0.0.0</value>
       </setting>
       <setting name="cluster" serializeAs="String">
         <value>2</value>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/84bf5b3e/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
index 700b7da..c24e177 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -1752,14 +1752,20 @@ namespace HypervResource
                 dynamic strtRouteCmd = cmdArray[0][CloudStackTypes.StartupRoutingCommand];
 
                 // Insert networking details
-                strtRouteCmd.privateIpAddress = config.PrivateIpAddress;
-                strtRouteCmd.privateNetmask = config.PrivateNetmask;
-                strtRouteCmd.privateMacAddress = config.PrivateMacAddress;
-                strtRouteCmd.storageIpAddress = config.PrivateIpAddress;
-                strtRouteCmd.storageNetmask = config.PrivateNetmask;
-                strtRouteCmd.storageMacAddress = config.PrivateMacAddress;
-                strtRouteCmd.gatewayIpAddress = config.GatewayIpAddress;
-                strtRouteCmd.hypervisorVersion = System.Environment.OSVersion.Version.ToString();
+                string privateIpAddress = strtRouteCmd.privateIpAddress;
+                string subnet;
+                System.Net.NetworkInformation.NetworkInterface privateNic = GetNicInfoFromIpAddress(privateIpAddress, out subnet);
+                strtRouteCmd.privateIpAddress = privateIpAddress;
+                strtRouteCmd.privateNetmask = subnet;
+                strtRouteCmd.privateMacAddress = privateNic.GetPhysicalAddress().ToString();
+                string storageip = strtRouteCmd.storageIpAddress;
+                System.Net.NetworkInformation.NetworkInterface storageNic = GetNicInfoFromIpAddress(storageip, out subnet);
+
+                strtRouteCmd.storageIpAddress = storageip;
+                strtRouteCmd.storageNetmask = subnet;
+                strtRouteCmd.storageMacAddress = storageNic.GetPhysicalAddress().ToString();
+                strtRouteCmd.gatewayIpAddress = storageNic.GetPhysicalAddress().ToString();
+
                 strtRouteCmd.caps = "hvm";
 
                 dynamic details = strtRouteCmd.hostDetails;
@@ -1850,9 +1856,11 @@ namespace HypervResource
         public static System.Net.NetworkInformation.NetworkInterface GetNicInfoFromIpAddress(string ipAddress, out string subnet)
         {
             System.Net.NetworkInformation.NetworkInterface[] nics = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
+            System.Net.NetworkInformation.NetworkInterface defaultnic = null;
             foreach (var nic in nics)
             {
                 subnet = null;
+                defaultnic = nic;
                 // TODO: use to remove NETMASK and MAC from the config file, and to validate the IPAddress.
                 var nicProps = nic.GetIPProperties();
                 bool found = false;
@@ -1870,7 +1878,9 @@ namespace HypervResource
                 }
                 return nic;
             }
-            throw new ArgumentException("No NIC for ipAddress " + ipAddress);
+            var defaultSubnet = defaultnic.GetIPProperties().UnicastAddresses[0];
+            subnet = defaultSubnet.IPv4Mask.ToString();
+            return defaultnic;
         }
 
         public static void GetCapacityForLocalPath(string localStoragePath, out long capacityBytes, out long availableBytes)