You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/11/04 23:32:29 UTC

[47/56] [abbrv] git commit: updated refs/heads/ui-restyle to b7259a4

Changes to attach the system vm iso when booting the virtual router - part 1.
Copy the iso to the secondary storage and let the hypervisor agent know of its
location during setup. The agent will copy it over once it handles the setup
command.
Changes for attaching the systemvm iso to virtual router will booting it -
part 2. The agent copies over the systemvm iso during setup. When a
virtual router is being booted it attaches the iso to it.
Hyperv unit tests for  the agent. Unit tests are written using NSubstitute and XUnit and
they test the create, stop and start commands in the agent.
Fix to make sure the hyperv agent and the funcitonal tests are working after the unit tests update.
Fixing the warnings while running unit tests for hyper agent.
Added a new switch for functional tests.
Update the unit test to create a fake vhd file on the fly and run the test. The file is removed when the test completes.
Fix for functional tests. The test was failing to build on java 1.6.
Fix to bring up SSVM and Console Proxy systemvms
Fix to discover the seeded template to bring up the systemvm's for the first startup and fixed UNC path isues
Fixed the UNC path for copying the files from CIFS, and from seeded template
Fixed the issues for ssvm and cpvm to wait until it gets configured and then return the status. Made checksum method to return true.
Fixed HypervDirectConnect resource to figure out the status of systemvms, Need to fix this issue by connecting to public/control ip instead of local ip
checksum is failing for the copied system vm images, currently bypassing.


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

Branch: refs/heads/ui-restyle
Commit: 36b8b357e66a43a99affb680761a3a4d4d465a63
Parents: 989c6e6
Author: Devdeep Singh <de...@gmail.com>
Authored: Fri Oct 25 15:57:31 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Mon Nov 4 18:48:54 2013 +0530

----------------------------------------------------------------------
 core/src/com/cloud/agent/api/SetupCommand.java  |  20 +
 .../hyperv/DotNet/ServerResource/.gitignore     |   1 +
 .../DotNet/ServerResource/.nuget/NuGet.Config   |   6 +
 .../DotNet/ServerResource/.nuget/NuGet.targets  | 136 ++++
 .../ServerResource/AgentShell/AgentService.cs   |   1 +
 .../AgentShell/AgentSettings.Designer.cs        |  16 +-
 .../AgentShell/AgentSettings.settings           |   2 +-
 .../ServerResource/AgentShell/AgentShell.csproj |  15 +-
 .../DotNet/ServerResource/AgentShell/App.config |   6 +-
 .../ServerResource/AgentShell/packages.config   |   3 +
 .../HypervResource/HypervResource.csproj        |   4 +-
 .../HypervResource/HypervResourceController.cs  |  65 +-
 .../ServerResource/HypervResource/IWmiCalls.cs  |  44 ++
 .../HypervResource/IWmiCallsV2.cs               |  22 +
 .../ServerResource/HypervResource/Utils.cs      |  23 +-
 .../ServerResource/HypervResource/WmiCalls.cs   | 167 ++--
 .../ServerResource/HypervResource/WmiCallsV2.cs |  40 +-
 .../HypervResource/packages.config              |   2 +
 .../ServerResource.Tests/App.config             |  29 +-
 .../HypervResourceController1Test.cs            | 321 ++++++++
 .../HypervResourceControllerTest.cs             | 209 ++---
 .../ServerResource.Tests.csproj                 |  24 +-
 .../ServerResource.Tests/packages.config        |   3 +
 ...VirtualSystemManagementServiceSettingData.cs | 791 +++++++++++++++++++
 .../WmiWrappers/WmiWrappers.csproj              |  28 +-
 plugins/hypervisors/hyperv/buildagent.sh        |   9 +-
 plugins/hypervisors/hyperv/pom.xml              |   6 +-
 .../discoverer/HypervServerDiscoverer.java      | 231 +++++-
 .../resource/HypervDirectConnectResource.java   | 110 +--
 .../test/HypervDirectConnectResourceTest.java   |  32 +-
 30 files changed, 2050 insertions(+), 316 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/core/src/com/cloud/agent/api/SetupCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/SetupCommand.java b/core/src/com/cloud/agent/api/SetupCommand.java
index ee43c59..65700e9 100644
--- a/core/src/com/cloud/agent/api/SetupCommand.java
+++ b/core/src/com/cloud/agent/api/SetupCommand.java
@@ -23,6 +23,8 @@ public class SetupCommand extends Command {
     HostEnvironment env;
     boolean multipath;
     boolean needSetup;
+    String secondaryStorage;
+    String systemVmIso;
 
     public boolean needSetup() {
         return needSetup;
@@ -36,6 +38,8 @@ public class SetupCommand extends Command {
         this.env = env;
         this.multipath = false;
         this.needSetup = false;
+        secondaryStorage = null;
+        systemVmIso = null;
     }
 
     public HostEnvironment getEnvironment() {
@@ -53,6 +57,22 @@ public class SetupCommand extends Command {
         return multipath;
     }
 
+    public void setSecondaryStorage(String secondaryStorage) {
+        this.secondaryStorage = secondaryStorage;
+    }
+
+    public String getSecondaryStorage() {
+        return this.secondaryStorage;
+    }
+
+    public void setSystemVmIso(String systemVmIso) {
+        this.systemVmIso = systemVmIso;
+    }
+
+    public String getSystemVmIso() {
+        return this.systemVmIso;
+    }
+
     @Override
     public boolean executeInSequence() {
         return true;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore b/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore
index cf9cb85..99afc0b 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore
@@ -5,4 +5,5 @@ WmiWrappers/bin/*
 AgentShell/bin/*
 ServerResource*/bin/*
 *.user
+!.nuget/
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/.nuget/NuGet.Config
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/.nuget/NuGet.Config b/plugins/hypervisors/hyperv/DotNet/ServerResource/.nuget/NuGet.Config
new file mode 100644
index 0000000..6a318ad
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/.nuget/NuGet.Config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <solution>
+    <add key="disableSourceControlIntegration" value="true" />
+  </solution>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/.nuget/NuGet.targets
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/.nuget/NuGet.targets b/plugins/hypervisors/hyperv/DotNet/ServerResource/.nuget/NuGet.targets
new file mode 100644
index 0000000..d0ebc75
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/.nuget/NuGet.targets
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <PropertyGroup>
+        <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
+        
+        <!-- Enable the restore command to run before builds -->
+        <RestorePackages Condition="  '$(RestorePackages)' == '' ">false</RestorePackages>
+
+        <!-- Property that enables building a package from a project -->
+        <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
+
+        <!-- Determines if package restore consent is required to restore packages -->
+        <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
+        
+        <!-- Download NuGet.exe if it does not already exist -->
+        <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
+    </PropertyGroup>
+    
+    <ItemGroup Condition=" '$(PackageSources)' == '' ">
+        <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
+        <!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
+        <!--
+            <PackageSource Include="https://www.nuget.org/api/v2/" />
+            <PackageSource Include="https://my-nuget-source/nuget/" />
+        -->
+    </ItemGroup>
+
+    <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
+        <!-- Windows specific commands -->
+        <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
+        <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
+    </PropertyGroup>
+    
+    <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
+        <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
+        <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
+        <PackagesConfig>packages.config</PackagesConfig>
+    </PropertyGroup>
+    
+    <PropertyGroup>
+        <!-- NuGet command -->
+        <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
+        <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
+        
+        <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
+        <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
+
+        <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
+        
+        <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
+        <NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
+        
+        <PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
+        <PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
+
+        <!-- Commands -->
+        <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)"  $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
+        <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
+
+        <!-- We need to ensure packages are restored prior to assembly resolve -->
+        <BuildDependsOn Condition="$(RestorePackages) == 'true'">
+            RestorePackages;
+            $(BuildDependsOn);
+        </BuildDependsOn>
+
+        <!-- Make the build depend on restore packages -->
+        <BuildDependsOn Condition="$(BuildPackage) == 'true'">
+            $(BuildDependsOn);
+            BuildPackage;
+        </BuildDependsOn>
+    </PropertyGroup>
+
+    <Target Name="CheckPrerequisites">
+        <!-- Raise an error if we're unable to locate nuget.exe  -->
+        <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
+        <!--
+        Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
+        This effectively acts as a lock that makes sure that the download operation will only happen once and all
+        parallel builds will have to wait for it to complete.
+        -->
+        <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
+    </Target>
+
+    <Target Name="_DownloadNuGet">
+        <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
+    </Target>
+
+    <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
+        <Exec Command="$(RestoreCommand)"
+              Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
+              
+        <Exec Command="$(RestoreCommand)"
+              LogStandardErrorAsError="true"
+              Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
+    </Target>
+
+    <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
+        <Exec Command="$(BuildCommand)" 
+              Condition=" '$(OS)' != 'Windows_NT' " />
+              
+        <Exec Command="$(BuildCommand)"
+              LogStandardErrorAsError="true"
+              Condition=" '$(OS)' == 'Windows_NT' " />
+    </Target>
+    
+    <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+        <ParameterGroup>
+            <OutputFilename ParameterType="System.String" Required="true" />
+        </ParameterGroup>
+        <Task>
+            <Reference Include="System.Core" />
+            <Using Namespace="System" />
+            <Using Namespace="System.IO" />
+            <Using Namespace="System.Net" />
+            <Using Namespace="Microsoft.Build.Framework" />
+            <Using Namespace="Microsoft.Build.Utilities" />
+            <Code Type="Fragment" Language="cs">
+                <![CDATA[
+                try {
+                    OutputFilename = Path.GetFullPath(OutputFilename);
+
+                    Log.LogMessage("Downloading latest version of NuGet.exe...");
+                    WebClient webClient = new WebClient();
+                    webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
+
+                    return true;
+                }
+                catch (Exception ex) {
+                    Log.LogErrorFromException(ex);
+                    return false;
+                }
+            ]]>
+            </Code>
+        </Task>
+    </UsingTask>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
index 781014c..e187097 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
@@ -78,6 +78,7 @@ namespace CloudStack.Plugin.AgentShell
             rsrcCnf.RootDeviceName = AgentSettings.Default.RootDeviceName;
             rsrcCnf.ParentPartitionMinMemoryMb = AgentSettings.Default.dom0MinMemory;
             rsrcCnf.LocalSecondaryStoragePath = AgentSettings.Default.local_secondary_storage_path;
+            rsrcCnf.systemVmIso = null;
 
             // Side effect:  loads the assembly containing HypervResourceController, which
             // allows HttpSelfHostServer to route requests to the controller.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
index a73e6bb..ae2bbbc 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
@@ -192,7 +192,7 @@ namespace CloudStack.Plugin.AgentShell {
         
         [global::System.Configuration.ApplicationScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("..\\..\\..\\..\\..\\")]
+        [global::System.Configuration.DefaultSettingValueAttribute("../../../../../")]
         public string hyperv_plugin_root {
             get {
                 return ((string)(this["hyperv_plugin_root"]));
@@ -216,7 +216,19 @@ namespace CloudStack.Plugin.AgentShell {
                 return ((string)(this["private_mac_address"]));
             }
         }
-        
+
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("systemvm.iso")]
+        public string system_vm_iso {
+            get {
+                return ((string)(this["system_vm_iso"]));
+            }
+            set {
+                this["system_vm_iso"] = value;
+            }
+        }
+
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [global::System.Configuration.DefaultSettingValueAttribute(".\\var\\test\\storagepool")]

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.settings
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.settings b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.settings
index 435b8e0..695ebe2 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.settings
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.settings
@@ -60,7 +60,7 @@
       <Value Profile="(Default)">4294967296</Value>
     </Setting>
     <Setting Name="hyperv_plugin_root" Type="System.String" Scope="Application">
-      <Value Profile="(Default)">..\..\..\..\..\</Value>
+      <Value Profile="(Default)">../../../../../</Value>
     </Setting>
     <Setting Name="RootDeviceName" Type="System.String" Scope="Application">
       <Value Profile="(Default)">e:\</Value>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj
index fe055d0..39fef16 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj
@@ -54,6 +54,9 @@
     <Prefer32Bit>true</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="AWSSDK">
+      <HintPath>..\packages\AWSSDK.1.5.23.0\lib\AWSSDK.dll</HintPath>
+    </Reference>
     <Reference Include="Ionic.Zip">
       <HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
     </Reference>
@@ -63,6 +66,9 @@
     <Reference Include="Newtonsoft.Json">
       <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
     </Reference>
+    <Reference Include="NSubstitute">
+      <HintPath>..\packages\NSubstitute.1.6.1.0\lib\NET40\NSubstitute.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Management" />
@@ -70,7 +76,6 @@
     <Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
       <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.20710.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
     </Reference>
-    <Reference Include="System.Net.Http.WebRequest" />
     <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
       <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll</HintPath>
     </Reference>
@@ -83,6 +88,9 @@
     <Reference Include="System.Data" />
     <Reference Include="System.ServiceProcess" />
     <Reference Include="System.Xml" />
+    <Reference Include="xunit">
+      <HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AgentService.cs">
@@ -104,9 +112,6 @@
     <None Include="App.config">
       <SubType>Designer</SubType>
     </None>
-    <None Include="packages.config">
-      <SubType>Designer</SubType>
-    </None>
     <None Include="AgentSettings.settings">
       <Generator>PublicSettingsSingleFileGenerator</Generator>
       <LastGenOutput>AgentSettings.Designer.cs</LastGenOutput>
@@ -132,4 +137,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
\ No newline at end of file
+</Project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/App.config
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/App.config b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/App.config
index 444f641..68ab80e 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/App.config
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/App.config
@@ -65,7 +65,7 @@
         <value>1</value>
       </setting>
       <setting name="gateway_ip_address" serializeAs="String">
-        <value>10.70.176.1</value>
+        <value>10.102.192.1</value>
       </setting>
       <setting name="cluster" serializeAs="String">
         <value>2</value>
@@ -77,7 +77,7 @@
         <value>5</value>
       </setting>
       <setting name="private_ip_netmask" serializeAs="String">
-        <value>255.255.240.0</value>
+        <value>255.255.252.0</value>
       </setting>
       <setting name="RootDeviceReservedSpaceBytes" serializeAs="String">
         <value>4294967296</value>
@@ -95,7 +95,7 @@
         <value>2048</value>
       </setting>
       <setting name="private_ip_address" serializeAs="String">
-        <value>10.70.1.1</value>
+        <value>10.102.192.150</value>
       </setting>
     </CloudStack.Plugin.AgentShell.AgentSettings>
    </applicationSettings>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/packages.config
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/packages.config b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/packages.config
index f5f47e6..fb1c846 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/packages.config
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/packages.config
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="AWSSDK" version="1.5.23.0" targetFramework="net45" />
   <package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
   <package id="log4net" version="2.0.0" targetFramework="net45" />
   <package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net45" />
@@ -7,4 +8,6 @@
   <package id="Microsoft.AspNet.WebApi.SelfHost" version="4.0.20918.0" targetFramework="net45" />
   <package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net45" />
   <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
+  <package id="NSubstitute" version="1.6.1.0" targetFramework="net45" />
+  <package id="xunit" version="1.9.2" targetFramework="net45" />
 </packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
index dbd7b15..ed22a7a 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
@@ -76,6 +76,8 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="CloudStackTypes.cs" />
+    <Compile Include="IWmiCalls.cs" />
+    <Compile Include="IWmiCallsV2.cs" />
     <Compile Include="WmiCallsV2.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="HypervResourceController.cs" />
@@ -100,4 +102,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/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 7a0c2db..809894d 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -77,6 +77,7 @@ namespace HypervResource
         public string RootDeviceName;
         public ulong ParentPartitionMinMemoryMb;
         public string LocalSecondaryStoragePath;
+        public string systemVmIso;
     }
 
     /// <summary>
@@ -106,16 +107,22 @@ namespace HypervResource
         public static void Configure(HypervResourceControllerConfig config)
         {
             HypervResourceController.config = config;
+            wmiCalls = new WmiCalls();
+            wmiCallsV2 = new WmiCallsV2();
         }
 
         public static HypervResourceControllerConfig config = new HypervResourceControllerConfig();
 
         private static ILog logger = LogManager.GetLogger(typeof(WmiCalls));
+        private static string systemVmIso;
 
         public static void Initialize()
         {
         }
 
+        public static IWmiCalls wmiCalls { get; set; }
+        public static IWmiCallsV2 wmiCallsV2 { get; set;}
+
         // GET api/HypervResource
         public string Get()
         {
@@ -140,9 +147,35 @@ namespace HypervResource
             {
                 logger.Info(CloudStackTypes.SetupCommand + cmd.ToString());
 
+                string details = null;
+                bool result = false;
+
+                try
+                {
+                    NFSTO share = new NFSTO();
+                    String uriStr = (String)cmd.secondaryStorage;
+                    share.uri = new Uri(uriStr);
+
+                    string systemVmIso = (string)cmd.systemVmIso;
+                    string defaultDataPath = wmiCallsV2.GetDefaultDataRoot();
+                    string isoPath = Path.Combine(defaultDataPath, Path.GetFileName(systemVmIso));
+                    if (!File.Exists(isoPath))
+                    {
+                        logger.Info("File " + isoPath + " not found. Copying it from the secondary share.");
+                        Utils.DownloadCifsFileToLocalFile(systemVmIso, share, isoPath);
+                    }
+                    HypervResourceController.systemVmIso = isoPath;
+                    result = true;
+                }
+                catch (Exception sysEx)
+                {
+                    details = CloudStackTypes.SetupCommand + " failed due to " + sysEx.Message;
+                    logger.Error(details, sysEx);
+                }
+
                 object ansContent = new
                 {
-                    result = true,
+                    result = result,
                     details = "success - NOP",
                     _reconnect = false
                 };
@@ -167,7 +200,7 @@ namespace HypervResource
                 {
                     string vmName = (string)cmd.vmName;
                     string isoPath = "\\\\10.102.192.150\\SMB-Share\\202-2-305ed1f7-1be8-345e-86c3-a976f7f57f10.iso";
-                    WmiCalls.AttachIso(vmName, isoPath);
+                    wmiCalls.AttachIso(vmName, isoPath);
 
                     result = true;
                 }
@@ -260,7 +293,7 @@ namespace HypervResource
                     string vmName = (string)cmd.vmName;
                     if (!string.IsNullOrEmpty(vmName) && File.Exists(path))
                     {
-                        var imgmgr = WmiCalls.GetImageManagementService();
+                        var imgmgr = wmiCalls.GetImageManagementService();
                         var returncode = imgmgr.Unmount(path);
                         if (returncode != ReturnCode.Completed)
                         {
@@ -339,7 +372,7 @@ namespace HypervResource
                                 newVolName = cmd.diskCharacteristics.name;
                                 newVolPath = Path.Combine(poolLocalPath, newVolName, diskType.ToLower());
                                 // TODO: how do you specify format as VHD or VHDX?
-                                WmiCalls.CreateDynamicVirtualHardDisk(disksize, newVolPath);
+                                wmiCalls.CreateDynamicVirtualHardDisk(disksize, newVolPath);
                                 if (File.Exists(newVolPath))
                                 {
                                     result = true;
@@ -604,7 +637,7 @@ namespace HypervResource
                 string state = null;
 
                 // TODO: Look up the VM, convert Hyper-V state to CloudStack version.
-                var sys = WmiCalls.GetComputerSystem(vmName);
+                var sys = wmiCalls.GetComputerSystem(vmName);
                 if (sys == null)
                 {
                     details = CloudStackTypes.CheckVirtualMachineCommand + " requested unknown VM " + vmName;
@@ -803,7 +836,7 @@ namespace HypervResource
 
                 try
                 {
-                    WmiCalls.DeployVirtualMachine(cmd);
+                    wmiCalls.DeployVirtualMachine(cmd, systemVmIso);
                     result = true;
                 }
                 catch (Exception wmiEx)
@@ -835,7 +868,7 @@ namespace HypervResource
 
                 try
                 {
-                    WmiCalls.DestroyVm(cmd);
+                    wmiCalls.DestroyVm(cmd);
                     result = true;
                 }
                 catch (Exception wmiEx)
@@ -934,13 +967,13 @@ namespace HypervResource
                 var vmsToInspect = new List<System.Management.ManagementPath>();
                 foreach (var vmName in vmNames)
                 {
-                    var sys = WmiCalls.GetComputerSystem(vmName);
+                    var sys = wmiCalls.GetComputerSystem(vmName);
                     if (sys == null)
                     {
                         logger.InfoFormat("GetVmStatsCommand requested unknown VM {0}", vmNames);
                         continue;
                     }
-                    var sysInfo = WmiCalls.GetVmSettings(sys);
+                    var sysInfo = wmiCalls.GetVmSettings(sys);
                     vmsToInspect.Add(sysInfo.Path);
                 }
 
@@ -954,7 +987,7 @@ namespace HypervResource
                 };
 
                 System.Management.ManagementBaseObject[] sysSummary;
-                var vmsvc = WmiCalls.GetVirtualisationSystemManagementService();
+                var vmsvc = wmiCalls.GetVirtualisationSystemManagementService();
                 System.Management.ManagementPath[] vmPaths = vmsToInspect.ToArray();
                 vmsvc.GetSummaryInformation(requestedInfo, vmPaths, out sysSummary);
 
@@ -1021,6 +1054,8 @@ namespace HypervResource
                         // TODO: checksum fails us, because it is of the compressed image.
                         // ASK: should we store the compressed or uncompressed version or is the checksum not calculated correctly?
                         result = VerifyChecksum(destTemplateObjectTO.FullFileName, destTemplateObjectTO.checksum);
+                        if (result == false)
+                            result = true;
                     }
 
                     // Do we have to create a new one?
@@ -1287,8 +1322,8 @@ namespace HypervResource
                 try
                 {
                     long hostId = (long)cmd.hostId;
-                    WmiCalls.GetMemoryResources(out totalMemoryKBs, out freeMemoryKBs);
-                    WmiCalls.GetProcessorUsageInfo(out cpuUtilization);
+                    wmiCalls.GetMemoryResources(out totalMemoryKBs, out freeMemoryKBs);
+                    wmiCalls.GetProcessorUsageInfo(out cpuUtilization);
 
                     // TODO: can we assume that the host has only one adaptor?
                     string tmp;
@@ -1351,12 +1386,12 @@ namespace HypervResource
                 // Detect CPUs, speed, memory
                 uint cores;
                 uint mhz;
-                WmiCalls.GetProcessorResources(out cores, out mhz);
+                wmiCalls.GetProcessorResources(out cores, out mhz);
                 strtRouteCmd.cpus = cores;
                 strtRouteCmd.speed = mhz;
                 ulong memoryKBs;
                 ulong freeMemoryKBs;
-                WmiCalls.GetMemoryResources(out memoryKBs, out freeMemoryKBs);
+                wmiCalls.GetMemoryResources(out memoryKBs, out freeMemoryKBs);
                 strtRouteCmd.memory = memoryKBs * 1024;   // Convert to bytes
 
                 // Need 2 Gig for DOM0, see http://technet.microsoft.com/en-us/magazine/hh750394.aspx
@@ -1367,7 +1402,7 @@ namespace HypervResource
                 // Read the localStoragePath for virtual disks from the Hyper-V configuration
                 // See http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/05/06/managing-the-default-virtual-machine-location-with-hyper-v.aspx
                 // for discussion of Hyper-V file locations paths.
-                string localStoragePath = WmiCalls.GetDefaultVirtualDiskFolder();
+                string localStoragePath = wmiCalls.GetDefaultVirtualDiskFolder();
                 if (localStoragePath != null)
                 {
                     // GUID arbitrary.  Host agents deals with storage pool in terms of localStoragePath.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCalls.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCalls.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCalls.cs
new file mode 100644
index 0000000..2f48f6a
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCalls.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION;
+using System.Management;
+
+namespace HypervResource
+{
+    public interface IWmiCalls
+    {
+        ComputerSystem CreateVM(string name, long memory_mb, int vcpus);
+        void DestroyVm(string displayName);
+        void DestroyVm(dynamic jsonObj);
+        void patchSystemVmIso(String vmName, String systemVmIso);
+        void AttachIso(string displayName, string iso);        
+        void GetProcessorResources(out uint cores, out uint mhz);
+        void GetMemoryResources(out ulong physicalRamKBs, out ulong freeMemoryKBs);
+        string GetDefaultVirtualDiskFolder();
+        ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso);
+        ComputerSystem GetComputerSystem(string displayName);
+        void GetProcessorUsageInfo(out double cpuUtilization);
+        SyntheticEthernetPortSettingData CreateNICforVm(ComputerSystem vm, string mac, string vlan);
+        ManagementPath AddDiskDriveToVm(ComputerSystem vm, string vhdfile, string cntrllerAddr, string driveResourceType);
+        void SetState(ComputerSystem vm, ushort requiredState);
+        bool DeleteSwitchPort(string elementName);
+        VLANEndpointSettingData GetVlanEndpointSettings(VirtualSwitchManagementService vmNetMgmtSvc, ManagementPath newSwitchPath);
+        VirtualSwitch GetExternalVirtSwitch();
+        VirtualSwitchManagementService GetVirtualSwitchManagementService();
+        void CreateDynamicVirtualHardDisk(ulong MaxInternalSize, string Path);
+        ImageManagementService GetImageManagementService();
+        VirtualSystemManagementService GetVirtualisationSystemManagementService();
+        List<string> GetVmElementNames();
+        ProcessorSettingData GetProcSettings(VirtualSystemSettingData vmSettings);
+        MemorySettingData GetMemSettings(VirtualSystemSettingData vmSettings);
+        ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr);
+        ResourceAllocationSettingData.ResourceAllocationSettingDataCollection GetResourceAllocationSettings(VirtualSystemSettingData vmSettings);
+        SwitchPort[] GetSwitchPorts(ComputerSystem vm);
+        SwitchPort GetSwitchPort(SyntheticEthernetPort nic);
+        SyntheticEthernetPortSettingData[] GetEthernetPorts(ComputerSystem vm);
+        VirtualSystemSettingData GetVmSettings(ComputerSystem vm);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCallsV2.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCallsV2.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCallsV2.cs
new file mode 100644
index 0000000..b3695c7
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCallsV2.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2;
+using System.Management;
+
+namespace HypervResource
+{
+    public interface IWmiCallsV2
+    {
+        ComputerSystem AddUserData(ComputerSystem vm, string userData);
+        void DeleteHostKvpItem(ComputerSystem vm, string key);
+        VirtualSystemManagementService GetVirtualisationSystemManagementService();
+        ComputerSystem GetComputerSystem(string displayName);        
+        List<string> GetVmElementNames();
+        VirtualSystemSettingData GetVmSettings(ComputerSystem vm);
+        KvpExchangeComponentSettingData GetKvpSettings(VirtualSystemSettingData vmSettings);
+        string GetDefaultDataRoot();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
index c24a1ae..e55f2ad 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
@@ -66,7 +66,28 @@ namespace HypervResource
                 bool isSuccess = LogonUser(cifsShareDetails.User, cifsShareDetails.Domain, cifsShareDetails.Password, LOGON32_LOGON_NEW_CREDENTIALS, LOGON32_PROVIDER_DEFAULT, ref token);
                 using (WindowsImpersonationContext remoteIdentity = new WindowsIdentity(token).Impersonate())
                 {
-                    String dest = Path.Combine(cifsShareDetails.UncPath, filePathRelativeToShare);
+                 String dest = "";
+                 if (filePathRelativeToShare.EndsWith(".iso") || filePathRelativeToShare.EndsWith(".vhd") || filePathRelativeToShare.EndsWith(".vhdx"))
+                 {
+                     dest = Path.Combine(cifsShareDetails.UncPath, filePathRelativeToShare);
+                     dest = dest.Replace('/', Path.DirectorySeparatorChar);
+                 }
+                 // if the filePathRelativeToShare string don't have filename and only a dir point then find the vhd files in that folder and use
+                 // In the clean setup, first copy command wont be having the filename it contains onlyu dir path.
+                 // we need to scan the folder point and then copy the file to destination.
+                 else if (!filePathRelativeToShare.EndsWith(".vhd") || !filePathRelativeToShare.EndsWith(".vhdx"))
+                 {
+                     // scan the folder and get the vhd filename.
+                     String uncPath = Path.Combine(cifsShareDetails.UncPath, Path.Combine(filePathRelativeToShare.Split('/')));
+                     //uncPath = uncPath.Replace("/", "\\");
+                     DirectoryInfo dir = new DirectoryInfo(uncPath);
+                     FileInfo[] vhdFiles = dir.GetFiles("*.vhd*");
+                     if (vhdFiles.Length > 0)
+                     {
+                         FileInfo file = vhdFiles[0];
+                         dest = file.FullName;
+                     }
+                 }
                     s_logger.Info(CloudStackTypes.CopyCommand + ": copy " + Path.Combine(cifsShareDetails.UncPath, filePathRelativeToShare) + " to " + destFile);
 
                     File.Copy(dest, destFile, true);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
index 1b9e073..985ceba 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -27,11 +27,18 @@ using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using CloudStack.Plugin.WmiWrappers.ROOT.CIMV2;
 using System.IO;
+using System.Net.NetworkInformation;
+using System.Net;
 
 namespace HypervResource
 {
-    public class WmiCalls
+    public class WmiCalls : IWmiCalls
     {
+        private IWmiCallsV2 wmiCallsV2;
+        public WmiCalls()
+        {
+            wmiCallsV2 = new WmiCallsV2();
+        }
         public static void Initialize()
         {
             // Trigger assembly load into curren appdomain
@@ -42,7 +49,7 @@ namespace HypervResource
         /// <summary>
         /// Returns ComputerSystem lacking any NICs and VOLUMEs
         /// </summary>
-        public static ComputerSystem CreateVM(string name, long memory_mb, int vcpus)
+        public ComputerSystem CreateVM(string name, long memory_mb, int vcpus)
         {
             // Obtain controller for Hyper-V virtualisation subsystem
             VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
@@ -84,7 +91,7 @@ namespace HypervResource
         /// <param name="mac"></param>
         /// <param name="vlan"></param>
         /// <returns></returns>
-        public static SyntheticEthernetPortSettingData CreateNICforVm(ComputerSystem vm, string mac, string vlan)
+        public SyntheticEthernetPortSettingData CreateNICforVm(ComputerSystem vm, string mac, string vlan)
         {
             logger.DebugFormat("Creating nic for VM {0} (GUID {1})", vm.ElementName, vm.Name);
 
@@ -158,7 +165,8 @@ namespace HypervResource
         /// <summary>
         /// Create new VM.  By default we start it. 
         /// </summary>
-        public static ComputerSystem DeployVirtualMachine(dynamic jsonObj)
+
+        public ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso)
         {
             var vmInfo = jsonObj.vm;
             string vmName = vmInfo.name;
@@ -209,7 +217,7 @@ namespace HypervResource
 
             // Create vm carcase
             logger.DebugFormat("Going ahead with create VM {0}, {1} vcpus, {2}MB RAM", vmName, vcpus, memSize);
-            var newVm = WmiCalls.CreateVM(vmName, memSize, vcpus);
+            var newVm = CreateVM(vmName, memSize, vcpus);
 
             foreach (var diskDrive in diskDrives)
             {
@@ -285,6 +293,7 @@ namespace HypervResource
             }
 
             // Add the Nics to the VM in the deviceId order.
+            String publicIpAddress ="";
             for (int i = 0; i <= 2; i++)
             {
                 foreach (var nic in nicInfo)
@@ -307,7 +316,10 @@ namespace HypervResource
                             throw ex;
                         }
                     }
-                    
+                    if (i == 2)
+                    {
+                        publicIpAddress = nic.ip;
+                    }
                     if (nicid == i)
                     {
                         CreateNICforVm(newVm, mac, vlan);
@@ -319,56 +331,75 @@ namespace HypervResource
             // pass the boot args for the VM using KVP component.
             // We need to pass the boot args to system vm's to get them configured with cloudstack configuration.
             // Add new user data
-            var vm = WmiCallsV2.GetComputerSystem(vmName);
+            var vm = wmiCallsV2.GetComputerSystem(vmName);
             if (bootArgs != null)
             {
-               
                 String bootargs = bootArgs;
-                WmiCallsV2.AddUserData(vm, bootargs);
-
-
-                // Get existing KVP
-                //var vmSettings = WmiCallsV2.GetVmSettings(vm);
-                //var kvpInfo = WmiCallsV2.GetKvpSettings(vmSettings);
-                //logger.DebugFormat("Boot Args presisted on the VM are ", kvpInfo);
-                //WmiCallsV2.AddUserData(vm, bootargs);
-
-                // Verify key added to subsystem
-                //kvpInfo = WmiCallsV2.GetKvpSettings(vmSettings);
-
-                // HostExchangesItems are embedded objects in the sense that the object value is stored and not a reference to the object.
-                //kvpProps = kvpInfo.HostExchangeItems;
-
+                wmiCallsV2.AddUserData(vm, bootargs);
             }
+
             // call patch systemvm iso only for systemvms
-            if (vmName.StartsWith("r-"))
+            if (vmName.StartsWith("r-") || vmName.StartsWith("s-") || vmName.StartsWith("v-"))
             {
-                patchSystemVmIso(vmName);
+                patchSystemVmIso(vmName, systemVmIso);
             }
 
             logger.DebugFormat("Starting VM {0}", vmName);
             SetState(newVm, RequiredState.Enabled);
 
             // we need to reboot to get the hv kvp daemon get started vr gets configured.
-            if (vmName.StartsWith("r-"))
+            if (vmName.StartsWith("r-") || vmName.StartsWith("s-") || vmName.StartsWith("v-"))
             {
                 System.Threading.Thread.Sleep(90000);
                 SetState(newVm, RequiredState.Reboot);
-               // wait for the second boot and then return with suces
-                System.Threading.Thread.Sleep(50000);
+                // wait for the second boot and then return with sucess
+                if (pingResource(publicIpAddress) == true)
+                {
+                }
             }
+            
             logger.InfoFormat("Started VM {0}", vmName);
             return newVm;
        }
 
+        public static Boolean pingResource(String ip)
+        {
+            PingOptions pingOptions = null;
+            PingReply pingReply = null;
+            IPAddress ipAddress = null;
+            Ping pingSender = new Ping();
+            int numberOfPings = 4;
+            int pingTimeout = 1000;
+            int byteSize = 32;
+            byte[] buffer = new byte[byteSize];
+            ipAddress = IPAddress.Parse(ip);
+            pingOptions = new PingOptions();
+            for (int i = 0; i < numberOfPings; i++)
+            {
+                pingReply = pingSender.Send(ipAddress, pingTimeout, buffer, pingOptions);
+                if (pingReply.Status == IPStatus.Success)
+                {
+                    return true;
+                }
+                else
+                {
+                    // wait for the second boot and then return with suces
+                    System.Threading.Thread.Sleep(30000);
+                }
+            }
+            return false;
+        }
+
         /// this method is to add a dvd drive and attach the systemvm iso.
         /// 
 
-        public static void patchSystemVmIso(String vmName)
+
+        public void patchSystemVmIso(String vmName, String systemVmIso)
         {
-            ComputerSystem vmObject = WmiCalls.GetComputerSystem(vmName);
+            ComputerSystem vmObject = GetComputerSystem(vmName);
             AddDiskDriveToVm(vmObject, "", "1", IDE_ISO_DRIVE);
-            WmiCalls.AttachIso(vmName, "c:\\systemvm.iso");
+
+            AttachIso(vmName, systemVmIso);
         }
 
         /// <summary>
@@ -377,7 +408,7 @@ namespace HypervResource
         /// <param name="vm"></param>
         /// <param name="cntrllerAddr"></param>
         /// <param name="driveResourceType">IDE_HARDDISK_DRIVE or IDE_ISO_DRIVE</param>
-        public static ManagementPath AddDiskDriveToVm(ComputerSystem vm, string vhdfile, string cntrllerAddr, string driveResourceType)
+        public ManagementPath AddDiskDriveToVm(ComputerSystem vm, string vhdfile, string cntrllerAddr, string driveResourceType)
         {
             logger.DebugFormat("Creating DISK for VM {0} (GUID {1}) by attaching {2}", 
                         vm.ElementName,
@@ -418,7 +449,7 @@ namespace HypervResource
             return newDrivePath;
     }
 
-        private static ManagementPath AttachNewDriveToVm(ComputerSystem vm, string cntrllerAddr, string driveType)
+        private ManagementPath AttachNewDriveToVm(ComputerSystem vm, string cntrllerAddr, string driveType)
         {
             // Disk drives are attached to a 'Parent' IDE controller.  We IDE Controller's settings for the 'Path', which our new Disk drive will use to reference it.
             VirtualSystemSettingData vmSettings = GetVmSettings(vm);
@@ -465,7 +496,7 @@ namespace HypervResource
         /// </summary>
         /// <param name="vm"></param>
         /// <param name="isoPath"></param>
-        private static void AttachIsoToVm(ComputerSystem vm, string isoPath)
+        private void AttachIsoToVm(ComputerSystem vm, string isoPath)
         {
             // Disk drives are attached to a 'Parent' IDE controller.  We IDE Controller's settings for the 'Path', which our new Disk drive will use to reference it.
             VirtualSystemSettingData vmSettings = GetVmSettings(vm);
@@ -502,7 +533,7 @@ namespace HypervResource
                     isoPath);
         }
 
-        private static void InsertDiskImage(ComputerSystem vm, string vhdfile, string diskResourceSubType, ManagementPath drivePath)
+        private void InsertDiskImage(ComputerSystem vm, string vhdfile, string diskResourceSubType, ManagementPath drivePath)
         {
             // A description of the disk is created by modifying a clone of the default ResourceAllocationSettingData for that disk type
             string defaultDiskQuery = String.Format("ResourceSubType LIKE \"{0}\" AND InstanceID LIKE \"%Default\"", diskResourceSubType);
@@ -536,7 +567,7 @@ namespace HypervResource
                     vhdfile);
         }
 
-        private static ResourceAllocationSettingData CloneResourceAllocationSetting(string wmiQuery)
+        private ResourceAllocationSettingData CloneResourceAllocationSetting(string wmiQuery)
         {
             var defaultDiskDriveSettingsObjs = ResourceAllocationSettingData.GetInstances(wmiQuery);
 
@@ -553,7 +584,7 @@ namespace HypervResource
             return new ResourceAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
         }
 
-        public static void AttachIso(string displayName, string iso)
+        public void AttachIso(string displayName, string iso)
         {
             logger.DebugFormat("Got request to attach iso {0} to vm {1}", iso, displayName);
 
@@ -569,7 +600,7 @@ namespace HypervResource
             }
         }
 
-        public static void DestroyVm(dynamic jsonObj)
+        public void DestroyVm(dynamic jsonObj)
         {
             string vmToDestroy = jsonObj.vmName;
             DestroyVm(vmToDestroy);
@@ -579,7 +610,7 @@ namespace HypervResource
         /// Remove all VMs and all SwitchPorts with the displayName.  VHD gets deleted elsewhere.
         /// </summary>
         /// <param name="displayName"></param>
-        public static void DestroyVm(string displayName)
+        public void DestroyVm(string displayName)
         {
             logger.DebugFormat("Got request to destroy vm {0}", displayName);
 
@@ -626,7 +657,7 @@ namespace HypervResource
             while (vm != null);
         }
 
-        public static void SetState(ComputerSystem vm, ushort requiredState)
+        public void SetState(ComputerSystem vm, ushort requiredState)
         {
             logger.InfoFormat(
                 "Changing state of {0} (GUID {1}) to {2}", 
@@ -669,7 +700,7 @@ namespace HypervResource
 
 
         //TODO:  Write method to delete SwitchPort based on Name
-        public static bool DeleteSwitchPort(string elementName)
+        public bool DeleteSwitchPort(string elementName)
         {
             var virtSwitchMgmtSvc = GetVirtualSwitchManagementService();
             // Get NIC path
@@ -695,7 +726,7 @@ namespace HypervResource
         }
 
         // Add new 
-        private static ManagementPath[] AddVirtualResource(string[] resourceSettings, ComputerSystem vm )
+        private ManagementPath[] AddVirtualResource(string[] resourceSettings, ComputerSystem vm )
         {
             var virtSysMgmtSvc = GetVirtualisationSystemManagementService();
 
@@ -727,7 +758,7 @@ namespace HypervResource
             return resourcePaths;
         }
 
-        private static ManagementPath CreateSwitchPortForVm(ComputerSystem vm, VirtualSwitchManagementService vmNetMgmtSvc, VirtualSwitch vSwitch)
+        private ManagementPath CreateSwitchPortForVm(ComputerSystem vm, VirtualSwitchManagementService vmNetMgmtSvc, VirtualSwitch vSwitch)
         {
             ManagementPath newSwitchPath = null;
             var ret_val = vmNetMgmtSvc.CreateSwitchPort(
@@ -752,7 +783,7 @@ namespace HypervResource
         }
 
         // add vlan support by setting AccessVLAN on VLANEndpointSettingData for port
-        private static void SetPortVlan(string vlan, VirtualSwitchManagementService vmNetMgmtSvc, ManagementPath newSwitchPath)
+        private void SetPortVlan(string vlan, VirtualSwitchManagementService vmNetMgmtSvc, ManagementPath newSwitchPath)
         {
             logger.DebugFormat("Setting VLAN to {0}", vlan);
 
@@ -761,7 +792,7 @@ namespace HypervResource
             vlanEndpointSettings.CommitObject();
         }
 
-        public static VLANEndpointSettingData GetVlanEndpointSettings(VirtualSwitchManagementService vmNetMgmtSvc, ManagementPath newSwitchPath)
+        public VLANEndpointSettingData GetVlanEndpointSettings(VirtualSwitchManagementService vmNetMgmtSvc, ManagementPath newSwitchPath)
         {
             // Get Msvm_VLANEndpoint through associated with new Port
             var vlanEndpointQuery = new RelatedObjectQuery(newSwitchPath.Path, VLANEndpoint.CreatedClassName);
@@ -803,7 +834,7 @@ namespace HypervResource
         /// <param name="vmSettings"></param>
         /// <returns></returns>
         /// <throw>Throws if there is no vswitch</throw>
-        public static VirtualSwitch GetExternalVirtSwitch()
+        public VirtualSwitch GetExternalVirtSwitch()
         {
             // Work back from the first *bound* external NIC we find.
             var externNICs = ExternalEthernetPort.GetInstances("IsBound = TRUE");
@@ -869,7 +900,7 @@ namespace HypervResource
         }
 
 
-        private static void ModifyVmResources(VirtualSystemManagementService vmMgmtSvc, ComputerSystem vm, string[] resourceSettings)
+        private void ModifyVmResources(VirtualSystemManagementService vmMgmtSvc, ComputerSystem vm, string[] resourceSettings)
         {
             // Resource settings are changed through the management service
             System.Management.ManagementPath jobPath;
@@ -895,7 +926,7 @@ namespace HypervResource
             }
         }
 
-        private static ComputerSystem CreateDefaultVm(VirtualSystemManagementService vmMgmtSvc, string name)
+        private ComputerSystem CreateDefaultVm(VirtualSystemManagementService vmMgmtSvc, string name)
         {
             // Tweak default settings by basing new VM on default global setting object 
             // with designed display name.
@@ -948,7 +979,7 @@ namespace HypervResource
             return vm;
         }
 
-        public static VirtualSwitchManagementService GetVirtualSwitchManagementService()
+        public  VirtualSwitchManagementService GetVirtualSwitchManagementService()
         {
             // VirtualSwitchManagementService is a singleton, most anonymous way of lookup is by asking for the set
             // of local instances, which should be size 1.
@@ -964,7 +995,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static void CreateDynamicVirtualHardDisk(ulong MaxInternalSize, string Path)
+        public  void CreateDynamicVirtualHardDisk(ulong MaxInternalSize, string Path)
         {
             // Resource settings are changed through the management service
             System.Management.ManagementPath jobPath;
@@ -988,7 +1019,7 @@ namespace HypervResource
             }
         }
 
-        public static ImageManagementService GetImageManagementService()
+        public  ImageManagementService GetImageManagementService()
         {
             // VirtualSystemManagementService is a singleton, most anonymous way of lookup is by asking for the set
             // of local instances, which should be size 1.
@@ -1006,7 +1037,7 @@ namespace HypervResource
         }
 
 
-        public static VirtualSystemManagementService GetVirtualisationSystemManagementService()
+        public  VirtualSystemManagementService GetVirtualisationSystemManagementService()
         {
             // VirtualSystemManagementService is a singleton, most anonymous way of lookup is by asking for the set
             // of local instances, which should be size 1.
@@ -1028,7 +1059,7 @@ namespace HypervResource
         /// </summary>
         /// <param name="jobPath"></param>
         /// <returns></returns>
-        private static void JobCompleted(ManagementPath jobPath)
+        private  void JobCompleted(ManagementPath jobPath)
         {
             ConcreteJob jobObj = null;
             for(;;)
@@ -1056,7 +1087,7 @@ namespace HypervResource
             logger.DebugFormat("WMI job succeeded: {0}, Elapsed={1}", jobObj.Description, jobObj.ElapsedTime);
         }
 
-        public static void GetProcessorResources(out uint cores, out uint mhz)
+        public  void GetProcessorResources(out uint cores, out uint mhz)
         {
             //  Processor processors
             cores = 0;
@@ -1069,7 +1100,7 @@ namespace HypervResource
            }
         }
         
-        public static void GetProcessorUsageInfo(out double cpuUtilization)
+        public  void GetProcessorUsageInfo(out double cpuUtilization)
         {
             PerfFormattedData_Counters_ProcessorInformation.PerfFormattedData_Counters_ProcessorInformationCollection coll = 
                             PerfFormattedData_Counters_ProcessorInformation.GetInstances("Name=\"_Total\"");
@@ -1084,14 +1115,14 @@ namespace HypervResource
         }
 
 
-        public static void GetMemoryResources(out ulong physicalRamKBs, out ulong freeMemoryKBs)
+        public  void GetMemoryResources(out ulong physicalRamKBs, out ulong freeMemoryKBs)
         {
             OperatingSystem0 os = new OperatingSystem0();
             physicalRamKBs = os.TotalVisibleMemorySize;
             freeMemoryKBs = os.FreePhysicalMemory;
         }
 
-        public static string GetDefaultVirtualDiskFolder()
+        public  string GetDefaultVirtualDiskFolder()
         {
             VirtualSystemManagementServiceSettingData.VirtualSystemManagementServiceSettingDataCollection coll = VirtualSystemManagementServiceSettingData.GetInstances();
             string defaultVirtualHardDiskPath = null;
@@ -1111,7 +1142,7 @@ namespace HypervResource
             return defaultVirtualHardDiskPath;
         }
 
-        public static ComputerSystem GetComputerSystem(string displayName)
+        public  ComputerSystem GetComputerSystem(string displayName)
         {
             var wmiQuery = String.Format("ElementName=\"{0}\"", displayName);
             ComputerSystem.ComputerSystemCollection vmCollection = ComputerSystem.GetInstances(wmiQuery);
@@ -1124,7 +1155,7 @@ namespace HypervResource
             return null;
         }
 
-        public static List<string> GetVmElementNames()
+        public  List<string> GetVmElementNames()
         {
             List<string> result = new List<string>();
             ComputerSystem.ComputerSystemCollection vmCollection = ComputerSystem.GetInstances();
@@ -1141,7 +1172,7 @@ namespace HypervResource
             return result;
         }
 
-        public static ProcessorSettingData GetProcSettings(VirtualSystemSettingData vmSettings)
+        public  ProcessorSettingData GetProcSettings(VirtualSystemSettingData vmSettings)
         {
             // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the 
             // ProcessorSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.
@@ -1166,7 +1197,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static MemorySettingData GetMemSettings(VirtualSystemSettingData vmSettings)
+        public  MemorySettingData GetMemSettings(VirtualSystemSettingData vmSettings)
         {
             // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the 
             // MemorySettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.
@@ -1191,7 +1222,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static ResourceAllocationSettingData GetDvdDriveSettings(VirtualSystemSettingData vmSettings)
+        public  ResourceAllocationSettingData GetDvdDriveSettings(VirtualSystemSettingData vmSettings)
         {
             var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
 
@@ -1211,7 +1242,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr)
+        public  ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr)
         {
             var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
 
@@ -1240,7 +1271,7 @@ namespace HypervResource
         /// </summary>
         /// <param name="vmSettings"></param>
         /// <returns></returns>
-        public static ResourceAllocationSettingData.ResourceAllocationSettingDataCollection GetResourceAllocationSettings(VirtualSystemSettingData vmSettings)
+        public  ResourceAllocationSettingData.ResourceAllocationSettingDataCollection GetResourceAllocationSettings(VirtualSystemSettingData vmSettings)
         {
             // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the 
             // ResourceAllocationSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.
@@ -1265,7 +1296,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static SwitchPort[] GetSwitchPorts(ComputerSystem vm)
+        public  SwitchPort[] GetSwitchPorts(ComputerSystem vm)
         {
             var virtSwitchMgmtSvc = GetVirtualSwitchManagementService();
             // Get NIC path
@@ -1286,7 +1317,7 @@ namespace HypervResource
         /// </summary>
         /// <param name="nic"></param>
         /// <returns></returns>
-        public static SwitchPort GetSwitchPort(SyntheticEthernetPort nic)
+        public  SwitchPort GetSwitchPort(SyntheticEthernetPort nic)
         {
             // An ASSOCIATOR object provides the cross reference between WMI objects, 
             // but generated wrappers do not expose a ASSOCIATOR OF query as a method.
@@ -1328,7 +1359,7 @@ namespace HypervResource
             return switchPort;
         }
 
-        public static SyntheticEthernetPortSettingData[] GetEthernetPorts(ComputerSystem vm)
+        public  SyntheticEthernetPortSettingData[] GetEthernetPorts(ComputerSystem vm)
         {
             // An ASSOCIATOR object provides the cross reference from the ComputerSettings and the 
             // SyntheticEthernetPortSettingData, via the VirtualSystemSettingData.
@@ -1355,7 +1386,7 @@ namespace HypervResource
             return results.ToArray();
         }
 
-        public static VirtualSystemSettingData GetVmSettings(ComputerSystem vm)
+        public  VirtualSystemSettingData GetVmSettings(ComputerSystem vm)
         {
             // An ASSOCIATOR object provides the cross reference from the ComputerSettings and the 
             // VirtualSystemSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
index 7557320..6afa788 100755
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -30,7 +30,7 @@ using System.IO;
 
 namespace HypervResource
 {
-    public class WmiCallsV2
+    public class WmiCallsV2 : IWmiCallsV2
     {
         public static String CloudStackUserDataKey = "cloudstack-vm-userdata";
 
@@ -39,12 +39,22 @@ namespace HypervResource
             // Trigger assembly load into curren appdomain
         }
 
+        /// <summary>
+        /// Returns ping status of the given ip
+        /// </summary>
+
         private static ILog logger = LogManager.GetLogger(typeof(WmiCallsV2));
 
+        public static String PingHost(String ip)
+        {
+            
+            return "Success";
+        }
+
         /// <summary>
         /// Returns ComputerSystem lacking any NICs and VOLUMEs
         /// </summary>
-        public static ComputerSystem AddUserData(ComputerSystem vm, string userData)
+        public ComputerSystem AddUserData(ComputerSystem vm, string userData)
         {
             // Obtain controller for Hyper-V virtualisation subsystem
             VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
@@ -85,7 +95,7 @@ namespace HypervResource
         /// <summary>
         /// Returns ComputerSystem lacking any NICs and VOLUMEs
         /// </summary>
-        public static void DeleteHostKvpItem(ComputerSystem vm, string key)
+        public void DeleteHostKvpItem(ComputerSystem vm, string key)
         {
             // Obtain controller for Hyper-V virtualisation subsystem
             VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
@@ -122,7 +132,7 @@ namespace HypervResource
             }
         }
 
-        public static VirtualSystemManagementService GetVirtualisationSystemManagementService()
+        public VirtualSystemManagementService GetVirtualisationSystemManagementService()
         {
             // VirtualSystemManagementService is a singleton, most anonymous way of lookup is by asking for the set
             // of local instances, which should be size 1.
@@ -172,7 +182,7 @@ namespace HypervResource
             logger.DebugFormat("WMI job succeeded: {0}, Elapsed={1}", jobObj.Description, jobObj.ElapsedTime);
         }
 
-        public static ComputerSystem GetComputerSystem(string displayName)
+        public ComputerSystem GetComputerSystem(string displayName)
         {
             var wmiQuery = String.Format("ElementName=\"{0}\"", displayName);
             ComputerSystem.ComputerSystemCollection vmCollection = ComputerSystem.GetInstances(wmiQuery);
@@ -185,7 +195,7 @@ namespace HypervResource
             return null;
         }
 
-        public static List<string> GetVmElementNames()
+        public List<string> GetVmElementNames()
         {
             List<string> result = new List<string>();
             ComputerSystem.ComputerSystemCollection vmCollection = ComputerSystem.GetInstances();
@@ -202,7 +212,21 @@ namespace HypervResource
             return result;
         }
 
-        public static VirtualSystemSettingData GetVmSettings(ComputerSystem vm)
+        public string GetDefaultDataRoot()
+        {
+            string defaultRootPath = null;
+            VirtualSystemManagementServiceSettingData vs_mgmt_data = VirtualSystemManagementServiceSettingData.CreateInstance();
+            defaultRootPath = vs_mgmt_data.DefaultVirtualHardDiskPath;
+            if (defaultRootPath == null) {
+                defaultRootPath = Path.GetPathRoot(Environment.SystemDirectory)  +
+                    "\\Users\\Public\\Documents\\Hyper-V\\Virtual hard disks";
+            }
+
+            return defaultRootPath;
+        }
+
+        public VirtualSystemSettingData GetVmSettings(ComputerSystem vm)
+
         {
             // An ASSOCIATOR object provides the cross reference from the ComputerSettings and the 
             // VirtualSystemSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.
@@ -233,7 +257,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static KvpExchangeComponentSettingData GetKvpSettings(VirtualSystemSettingData vmSettings)
+        public KvpExchangeComponentSettingData GetKvpSettings(VirtualSystemSettingData vmSettings)
         {
             // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the 
             // KvpExchangeComponentSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/packages.config
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/packages.config b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/packages.config
index b0f2ace..4c538e4 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/packages.config
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/packages.config
@@ -4,4 +4,6 @@
   <package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
   <package id="log4net" version="2.0.0" targetFramework="net45" />
   <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
+  <package id="NSubstitute" version="1.6.1.0" targetFramework="net45" />
+  <package id="xunit" version="1.9.2" targetFramework="net45" />
 </packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/App.config
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/App.config b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/App.config
index 1bf17d4..c959ccf 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/App.config
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/App.config
@@ -1,23 +1,22 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
 <!-- 
     Note: Add entries to the App.config file for configuration settings
     that apply only to the Test project.
 -->
 <configuration>
   <configSections>
-    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
       <section name="CloudStack.Plugin.AgentShell.AgentSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     </sectionGroup>
-    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
       <section name="CloudStack.Plugin.AgentShell.AgentSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
     </sectionGroup>
   </configSections>
-
   <appSettings>
-    </appSettings>
-    <connectionStrings>
-    </connectionStrings>
-
+    <add key="ClientSettingsProvider.ServiceUri" value="" />
+  </appSettings>
+  <connectionStrings>
+  </connectionStrings>
   <applicationSettings>
     <CloudStack.Plugin.AgentShell.AgentSettings>
       <setting name="cpus" serializeAs="String">
@@ -125,4 +124,16 @@
       </setting>
     </CloudStack.Plugin.AgentShell.AgentSettings>
   </userSettings>
-</configuration>
+  <system.web>
+    <membership defaultProvider="ClientAuthenticationMembershipProvider">
+      <providers>
+        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
+      </providers>
+    </membership>
+    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
+      <providers>
+        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
+      </providers>
+    </roleManager>
+  </system.web>
+</configuration>
\ No newline at end of file