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:31:43 UTC

[01/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Updated Branches:
  refs/heads/ui-restyle e13c32f34 -> b7259a48e


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
index ad6245e..da0c0d6 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
@@ -1,193 +1,175 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{DB824727-BDC3-437C-A364-7A811D8A160F}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>CloudStack.Plugin.WmiWrappers</RootNamespace>
-    <AssemblyName>WmiWrappers</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
-    <RestorePackages>true</RestorePackages>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTestsDebug|AnyCPU'">
-    <DebugSymbols>true</DebugSymbols>
-    <OutputPath>bin\NoUnitTestsDebug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <DebugType>full</DebugType>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTests|AnyCPU'">
-    <OutputPath>bin\NoUnitTests\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <Optimize>true</Optimize>
-    <DebugType>pdbonly</DebugType>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-  </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>
-    <Reference Include="log4net">
-      <HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
-    </Reference>
-    <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" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-    <Reference Include="xunit">
-      <HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
-    </Reference>
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="ROOT.CIMV2.Win32_OperatingSystem.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="root.CIMV2.Win32_PerfFormattedData_Counters_ProcessorInformation.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.CIMV2.Win32_Processor.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_ComputerSystem.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_ConcreteJob.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_ExternalEthernetPort.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_ImageManagementService.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_MemorySettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_ProcessorSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_ResourceAllocationSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_SummaryInformation.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_SwitchLANEndpoint.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_SwitchPort.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_SyntheticEthernetPort.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_SyntheticEthernetPortSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VirtualSwitch.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VirtualSwitchManagementService.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VirtualSystemGlobalSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VirtualSystemManagementService.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VirtualSystemManagementServiceSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VirtualSystemSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VLANEndpoint.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VLANEndpointSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.Msvm_VmLANEndpoint.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.v2.Msvm_ComputerSystem.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.v2.Msvm_ConcreteJob.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.v2.Msvm_KvpExchangeComponentSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.v2.Msvm_KvpExchangeDataItem.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemSettingData.cs">
-      <SubType>Component</SubType>
-    </Compile>
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Readme.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Properties\" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{DB824727-BDC3-437C-A364-7A811D8A160F}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>CloudStack.Plugin.WmiWrappers</RootNamespace>
+    <AssemblyName>WmiWrappers</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTestsDebug|AnyCPU'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\NoUnitTestsDebug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTests|AnyCPU'">
+    <OutputPath>bin\NoUnitTests\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </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>
+    <Reference Include="log4net">
+      <HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
+    </Reference>
+    <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" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="xunit">
+      <HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ROOT.CIMV2.Win32_OperatingSystem.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="root.CIMV2.Win32_PerfFormattedData_Counters_ProcessorInformation.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.CIMV2.Win32_Processor.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_ComputerSystem.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_ConcreteJob.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_ImageManagementService.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_KvpExchangeComponentSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_KvpExchangeDataItem.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_LANEndpoint.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_MemorySettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_SummaryInformation.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="Readme.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>


[39/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs
index 1226561..6cc5748 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs
@@ -1,321 +1,320 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-using System;
-using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION;
-using System.Management;
-using Newtonsoft.Json.Linq;
-using Newtonsoft.Json;
-using System.IO;
-using log4net;
-using HypervResource;
-using CloudStack.Plugin.AgentShell;
-using System.Collections.Generic;
-using NSubstitute;
-using System.Web.Http;
-using Xunit;
-
-namespace ServerResource.Tests
-{
-    public class HypervResourceController1Test
-    {
-
-        protected static string testCifsUrl = AgentSettings.Default.testCifsUrl;
-        protected static string testCifsPath = AgentSettings.Default.testCifsPath;
-        protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress;
-        protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName;
-        protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName;
-        protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName;
-        protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt;
-        protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2";
-        protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool");
-        protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary");
-
-        // TODO: differentiate between NFS and HTTP template URLs.
-        protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx";
-        protected static String testSampleTemplateURL = testSampleTemplateUUID;
-
-        // test volumes are both a minimal size vhdx.  Changing the extension to .vhd makes on corrupt.
-        protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx";
-        protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd";
-        protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx";
-        protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp";
-        protected static String testSampleVolumeWorkingURIJSON;
-        protected static String testSampleVolumeCorruptURIJSON;
-        protected static String testSampleVolumeTempURIJSON;
-
-        protected static String testSampleTemplateURLJSON;
-        protected static String testLocalStorePathJSON;
-
-        protected static IWmiCalls wmiCalls;
-
-
-        private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceController1Test));
-
-        /// <summary>
-        /// Test WmiCalls to which incoming HTTP POST requests are dispatched.
-        /// 
-        /// TODO: revise beyond first approximation
-        /// First approximation is a quick port of the existing Java tests for Hyper-V server resource.
-        /// A second approximation would use the AgentShell settings files directly.
-        /// A third approximation would look to invoke ServerResource methods via an HTTP request
-        /// </summary>
-
-        public HypervResourceController1Test()
-        {
-            wmiCalls = Substitute.For<IWmiCalls>();
-            //AgentService.ConfigServerResource();
-            HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address;
-            HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask;
-            HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress;
-            HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress;
-            HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask;
-
-
-            // Used to create existing StoragePool in preparation for the ModifyStoragePool
-            testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString();
-
-            // Make sure secondary store is available.
-            string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath);
-            s_logger.Info("Test secondary storage in " + fullPath);
-            DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath);
-            if (!testSecondarStoreDir.Exists)
-            {
-                try
-                {
-                    testSecondarStoreDir.Create();
-                }
-                catch (System.IO.IOException ex)
-                {
-                    throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message);
-                }
-            }
-
-            // Convert to secondary storage string to canonical path
-            testSecondaryStoreLocalPath = testSecondarStoreDir.FullName;
-            AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath;
-
-            // Make sure local primary storage is available
-            DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath);
-            //Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName);
-
-            // Convert to local primary storage string to canonical path
-            testLocalStorePath = testPoolDir.FullName;
-            AgentSettings.Default.local_storage_path = testLocalStorePath;
-
-            // Clean up old test files in local storage folder
-            FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID));
-            // Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName);           
-            
-            testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID);
-            s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage.");           
-
-
-            // Capture other JSON encoded paths
-            testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName);
-            testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath);
-
-            // TODO: may need to initialise the server resource in future.
-            //    s_hypervresource.initialize();
-
-            // Verify sample template is in place storage pool
-            s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON
-                      + " sample template at " + testSampleTemplateURLJSON);
-        }
-
-        private String CreateTestDiskImageFromExistingImage(FileInfo srcFile,
-        String dstPath,
-        String dstFileName)
-        {
-            var newFullname = Path.Combine(dstPath, dstFileName);
-            var newFileInfo = new FileInfo(newFullname);
-            if (!newFileInfo.Exists)
-            {
-                newFileInfo = srcFile.CopyTo(newFullname);
-            }
-            newFileInfo.Refresh();
-            Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName);
-
-            return JsonConvert.SerializeObject(newFileInfo.FullName);
-        }
-        
-        [Fact]
-        public void TestCreateCommand()
-        {
-            DirectoryInfo localStorePath = new DirectoryInfo(testLocalStorePath);
-            if (!localStorePath.Exists)
-            {
-                try
-                {
-                    localStorePath.Create();
-                }
-                catch (System.IO.IOException ex)
-                {
-                    throw new NotImplementedException("Need to be able to create the folder " + localStorePath.FullName + " failed due to " + ex.Message);
-                }
-            }
-
-            FileInfo sampleTemplateFile = new FileInfo(Path.Combine(testLocalStorePath, testSampleTemplateUUID));
-            if (!sampleTemplateFile.Exists)
-            {
-                //Create a file to write to.
-                using (StreamWriter sw = sampleTemplateFile.CreateText())
-                {
-                    sw.WriteLine("This is fake template file for test");
-                }
-            }
-            var counter = 0;
-            wmiCalls.When(x => x.CreateDynamicVirtualHardDisk(Arg.Any<ulong>(), Arg.Any<String>())).Do(x => counter++);
-            // TODO: Need sample to update the test.
-            // Arrange
-            String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" +
-                            ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," +
-                            "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," +
-                            "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}";
-            dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd);
-            HypervResourceController rsrcServer = new HypervResourceController();
-            HypervResourceController.wmiCalls = wmiCalls;
-
-            Assert.True(Directory.Exists(testLocalStorePath), testLocalStorePath + " does not exist ");
-            string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON));
-            Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath);
-            int fileCount = Directory.GetFiles(testLocalStorePath).Length;
-            s_logger.Debug(" test local store has " + fileCount + "files");
-
-            // Act
-            // Test requires there to be a template at the tempalteUrl, which is its location in the local file system.
-            dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd);
-            s_logger.Debug("CreateDynamicVirtualHardDisk method is called " + counter + " times");
-
-            //Assert.Equal(counter, 1);
-
-            JObject ansAsProperty2 = jsonResult[0];
-            dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
-            Assert.NotNull(ans);
-            Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result);
-            Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1);
-            FileInfo newFile = new FileInfo((string)ans.volume.path);
-            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
-            newFile.Delete();
-            sampleTemplateFile.Delete();
-        }
-
-        /// <summary>
-        /// Possible additional tests:  place an ISO in the drive
-        /// </summary>        
-
-        [Fact]
-        public void TestStartCommand()
-        {
-            ComputerSystem system = new ComputerSystem();
-            wmiCalls.DeployVirtualMachine(Arg.Any<Object>(), Arg.Any<string>()).Returns(system);
-
-            // Arrange
-            HypervResourceController rsrcServer = new HypervResourceController();
-            HypervResourceController.wmiCalls = wmiCalls;
-            String sample = getSampleStartCommand();
-
-
-            dynamic jsonStartCmd = JsonConvert.DeserializeObject(sample);
-
-            // Act
-            dynamic startAns = rsrcServer.StartCommand(jsonStartCmd);
-
-            // Assert
-            Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]);
-            Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details);
-
-            Assert.Null((string)startAns[0][CloudStackTypes.StartAnswer].details);            
-        }
-
-        [Fact]
-        public void TestStopCommand()
-        {
-            //string vmName = "Test VM";
-            var counter = 0;
-            wmiCalls.When(x => x.DestroyVm(Arg.Any<Object>())).Do(x => counter++);
-
-            // Arrange
-            HypervResourceController rsrcServer = new HypervResourceController();
-            HypervResourceController.wmiCalls = wmiCalls;
-
-            String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\",\"contextMap\":{},\"wait\":0}";
-            dynamic jsonStopCmd = JsonConvert.DeserializeObject(sampleStop);
-
-            // Act
-            dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd);
-
-            // Assert VM is gone!
-            Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]);
-            Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details);
-
-            Assert.Null((string)stopAns[0][CloudStackTypes.StopAnswer].details);
-            Assert.Equal<int>(counter, 1);
-        }
-
-        public static String getSamplePrimaryDataStoreInfo()
-        {
-            String samplePrimaryDataStoreInfo =
-            "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" +
-                "{\"uuid\":\"" + testLocalStoreUUID + "\"," +
-                "\"id\":201," +
-                "\"host\":\"" + testPrimaryDataStoreHost + "\"," +
-                "\"type\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
-                "\"poolType\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
-                "\"path\":" + testLocalStorePathJSON + "," +
-                "\"port\":0}" +
-            "}";
-            return samplePrimaryDataStoreInfo;
-        }
-
-        public static String getSampleVolumeObjectTO()
-        {
-            String sampleVolumeObjectTO =
-                    "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" +
-                        "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," +
-                        "\"volumeType\":\"ROOT\"," +
-                        "\"format\":\"VHDX\"," +
-                        "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
-                        "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," +
-                        "\"size\":52428800," +
-                        "\"volumeId\":10," +
-                //                            "\"vmName\":\"i-3-5-VM\"," +  // TODO: do we have to fill in the vmName?
-                        "\"accountId\":3,\"id\":10}" +
-                    "}";  // end of destTO 
-            return sampleVolumeObjectTO;
-        }
-
-        public static String getSampleStartCommand()
-        {
-            String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," +
-                                "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," +
-                                "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," +
-                                "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," +
-                                "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" +
-                            ",\"disks\":[" +
-                               "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," +
-                               "{\"diskSeq\":1,\"type\":\"ISO\"}" +
-                            "]," +
-                            "\"nics\":[" +
-                                    "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," +
-                                    "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," +
-                                    "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," +
-                                    "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" +
-                            "]},\"contextMap\":{},\"wait\":0}";
-            return sample;
-        }        
-    }
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+using System;
+using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2;
+using System.Management;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System.IO;
+using log4net;
+using HypervResource;
+using CloudStack.Plugin.AgentShell;
+using System.Collections.Generic;
+using NSubstitute;
+using System.Web.Http;
+using Xunit;
+
+namespace ServerResource.Tests
+{
+    public class HypervResourceController1Test
+    {
+        protected static string testCifsUrl = AgentSettings.Default.testCifsUrl;
+        protected static string testCifsPath = AgentSettings.Default.testCifsPath;
+        protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress;
+        protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName;
+        protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName;
+        protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName;
+        protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt;
+        protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2";
+        protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool");
+        protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary");
+
+        // TODO: differentiate between NFS and HTTP template URLs.
+        protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx";
+        protected static String testSampleTemplateURL = testSampleTemplateUUID;
+
+        // test volumes are both a minimal size vhdx.  Changing the extension to .vhd makes on corrupt.
+        protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx";
+        protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd";
+        protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx";
+        protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp";
+        protected static String testSampleVolumeWorkingURIJSON;
+        protected static String testSampleVolumeCorruptURIJSON;
+        protected static String testSampleVolumeTempURIJSON;
+
+        protected static String testSampleTemplateURLJSON;
+        protected static String testLocalStorePathJSON;
+
+        protected static IWmiCallsV2 wmiCallsV2;
+
+
+        private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceController1Test));
+
+        /// <summary>
+        /// Test WmiCalls to which incoming HTTP POST requests are dispatched.
+        /// 
+        /// TODO: revise beyond first approximation
+        /// First approximation is a quick port of the existing Java tests for Hyper-V server resource.
+        /// A second approximation would use the AgentShell settings files directly.
+        /// A third approximation would look to invoke ServerResource methods via an HTTP request
+        /// </summary>
+
+        public HypervResourceController1Test()
+        {
+            wmiCallsV2 = Substitute.For<IWmiCallsV2>();
+            //AgentService.ConfigServerResource();
+            HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address;
+            HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask;
+            HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress;
+            HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress;
+            HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask;
+
+
+            // Used to create existing StoragePool in preparation for the ModifyStoragePool
+            testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString();
+
+            // Make sure secondary store is available.
+            string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath);
+            s_logger.Info("Test secondary storage in " + fullPath);
+            DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath);
+            if (!testSecondarStoreDir.Exists)
+            {
+                try
+                {
+                    testSecondarStoreDir.Create();
+                }
+                catch (System.IO.IOException ex)
+                {
+                    throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message);
+                }
+            }
+
+            // Convert to secondary storage string to canonical path
+            testSecondaryStoreLocalPath = testSecondarStoreDir.FullName;
+            AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath;
+
+            // Make sure local primary storage is available
+            DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath);
+            //Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName);
+
+            // Convert to local primary storage string to canonical path
+            testLocalStorePath = testPoolDir.FullName;
+            AgentSettings.Default.local_storage_path = testLocalStorePath;
+
+            // Clean up old test files in local storage folder
+            FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID));
+            // Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName);           
+            
+            testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID);
+            s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage.");           
+
+
+            // Capture other JSON encoded paths
+            testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName);
+            testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath);
+
+            // TODO: may need to initialise the server resource in future.
+            //    s_hypervresource.initialize();
+
+            // Verify sample template is in place storage pool
+            s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON
+                      + " sample template at " + testSampleTemplateURLJSON);
+        }
+
+        private String CreateTestDiskImageFromExistingImage(FileInfo srcFile,
+        String dstPath,
+        String dstFileName)
+        {
+            var newFullname = Path.Combine(dstPath, dstFileName);
+            var newFileInfo = new FileInfo(newFullname);
+            if (!newFileInfo.Exists)
+            {
+                newFileInfo = srcFile.CopyTo(newFullname);
+            }
+            newFileInfo.Refresh();
+            Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName);
+
+            return JsonConvert.SerializeObject(newFileInfo.FullName);
+        }
+        
+        [Fact]
+        public void TestCreateCommand()
+        {
+            DirectoryInfo localStorePath = new DirectoryInfo(testLocalStorePath);
+            if (!localStorePath.Exists)
+            {
+                try
+                {
+                    localStorePath.Create();
+                }
+                catch (System.IO.IOException ex)
+                {
+                    throw new NotImplementedException("Need to be able to create the folder " + localStorePath.FullName + " failed due to " + ex.Message);
+                }
+            }
+
+            FileInfo sampleTemplateFile = new FileInfo(Path.Combine(testLocalStorePath, testSampleTemplateUUID));
+            if (!sampleTemplateFile.Exists)
+            {
+                //Create a file to write to.
+                using (StreamWriter sw = sampleTemplateFile.CreateText())
+                {
+                    sw.WriteLine("This is fake template file for test");
+                }
+            }
+            var counter = 0;
+            wmiCallsV2.When(x => x.CreateDynamicVirtualHardDisk(Arg.Any<ulong>(), Arg.Any<String>())).Do(x => counter++);
+            // TODO: Need sample to update the test.
+            // Arrange
+            String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" +
+                            ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," +
+                            "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," +
+                            "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}";
+            dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd);
+            HypervResourceController rsrcServer = new HypervResourceController();
+            HypervResourceController.wmiCallsV2 = wmiCallsV2;
+
+            Assert.True(Directory.Exists(testLocalStorePath), testLocalStorePath + " does not exist ");
+            string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON));
+            Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath);
+            int fileCount = Directory.GetFiles(testLocalStorePath).Length;
+            s_logger.Debug(" test local store has " + fileCount + "files");
+
+            // Act
+            // Test requires there to be a template at the tempalteUrl, which is its location in the local file system.
+            dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd);
+            s_logger.Debug("CreateDynamicVirtualHardDisk method is called " + counter + " times");
+
+            //Assert.Equal(counter, 1);
+
+            JObject ansAsProperty2 = jsonResult[0];
+            dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
+            Assert.NotNull(ans);
+            Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result);
+            Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1);
+            FileInfo newFile = new FileInfo((string)ans.volume.path);
+            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
+            newFile.Delete();
+            sampleTemplateFile.Delete();
+        }
+
+        /// <summary>
+        /// Possible additional tests:  place an ISO in the drive
+        /// </summary>        
+
+        [Fact]
+        public void TestStartCommand()
+        {
+            ComputerSystem system = new ComputerSystem();
+            wmiCallsV2.DeployVirtualMachine(Arg.Any<Object>(), Arg.Any<string>()).Returns(system);
+
+            // Arrange
+            HypervResourceController rsrcServer = new HypervResourceController();
+            HypervResourceController.wmiCallsV2 = wmiCallsV2;
+            String sample = getSampleStartCommand();
+
+
+            dynamic jsonStartCmd = JsonConvert.DeserializeObject(sample);
+
+            // Act
+            dynamic startAns = rsrcServer.StartCommand(jsonStartCmd);
+
+            // Assert
+            Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]);
+            Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details);
+
+            Assert.Null((string)startAns[0][CloudStackTypes.StartAnswer].details);            
+        }
+
+        [Fact]
+        public void TestStopCommand()
+        {
+            //string vmName = "Test VM";
+            var counter = 0;
+            wmiCallsV2.When(x => x.DestroyVm(Arg.Any<Object>())).Do(x => counter++);
+
+            // Arrange
+            HypervResourceController rsrcServer = new HypervResourceController();
+            HypervResourceController.wmiCallsV2 = wmiCallsV2;
+
+            String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\",\"contextMap\":{},\"wait\":0}";
+            dynamic jsonStopCmd = JsonConvert.DeserializeObject(sampleStop);
+
+            // Act
+            dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd);
+
+            // Assert VM is gone!
+            Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]);
+            Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details);
+
+            Assert.Null((string)stopAns[0][CloudStackTypes.StopAnswer].details);
+            Assert.Equal<int>(counter, 1);
+        }
+
+        public static String getSamplePrimaryDataStoreInfo()
+        {
+            String samplePrimaryDataStoreInfo =
+            "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" +
+                "{\"uuid\":\"" + testLocalStoreUUID + "\"," +
+                "\"id\":201," +
+                "\"host\":\"" + testPrimaryDataStoreHost + "\"," +
+                "\"type\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
+                "\"poolType\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
+                "\"path\":" + testLocalStorePathJSON + "," +
+                "\"port\":0}" +
+            "}";
+            return samplePrimaryDataStoreInfo;
+        }
+
+        public static String getSampleVolumeObjectTO()
+        {
+            String sampleVolumeObjectTO =
+                    "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" +
+                        "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," +
+                        "\"volumeType\":\"ROOT\"," +
+                        "\"format\":\"VHDX\"," +
+                        "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
+                        "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," +
+                        "\"size\":52428800," +
+                        "\"volumeId\":10," +
+                //                            "\"vmName\":\"i-3-5-VM\"," +  // TODO: do we have to fill in the vmName?
+                        "\"accountId\":3,\"id\":10}" +
+                    "}";  // end of destTO 
+            return sampleVolumeObjectTO;
+        }
+
+        public static String getSampleStartCommand()
+        {
+            String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," +
+                                "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," +
+                                "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," +
+                                "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," +
+                                "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" +
+                            ",\"disks\":[" +
+                               "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," +
+                               "{\"diskSeq\":1,\"type\":\"ISO\"}" +
+                            "]," +
+                            "\"nics\":[" +
+                                    "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," +
+                                    "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," +
+                                    "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," +
+                                    "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" +
+                            "]},\"contextMap\":{},\"wait\":0}";
+            return sample;
+        }        
+    }
+}


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

Posted by bf...@apache.org.
CLOUDSTACK-3216 /var/log/cloud.log did not have a logrotate script, here
is a basic one.


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

Branch: refs/heads/ui-restyle
Commit: 70330f5cf32f4a0463edf5024cf841e0e678f423
Parents: 256763c
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Mon Nov 4 08:46:29 2013 -0700
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Mon Nov 4 08:47:15 2013 -0700

----------------------------------------------------------------------
 patches/systemvm/debian/config/etc/logrotate.d/cloud | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/70330f5c/patches/systemvm/debian/config/etc/logrotate.d/cloud
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/etc/logrotate.d/cloud b/patches/systemvm/debian/config/etc/logrotate.d/cloud
new file mode 100644
index 0000000..40c4203
--- /dev/null
+++ b/patches/systemvm/debian/config/etc/logrotate.d/cloud
@@ -0,0 +1,11 @@
+/var/log/cloud.log {
+        rotate 4
+        daily
+        missingok
+        notifempty
+        compress
+        delaycompress
+        postrotate
+                pkill socat > /dev/null
+        endscript
+}


[26/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPort.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPort.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPort.cs
deleted file mode 100644
index b303127..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPort.cs
+++ /dev/null
@@ -1,1960 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_SyntheticEthernetPort
-    public class SyntheticEthernetPort : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_SyntheticEthernetPort";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public SyntheticEthernetPort() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public SyntheticEthernetPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(SyntheticEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public SyntheticEthernetPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(SyntheticEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public SyntheticEthernetPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public SyntheticEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public SyntheticEthernetPort(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public SyntheticEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public SyntheticEthernetPort(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public SyntheticEthernetPort(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsActiveMaximumTransmissionUnitNull {
-            get {
-                if ((curObj["ActiveMaximumTransmissionUnit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong ActiveMaximumTransmissionUnit {
-            get {
-                if ((curObj["ActiveMaximumTransmissionUnit"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["ActiveMaximumTransmissionUnit"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] AdditionalAvailability {
-            get {
-                return ((ushort[])(curObj["AdditionalAvailability"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutoSenseNull {
-            get {
-                if ((curObj["AutoSense"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutoSense {
-            get {
-                if ((curObj["AutoSense"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutoSense"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAvailabilityNull {
-            get {
-                if ((curObj["Availability"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort Availability {
-            get {
-                if ((curObj["Availability"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["Availability"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] Capabilities {
-            get {
-                return ((ushort[])(curObj["Capabilities"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] CapabilityDescriptions {
-            get {
-                return ((string[])(curObj["CapabilityDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string DeviceID {
-            get {
-                return ((string)(curObj["DeviceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] EnabledCapabilities {
-            get {
-                return ((ushort[])(curObj["EnabledCapabilities"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsErrorClearedNull {
-            get {
-                if ((curObj["ErrorCleared"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool ErrorCleared {
-            get {
-                if ((curObj["ErrorCleared"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["ErrorCleared"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ErrorDescription {
-            get {
-                return ((string)(curObj["ErrorDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsFullDuplexNull {
-            get {
-                if ((curObj["FullDuplex"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool FullDuplex {
-            get {
-                if ((curObj["FullDuplex"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["FullDuplex"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] IdentifyingDescriptions {
-            get {
-                return ((string[])(curObj["IdentifyingDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLastErrorCodeNull {
-            get {
-                if ((curObj["LastErrorCode"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint LastErrorCode {
-            get {
-                if ((curObj["LastErrorCode"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["LastErrorCode"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLinkTechnologyNull {
-            get {
-                if ((curObj["LinkTechnology"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort LinkTechnology {
-            get {
-                if ((curObj["LinkTechnology"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["LinkTechnology"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLocationIndicatorNull {
-            get {
-                if ((curObj["LocationIndicator"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort LocationIndicator {
-            get {
-                if ((curObj["LocationIndicator"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["LocationIndicator"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxDataSizeNull {
-            get {
-                if ((curObj["MaxDataSize"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint MaxDataSize {
-            get {
-                if ((curObj["MaxDataSize"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["MaxDataSize"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxQuiesceTimeNull {
-            get {
-                if ((curObj["MaxQuiesceTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong MaxQuiesceTime {
-            get {
-                if ((curObj["MaxQuiesceTime"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["MaxQuiesceTime"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxSpeedNull {
-            get {
-                if ((curObj["MaxSpeed"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong MaxSpeed {
-            get {
-                if ((curObj["MaxSpeed"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["MaxSpeed"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] NetworkAddresses {
-            get {
-                return ((string[])(curObj["NetworkAddresses"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherEnabledCapabilities {
-            get {
-                return ((string[])(curObj["OtherEnabledCapabilities"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherIdentifyingInfo {
-            get {
-                return ((string[])(curObj["OtherIdentifyingInfo"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherLinkTechnology {
-            get {
-                return ((string)(curObj["OtherLinkTechnology"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherNetworkPortType {
-            get {
-                return ((string)(curObj["OtherNetworkPortType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherPortType {
-            get {
-                return ((string)(curObj["OtherPortType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PermanentAddress {
-            get {
-                return ((string)(curObj["PermanentAddress"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPortNumberNull {
-            get {
-                if ((curObj["PortNumber"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort PortNumber {
-            get {
-                if ((curObj["PortNumber"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["PortNumber"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPortTypeNull {
-            get {
-                if ((curObj["PortType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort PortType {
-            get {
-                if ((curObj["PortType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["PortType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] PowerManagementCapabilities {
-            get {
-                return ((ushort[])(curObj["PowerManagementCapabilities"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPowerManagementSupportedNull {
-            get {
-                if ((curObj["PowerManagementSupported"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool PowerManagementSupported {
-            get {
-                if ((curObj["PowerManagementSupported"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["PowerManagementSupported"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPowerOnHoursNull {
-            get {
-                if ((curObj["PowerOnHours"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong PowerOnHours {
-            get {
-                if ((curObj["PowerOnHours"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["PowerOnHours"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedSpeedNull {
-            get {
-                if ((curObj["RequestedSpeed"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong RequestedSpeed {
-            get {
-                if ((curObj["RequestedSpeed"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["RequestedSpeed"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsSpeedNull {
-            get {
-                if ((curObj["Speed"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Speed {
-            get {
-                if ((curObj["Speed"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Speed"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsStatusInfoNull {
-            get {
-                if ((curObj["StatusInfo"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort StatusInfo {
-            get {
-                if ((curObj["StatusInfo"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["StatusInfo"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsSupportedMaximumTransmissionUnitNull {
-            get {
-                if ((curObj["SupportedMaximumTransmissionUnit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong SupportedMaximumTransmissionUnit {
-            get {
-                if ((curObj["SupportedMaximumTransmissionUnit"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["SupportedMaximumTransmissionUnit"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTotalPowerOnHoursNull {
-            get {
-                if ((curObj["TotalPowerOnHours"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong TotalPowerOnHours {
-            get {
-                if ((curObj["TotalPowerOnHours"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["TotalPowerOnHours"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsUsageRestrictionNull {
-            get {
-                if ((curObj["UsageRestriction"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort UsageRestriction {
-            get {
-                if ((curObj["UsageRestriction"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["UsageRestriction"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeActiveMaximumTransmissionUnit() {
-            if ((this.IsActiveMaximumTransmissionUnitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutoSense() {
-            if ((this.IsAutoSenseNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAvailability() {
-            if ((this.IsAvailabilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeErrorCleared() {
-            if ((this.IsErrorClearedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeFullDuplex() {
-            if ((this.IsFullDuplexNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLastErrorCode() {
-            if ((this.IsLastErrorCodeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLinkTechnology() {
-            if ((this.IsLinkTechnologyNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLocationIndicator() {
-            if ((this.IsLocationIndicatorNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxDataSize() {
-            if ((this.IsMaxDataSizeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxQuiesceTime() {
-            if ((this.IsMaxQuiesceTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxSpeed() {
-            if ((this.IsMaxSpeedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePortNumber() {
-            if ((this.IsPortNumberNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePortType() {
-            if ((this.IsPortTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePowerManagementSupported() {
-            if ((this.IsPowerManagementSupportedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePowerOnHours() {
-            if ((this.IsPowerOnHoursNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedSpeed() {
-            if ((this.IsRequestedSpeedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeSpeed() {
-            if ((this.IsSpeedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeStatusInfo() {
-            if ((this.IsStatusInfoNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeSupportedMaximumTransmissionUnit() {
-            if ((this.IsSupportedMaximumTransmissionUnitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTotalPowerOnHours() {
-            if ((this.IsTotalPowerOnHoursNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeUsageRestriction() {
-            if ((this.IsUsageRestrictionNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_SyntheticEthernetPort";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static SyntheticEthernetPortCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static SyntheticEthernetPortCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static SyntheticEthernetPortCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static SyntheticEthernetPortCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static SyntheticEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_SyntheticEthernetPort";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new SyntheticEthernetPortCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static SyntheticEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static SyntheticEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static SyntheticEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SyntheticEthernetPort", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new SyntheticEthernetPortCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static SyntheticEthernetPort CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new SyntheticEthernetPort(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint EnableDevice(bool Enabled) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice");
-                inParams["Enabled"] = ((bool)(Enabled));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint OnlineDevice(bool Online) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice");
-                inParams["Online"] = ((bool)(Online));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint QuiesceDevice(bool Quiesce) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice");
-                inParams["Quiesce"] = ((bool)(Quiesce));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint Reset() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint RestoreProperties() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SaveProperties() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SetPowerState(ushort PowerState, System.DateTime Time) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState");
-                inParams["PowerState"] = ((ushort)(PowerState));
-                inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class SyntheticEthernetPortCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public SyntheticEthernetPortCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new SyntheticEthernetPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new SyntheticEthernetPortEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class SyntheticEthernetPortEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public SyntheticEthernetPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new SyntheticEthernetPort(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[27/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchPort.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchPort.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchPort.cs
deleted file mode 100644
index a2e44a4..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchPort.cs
+++ /dev/null
@@ -1,1708 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_SwitchPort
-    public class SwitchPort : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_SwitchPort";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public SwitchPort() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public SwitchPort(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(SwitchPort.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public SwitchPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(SwitchPort.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public SwitchPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public SwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public SwitchPort(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public SwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public SwitchPort(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public SwitchPort(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The list of IPv4 addresses which are valid in ARP and neighbor Discovery packets. 
-Each address in the list must point a text string of an IPv4 address in dotted-decimal notation as in ""192.168.16.0"", an example of an IPv4 address in dotted-decimalnotation.")]
-        public string[] AllowedIPv4Addresses {
-            get {
-                return ((string[])(curObj["AllowedIPv4Addresses"]));
-            }
-            set {
-                curObj["AllowedIPv4Addresses"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The list of IPv6 addresses which are valid in ARP and neighbor Discovery packets.The basic string representation consists of 8 hexadecimal numbers separated by colons.A string of consecutive zero numbers may be replaced with a double-colon.There can only be one double-colon in the string representation of the IPv6 address.The last 32 bits may be represented in IPv4-style dotted-octet notationif the address is a IPv4-compatible address.")]
-        public string[] AllowedIPv6Addresses {
-            get {
-                return ((string[])(curObj["AllowedIPv6Addresses"]));
-            }
-            set {
-                curObj["AllowedIPv6Addresses"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAllowMacSpoofingNull {
-            get {
-                if ((curObj["AllowMacSpoofing"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Indicates whether the port will allow MAC spoofing.
-TRUE: The port will allow MAC addresses to be spoofed. All valid unicast MAC address values are allowed except those of ports with the AllowMacSpoofing property set to FALSE.
-FALSE: The port will allow only MAC addresses configured within Hyper-V management to be used.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AllowMacSpoofing {
-            get {
-                if ((curObj["AllowMacSpoofing"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AllowMacSpoofing"]));
-            }
-            set {
-                curObj["AllowMacSpoofing"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsBroadcastResetSupportedNull {
-            get {
-                if ((curObj["BroadcastResetSupported"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool BroadcastResetSupported {
-            get {
-                if ((curObj["BroadcastResetSupported"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["BroadcastResetSupported"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsChimneyOffloadLimitNull {
-            get {
-                if ((curObj["ChimneyOffloadLimit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current Chimney offloading limit on this port. The limit is the maximum usage" +
-            " of TCP Chimney Offloading resources on the port.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint ChimneyOffloadLimit {
-            get {
-                if ((curObj["ChimneyOffloadLimit"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["ChimneyOffloadLimit"]));
-            }
-            set {
-                curObj["ChimneyOffloadLimit"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsChimneyOffloadUsageNull {
-            get {
-                if ((curObj["ChimneyOffloadUsage"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current Chimney offloading usage on this port.The usage is the amount of TCP " +
-            "Chimney Offloading resources in use on the port.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint ChimneyOffloadUsage {
-            get {
-                if ((curObj["ChimneyOffloadUsage"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["ChimneyOffloadUsage"]));
-            }
-            set {
-                curObj["ChimneyOffloadUsage"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsChimneyOffloadWeightNull {
-            get {
-                if ((curObj["ChimneyOffloadWeight"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The weight assigned to this port for TCP Chimney Offloading. The weight is the relative importance when assigning TCP Chimney Offloading resources. Setting the ChimneyOffloadWeight property to 0 disables TCP Chimney Offloading on the port. The default is 0.
-The ChimneyOffloadWeight property is not supported until Windows Server 2008 R2.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint ChimneyOffloadWeight {
-            get {
-                if ((curObj["ChimneyOffloadWeight"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["ChimneyOffloadWeight"]));
-            }
-            set {
-                curObj["ChimneyOffloadWeight"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string NameFormat {
-            get {
-                return ((string)(curObj["NameFormat"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherTypeDescription {
-            get {
-                return ((string)(curObj["OtherTypeDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPortNumberNull {
-            get {
-                if ((curObj["PortNumber"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort PortNumber {
-            get {
-                if ((curObj["PortNumber"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["PortNumber"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPreventIPSpoofingNull {
-            get {
-                if ((curObj["PreventIPSpoofing"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Indicates whether the IP spoofing prevention is enabled on the port.
-TRUE: IP Spoofing checks will be enabled on ARP and Neighbor Discoverypackets. Router Advertisements and Router redirects will be blocked from the port
-FALSE: No IP spoofing checks will be performed.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool PreventIPSpoofing {
-            get {
-                if ((curObj["PreventIPSpoofing"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["PreventIPSpoofing"]));
-            }
-            set {
-                curObj["PreventIPSpoofing"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolIFTypeNull {
-            get {
-                if ((curObj["ProtocolIFType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolIFType {
-            get {
-                if ((curObj["ProtocolIFType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolIFType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolTypeNull {
-            get {
-                if ((curObj["ProtocolType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolType {
-            get {
-                if ((curObj["ProtocolType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The Azman scope for the switch service. This scope will be used when performing a" +
-            "ccess checks for the switch service.")]
-        public string ScopeOfResidence {
-            get {
-                return ((string)(curObj["ScopeOfResidence"]));
-            }
-            set {
-                curObj["ScopeOfResidence"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The current status of the object. Operational and non-operational status can be defined. Operational status can include ""OK"", ""Degraded"", and ""Pred Fail"". ""Pred Fail"" indicates whether an element is functioning properly, but is predicting a failure (for example, a SMART-enabled hard drive).
-Non-operational status can include ""Error"", ""Starting"", ""Stopping"", and ""Service"". ""Service"" can apply during disk mirror-resilvering, reloading a user permissions list, or other administrative work. Not all such work is online, but the managed element is neither ""OK"" nor in one of the other states.")]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVMQOffloadLimitNull {
-            get {
-                if ((curObj["VMQOffloadLimit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current VMQ offloading limit on this port. The limit is the maximum usage of " +
-            "VMQ offloading resources on the port.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint VMQOffloadLimit {
-            get {
-                if ((curObj["VMQOffloadLimit"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["VMQOffloadLimit"]));
-            }
-            set {
-                curObj["VMQOffloadLimit"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVMQOffloadUsageNull {
-            get {
-                if ((curObj["VMQOffloadUsage"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current VMQ offloading usage on this port. The usage is the amount of VMQ res" +
-            "ources in use on the port.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint VMQOffloadUsage {
-            get {
-                if ((curObj["VMQOffloadUsage"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["VMQOffloadUsage"]));
-            }
-            set {
-                curObj["VMQOffloadUsage"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVMQOffloadWeightNull {
-            get {
-                if ((curObj["VMQOffloadWeight"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The weight assigned to this port for virtual machine queue (VMQ) offloading. The " +
-            "weight is the relative importance when assigning VMQ resources. Setting the VMQO" +
-            "ffloadWeight property to 0 disables VMQ on the port. The default is 100.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint VMQOffloadWeight {
-            get {
-                if ((curObj["VMQOffloadWeight"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["VMQOffloadWeight"]));
-            }
-            set {
-                curObj["VMQOffloadWeight"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private void ResetAllowedIPv4Addresses() {
-            curObj["AllowedIPv4Addresses"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private void ResetAllowedIPv6Addresses() {
-            curObj["AllowedIPv6Addresses"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeAllowMacSpoofing() {
-            if ((this.IsAllowMacSpoofingNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetAllowMacSpoofing() {
-            curObj["AllowMacSpoofing"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeBroadcastResetSupported() {
-            if ((this.IsBroadcastResetSupportedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeChimneyOffloadLimit() {
-            if ((this.IsChimneyOffloadLimitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetChimneyOffloadLimit() {
-            curObj["ChimneyOffloadLimit"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeChimneyOffloadUsage() {
-            if ((this.IsChimneyOffloadUsageNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetChimneyOffloadUsage() {
-            curObj["ChimneyOffloadUsage"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeChimneyOffloadWeight() {
-            if ((this.IsChimneyOffloadWeightNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetChimneyOffloadWeight() {
-            curObj["ChimneyOffloadWeight"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePortNumber() {
-            if ((this.IsPortNumberNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePreventIPSpoofing() {
-            if ((this.IsPreventIPSpoofingNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetPreventIPSpoofing() {
-            curObj["PreventIPSpoofing"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeProtocolIFType() {
-            if ((this.IsProtocolIFTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProtocolType() {
-            if ((this.IsProtocolTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetScopeOfResidence() {
-            curObj["ScopeOfResidence"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeVMQOffloadLimit() {
-            if ((this.IsVMQOffloadLimitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetVMQOffloadLimit() {
-            curObj["VMQOffloadLimit"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeVMQOffloadUsage() {
-            if ((this.IsVMQOffloadUsageNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetVMQOffloadUsage() {
-            curObj["VMQOffloadUsage"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeVMQOffloadWeight() {
-            if ((this.IsVMQOffloadWeightNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetVMQOffloadWeight() {
-            curObj["VMQOffloadWeight"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_SwitchPort";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static SwitchPortCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static SwitchPortCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static SwitchPortCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static SwitchPortCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static SwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_SwitchPort";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new SwitchPortCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static SwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static SwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static SwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SwitchPort", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new SwitchPortCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static SwitchPort CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new SwitchPort(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint BroadcastReset() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("BroadcastReset", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class SwitchPortCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public SwitchPortCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new SwitchPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new SwitchPortEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class SwitchPortEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public SwitchPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new SwitchPort(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


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

Posted by bf...@apache.org.
Merge branch 'asf-master' into ui-restyle

Conflicts:
	client/WEB-INF/classes/resources/messages.properties
	ui/dictionary.jsp


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

Branch: refs/heads/ui-restyle
Commit: b7259a48eae5b19fea1ba68b077fec857e8fabf8
Parents: e13c32f ed6c2d2
Author: Brian Federle <br...@citrix.com>
Authored: Mon Nov 4 14:30:38 2013 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Mon Nov 4 14:30:38 2013 -0800

----------------------------------------------------------------------
 .../cloud/agent/dao/impl/PropertiesStorage.java |   14 +-
 .../agent/dao/impl/PropertiesStorageTest.java   |   69 +
 api/src/com/cloud/agent/api/to/DataStoreTO.java |    5 +-
 api/src/com/cloud/agent/api/to/DiskTO.java      |   36 +-
 api/src/com/cloud/agent/api/to/NfsTO.java       |    1 +
 api/src/com/cloud/agent/api/to/S3TO.java        |    6 +-
 api/src/com/cloud/event/EventTypes.java         |    3 +
 api/src/com/cloud/network/Network.java          |    1 +
 api/src/com/cloud/network/RemoteAccessVpn.java  |    3 +-
 .../cloud/network/Site2SiteVpnConnection.java   |    1 +
 .../network/vpn/RemoteAccessVpnService.java     |    3 +-
 .../cloud/server/ResourceMetaDataService.java   |   12 +-
 api/src/com/cloud/server/ResourceTag.java       |    5 +-
 api/src/com/cloud/storage/StorageService.java   |   16 +-
 api/src/com/cloud/user/DomainService.java       |    3 +
 .../cloud/vm/snapshot/VMSnapshotService.java    |    2 +-
 .../org/apache/cloudstack/api/APICommand.java   |    4 +
 .../cloudstack/api/ApiCommandJobType.java       |    1 +
 .../org/apache/cloudstack/api/ApiConstants.java |    5 +-
 .../org/apache/cloudstack/api/Parameter.java    |    3 +
 .../apache/cloudstack/api/ResourceDetail.java   |    8 +-
 .../PrepareSecondaryStorageForMigrationCmd.java |  109 +
 .../command/admin/usage/GetUsageRecordsCmd.java |   19 +-
 .../api/command/admin/vm/AssignVMCmd.java       |    2 +-
 .../user/vmsnapshot/CreateVMSnapshotCmd.java    |   13 +-
 .../user/volume/ListResourceDetailsCmd.java     |   50 +-
 .../api/command/user/volume/ListVolumesCmd.java |    9 +
 .../user/vpn/CreateRemoteAccessVpnCmd.java      |   17 +-
 .../user/vpn/CreateVpnConnectionCmd.java        |   10 +
 .../api/response/ResourceDetailResponse.java    |   15 +-
 .../Site2SiteVpnConnectionResponse.java         |    7 +
 .../cloudstack/api/response/ZoneResponse.java   |    9 +
 .../apache/cloudstack/query/QueryService.java   |    2 +-
 .../apache/cloudstack/usage/UsageService.java   |    4 +-
 .../api/command/test/UsageCmdTest.java          |    9 +-
 .../com/cloud/bridge/persist/dao/BaseDao.java   |   28 +-
 .../util/EncryptionSecretKeyCheckerUtil.java    |  138 -
 .../classes/resources/messages.properties       |    3 +
 client/pom.xml                                  |   10 +
 client/tomcatconf/commands.properties.in        |   17 +-
 .../bootstrap/spring-bootstrap-context.xml      |    3 +-
 .../core/spring-core-registry-core-context.xml  |   78 +-
 ...re-lifecycle-network-context-inheritable.xml |   38 +-
 ...ng-lifecycle-storage-context-inheritable.xml |    6 +
 .../cloud/agent/api/CreateVMSnapshotAnswer.java |   12 +-
 .../agent/api/CreateVMSnapshotCommand.java      |    4 +-
 .../cloud/agent/api/DeleteVMSnapshotAnswer.java |   12 +-
 .../agent/api/DeleteVMSnapshotCommand.java      |    3 +-
 .../src/com/cloud/agent/api/MigrateCommand.java |   11 +-
 .../agent/api/RevertToVMSnapshotAnswer.java     |   14 +-
 .../agent/api/RevertToVMSnapshotCommand.java    |    3 +-
 core/src/com/cloud/agent/api/SetupCommand.java  |   20 +
 core/src/com/cloud/agent/api/StartAnswer.java   |   11 +
 .../cloud/agent/api/VMSnapshotBaseCommand.java  |   10 +-
 core/src/com/cloud/agent/api/VMSnapshotTO.java  |   12 +
 .../api/routing/RemoteAccessVpnCfgCommand.java  |   35 +-
 .../api/routing/Site2SiteVpnCfgCommand.java     |   12 +-
 .../virtualnetwork/VirtualRoutingResource.java  |    5 +
 .../StorageSubsystemCommandHandlerBase.java     |    7 +-
 .../storage/command/AttachCommand.java          |   72 -
 .../cloudstack/storage/to/ImageStoreTO.java     |    5 +
 .../storage/to/PrimaryDataStoreTO.java          |   10 +-
 .../cloudstack/storage/to/VolumeObjectTO.java   |   12 +
 .../api/storage/DataStoreLifeCycle.java         |    2 +
 .../subsystem/api/storage/DataStoreManager.java |    3 +
 .../subsystem/api/storage/PrimaryDataStore.java |   43 +
 .../api/storage/SnapshotDataFactory.java        |    4 +
 .../api/storage/StorageStrategyFactory.java     |    5 +-
 .../api/storage/TemplateDataFactory.java        |    6 +
 .../subsystem/api/storage/TemplateService.java  |    6 +-
 .../api/storage/VMSnapshotOptions.java          |   30 +
 .../api/storage/VMSnapshotStrategy.java         |   28 +
 .../api/storage/VolumeDataFactory.java          |    4 +
 .../com/cloud/agent/manager/AgentAttache.java   |    5 +-
 .../cloud/agent/manager/AgentManagerImpl.java   |   28 +-
 .../cloud/agent/manager/DirectAgentAttache.java |   33 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java |   77 +-
 .../orchestration/NetworkOrchestrator.java      |    2 +-
 .../orchestration/VolumeOrchestrator.java       |   43 +-
 .../spring-engine-schema-core-daos-context.xml  |    7 +-
 .../com/cloud/capacity/dao/CapacityDaoImpl.java |    2 +-
 .../src/com/cloud/dc/DataCenterDetailVO.java    |   82 +
 engine/schema/src/com/cloud/dc/DcDetailVO.java  |   79 -
 .../src/com/cloud/dc/dao/DataCenterDaoImpl.java |   14 +-
 .../com/cloud/dc/dao/DataCenterDetailsDao.java  |   25 +
 .../cloud/dc/dao/DataCenterDetailsDaoImpl.java  |   49 +
 .../src/com/cloud/dc/dao/DcDetailsDao.java      |   37 -
 .../src/com/cloud/dc/dao/DcDetailsDaoImpl.java  |  133 -
 .../com/cloud/network/dao/NetworkDetailVO.java  |   44 +-
 .../cloud/network/dao/NetworkDetailsDao.java    |   16 +-
 .../network/dao/NetworkDetailsDaoImpl.java      |   71 +-
 .../cloud/network/dao/RemoteAccessVpnDao.java   |    3 +-
 .../network/dao/RemoteAccessVpnDaoImpl.java     |    9 +
 .../cloud/network/dao/RemoteAccessVpnVO.java    |   15 +-
 .../network/dao/Site2SiteVpnConnectionVO.java   |   14 +-
 .../cloud/service/ServiceOfferingDetailsVO.java |   30 +-
 .../service/dao/ServiceOfferingDaoImpl.java     |   15 +-
 .../service/dao/ServiceOfferingDetailsDao.java  |    8 +-
 .../dao/ServiceOfferingDetailsDaoImpl.java      |   72 +-
 .../com/cloud/storage/VMTemplateDetailVO.java   |   40 +-
 .../src/com/cloud/storage/VolumeDetailVO.java   |   40 +-
 .../schema/src/com/cloud/storage/VolumeVO.java  |    2 +-
 .../storage/dao/StoragePoolDetailsDaoImpl.java  |   63 +-
 .../cloud/storage/dao/VMTemplateDaoImpl.java    |   27 +-
 .../cloud/storage/dao/VMTemplateDetailsDao.java |   16 +-
 .../storage/dao/VMTemplateDetailsDaoImpl.java   |   97 +-
 .../com/cloud/storage/dao/VolumeDetailsDao.java |   16 +-
 .../cloud/storage/dao/VolumeDetailsDaoImpl.java |   91 +-
 .../src/com/cloud/upgrade/DatabaseCreator.java  |   12 +-
 .../com/cloud/upgrade/dao/Upgrade307to410.java  |   25 +-
 .../com/cloud/upgrade/dao/Upgrade40to41.java    |   20 +-
 .../src/com/cloud/usage/dao/UsageDao.java       |    3 +-
 .../src/com/cloud/usage/dao/UsageDaoImpl.java   |    5 +-
 engine/schema/src/com/cloud/vm/NicDetailVO.java |   39 +-
 .../schema/src/com/cloud/vm/UserVmDetailVO.java |   42 +-
 .../src/com/cloud/vm/dao/NicDetailDao.java      |   35 -
 .../src/com/cloud/vm/dao/NicDetailDaoImpl.java  |  103 -
 .../src/com/cloud/vm/dao/NicDetailsDao.java     |   25 +
 .../src/com/cloud/vm/dao/NicDetailsDaoImpl.java |   34 +
 .../src/com/cloud/vm/dao/UserVmDaoImpl.java     |   18 +-
 .../src/com/cloud/vm/dao/UserVmDetailsDao.java  |   18 +-
 .../com/cloud/vm/dao/UserVmDetailsDaoImpl.java  |  106 +-
 .../cloud/vm/snapshot/VMSnapshotDetailsVO.java  |   87 +
 .../src/com/cloud/vm/snapshot/VMSnapshotVO.java |   18 +-
 .../vm/snapshot/dao/VMSnapshotDetailsDao.java   |   28 +
 .../snapshot/dao/VMSnapshotDetailsDaoImpl.java  |   52 +
 .../resourcedetail/FirewallRuleDetailVO.java    |   80 +
 .../resourcedetail/ResourceDetailsDao.java      |   71 +
 .../resourcedetail/ResourceDetailsDaoBase.java  |  139 +
 .../dao/FirewallRuleDetailsDao.java             |   26 +
 .../dao/FirewallRuleDetailsDaoImpl.java         |   34 +
 .../storage/datastore/db/ImageStoreDao.java     |    2 +
 .../datastore/db/PrimaryDataStoreDaoImpl.java   |   14 +-
 .../datastore/db/PrimaryDataStoreDetailVO.java  |   40 +-
 .../db/PrimaryDataStoreDetailsDao.java          |   10 +-
 .../datastore/db/SnapshotDataStoreDao.java      |    9 +
 .../datastore/db/SnapshotDataStoreVO.java       |   34 +-
 .../datastore/db/StoragePoolDetailVO.java       |   44 +-
 .../datastore/db/StoragePoolDetailsDao.java     |   10 +-
 .../datastore/db/TemplateDataStoreDao.java      |   10 +-
 .../datastore/db/TemplateDataStoreVO.java       |   51 +-
 .../datastore/db/VolumeDataStoreDao.java        |    2 +
 .../storage/datastore/db/VolumeDataStoreVO.java |   47 +-
 .../motion/AncientDataMotionStrategy.java       |  155 +-
 .../storage/image/TemplateDataFactoryImpl.java  |   38 +-
 .../storage/image/TemplateServiceImpl.java      |  113 +-
 .../manager/ImageStoreProviderManagerImpl.java  |   15 +-
 .../storage/image/store/TemplateObject.java     |    8 +
 .../vm/snapshot/dao/VmSnapshotDaoTest.java      |   46 +
 .../storage/test/ChildTestConfiguration.java    |   51 +-
 .../cloudstack/storage/test/SnapshotTest.java   |   89 +-
 .../test/resources/storageContext.xml           |    5 +
 .../core/spring-engine-storage-core-context.xml |    5 +
 engine/storage/snapshot/pom.xml                 |   32 +
 ...-engine-storage-snapshot-storage-context.xml |    5 +-
 .../snapshot/SnapshotDataFactoryImpl.java       |   22 +-
 .../storage/snapshot/SnapshotServiceImpl.java   |   46 +-
 .../snapshot/XenserverSnapshotStrategy.java     |   34 +-
 .../vmsnapshot/DefaultVMSnapshotStrategy.java   |  371 +++
 .../snapshot/test/resources/db.properties       |   70 +
 .../test/src/VMSnapshotStrategyTest.java        |  256 ++
 .../storage/datastore/DataStoreManagerImpl.java |    5 +
 .../storage/datastore/PrimaryDataStore.java     |   43 -
 .../PrimaryDataStoreProviderManager.java        |    1 +
 .../endpoint/DefaultEndPointSelector.java       |   33 +-
 .../storage/helper/HypervisorHelper.java        |   11 +-
 .../storage/helper/HypervisorHelperImpl.java    |  106 +-
 .../helper/StorageStrategyFactoryImpl.java      |   22 +
 .../storage/helper/VMSnapshotHelperImpl.java    |  148 +
 .../storage/image/BaseImageStoreDriverImpl.java |   45 +-
 .../image/datastore/ImageStoreHelper.java       |   21 +-
 .../datastore/ImageStoreProviderManager.java    |    2 +
 .../storage/image/db/ImageStoreDaoImpl.java     |   10 +-
 .../image/db/SnapshotDataStoreDaoImpl.java      |   82 +-
 .../image/db/TemplateDataStoreDaoImpl.java      |  104 +
 .../image/db/VolumeDataStoreDaoImpl.java        |   55 +-
 .../storage/vmsnapshot/VMSnapshotHelper.java    |   38 +
 .../volume/TemplateOnPrimaryDataStoreInfo.java  |    2 +-
 .../db/PrimaryDataStoreDetailsDaoImpl.java      |   50 +-
 engine/storage/storage.ucls                     |    2 +-
 .../storage/datastore/PrimaryDataStoreImpl.java |   16 +-
 .../PrimaryDataStoreProviderManagerImpl.java    |    2 +-
 .../storage/volume/VolumeDataFactoryImpl.java   |   33 +-
 .../storage/volume/VolumeServiceImpl.java       |   26 +-
 .../com/cloud/cluster/ClusterManagerImpl.java   |   12 +-
 .../cluster/ClusterServiceServletAdapter.java   |   19 +-
 .../src/com/cloud/utils/db/GenericDaoBase.java  |    7 +
 .../com/cloud/utils/db/TransactionLegacy.java   |   38 +-
 .../jobs/impl/AsyncJobManagerImpl.java          |   15 +-
 parents/checkstyle/pom.xml                      |    7 +
 .../src/main/resources/tooling/checkstyle.xml   |   21 +
 .../debian/config/etc/logrotate.d/cloud         |   11 +
 .../debian/config/opt/cloud/bin/savepassword.sh |   62 -
 .../acl/StaticRoleBasedAPIAccessChecker.java    |   37 +-
 .../cloud/deploy/ImplicitDedicationPlanner.java |    2 +-
 .../implicitplanner/ImplicitPlannerTest.java    |    2 +-
 .../hyperv/DotNet/ServerResource/.gitignore     |    9 +
 .../DotNet/ServerResource/.nuget/NuGet.Config   |   15 +
 .../DotNet/ServerResource/.nuget/NuGet.targets  |  136 +
 .../AgentShell/AgentService.Designer.cs         |   53 +
 .../ServerResource/AgentShell/AgentService.cs   |  132 +
 .../AgentShell/AgentSettings.Designer.cs        |  402 +++
 .../AgentShell/AgentSettings.settings           |  130 +
 .../ServerResource/AgentShell/AgentShell.csproj |  140 +
 .../AgentShell/AgentShellException.cs           |   28 +
 .../DotNet/ServerResource/AgentShell/App.config |  145 +
 .../DotNet/ServerResource/AgentShell/Program.cs |   58 +
 .../AgentShell/Properties/AssemblyInfo.cs       |   56 +
 .../ServerResource/AgentShell/packages.config   |   13 +
 .../ServerResource/HypervResource/App.config    |  128 +
 .../HypervResource/CloudStackTypes.cs           |  642 +++++
 .../HypervResource/HypervResource.csproj        |  103 +
 .../HypervResource/HypervResourceController.cs  | 1459 ++++++++++
 .../HypervResource/IWmiCallsV2.cs               |   67 +
 .../HypervResource/Properties/AssemblyInfo.cs   |   53 +
 .../ServerResource/HypervResource/Utils.cs      |  131 +
 .../ServerResource/HypervResource/WmiCallsV2.cs | 2120 +++++++++++++++
 .../HypervResource/packages.config              |    9 +
 .../ServerResource.Tests/App.config             |  139 +
 .../HypervResourceController1Test.cs            |  350 +++
 .../HypervResourceControllerTest.cs             | 1147 ++++++++
 .../Properties/AssemblyInfo.cs                  |   52 +
 .../ServerResource.Tests.csproj                 |  135 +
 .../ServerResource.Tests/packages.config        |    9 +
 .../DotNet/ServerResource/ServerResource.sln    |   61 +
 .../WmiWrappers/Properties/AssemblyInfo.cs      |   53 +
 .../ROOT.CIMV2.Win32_OperatingSystem.cs         | 2452 +++++++++++++++++
 .../WmiWrappers/ROOT.CIMV2.Win32_Processor.cs   | 2540 ++++++++++++++++++
 ...OOT.virtualization.v2.Msvm_ComputerSystem.cs | 1818 +++++++++++++
 .../ROOT.virtualization.v2.Msvm_ConcreteJob.cs  | 1843 +++++++++++++
 ...v2.Msvm_EthernetPortAllocationSettingData.cs | 1164 ++++++++
 ...virtualization.v2.Msvm_EthernetSwitchPort.cs | 2119 +++++++++++++++
 ...v2.Msvm_EthernetSwitchPortVlanSettingData.cs | 1022 +++++++
 ...rtualization.v2.Msvm_ExternalEthernetPort.cs | 2087 ++++++++++++++
 ...ualization.v2.Msvm_ImageManagementService.cs | 1525 +++++++++++
 ...rtualization.v2.Msvm_KvpExchangeComponent.cs | 1615 +++++++++++
 ...n.v2.Msvm_KvpExchangeComponentSettingData.cs | 1054 ++++++++
 ...irtualization.v2.Msvm_KvpExchangeDataItem.cs |  670 +++++
 .../ROOT.virtualization.v2.Msvm_LANEndpoint.cs  | 1422 ++++++++++
 ....virtualization.v2.Msvm_MemorySettingData.cs | 1163 ++++++++
 ...rtualization.v2.Msvm_ProcessorSettingData.cs | 1134 ++++++++
 ...ion.v2.Msvm_ResourceAllocationSettingData.cs | 1010 +++++++
 ...tion.v2.Msvm_StorageAllocationSettingData.cs | 1214 +++++++++
 ...virtualization.v2.Msvm_SummaryInformation.cs | 1537 +++++++++++
 ....v2.Msvm_SyntheticEthernetPortSettingData.cs | 1083 ++++++++
 ...tualization.v2.Msvm_VirtualEthernetSwitch.cs | 1386 ++++++++++
 ...vm_VirtualEthernetSwitchManagementService.cs | 1515 +++++++++++
 ...zation.v2.Msvm_VirtualHardDiskSettingData.cs | 1051 ++++++++
 ...on.v2.Msvm_VirtualSystemManagementService.cs | 1916 +++++++++++++
 ...VirtualSystemManagementServiceSettingData.cs |  809 ++++++
 ...lization.v2.Msvm_VirtualSystemSettingData.cs | 1690 ++++++++++++
 .../ServerResource/WmiWrappers/Readme.txt       |   20 +
 .../WmiWrappers/WmiWrappers.csproj              |  175 ++
 ...rmattedData_Counters_ProcessorInformation.cs | 1754 ++++++++++++
 plugins/hypervisors/hyperv/buildagent.sh        |   28 +
 .../hypervisors/hyperv/conf/agent.properties    |   35 +
 .../hyperv/conf/developer.properties.template   |   55 +
 .../hyperv/conf/environment.properties.in       |   21 +
 plugins/hypervisors/hyperv/conf/log4j-cloud.xml |   93 +
 .../hypervisors/hyperv/conf/log4j-cloud.xml.in  |   93 +
 plugins/hypervisors/hyperv/conf/log4j.xml       |   93 +
 plugins/hypervisors/hyperv/pom.xml              |  163 ++
 .../cloudstack/hyperv-compute/module.properties |   18 +
 .../spring-hyperv-compute-context.xml           |   24 +
 .../hyperv-discoverer/module.properties         |   18 +
 .../spring-hyperv-discoverer-context.xml        |   25 +
 .../discoverer/HypervServerDiscoverer.java      |  690 +++++
 .../hypervisor/hyperv/guru/HypervGuru.java      |   68 +
 .../resource/HypervDirectConnectResource.java   | 1745 ++++++++++++
 .../test/HypervDirectConnectResourceTest.java   |  938 +++++++
 .../kvm/resource/BridgeVifDriver.java           |   29 +-
 .../kvm/resource/LibvirtComputingResource.java  |   95 +-
 .../hypervisor/kvm/storage/KVMStoragePool.java  |   12 +-
 .../kvm/storage/KVMStoragePoolManager.java      |  112 +-
 .../kvm/storage/KVMStorageProcessor.java        |    8 +-
 .../kvm/storage/LibvirtStorageAdaptor.java      |   85 +-
 .../kvm/storage/LibvirtStoragePool.java         |   11 +
 .../hypervisor/kvm/storage/StorageAdaptor.java  |   13 +
 .../kvm/storage/iScsiAdmStorageAdaptor.java     |  373 +++
 .../kvm/storage/iScsiAdmStoragePool.java        |  167 ++
 .../simulator-planner/module.properties         |   18 -
 .../simulator-planner/spring-context.xml        |   34 -
 .../driver/SimulatorImageStoreDriverImpl.java   |   34 +-
 .../SimulatorImageStoreLifeCycleImpl.java       |   36 +-
 .../vmware/manager/VmwareHostService.java       |    3 +
 .../manager/VmwareStorageManagerImpl.java       |   87 +-
 .../vmware/resource/VmwareResource.java         |   74 +-
 .../VmwareSecondaryStorageResourceHandler.java  |    4 +
 .../resource/VmwareStorageProcessor.java        |  123 +-
 .../xen/discoverer/XcpServerDiscoverer.java     |    3 +
 .../xen/resource/CitrixResourceBase.java        |  315 ++-
 .../xen/resource/XenServer56FP1Resource.java    |  133 -
 .../xen/resource/XenServerStorageProcessor.java |   33 +-
 .../api/ConfigureNexusVsmForAsaCommand.java     |    3 +
 .../cloud/network/element/CiscoVnmcElement.java |  206 +-
 .../network-elements/juniper-contrail/pom.xml   |  136 +
 .../api/command/CreateServiceInstanceCmd.java   |  182 ++
 .../api/response/ServiceInstanceResponse.java   |   83 +
 .../contrail/management/ContrailElement.java    |   28 +
 .../management/ContrailElementImpl.java         |  349 +++
 .../contrail/management/ContrailGuru.java       |  333 +++
 .../contrail/management/ContrailManager.java    |   93 +
 .../management/ContrailManagerImpl.java         |  769 ++++++
 .../contrail/management/DBSyncGeneric.java      |  322 +++
 .../network/contrail/management/EventUtils.java |  120 +
 .../management/ManagementNetworkGuru.java       |  114 +
 .../contrail/management/ModelDatabase.java      |   89 +
 .../contrail/management/ServerDBSync.java       |   39 +
 .../contrail/management/ServerDBSyncImpl.java   |  965 +++++++
 .../contrail/management/ServerEventHandler.java |   22 +
 .../management/ServerEventHandlerImpl.java      |  251 ++
 .../contrail/management/ServiceManager.java     |   40 +
 .../contrail/management/ServiceManagerImpl.java |  249 ++
 .../management/ServiceVirtualMachine.java       |   30 +
 .../network/contrail/model/FloatingIpModel.java |  213 ++
 .../contrail/model/FloatingIpPoolModel.java     |  170 ++
 .../network/contrail/model/InstanceIpModel.java |  174 ++
 .../network/contrail/model/ModelController.java |   85 +
 .../network/contrail/model/ModelObject.java     |  118 +
 .../network/contrail/model/ModelObjectBase.java |  111 +
 .../contrail/model/ServiceInstanceModel.java    |  320 +++
 .../contrail/model/VMInterfaceModel.java        |  265 ++
 .../contrail/model/VirtualMachineModel.java     |  349 +++
 .../contrail/model/VirtualNetworkModel.java     |  494 ++++
 .../management/ApiConnectorMockito.java         |  149 +
 .../IntegrationTestConfiguration.java           |  835 ++++++
 .../management/ManagementServerMock.java        |  393 +++
 .../contrail/management/MockAccountManager.java |  372 +++
 .../management/NetworkProviderTest.java         |  477 ++++
 .../management/ProviderTestConfiguration.java   |   12 +
 .../contrail/management/PublicNetworkTest.java  |  147 +
 .../PublicNetworkTestConfiguration.java         |   13 +
 .../contrail/management/TestDbSetup.java        |  151 ++
 .../management/VirtualNetworkModelTest.java     |   62 +
 .../test/resources/commonContext.xml            |  172 ++
 .../test/resources/contrail.properties          |   19 +
 .../test/resources/db.properties                |   66 +
 .../test/resources/log4j.properties             |   35 +
 .../test/resources/mysql_db_start.sh            |   51 +
 .../test/resources/mysql_db_stop.sh             |   31 +
 .../test/resources/providerContext.xml          |   16 +
 .../test/resources/publicNetworkContext.xml     |   16 +
 plugins/network-elements/nicira-nvp/pom.xml     |   35 +
 .../cloudstack/nvp/spring-nvp-context.xml       |    2 +-
 ...ortForwardingRulesOnLogicalRouterAnswer.java |   18 +-
 ...rtForwardingRulesOnLogicalRouterCommand.java |   69 +-
 ...ConfigurePublicIpsOnLogicalRouterAnswer.java |   13 +-
 ...onfigurePublicIpsOnLogicalRouterCommand.java |   80 +-
 ...gureStaticNatRulesOnLogicalRouterAnswer.java |   36 +-
 ...ureStaticNatRulesOnLogicalRouterCommand.java |   74 +-
 .../agent/api/CreateLogicalRouterAnswer.java    |    8 +-
 .../agent/api/CreateLogicalRouterCommand.java   |  178 +-
 .../agent/api/CreateLogicalSwitchAnswer.java    |    4 +-
 .../agent/api/CreateLogicalSwitchCommand.java   |   10 +-
 .../api/CreateLogicalSwitchPortAnswer.java      |    6 +-
 .../api/CreateLogicalSwitchPortCommand.java     |   14 +-
 .../agent/api/DeleteLogicalRouterAnswer.java    |    6 +-
 .../agent/api/DeleteLogicalRouterCommand.java   |   37 +-
 .../agent/api/DeleteLogicalSwitchCommand.java   |    6 +-
 .../api/DeleteLogicalSwitchPortCommand.java     |   10 +-
 .../agent/api/FindLogicalSwitchPortAnswer.java  |    6 +-
 .../agent/api/FindLogicalSwitchPortCommand.java |   16 +-
 .../api/UpdateLogicalSwitchPortAnswer.java      |    6 +-
 .../api/UpdateLogicalSwitchPortCommand.java     |   16 +-
 .../api/commands/AddNiciraNvpDeviceCmd.java     |   45 +-
 .../api/commands/DeleteNiciraNvpDeviceCmd.java  |   24 +-
 .../ListNiciraNvpDeviceNetworksCmd.java         |    8 +-
 .../api/commands/ListNiciraNvpDevicesCmd.java   |   14 +-
 .../api/response/NiciraNvpDeviceResponse.java   |   30 +-
 .../com/cloud/network/NiciraNvpDeviceVO.java    |   25 +-
 .../cloud/network/NiciraNvpNicMappingVO.java    |   17 +-
 .../cloud/network/NiciraNvpRouterMappingVO.java |   92 +-
 .../com/cloud/network/dao/NiciraNvpDaoImpl.java |    6 +-
 .../network/dao/NiciraNvpNicMappingDao.java     |    9 +-
 .../network/dao/NiciraNvpNicMappingDaoImpl.java |    6 +-
 .../network/dao/NiciraNvpRouterMappingDao.java  |    2 +-
 .../dao/NiciraNvpRouterMappingDaoImpl.java      |   29 +-
 .../cloud/network/element/NiciraNvpElement.java |   38 +-
 .../network/guru/NiciraNvpGuestNetworkGuru.java |    1 -
 .../network/nicira/ControlClusterStatus.java    |  108 +-
 .../network/nicira/DestinationNatRule.java      |    5 +-
 .../network/nicira/L3GatewayAttachment.java     |   60 +-
 .../network/nicira/LogicalRouterConfig.java     |   53 +-
 .../cloud/network/nicira/LogicalRouterPort.java |  132 +-
 .../com/cloud/network/nicira/LogicalSwitch.java |   28 +-
 .../cloud/network/nicira/LogicalSwitchPort.java |    4 +-
 .../src/com/cloud/network/nicira/Match.java     |  238 +-
 .../src/com/cloud/network/nicira/NatRule.java   |   14 +-
 .../com/cloud/network/nicira/NiciraNvpApi.java  |  351 +--
 .../com/cloud/network/nicira/NiciraNvpList.java |    4 +-
 .../com/cloud/network/nicira/NiciraNvpTag.java  |   14 +-
 .../cloud/network/nicira/PatchAttachment.java   |   31 +-
 .../com/cloud/network/nicira/RouterNextHop.java |   34 +-
 .../SingleDefaultRouteImplictRoutingConfig.java |   34 +-
 .../com/cloud/network/nicira/SourceNatRule.java |    4 +-
 .../network/nicira/TransportZoneBinding.java    |    6 +-
 .../com/cloud/network/nicira/VifAttachment.java |    8 +-
 .../network/resource/NiciraNvpResource.java     |  978 +++----
 .../network/element/NiciraNvpElementTest.java   |   21 +-
 .../guru/NiciraNvpGuestNetworkGuruTest.java     |  811 +++---
 .../com/cloud/network/nicira/NatRuleTest.java   |   16 +-
 .../cloud/network/nicira/NiciraNvpApiTest.java  |  542 ++--
 .../network/resource/NiciraNvpResourceTest.java | 1533 +++++------
 plugins/pom.xml                                 |    2 +
 .../driver/CloudStackImageStoreDriverImpl.java  |   16 +-
 .../CloudStackImageStoreLifeCycleImpl.java      |    9 +
 .../lifecycle/S3ImageStoreLifeCycleImpl.java    |   12 +-
 .../SampleImageStoreLifeCycleImpl.java          |    9 +
 .../driver/SwiftImageStoreDriverImpl.java       |   30 +-
 .../lifecycle/SwiftImageStoreLifeCycleImpl.java |   30 +-
 .../CloudStackPrimaryDataStoreDriverImpl.java   |   16 +-
 ...CloudStackPrimaryDataStoreLifeCycleImpl.java |   18 +-
 .../SamplePrimaryDataStoreDriverImpl.java       |    9 +-
 .../SamplePrimaryDataStoreLifeCycleImpl.java    |   34 +-
 .../SolidFirePrimaryDataStoreLifeCycle.java     |   54 +-
 .../provider/SolidFireHostListener.java         |  102 +
 .../SolidfirePrimaryDataStoreProvider.java      |   10 +-
 .../api/command/LdapImportUsersCmd.java         |  161 ++
 .../api/response/LdapUserResponse.java          |  162 +-
 .../cloudstack/ldap/LdapConfiguration.java      |   16 +-
 .../org/apache/cloudstack/ldap/LdapManager.java |    2 +
 .../apache/cloudstack/ldap/LdapManagerImpl.java |   24 +-
 .../org/apache/cloudstack/ldap/LdapUser.java    |   12 +-
 .../apache/cloudstack/ldap/LdapUserManager.java |  230 +-
 .../ldap/LdapConfigurationSpec.groovy           |   37 +-
 .../ldap/LdapCreateAccountCmdSpec.groovy        |    8 +-
 .../ldap/LdapImportUsersCmdSpec.groovy          |  191 ++
 .../cloudstack/ldap/LdapListUsersCmdSpec.groovy |   10 +-
 .../cloudstack/ldap/LdapManagerImplSpec.groovy  |   55 +-
 .../ldap/LdapSearchUserCmdSpec.groovy           |    5 +-
 .../cloudstack/ldap/LdapUserManagerSpec.groovy  |   77 +
 .../cloudstack/ldap/LdapUserResponseSpec.groovy |   18 +
 .../apache/cloudstack/ldap/LdapUserSpec.groovy  |   31 +-
 pom.xml                                         |   11 +
 python/lib/cloudutils/serviceConfig.py          |    5 +-
 scripts/storage/secondary/createtmplt.sh        |   23 +-
 scripts/vm/hypervisor/xenserver/s3xen           |   68 +-
 scripts/vm/hypervisor/xenserver/vmops           |    8 +-
 scripts/vm/network/vnet/modifyvxlan.sh          |   37 +-
 .../spring-server-core-managers-context.xml     |   20 +-
 .../system/spring-server-system-context.xml     |   36 +
 server/src/com/cloud/api/ApiDBUtils.java        |   35 +-
 server/src/com/cloud/api/ApiDispatcher.java     |   21 +-
 server/src/com/cloud/api/ApiResponseHelper.java |    8 +-
 .../com/cloud/api/query/QueryManagerImpl.java   |   88 +-
 .../com/cloud/api/query/ViewResponseHelper.java |    6 +-
 .../api/query/dao/DataCenterJoinDaoImpl.java    |    2 +
 .../query/dao/ServiceOfferingJoinDaoImpl.java   |    3 +-
 server/src/com/cloud/configuration/Config.java  |    3 +
 .../configuration/ConfigurationManagerImpl.java |   36 +-
 .../consoleproxy/ConsoleProxyManagerImpl.java   |    2 +-
 .../cloud/ha/HighAvailabilityManagerImpl.java   |    9 +-
 .../hypervisor/CloudZonesStartupProcessor.java  |   13 +-
 .../cloud/hypervisor/HypervisorGuruBase.java    |    2 +-
 .../metadata/ResourceMetaDataManagerImpl.java   |  162 +-
 .../ExternalFirewallDeviceManagerImpl.java      |   17 +-
 .../com/cloud/network/NetworkServiceImpl.java   |   26 +-
 .../network/element/VirtualRouterElement.java   |   15 +-
 .../element/VpcVirtualRouterElement.java        |   45 +
 .../network/firewall/FirewallManagerImpl.java   |   51 +-
 .../cloud/network/guru/ControlNetworkGuru.java  |    4 +-
 .../lb/LoadBalancingRulesManagerImpl.java       |   10 +-
 .../VirtualNetworkApplianceManagerImpl.java     |   13 +-
 .../VpcVirtualNetworkApplianceManager.java      |   29 +
 .../VpcVirtualNetworkApplianceManagerImpl.java  |  120 +-
 .../network/vpc/NetworkACLManagerImpl.java      |   10 +-
 .../network/vpn/RemoteAccessVpnManagerImpl.java |   89 +-
 .../network/vpn/Site2SiteVpnManagerImpl.java    |   20 +-
 .../com/cloud/server/ManagementServerImpl.java  |   89 +-
 .../com/cloud/storage/StorageManagerImpl.java   |   76 +-
 .../com/cloud/storage/VolumeApiServiceImpl.java |  190 +-
 .../storage/download/DownloadMonitorImpl.java   |   15 +-
 .../storage/listener/StoragePoolMonitor.java    |    3 +
 .../secondary/SecondaryStorageManagerImpl.java  |    2 +-
 .../storage/snapshot/SnapshotManagerImpl.java   |  110 +-
 .../cloud/storage/upload/UploadListener.java    |    7 +-
 .../cloud/storage/upload/UploadMonitorImpl.java |  118 +-
 .../cloud/tags/TaggedResourceManagerImpl.java   |    5 +
 .../template/HypervisorTemplateAdapter.java     |   29 +-
 .../com/cloud/template/TemplateManagerImpl.java |  109 +-
 .../src/com/cloud/usage/UsageServiceImpl.java   |   15 +-
 .../src/com/cloud/user/DomainManagerImpl.java   |    9 +
 server/src/com/cloud/vm/UserVmManagerImpl.java  |   32 +-
 .../vm/snapshot/VMSnapshotManagerImpl.java      |  456 +---
 .../cloudstack/region/RegionManagerImpl.java    |   21 +-
 .../metadata/ResourceMetaDataManagerTest.java   |   12 +-
 .../SecurityGroupManagerTestConfiguration.java  |    4 +-
 .../com/cloud/user/MockDomainManagerImpl.java   |    6 +
 .../vm/snapshot/VMSnapshotManagerTest.java      |    7 -
 .../MockVpcVirtualNetworkApplianceManager.java  |   22 +
 .../com/cloud/vpc/VpcTestConfiguration.java     |    4 +-
 .../networkoffering/ChildTestConfiguration.java |    4 +-
 setup/db/db/schema-420to421.sql                 |    7 +-
 setup/db/db/schema-421to430.sql                 |   41 +
 .../debian/config/etc/init.d/cloud-early-config |   17 +-
 .../debian/config/opt/cloud/bin/ipsectunnel.sh  |   47 +-
 .../debian/vpn/opt/cloud/bin/vpc_vpn_l2tp.sh    |  178 --
 .../debian/vpn/opt/cloud/bin/vpn_l2tp.sh        |   95 +-
 .../component/maint/test_multiple_ip_ranges.py  |  557 ++--
 .../component/test_base_image_updation.py       |  648 +++++
 .../component/test_deploy_vm_userdata_reg.py    |  220 ++
 test/integration/component/test_egress_rules.py |  207 --
 .../component/test_non_contiguous_vlan.py       |  446 +++
 .../component/test_reset_ssh_keypair.py         |   48 +-
 .../component/test_resource_limits.py           |    2 +-
 test/integration/component/test_routers.py      |   52 +-
 .../component/test_shared_network_offering.py   |  213 --
 .../component/test_shared_networks.py           |  786 +++---
 .../component/test_snapshots_improvement.py     |  693 +++++
 test/integration/component/test_vpc_network.py  |  241 +-
 .../component/test_vpc_vms_deployment.py        |   40 +-
 test/integration/smoke/test_routers.py          |   15 +-
 test/integration/smoke/test_vpc_vpn.py          |  391 +++
 tools/apidoc/gen_toc.py                         |    1 +
 tools/eclipse/ApacheCloudStack.xml              |  309 +++
 tools/marvin/marvin/asyncJobMgr.py              |    4 +-
 tools/marvin/marvin/cloudstackTestClient.py     |   15 +
 tools/marvin/marvin/codes.py                    |    9 +-
 tools/marvin/marvin/config/setup.cfg            |  228 ++
 tools/marvin/marvin/configGenerator.py          |  169 +-
 tools/marvin/marvin/deployDataCenter.py         |   18 +-
 tools/marvin/marvin/integration/lib/base.py     |   11 +
 tools/marvin/marvin/integration/lib/utils.py    |   75 +
 tools/marvin/marvin/marvinPlugin.py             |   20 +-
 ui/css/cloudstack3.css                          | 1301 +++++----
 ui/dictionary.jsp                               |    3 +
 ui/images/header-gradient.png                   |  Bin 0 -> 62651 bytes
 ui/images/overlay-pattern.png                   |  Bin 0 -> 14969 bytes
 ui/images/sprites.png                           |  Bin 193277 -> 207810 bytes
 ui/index.jsp                                    |   37 +-
 ui/scripts/accounts.js                          |   22 +-
 ui/scripts/configuration.js                     |   33 +-
 ui/scripts/events.js                            |  142 +-
 ui/scripts/instanceWizard.js                    |   43 +-
 ui/scripts/instances.js                         |  197 +-
 ui/scripts/network.js                           |   53 +
 ui/scripts/plugins.js                           |    3 +-
 ui/scripts/sharedFunctions.js                   |    2 +-
 ui/scripts/system.js                            |   40 +-
 ui/scripts/ui-custom/instanceWizard.js          |   23 +-
 ui/scripts/ui-custom/physicalResources.js       |   24 +
 ui/scripts/ui-custom/pluginListing.js           |    8 +
 ui/scripts/ui/core.js                           |   21 +-
 ui/scripts/ui/widgets/detailView.js             |   43 +-
 ui/scripts/ui/widgets/listView.js               |    6 +-
 ui/scripts/ui/widgets/notifications.js          |   20 +-
 ui/scripts/vpc.js                               |   10 +-
 utils/src/com/cloud/utils/ProcessUtil.java      |    5 +-
 utils/src/com/cloud/utils/PropertiesUtil.java   |   10 +-
 .../com/cloud/utils/crypt/DBEncryptionUtil.java |   26 +-
 .../utils/crypt/EncryptionSecretKeyChecker.java |  179 +-
 utils/src/com/cloud/utils/db/DbProperties.java  |  105 +
 .../com/cloud/utils/PropertiesUtilsTest.java    |   13 +
 .../hypervisor/vmware/mo/VirtualMachineMO.java  |   16 +-
 554 files changed, 77172 insertions(+), 9481 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --cc client/WEB-INF/classes/resources/messages.properties
index 5536b07,12d2a11..e473eb4
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@@ -14,10 -14,9 +14,13 @@@
  # KIND, either express or implied.  See the License for the
  # specific language governing permissions and limitations
  # under the License.
 +message.select.compute.offering=Please select a compute offering to associate with this instance.
 +message.select.disk.offering=(Optional) Select an additional disk offering to attach to this instance.
 +label.home=Home
 +label.use.default.language=Use default language
+ label.hypervisors=Hypervisors
+ label.home=Home
+ label.sockets=Sockets
  label.root.disk.size=Root disk size
  label.s3.nfs.server=S3 NFS Server
  label.s3.nfs.path=S3 NFS Path

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/ui/dictionary.jsp
----------------------------------------------------------------------
diff --cc ui/dictionary.jsp
index 8db8308,1bf0eab..92ea06c
--- a/ui/dictionary.jsp
+++ b/ui/dictionary.jsp
@@@ -25,10 -25,9 +25,13 @@@ under the License
  <% long now = System.currentTimeMillis(); %>
  <script language="javascript">
  dictionary = {
 +'message.select.compute.offering': '<fmt:message key="message.select.compute.offering" />',
 +'message.select.disk.offering': '<fmt:message key="message.select.disk.offering" />',
 +'label.home': '<fmt:message key="label.home" />',
 +'label.use.default.language': '<fmt:message key="label.use.default.language" />',
+ 'label.hypervisors': '<fmt:message key="label.hypervisors" />',
+ 'label.home': '<fmt:message key="label.home" />',
+ 'label.sockets': '<fmt:message key="label.sockets" />',
  'label.root.disk.size': '<fmt:message key="label.root.disk.size" />',
  'label.s3.nfs.path': '<fmt:message key="label.s3.nfs.path" />',
  'label.s3.nfs.server': '<fmt:message key="label.s3.nfs.server" />',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/ui/index.jsp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/ui/scripts/sharedFunctions.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/ui/scripts/ui-custom/instanceWizard.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/ui/scripts/ui/core.js
----------------------------------------------------------------------
diff --cc ui/scripts/ui/core.js
index 8e84acd,06be12b..97f10aa
--- a/ui/scripts/ui/core.js
+++ b/ui/scripts/ui/core.js
@@@ -292,9 -302,9 +303,9 @@@
          var $options = $('<div>').attr({
              id: 'user-options'
          })
-             .appendTo($('#header'));
+             .appendTo($('#user'));
  
 -        $(['label.logout', 'label.help', 'label.about']).each(function() {
 +        $(['label.about', 'label.help', 'label.logout']).each(function() {
              var $link = $('<a>')
                  .attr({
                      href: '#'

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/ui/scripts/ui/widgets/listView.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b7259a48/ui/scripts/ui/widgets/notifications.js
----------------------------------------------------------------------


[49/56] [abbrv] Fix checkstyle errors in Nicira NVP plugin

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
index 58c0333..42e436f 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
@@ -16,8 +16,19 @@
 // under the License.
 package com.cloud.network.guru;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Arrays;
 import java.util.Collections;
 
 import org.junit.Before;
@@ -25,16 +36,13 @@ import org.junit.Test;
 
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.CreateLogicalSwitchAnswer;
 import com.cloud.agent.api.DeleteLogicalSwitchAnswer;
 import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.DataCenter.NetworkType;
+import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.deploy.DeploymentPlan;
@@ -61,404 +69,401 @@ import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
 import com.cloud.user.Account;
 import com.cloud.vm.ReservationContext;
 
-import java.util.Arrays;
-
 public class NiciraNvpGuestNetworkGuruTest {
-	PhysicalNetworkDao physnetdao = mock (PhysicalNetworkDao.class);
-	NiciraNvpDao nvpdao = mock(NiciraNvpDao.class);
-	DataCenterDao dcdao = mock(DataCenterDao.class);
-	NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class);
-	AgentManager agentmgr = mock (AgentManager.class);
-	NetworkOrchestrationService netmgr = mock (NetworkOrchestrationService.class);
-	NetworkModel netmodel = mock (NetworkModel.class);
-
-	HostDao hostdao = mock (HostDao.class);
-	NetworkDao netdao = mock(NetworkDao.class);
-	NiciraNvpGuestNetworkGuru guru;
-	
-	
-	@Before
-	public void setUp() {
-		guru = new NiciraNvpGuestNetworkGuru();
-		((GuestNetworkGuru) guru)._physicalNetworkDao = physnetdao;
-		guru._physicalNetworkDao = physnetdao;
-		guru._niciraNvpDao = nvpdao;
-		guru._dcDao = dcdao;
-		guru._ntwkOfferingSrvcDao = nosd;
-		guru._networkModel = netmodel;
-		guru._hostDao = hostdao;
-		guru._agentMgr = agentmgr;
-		guru._networkDao = netdao;
-		
-		DataCenterVO dc = mock(DataCenterVO.class);
-		when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
-		when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
-		
-		when(dcdao.findById((Long) any())).thenReturn((DataCenterVO) dc);
-	}
-	
-	@Test
-	public void testCanHandle() {
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-	
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(true);
-		
-		assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
-		
-		// Not supported TrafficType != Guest
-		when(offering.getTrafficType()).thenReturn(TrafficType.Management);
-		assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
-		
-		// Not supported: GuestType Shared
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Shared);
-		assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
-		
-		// Not supported: Basic networking
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true);
-		
-		// Not supported: IsolationMethod != STT
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
-		assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
-		
-	}
-	
-	
-	@Test
-	public void testDesign() {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(true);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		Network network = mock(Network.class);
-		Account account = mock(Account.class);
-		
-		Network designednetwork = guru.design(offering, plan, network, account);
-		assertTrue(designednetwork != null);
-		assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Lswitch);		
-	}
-	
-	@Test
-	public void testDesignNoElementOnPhysicalNetwork() {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		Network network = mock(Network.class);
-		Account account = mock(Account.class);
-		
-		Network designednetwork = guru.design(offering, plan, network, account);
-		assertTrue(designednetwork == null);	
-	}
-	
-	@Test
-	public void testDesignNoIsolationMethodSTT() {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		Network network = mock(Network.class);
-		Account account = mock(Account.class);
-		
-		Network designednetwork = guru.design(offering, plan, network, account);
-		assertTrue(designednetwork == null);			
-	}
-	
-	@Test
-	public void testDesignNoConnectivityInOffering() {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		Network network = mock(Network.class);
-		Account account = mock(Account.class);
-		
-		Network designednetwork = guru.design(offering, plan, network, account);
-		assertTrue(designednetwork == null);		
-	}
-	
-	@Test
-	public void testImplement() throws InsufficientVirtualNetworkCapcityException {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		
-		NetworkVO network = mock(NetworkVO.class);
-		when(network.getName()).thenReturn("testnetwork");
-		when(network.getState()).thenReturn(State.Implementing);
-		when(network.getPhysicalNetworkId()).thenReturn(42L);
-		
-		DeployDestination dest = mock(DeployDestination.class);
-		
-		DataCenter dc = mock(DataCenter.class);
-		when(dest.getDataCenter()).thenReturn(dc);
-		
-		HostVO niciraHost = mock(HostVO.class);
-		when(hostdao.findById(anyLong())).thenReturn(niciraHost);
-		when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
-		when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
-		when(niciraHost.getId()).thenReturn(42L);
-		
-		when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
-		Domain dom = mock(Domain.class);
-		when(dom.getName()).thenReturn("domain");
-		Account acc = mock(Account.class);
-		when(acc.getAccountName()).thenReturn("accountname");
-		ReservationContext res = mock(ReservationContext.class);
-		when(res.getDomain()).thenReturn(dom);
-		when(res.getAccount()).thenReturn(acc);
-		
-		CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
-		when(answer.getResult()).thenReturn(true);
-		when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
- 		when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);		
-
- 		Network implementednetwork = guru.implement(network, offering, dest, res);
-		assertTrue(implementednetwork != null);		
-		verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
-	}
-
-	@Test
-	public void testImplementWithCidr() throws InsufficientVirtualNetworkCapcityException {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		
-		NetworkVO network = mock(NetworkVO.class);
-		when(network.getName()).thenReturn("testnetwork");
-		when(network.getState()).thenReturn(State.Implementing);
-		when(network.getGateway()).thenReturn("10.1.1.1");
-		when(network.getCidr()).thenReturn("10.1.1.0/24");
-		when(network.getPhysicalNetworkId()).thenReturn(42L);
-		
-		DeployDestination dest = mock(DeployDestination.class);
-		
-		DataCenter dc = mock(DataCenter.class);
-		when(dest.getDataCenter()).thenReturn(dc);
-		
-		HostVO niciraHost = mock(HostVO.class);
-		when(hostdao.findById(anyLong())).thenReturn(niciraHost);
-		when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
-		when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
-		when(niciraHost.getId()).thenReturn(42L);
-		
-		when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
-		Domain dom = mock(Domain.class);
-		when(dom.getName()).thenReturn("domain");
-		Account acc = mock(Account.class);
-		when(acc.getAccountName()).thenReturn("accountname");
-		ReservationContext res = mock(ReservationContext.class);
-		when(res.getDomain()).thenReturn(dom);
-		when(res.getAccount()).thenReturn(acc);
-		
-		CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
-		when(answer.getResult()).thenReturn(true);
-		when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
- 		when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);		
-
- 		Network implementednetwork = guru.implement(network, offering, dest, res);
-		assertTrue(implementednetwork != null);		
-		assertTrue(implementednetwork.getCidr().equals("10.1.1.0/24"));
-		assertTrue(implementednetwork.getGateway().equals("10.1.1.1"));
-		verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
-	}
-	
-	@Test
-	public void testImplementURIException() throws InsufficientVirtualNetworkCapcityException {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		
-		NetworkVO network = mock(NetworkVO.class);
-		when(network.getName()).thenReturn("testnetwork");
-		when(network.getState()).thenReturn(State.Implementing);
-		when(network.getPhysicalNetworkId()).thenReturn(42L);
-		
-		DeployDestination dest = mock(DeployDestination.class);
-		
-		DataCenter dc = mock(DataCenter.class);
-		when(dest.getDataCenter()).thenReturn(dc);
-		
-		HostVO niciraHost = mock(HostVO.class);
-		when(hostdao.findById(anyLong())).thenReturn(niciraHost);
-		when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
-		when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
-		when(niciraHost.getId()).thenReturn(42L);
-		
-		when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
-		Domain dom = mock(Domain.class);
-		when(dom.getName()).thenReturn("domain");
-		Account acc = mock(Account.class);
-		when(acc.getAccountName()).thenReturn("accountname");
-		ReservationContext res = mock(ReservationContext.class);
-		when(res.getDomain()).thenReturn(dom);
-		when(res.getAccount()).thenReturn(acc);
-		
-		CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
-		when(answer.getResult()).thenReturn(true);
-		//when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
- 		when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);		
-
- 		Network implementednetwork = guru.implement(network, offering, dest, res);
-		assertTrue(implementednetwork == null);		
-		verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
-	}
-	
-	@Test
-	public void testShutdown() throws InsufficientVirtualNetworkCapcityException, URISyntaxException {
-		PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
-		when(physnetdao.findById((Long) any())).thenReturn(physnet);
-		when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
-		when(physnet.getId()).thenReturn(42L);
-		
-		NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
-		when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
-		when(device.getId()).thenReturn(1L);
-		
-		NetworkOffering offering = mock(NetworkOffering.class);
-		when(offering.getId()).thenReturn(42L);
-		when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
-		when(offering.getGuestType()).thenReturn(GuestType.Isolated);
-		
-		when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
-		
-		DeploymentPlan plan = mock(DeploymentPlan.class);
-		
-		NetworkVO network = mock(NetworkVO.class);
-		when(network.getName()).thenReturn("testnetwork");
-		when(network.getState()).thenReturn(State.Implementing);
-		when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
-		when(network.getBroadcastUri()).thenReturn(new URI("lswitch:aaaaa"));
-		when(network.getPhysicalNetworkId()).thenReturn(42L);
-		when(netdao.findById(42L)).thenReturn(network);
-		
-		DeployDestination dest = mock(DeployDestination.class);
-		
-		DataCenter dc = mock(DataCenter.class);
-		when(dest.getDataCenter()).thenReturn(dc);
-		
-		HostVO niciraHost = mock(HostVO.class);
-		when(hostdao.findById(anyLong())).thenReturn(niciraHost);
-		when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
-		when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
-		when(niciraHost.getId()).thenReturn(42L);
-		
-		when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
-		Domain dom = mock(Domain.class);
-		when(dom.getName()).thenReturn("domain");
-		Account acc = mock(Account.class);
-		when(acc.getAccountName()).thenReturn("accountname");
-		ReservationContext res = mock(ReservationContext.class);
-		when(res.getDomain()).thenReturn(dom);
-		when(res.getAccount()).thenReturn(acc);
-		
-		DeleteLogicalSwitchAnswer answer = mock(DeleteLogicalSwitchAnswer.class);
-		when(answer.getResult()).thenReturn(true);
- 		when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);		
-
- 		NetworkProfile implementednetwork = mock(NetworkProfile.class);
- 		when(implementednetwork.getId()).thenReturn(42L);
- 		when(implementednetwork.getBroadcastUri()).thenReturn(new URI("lswitch:aaaa"));
- 		when(offering.getSpecifyVlan()).thenReturn(false);
- 		
- 		guru.shutdown(implementednetwork, offering);
-		verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
-		verify(implementednetwork, times(1)).setBroadcastUri(null);
-	}
+    PhysicalNetworkDao physnetdao = mock(PhysicalNetworkDao.class);
+    NiciraNvpDao nvpdao = mock(NiciraNvpDao.class);
+    DataCenterDao dcdao = mock(DataCenterDao.class);
+    NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class);
+    AgentManager agentmgr = mock (AgentManager.class);
+    NetworkOrchestrationService netmgr = mock (NetworkOrchestrationService.class);
+    NetworkModel netmodel = mock (NetworkModel.class);
+
+    HostDao hostdao = mock (HostDao.class);
+    NetworkDao netdao = mock(NetworkDao.class);
+    NiciraNvpGuestNetworkGuru guru;
+
+
+    @Before
+    public void setUp() {
+        guru = new NiciraNvpGuestNetworkGuru();
+        ((GuestNetworkGuru) guru)._physicalNetworkDao = physnetdao;
+        guru._physicalNetworkDao = physnetdao;
+        guru._niciraNvpDao = nvpdao;
+        guru._dcDao = dcdao;
+        guru._ntwkOfferingSrvcDao = nosd;
+        guru._networkModel = netmodel;
+        guru._hostDao = hostdao;
+        guru._agentMgr = agentmgr;
+        guru._networkDao = netdao;
+
+        DataCenterVO dc = mock(DataCenterVO.class);
+        when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
+        when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
+
+        when(dcdao.findById((Long) any())).thenReturn(dc);
+    }
+
+    @Test
+    public void testCanHandle() {
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(true);
+
+        assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported TrafficType != Guest
+        when(offering.getTrafficType()).thenReturn(TrafficType.Management);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported: GuestType Shared
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Shared);
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+        // Not supported: Basic networking
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+        assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true);
+
+        // Not supported: IsolationMethod != STT
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
+        assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true);
+
+    }
+
+    @Test
+    public void testDesign() {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(true);
+
+        DeploymentPlan plan = mock(DeploymentPlan.class);
+        Network network = mock(Network.class);
+        Account account = mock(Account.class);
+
+        Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork != null);
+        assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Lswitch);
+    }
+
+    @Test
+    public void testDesignNoElementOnPhysicalNetwork() {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        DeploymentPlan plan = mock(DeploymentPlan.class);
+        Network network = mock(Network.class);
+        Account account = mock(Account.class);
+
+        Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork == null);
+    }
+
+    @Test
+    public void testDesignNoIsolationMethodSTT() {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VLAN" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        DeploymentPlan plan = mock(DeploymentPlan.class);
+        Network network = mock(Network.class);
+        Account account = mock(Account.class);
+
+        Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork == null);
+    }
+
+    @Test
+    public void testDesignNoConnectivityInOffering() {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        DeploymentPlan plan = mock(DeploymentPlan.class);
+        Network network = mock(Network.class);
+        Account account = mock(Account.class);
+
+        Network designednetwork = guru.design(offering, plan, network, account);
+        assertTrue(designednetwork == null);
+    }
+
+    @Test
+    public void testImplement() throws InsufficientVirtualNetworkCapcityException {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(42L);
+
+        DeployDestination dest = mock(DeployDestination.class);
+
+        DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        HostVO niciraHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(niciraHost);
+        when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
+        when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
+        when(niciraHost.getId()).thenReturn(42L);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
+        Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
+        when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);
+
+        Network implementednetwork = guru.implement(network, offering, dest, res);
+        assertTrue(implementednetwork != null);
+        verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
+    }
+
+    @Test
+    public void testImplementWithCidr() throws InsufficientVirtualNetworkCapcityException {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getGateway()).thenReturn("10.1.1.1");
+        when(network.getCidr()).thenReturn("10.1.1.0/24");
+        when(network.getPhysicalNetworkId()).thenReturn(42L);
+
+        DeployDestination dest = mock(DeployDestination.class);
+
+        DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        HostVO niciraHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(niciraHost);
+        when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
+        when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
+        when(niciraHost.getId()).thenReturn(42L);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
+        Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
+        when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);
+
+        Network implementednetwork = guru.implement(network, offering, dest, res);
+        assertTrue(implementednetwork != null);
+        assertTrue(implementednetwork.getCidr().equals("10.1.1.0/24"));
+        assertTrue(implementednetwork.getGateway().equals("10.1.1.1"));
+        verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
+    }
+
+    @Test
+    public void testImplementURIException() throws InsufficientVirtualNetworkCapcityException {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getPhysicalNetworkId()).thenReturn(42L);
+
+        DeployDestination dest = mock(DeployDestination.class);
+
+        DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        HostVO niciraHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(niciraHost);
+        when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
+        when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
+        when(niciraHost.getId()).thenReturn(42L);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
+        Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        //when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
+        when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);
+
+        Network implementednetwork = guru.implement(network, offering, dest, res);
+        assertTrue(implementednetwork == null);
+        verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
+    }
+
+    @Test
+    public void testShutdown() throws InsufficientVirtualNetworkCapcityException, URISyntaxException {
+        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        when(physnetdao.findById((Long) any())).thenReturn(physnet);
+        when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
+        when(physnet.getId()).thenReturn(42L);
+
+        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        when(nvpdao.listByPhysicalNetwork(42L)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
+        when(device.getId()).thenReturn(1L);
+
+        NetworkOffering offering = mock(NetworkOffering.class);
+        when(offering.getId()).thenReturn(42L);
+        when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(offering.getGuestType()).thenReturn(GuestType.Isolated);
+
+        when(nosd.areServicesSupportedByNetworkOffering(42L, Service.Connectivity)).thenReturn(false);
+
+        mock(DeploymentPlan.class);
+
+        NetworkVO network = mock(NetworkVO.class);
+        when(network.getName()).thenReturn("testnetwork");
+        when(network.getState()).thenReturn(State.Implementing);
+        when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
+        when(network.getBroadcastUri()).thenReturn(new URI("lswitch:aaaaa"));
+        when(network.getPhysicalNetworkId()).thenReturn(42L);
+        when(netdao.findById(42L)).thenReturn(network);
+
+        DeployDestination dest = mock(DeployDestination.class);
+
+        DataCenter dc = mock(DataCenter.class);
+        when(dest.getDataCenter()).thenReturn(dc);
+
+        HostVO niciraHost = mock(HostVO.class);
+        when(hostdao.findById(anyLong())).thenReturn(niciraHost);
+        when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
+        when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
+        when(niciraHost.getId()).thenReturn(42L);
+
+        when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(42L);
+        Domain dom = mock(Domain.class);
+        when(dom.getName()).thenReturn("domain");
+        Account acc = mock(Account.class);
+        when(acc.getAccountName()).thenReturn("accountname");
+        ReservationContext res = mock(ReservationContext.class);
+        when(res.getDomain()).thenReturn(dom);
+        when(res.getAccount()).thenReturn(acc);
+
+        DeleteLogicalSwitchAnswer answer = mock(DeleteLogicalSwitchAnswer.class);
+        when(answer.getResult()).thenReturn(true);
+        when(agentmgr.easySend(eq(42L), (Command)any())).thenReturn(answer);
+
+        NetworkProfile implementednetwork = mock(NetworkProfile.class);
+        when(implementednetwork.getId()).thenReturn(42L);
+        when(implementednetwork.getBroadcastUri()).thenReturn(new URI("lswitch:aaaa"));
+        when(offering.getSpecifyVlan()).thenReturn(false);
+
+        guru.shutdown(implementednetwork, offering);
+        verify(agentmgr, times(1)).easySend(eq(42L), (Command)any());
+        verify(implementednetwork, times(1)).setBroadcastUri(null);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
index 8e7245e..9c6f85e 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
@@ -16,7 +16,7 @@
 // under the License.
 package com.cloud.network.nicira;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
@@ -25,14 +25,14 @@ import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
 public class NatRuleTest {
-	
+
     @Test
     public void testNatRuleEncoding() {
         Gson gson = new GsonBuilder()
-            .registerTypeAdapter(NatRule.class, new com.cloud.network.nicira.NiciraNvpApi.NatRuleAdapter())
-            .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
-            .create();
-        
+        .registerTypeAdapter(NatRule.class, new com.cloud.network.nicira.NiciraNvpApi.NatRuleAdapter())
+        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
+        .create();
+
         DestinationNatRule rn1 = new DestinationNatRule();
         rn1.setToDestinationIpAddress("10.10.10.10");
         rn1.setToDestinationPort(80);
@@ -41,12 +41,12 @@ public class NatRuleTest {
         mr1.setEthertype("IPv4");
         mr1.setProtocol(6);
         rn1.setMatch(mr1);
-        
+
         String jsonString = gson.toJson(rn1);
         NatRule dnr = gson.fromJson(jsonString, NatRule.class);
 
         assertTrue(dnr instanceof DestinationNatRule);
         assertTrue(rn1.equals(dnr));
     }
-	
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
index 42eb96e..1467d47 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
@@ -16,8 +16,12 @@
 // under the License.
 package com.cloud.network.nicira;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -36,271 +40,271 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class NiciraNvpApiTest {
-	NiciraNvpApi _api;
-	HttpClient _client = mock(HttpClient.class);
-	HttpMethod _method;
-	
-	@Before
-	public void setUp() {
-		HttpClientParams hmp = mock(HttpClientParams.class);
-		when (_client.getParams()).thenReturn(hmp);
-		_api = new NiciraNvpApi() {
-			@Override
-			protected HttpClient createHttpClient() {
-				return _client;
-			}
-			
-			@Override
-			protected HttpMethod createMethod(String type, String uri) {
-				return _method;
-			}
-		};
-		_api.setAdminCredentials("admin", "adminpass");
-		_api.setControllerAddress("localhost");
-	}
-	
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteLoginWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.login();
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteLoginWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.login();
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteUpdateObjectWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteUpdateObjectWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteCreateObjectWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteCreateObjectWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteDeleteObjectWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.executeDeleteObject("/");
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteDeleteObjectWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.executeDeleteObject("/");
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteRetrieveObjectWithoutHostname() throws NiciraNvpApiException {
-		_api.setControllerAddress(null);
-		_api.executeRetrieveObject(String.class, "/", Collections.<String, String> emptyMap());
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteRetrieveObjectWithoutCredentials() throws NiciraNvpApiException {
-		_api.setAdminCredentials(null, null);
-		_api.executeDeleteObject("/");
-	}
-
-	@Test
-	public void executeMethodTest() throws NiciraNvpApiException {
-		GetMethod gm = mock(GetMethod.class);
-		
-		when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		_api.executeMethod(gm);
-		verify(gm, times(1)).getStatusCode();
-	}
-
-	/* Bit of a roundabout way to ensure that login is called after an un authorized result
-	 * It not possible to properly mock login()
-	 */
-	@Test (expected=NiciraNvpApiException.class)
-	public void executeMethodTestWithLogin() throws NiciraNvpApiException, HttpException, IOException {
-		GetMethod gm = mock(GetMethod.class);
-		when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
-		when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
-		_api.executeMethod(gm);
-		verify(gm, times(1)).getStatusCode();
-	}
-	
-	@Test
-	public void testExecuteCreateObject() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PostMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
-		when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
-		ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		assertTrue("aaaa".equals(ls.getUuid()));
-		verify(_method, times(1)).releaseConnection();
-		
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteCreateObjectFailure() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PostMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		when(_method.isRequestSent()).thenReturn(true);
-		try {
-			ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteCreateObjectException() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
-		_method = mock(PostMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		try {
-			ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test
-	public void testExecuteUpdateObject() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PutMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		_api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-		verify(_method, times(1)).releaseConnection();
-		verify(_client, times(1)).executeMethod(_method);
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteUpdateObjectFailure() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PutMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		when(_method.isRequestSent()).thenReturn(true);
-		try {
-			_api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteUpdateObjectException() throws NiciraNvpApiException, IOException {
-		LogicalSwitch ls = new LogicalSwitch();
-		_method = mock(PutMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		when(_client.executeMethod((HttpMethod) any())).thenThrow(new IOException());
-		try {
-			_api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test
-	public void testExecuteDeleteObject() throws NiciraNvpApiException, IOException {
-		_method = mock(DeleteMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
-		_api.executeDeleteObject("/");
-		verify(_method, times(1)).releaseConnection();
-		verify(_client, times(1)).executeMethod(_method);
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteDeleteObjectFailure() throws NiciraNvpApiException, IOException {
-		_method = mock(DeleteMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		when(_method.isRequestSent()).thenReturn(true);
-		try {
-			_api.executeDeleteObject("/");
-		} finally {
-			verify(_method, times(1)).releaseConnection();			
-		}
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteDeleteObjectException() throws NiciraNvpApiException, IOException {
-		_method = mock(DeleteMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
-		when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
-		try {
-			_api.executeDeleteObject("/");
-		} finally {
-			verify(_method, times(1)).releaseConnection();			
-		}	
-	}
-
-	@Test
-	public void testExecuteRetrieveObject() throws NiciraNvpApiException, IOException {
-		_method = mock(GetMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
-		_api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		verify(_method, times(1)).releaseConnection();
-		verify(_client, times(1)).executeMethod(_method);
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteRetrieveObjectFailure() throws NiciraNvpApiException, IOException {
-		_method = mock(GetMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-		when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
-		Header header = mock(Header.class);
-		when(header.getValue()).thenReturn("text/html");
-		when(_method.getResponseHeader("Content-Type")).thenReturn(header);
-		when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-		when(_method.isRequestSent()).thenReturn(true);
-		try {
-			_api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-
-	@Test (expected=NiciraNvpApiException.class)
-	public void testExecuteRetrieveObjectException() throws NiciraNvpApiException, IOException {
-		_method = mock(GetMethod.class);
-		when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-		when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
-		when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
-		try {
-			_api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-		} finally {
-			verify(_method, times(1)).releaseConnection();
-		}
-	}
-	
+    NiciraNvpApi _api;
+    HttpClient _client = mock(HttpClient.class);
+    HttpMethod _method;
+
+    @Before
+    public void setUp() {
+        HttpClientParams hmp = mock(HttpClientParams.class);
+        when (_client.getParams()).thenReturn(hmp);
+        _api = new NiciraNvpApi() {
+            @Override
+            protected HttpClient createHttpClient() {
+                return _client;
+            }
+
+            @Override
+            protected HttpMethod createMethod(String type, String uri) {
+                return _method;
+            }
+        };
+        _api.setAdminCredentials("admin", "adminpass");
+        _api.setControllerAddress("localhost");
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteLoginWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.login();
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteLoginWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.login();
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteUpdateObjectWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteUpdateObjectWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteCreateObjectWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteCreateObjectWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteDeleteObjectWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.executeDeleteObject("/");
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteDeleteObjectWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.executeDeleteObject("/");
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteRetrieveObjectWithoutHostname() throws NiciraNvpApiException {
+        _api.setControllerAddress(null);
+        _api.executeRetrieveObject(String.class, "/", Collections.<String, String> emptyMap());
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteRetrieveObjectWithoutCredentials() throws NiciraNvpApiException {
+        _api.setAdminCredentials(null, null);
+        _api.executeDeleteObject("/");
+    }
+
+    @Test
+    public void executeMethodTest() throws NiciraNvpApiException {
+        GetMethod gm = mock(GetMethod.class);
+
+        when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        _api.executeMethod(gm);
+        verify(gm, times(1)).getStatusCode();
+    }
+
+    /* Bit of a roundabout way to ensure that login is called after an un authorized result
+     * It not possible to properly mock login()
+     */
+    @Test (expected=NiciraNvpApiException.class)
+    public void executeMethodTestWithLogin() throws NiciraNvpApiException, HttpException, IOException {
+        GetMethod gm = mock(GetMethod.class);
+        when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
+        when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
+        _api.executeMethod(gm);
+        verify(gm, times(1)).getStatusCode();
+    }
+
+    @Test
+    public void testExecuteCreateObject() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PostMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
+        when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
+        ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        assertTrue("aaaa".equals(ls.getUuid()));
+        verify(_method, times(1)).releaseConnection();
+
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteCreateObjectFailure() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PostMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        when(_method.isRequestSent()).thenReturn(true);
+        try {
+            ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteCreateObjectException() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
+        _method = mock(PostMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        try {
+            ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test
+    public void testExecuteUpdateObject() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PutMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        _api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+        verify(_method, times(1)).releaseConnection();
+        verify(_client, times(1)).executeMethod(_method);
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteUpdateObjectFailure() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PutMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        when(_method.isRequestSent()).thenReturn(true);
+        try {
+            _api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteUpdateObjectException() throws NiciraNvpApiException, IOException {
+        LogicalSwitch ls = new LogicalSwitch();
+        _method = mock(PutMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        when(_client.executeMethod((HttpMethod) any())).thenThrow(new IOException());
+        try {
+            _api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test
+    public void testExecuteDeleteObject() throws NiciraNvpApiException, IOException {
+        _method = mock(DeleteMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        _api.executeDeleteObject("/");
+        verify(_method, times(1)).releaseConnection();
+        verify(_client, times(1)).executeMethod(_method);
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteDeleteObjectFailure() throws NiciraNvpApiException, IOException {
+        _method = mock(DeleteMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        when(_method.isRequestSent()).thenReturn(true);
+        try {
+            _api.executeDeleteObject("/");
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteDeleteObjectException() throws NiciraNvpApiException, IOException {
+        _method = mock(DeleteMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
+        try {
+            _api.executeDeleteObject("/");
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test
+    public void testExecuteRetrieveObject() throws NiciraNvpApiException, IOException {
+        _method = mock(GetMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
+        _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        verify(_method, times(1)).releaseConnection();
+        verify(_client, times(1)).executeMethod(_method);
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteRetrieveObjectFailure() throws NiciraNvpApiException, IOException {
+        _method = mock(GetMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
+        Header header = mock(Header.class);
+        when(header.getValue()).thenReturn("text/html");
+        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
+        when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
+        when(_method.isRequestSent()).thenReturn(true);
+        try {
+            _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
+    @Test (expected=NiciraNvpApiException.class)
+    public void testExecuteRetrieveObjectException() throws NiciraNvpApiException, IOException {
+        _method = mock(GetMethod.class);
+        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }");
+        when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
+        try {
+            _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
+        } finally {
+            verify(_method, times(1)).releaseConnection();
+        }
+    }
+
 }


[35/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ExternalEthernetPort.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ExternalEthernetPort.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ExternalEthernetPort.cs
deleted file mode 100644
index a479c60..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ExternalEthernetPort.cs
+++ /dev/null
@@ -1,1996 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_ExternalEthernetPort
-    public class ExternalEthernetPort : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_ExternalEthernetPort";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public ExternalEthernetPort() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public ExternalEthernetPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public ExternalEthernetPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public ExternalEthernetPort(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public ExternalEthernetPort(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public ExternalEthernetPort(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsActiveMaximumTransmissionUnitNull {
-            get {
-                if ((curObj["ActiveMaximumTransmissionUnit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong ActiveMaximumTransmissionUnit {
-            get {
-                if ((curObj["ActiveMaximumTransmissionUnit"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["ActiveMaximumTransmissionUnit"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] AdditionalAvailability {
-            get {
-                return ((ushort[])(curObj["AdditionalAvailability"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutoSenseNull {
-            get {
-                if ((curObj["AutoSense"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutoSense {
-            get {
-                if ((curObj["AutoSense"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutoSense"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAvailabilityNull {
-            get {
-                if ((curObj["Availability"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort Availability {
-            get {
-                if ((curObj["Availability"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["Availability"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] Capabilities {
-            get {
-                return ((ushort[])(curObj["Capabilities"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] CapabilityDescriptions {
-            get {
-                return ((string[])(curObj["CapabilityDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string DeviceID {
-            get {
-                return ((string)(curObj["DeviceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] EnabledCapabilities {
-            get {
-                return ((ushort[])(curObj["EnabledCapabilities"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsErrorClearedNull {
-            get {
-                if ((curObj["ErrorCleared"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool ErrorCleared {
-            get {
-                if ((curObj["ErrorCleared"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["ErrorCleared"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ErrorDescription {
-            get {
-                return ((string)(curObj["ErrorDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsFullDuplexNull {
-            get {
-                if ((curObj["FullDuplex"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool FullDuplex {
-            get {
-                if ((curObj["FullDuplex"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["FullDuplex"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] IdentifyingDescriptions {
-            get {
-                return ((string[])(curObj["IdentifyingDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsIsBoundNull {
-            get {
-                if ((curObj["IsBound"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("If this property is true, then this Ethernet port can be connected to the switche" +
-            "s and thus can provide connectivity to virtual machine. If this property is fals" +
-            "e, then this Ethernet is not being used by the virtual machine networking archit" +
-            "ecture.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool IsBound {
-            get {
-                if ((curObj["IsBound"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["IsBound"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLastErrorCodeNull {
-            get {
-                if ((curObj["LastErrorCode"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint LastErrorCode {
-            get {
-                if ((curObj["LastErrorCode"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["LastErrorCode"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLinkTechnologyNull {
-            get {
-                if ((curObj["LinkTechnology"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort LinkTechnology {
-            get {
-                if ((curObj["LinkTechnology"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["LinkTechnology"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLocationIndicatorNull {
-            get {
-                if ((curObj["LocationIndicator"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort LocationIndicator {
-            get {
-                if ((curObj["LocationIndicator"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["LocationIndicator"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxDataSizeNull {
-            get {
-                if ((curObj["MaxDataSize"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint MaxDataSize {
-            get {
-                if ((curObj["MaxDataSize"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["MaxDataSize"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxQuiesceTimeNull {
-            get {
-                if ((curObj["MaxQuiesceTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong MaxQuiesceTime {
-            get {
-                if ((curObj["MaxQuiesceTime"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["MaxQuiesceTime"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxSpeedNull {
-            get {
-                if ((curObj["MaxSpeed"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong MaxSpeed {
-            get {
-                if ((curObj["MaxSpeed"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["MaxSpeed"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] NetworkAddresses {
-            get {
-                return ((string[])(curObj["NetworkAddresses"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherEnabledCapabilities {
-            get {
-                return ((string[])(curObj["OtherEnabledCapabilities"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherIdentifyingInfo {
-            get {
-                return ((string[])(curObj["OtherIdentifyingInfo"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherLinkTechnology {
-            get {
-                return ((string)(curObj["OtherLinkTechnology"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherNetworkPortType {
-            get {
-                return ((string)(curObj["OtherNetworkPortType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherPortType {
-            get {
-                return ((string)(curObj["OtherPortType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PermanentAddress {
-            get {
-                return ((string)(curObj["PermanentAddress"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPortNumberNull {
-            get {
-                if ((curObj["PortNumber"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort PortNumber {
-            get {
-                if ((curObj["PortNumber"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["PortNumber"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPortTypeNull {
-            get {
-                if ((curObj["PortType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort PortType {
-            get {
-                if ((curObj["PortType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["PortType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] PowerManagementCapabilities {
-            get {
-                return ((ushort[])(curObj["PowerManagementCapabilities"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPowerManagementSupportedNull {
-            get {
-                if ((curObj["PowerManagementSupported"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool PowerManagementSupported {
-            get {
-                if ((curObj["PowerManagementSupported"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["PowerManagementSupported"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPowerOnHoursNull {
-            get {
-                if ((curObj["PowerOnHours"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong PowerOnHours {
-            get {
-                if ((curObj["PowerOnHours"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["PowerOnHours"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedSpeedNull {
-            get {
-                if ((curObj["RequestedSpeed"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong RequestedSpeed {
-            get {
-                if ((curObj["RequestedSpeed"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["RequestedSpeed"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsSpeedNull {
-            get {
-                if ((curObj["Speed"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Speed {
-            get {
-                if ((curObj["Speed"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Speed"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsStatusInfoNull {
-            get {
-                if ((curObj["StatusInfo"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort StatusInfo {
-            get {
-                if ((curObj["StatusInfo"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["StatusInfo"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsSupportedMaximumTransmissionUnitNull {
-            get {
-                if ((curObj["SupportedMaximumTransmissionUnit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong SupportedMaximumTransmissionUnit {
-            get {
-                if ((curObj["SupportedMaximumTransmissionUnit"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["SupportedMaximumTransmissionUnit"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTotalPowerOnHoursNull {
-            get {
-                if ((curObj["TotalPowerOnHours"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong TotalPowerOnHours {
-            get {
-                if ((curObj["TotalPowerOnHours"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["TotalPowerOnHours"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsUsageRestrictionNull {
-            get {
-                if ((curObj["UsageRestriction"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort UsageRestriction {
-            get {
-                if ((curObj["UsageRestriction"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["UsageRestriction"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeActiveMaximumTransmissionUnit() {
-            if ((this.IsActiveMaximumTransmissionUnitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutoSense() {
-            if ((this.IsAutoSenseNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAvailability() {
-            if ((this.IsAvailabilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeErrorCleared() {
-            if ((this.IsErrorClearedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeFullDuplex() {
-            if ((this.IsFullDuplexNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeIsBound() {
-            if ((this.IsIsBoundNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLastErrorCode() {
-            if ((this.IsLastErrorCodeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLinkTechnology() {
-            if ((this.IsLinkTechnologyNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLocationIndicator() {
-            if ((this.IsLocationIndicatorNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxDataSize() {
-            if ((this.IsMaxDataSizeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxQuiesceTime() {
-            if ((this.IsMaxQuiesceTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxSpeed() {
-            if ((this.IsMaxSpeedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePortNumber() {
-            if ((this.IsPortNumberNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePortType() {
-            if ((this.IsPortTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePowerManagementSupported() {
-            if ((this.IsPowerManagementSupportedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePowerOnHours() {
-            if ((this.IsPowerOnHoursNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedSpeed() {
-            if ((this.IsRequestedSpeedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeSpeed() {
-            if ((this.IsSpeedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeStatusInfo() {
-            if ((this.IsStatusInfoNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeSupportedMaximumTransmissionUnit() {
-            if ((this.IsSupportedMaximumTransmissionUnitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTotalPowerOnHours() {
-            if ((this.IsTotalPowerOnHoursNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeUsageRestriction() {
-            if ((this.IsUsageRestrictionNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_ExternalEthernetPort";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static ExternalEthernetPortCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static ExternalEthernetPortCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static ExternalEthernetPortCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static ExternalEthernetPortCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_ExternalEthernetPort";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new ExternalEthernetPortCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ExternalEthernetPort", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new ExternalEthernetPortCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static ExternalEthernetPort CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new ExternalEthernetPort(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint EnableDevice(bool Enabled) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice");
-                inParams["Enabled"] = ((bool)(Enabled));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint OnlineDevice(bool Online) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice");
-                inParams["Online"] = ((bool)(Online));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint QuiesceDevice(bool Quiesce) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice");
-                inParams["Quiesce"] = ((bool)(Quiesce));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint Reset() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint RestoreProperties() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SaveProperties() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SetPowerState(ushort PowerState, System.DateTime Time) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState");
-                inParams["PowerState"] = ((ushort)(PowerState));
-                inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class ExternalEthernetPortCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public ExternalEthernetPortCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new ExternalEthernetPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new ExternalEthernetPortEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class ExternalEthernetPortEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public ExternalEthernetPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new ExternalEthernetPort(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[18/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementServiceSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementServiceSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementServiceSettingData.cs
deleted file mode 100644
index fde04ac..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementServiceSettingData.cs
+++ /dev/null
@@ -1,731 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // An Early Bound class generated for the WMI class.Msvm_VirtualSystemManagementServiceSettingData
-    public class VirtualSystemManagementServiceSettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_VirtualSystemManagementServiceSettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VirtualSystemManagementServiceSettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemManagementServiceSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemManagementServiceSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Used by OEMs to allow BIOS-locked Windows operating systems to run in the virtual machine. This string must be exactly 32 characters in length.
-This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        public string BiosLockString {
-            get {
-                return ((string)(curObj["BiosLockString"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The default external data root. By default, \"root\\ProgramData\\Microsoft\\Windows\\V" +
-            "irtualization\".\nThis is a read-only property, but it can be changed using the Mo" +
-            "difyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        public string DefaultExternalDataRoot {
-            get {
-                return ((string)(curObj["DefaultExternalDataRoot"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The default virtual hard disk path. By default, \"root\\Users\\Public\\Documents\\Virt" +
-            "ual Hard Disks\".\nThis is a read-only property, but it can be changed using the M" +
-            "odifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        public string DefaultVirtualHardDiskPath {
-            get {
-                return ((string)(curObj["DefaultVirtualHardDiskPath"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The maximum MAC address for dynamically generated MAC addresses.\nThis is a read-o" +
-            "nly property, but it can be changed using the ModifyServiceSettings method of th" +
-            "e Msvm_VirtualSystemManagementService class.")]
-        public string MaximumMacAddress {
-            get {
-                return ((string)(curObj["MaximumMacAddress"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The minimum MAC address for dynamically generated MAC addresses.\nThis is a read-o" +
-            "nly property, but it can be changed using the ModifyServiceSettings method of th" +
-            "e Msvm_VirtualSystemManagementService class.")]
-        public string MinimumMacAddress {
-            get {
-                return ((string)(curObj["MinimumMacAddress"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsNumaSpanningEnabledNull {
-            get {
-                if ((curObj["NumaSpanningEnabled"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Reserved for future use.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool NumaSpanningEnabled {
-            get {
-                if ((curObj["NumaSpanningEnabled"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["NumaSpanningEnabled"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Controls memory allocation for the VMs on non-uniform memory access (NUMA) system" +
-            "s.\nThis is a read-only property, but it can be changed using the ModifyServiceSe" +
-            "ttings method of the Msvm_VirtualSystemManagementService class.")]
-        public string PrimaryOwnerContact {
-            get {
-                return ((string)(curObj["PrimaryOwnerContact"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Describes how the primary system owner can be reached (for example, phone number or e-mail address). By default, empty. This name may not exceed 256 characters in length.
-This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        public string PrimaryOwnerName {
-            get {
-                return ((string)(curObj["PrimaryOwnerName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("This is a read-only property, but it can be changed using the ModifyServiceSettin" +
-            "gs method of the Msvm_VirtualSystemManagementService class.")]
-        public string ScopeOfResidence {
-            get {
-                return ((string)(curObj["ScopeOfResidence"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeNumaSpanningEnabled() {
-            if ((this.IsNumaSpanningEnabledNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_VirtualSystemManagementServiceSettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VirtualSystemManagementServiceSettingData";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VirtualSystemManagementServiceSettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementServiceSettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VirtualSystemManagementServiceSettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VirtualSystemManagementServiceSettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VirtualSystemManagementServiceSettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VirtualSystemManagementServiceSettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VirtualSystemManagementServiceSettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VirtualSystemManagementServiceSettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VirtualSystemManagementServiceSettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VirtualSystemManagementServiceSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemSettingData.cs
deleted file mode 100644
index ae2b7f8..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemSettingData.cs
+++ /dev/null
@@ -1,1206 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_VirtualSystemSettingData
-    public class VirtualSystemSettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_VirtualSystemSettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VirtualSystemSettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VirtualSystemSettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VirtualSystemSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VirtualSystemSettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VirtualSystemSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VirtualSystemSettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VirtualSystemSettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutoActivateNull {
-            get {
-                if ((curObj["AutoActivate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutoActivate {
-            get {
-                if ((curObj["AutoActivate"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutoActivate"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The serial number of the base board for the virtual computer system.\nThis is a re" +
-            "ad-only property, but it can be changed using the ModifyVirtualSystem method of " +
-            "the Msvm_VirtualSystemManagementService class.")]
-        public string BaseBoardSerialNumber {
-            get {
-                return ((string)(curObj["BaseBoardSerialNumber"]));
-            }
-            set {
-                curObj["BaseBoardSerialNumber"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The globally-unique identifier for the BIOS of the virtual computer system.\nThis " +
-            "is a read-only property, but it can be changed using the ModifyVirtualSystem met" +
-            "hod of the Msvm_VirtualSystemManagementService class.")]
-        public string BIOSGUID {
-            get {
-                return ((string)(curObj["BIOSGUID"]));
-            }
-            set {
-                curObj["BIOSGUID"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsBIOSNumLockNull {
-            get {
-                if ((curObj["BIOSNumLock"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"This property is set to TRUE if the num lock key is set to on by the BIOS, FALSE if the num lock key is set to off by the BIOS.
-This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool BIOSNumLock {
-            get {
-                if ((curObj["BIOSNumLock"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["BIOSNumLock"]));
-            }
-            set {
-                curObj["BIOSNumLock"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The serial number of the BIOS for the virtual computer system.\nThis is a read-onl" +
-            "y property, but it can be changed using the ModifyVirtualSystem method of the Ms" +
-            "vm_VirtualSystemManagementService class.")]
-        public string BIOSSerialNumber {
-            get {
-                return ((string)(curObj["BIOSSerialNumber"]));
-            }
-            set {
-                curObj["BIOSSerialNumber"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The boot order set within the BIOS of the virtual computer system. This property is an array of values, max length 4, where each value indicates a device to boot from. The virtual computer system will first attempt to boot from the device indicated by the first value within the array. If that device does not contain a boot sector, the virtual computer system will attempt to boot from the next device specified by the BootOrder property and so on. If no device specified within the BootOrder contains a boot sector the virtual computer system will fail to boot. The default value for a virtual computer system is [0, 1, 2, 3, 4].
-Value definitions:
-0 (Floppy): The virtual computer system will attempt to boot from the floppy disk within the floppy drive.
-1 (CD-ROM): The virtual computer system will attempt to boot from the first CD or DVD disk found with a boot sector.
-2 (IDE Hard Drive): The virtual computer system will attempt to boot from the first hard drive found attached to an IDE controller with a boot sector.
-3 (PXE Boot): The virtual computer system will attempt to PXE boot from the network.
-4 (SCSI Hard Drive): The virtual computer system will attempt to boot from the first hard drive found attached to a SCSI controller with a boot sector.
-5-65535: Reserved
-This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        public ushort[] BootOrder {
-            get {
-                return ((ushort[])(curObj["BootOrder"]));
-            }
-            set {
-                curObj["BootOrder"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The asset tag of the chassis for the virtual computer system.\nThis is a read-only" +
-            " property, but it can be changed using the ModifyVirtualSystem method of the Msv" +
-            "m_VirtualSystemManagementService class.")]
-        public string ChassisAssetTag {
-            get {
-                return ((string)(curObj["ChassisAssetTag"]));
-            }
-            set {
-                curObj["ChassisAssetTag"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The serial number of the chassis for the virtual computer system.\nThis is a read-" +
-            "only property, but it can be changed using the ModifyVirtualSystem method of the" +
-            " Msvm_VirtualSystemManagementService class.")]
-        public string ChassisSerialNumber {
-            get {
-                return ((string)(curObj["ChassisSerialNumber"]));
-            }
-            set {
-                curObj["ChassisSerialNumber"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsCreationTimeNull {
-            get {
-                if ((curObj["CreationTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime CreationTime {
-            get {
-                if ((curObj["CreationTime"] != null)) {
-                    return ToDateTime(((string)(curObj["CreationTime"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("A free-form string containing notes for the system.\nThis is a read-only property," +
-            " but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualS" +
-            "ystemManagementService class.")]
-        public string Notes {
-            get {
-                return ((string)(curObj["Notes"]));
-            }
-            set {
-                curObj["Notes"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"For non-uniform memory access (NUMA)-capable systems, this is the list of NUMA nodes on which the virtual machine is to be run.
-This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        public ushort[] NumaNodeList {
-            get {
-                return ((ushort[])(curObj["NumaNodeList"]));
-            }
-            set {
-                curObj["NumaNodeList"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsNumaNodesAreRequiredNull {
-            get {
-                if ((curObj["NumaNodesAreRequired"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"For non-uniform memory access (NUMA)-capable systems, this value indicates whether the nodes specified in NumaNodeList are required or preferred. If this value is TRUE (the nodes are required), the virtual machine will fail to start if there are not enough resources available on the specified NUMA nodes.
-This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool NumaNodesAreRequired {
-            get {
-                if ((curObj["NumaNodesAreRequired"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["NumaNodesAreRequired"]));
-            }
-            set {
-                curObj["NumaNodesAreRequired"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherVirtualSystemType {
-            get {
-                return ((string)(curObj["OtherVirtualSystemType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The object path for the snapshot Msvm_VirtualSystemSettingData from which this ob" +
-            "ject is based. This property will be NULL if this object is not based off a snap" +
-            "shot.")]
-        public string Parent {
-            get {
-                return ((string)(curObj["Parent"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsSettingTypeNull {
-            get {
-                if ((curObj["SettingType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort SettingType {
-            get {
-                if ((curObj["SettingType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["SettingType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVirtualSystemTypeNull {
-            get {
-                if ((curObj["VirtualSystemType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort VirtualSystemType {
-            get {
-                if ((curObj["VirtualSystemType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["VirtualSystemType"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutoActivate() {
-            if ((this.IsAutoActivateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetBaseBoardSerialNumber() {
-            curObj["BaseBoardSerialNumber"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private void ResetBIOSGUID() {
-            curObj["BIOSGUID"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeBIOSNumLock() {
-            if ((this.IsBIOSNumLockNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetBIOSNumLock() {
-            curObj["BIOSNumLock"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private void ResetBIOSSerialNumber() {
-            curObj["BIOSSerialNumber"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private void ResetBootOrder() {
-            curObj["BootOrder"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private void ResetChassisAssetTag() {
-            curObj["ChassisAssetTag"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private void ResetChassisSerialNumber() {
-            curObj["ChassisSerialNumber"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeCreationTime() {
-            if ((this.IsCreationTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetNotes() {
-            curObj["Notes"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private void ResetNumaNodeList() {
-            curObj["NumaNodeList"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeNumaNodesAreRequired() {
-            if ((this.IsNumaNodesAreRequiredNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetNumaNodesAreRequired() {
-            curObj["NumaNodesAreRequired"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeSettingType() {
-            if ((this.IsSettingTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeVirtualSystemType() {
-            if ((this.IsVirtualSystemTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_VirtualSystemSettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VirtualSystemSettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VirtualSystemSettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VirtualSystemSettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VirtualSystemSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VirtualSystemSettingData";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VirtualSystemSettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VirtualSystemSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemSettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VirtualSystemSettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VirtualSystemSettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VirtualSystemSettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VirtualSystemSettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VirtualSystemSettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VirtualSystemSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VirtualSystemSettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VirtualSystemSettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VirtualSystemSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VirtualSystemSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


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

Posted by bf...@apache.org.
Fix checkstyle errors in Nicira NVP plugin


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

Branch: refs/heads/ui-restyle
Commit: 256763cf65beb9f9ee4dc74b720f1819017f83d9
Parents: f39b6b2
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Nov 4 15:23:02 2013 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Nov 4 15:24:54 2013 +0100

----------------------------------------------------------------------
 .../cloudstack/nvp/spring-nvp-context.xml       |    2 +-
 ...ortForwardingRulesOnLogicalRouterAnswer.java |   18 +-
 ...rtForwardingRulesOnLogicalRouterCommand.java |   69 +-
 ...ConfigurePublicIpsOnLogicalRouterAnswer.java |   13 +-
 ...onfigurePublicIpsOnLogicalRouterCommand.java |   80 +-
 ...gureStaticNatRulesOnLogicalRouterAnswer.java |   36 +-
 ...ureStaticNatRulesOnLogicalRouterCommand.java |   74 +-
 .../agent/api/CreateLogicalRouterAnswer.java    |    8 +-
 .../agent/api/CreateLogicalRouterCommand.java   |  178 +-
 .../agent/api/CreateLogicalSwitchAnswer.java    |    4 +-
 .../agent/api/CreateLogicalSwitchCommand.java   |   10 +-
 .../api/CreateLogicalSwitchPortAnswer.java      |    6 +-
 .../api/CreateLogicalSwitchPortCommand.java     |   14 +-
 .../agent/api/DeleteLogicalRouterAnswer.java    |    6 +-
 .../agent/api/DeleteLogicalRouterCommand.java   |   37 +-
 .../agent/api/DeleteLogicalSwitchCommand.java   |    6 +-
 .../api/DeleteLogicalSwitchPortCommand.java     |   10 +-
 .../agent/api/FindLogicalSwitchPortAnswer.java  |    6 +-
 .../agent/api/FindLogicalSwitchPortCommand.java |   16 +-
 .../api/UpdateLogicalSwitchPortAnswer.java      |    6 +-
 .../api/UpdateLogicalSwitchPortCommand.java     |   16 +-
 .../api/commands/AddNiciraNvpDeviceCmd.java     |   45 +-
 .../api/commands/DeleteNiciraNvpDeviceCmd.java  |   24 +-
 .../ListNiciraNvpDeviceNetworksCmd.java         |    8 +-
 .../api/commands/ListNiciraNvpDevicesCmd.java   |   14 +-
 .../api/response/NiciraNvpDeviceResponse.java   |   30 +-
 .../com/cloud/network/NiciraNvpDeviceVO.java    |   25 +-
 .../cloud/network/NiciraNvpNicMappingVO.java    |   17 +-
 .../cloud/network/NiciraNvpRouterMappingVO.java |   92 +-
 .../com/cloud/network/dao/NiciraNvpDaoImpl.java |    6 +-
 .../network/dao/NiciraNvpNicMappingDao.java     |    9 +-
 .../network/dao/NiciraNvpNicMappingDaoImpl.java |    6 +-
 .../network/dao/NiciraNvpRouterMappingDao.java  |    2 +-
 .../dao/NiciraNvpRouterMappingDaoImpl.java      |   29 +-
 .../cloud/network/element/NiciraNvpElement.java |   38 +-
 .../network/guru/NiciraNvpGuestNetworkGuru.java |    1 -
 .../network/nicira/ControlClusterStatus.java    |  108 +-
 .../network/nicira/DestinationNatRule.java      |    5 +-
 .../network/nicira/L3GatewayAttachment.java     |   60 +-
 .../network/nicira/LogicalRouterConfig.java     |   53 +-
 .../cloud/network/nicira/LogicalRouterPort.java |  132 +-
 .../com/cloud/network/nicira/LogicalSwitch.java |   28 +-
 .../cloud/network/nicira/LogicalSwitchPort.java |    4 +-
 .../src/com/cloud/network/nicira/Match.java     |  238 ++-
 .../src/com/cloud/network/nicira/NatRule.java   |   14 +-
 .../com/cloud/network/nicira/NiciraNvpApi.java  |  351 ++--
 .../com/cloud/network/nicira/NiciraNvpList.java |    4 +-
 .../com/cloud/network/nicira/NiciraNvpTag.java  |   14 +-
 .../cloud/network/nicira/PatchAttachment.java   |   31 +-
 .../com/cloud/network/nicira/RouterNextHop.java |   34 +-
 .../SingleDefaultRouteImplictRoutingConfig.java |   34 +-
 .../com/cloud/network/nicira/SourceNatRule.java |    4 +-
 .../network/nicira/TransportZoneBinding.java    |    6 +-
 .../com/cloud/network/nicira/VifAttachment.java |    8 +-
 .../network/resource/NiciraNvpResource.java     |  978 +++++------
 .../network/element/NiciraNvpElementTest.java   |   21 +-
 .../guru/NiciraNvpGuestNetworkGuruTest.java     |  811 ++++-----
 .../com/cloud/network/nicira/NatRuleTest.java   |   16 +-
 .../cloud/network/nicira/NiciraNvpApiTest.java  |  542 ++++---
 .../network/resource/NiciraNvpResourceTest.java | 1533 +++++++++---------
 60 files changed, 2993 insertions(+), 2997 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml b/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml
index 302b072..8d9813a 100644
--- a/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml
+++ b/plugins/network-elements/nicira-nvp/resources/META-INF/cloudstack/nvp/spring-nvp-context.xml
@@ -36,5 +36,5 @@
     <bean id="NiciraNvp" class="com.cloud.network.element.NiciraNvpElement">
         <property name="name" value="NiciraNvp" />
     </bean>
-    
+
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java
index 40bde6c..94931a0 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterAnswer.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,18 +17,16 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class ConfigurePortForwardingRulesOnLogicalRouterAnswer extends Answer {
 
-	public ConfigurePortForwardingRulesOnLogicalRouterAnswer(Command command,
-			boolean success, String details) {
-		super(command, success, details);
-	}
+    public ConfigurePortForwardingRulesOnLogicalRouterAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+    }
 
-	public ConfigurePortForwardingRulesOnLogicalRouterAnswer(Command command,
-			Exception e) {
-		super(command, e);
-	}
+    public ConfigurePortForwardingRulesOnLogicalRouterAnswer(Command command, Exception e) {
+        super(command, e);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java
index 5f0ea38..16ef2c4 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePortForwardingRulesOnLogicalRouterCommand.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -21,40 +21,41 @@ import java.util.List;
 import com.cloud.agent.api.to.PortForwardingRuleTO;
 
 /**
- * 
+ *
  */
 public class ConfigurePortForwardingRulesOnLogicalRouterCommand extends Command {
-	
-	private String logicalRouterUuid;
-	private List<PortForwardingRuleTO> rules;
-
-	public ConfigurePortForwardingRulesOnLogicalRouterCommand(String logicalRouterUuid, List<PortForwardingRuleTO> rules) {
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.rules = rules;
-	}
-	
-	public String getLogicalRouterUuid() {
-		return logicalRouterUuid;
-	}
-
-	public void setLogicalRouterUuid(String logicalRouterUuid) {
-		this.logicalRouterUuid = logicalRouterUuid;
-	}
-
-	public List<PortForwardingRuleTO> getRules() {
-		return rules;
-	}
-
-	public void setRules(List<PortForwardingRuleTO> rules) {
-		this.rules = rules;
-	}
-
-	/* (non-Javadoc)
-	 * @see com.cloud.agent.api.Command#executeInSequence()
-	 */
-	@Override
-	public boolean executeInSequence() {
-		return false;
-	}
+
+    private String logicalRouterUuid;
+    private List<PortForwardingRuleTO> rules;
+
+    public ConfigurePortForwardingRulesOnLogicalRouterCommand(String logicalRouterUuid, List<PortForwardingRuleTO> rules) {
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.rules = rules;
+    }
+
+    public String getLogicalRouterUuid() {
+        return logicalRouterUuid;
+    }
+
+    public void setLogicalRouterUuid(String logicalRouterUuid) {
+        this.logicalRouterUuid = logicalRouterUuid;
+    }
+
+    public List<PortForwardingRuleTO> getRules() {
+        return rules;
+    }
+
+    public void setRules(List<PortForwardingRuleTO> rules) {
+        this.rules = rules;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.cloud.agent.api.Command#executeInSequence()
+     */
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java
index 12b1a1f..09a3e7e 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterAnswer.java
@@ -18,13 +18,12 @@ package com.cloud.agent.api;
 
 public class ConfigurePublicIpsOnLogicalRouterAnswer extends Answer {
 
-	public ConfigurePublicIpsOnLogicalRouterAnswer(Command command,
-			boolean success, String details) {
-		super(command, success, details);
-	}
+    public ConfigurePublicIpsOnLogicalRouterAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+    }
 
-	public ConfigurePublicIpsOnLogicalRouterAnswer(Command command, Exception e) {
-		super(command, e);
-	}
+    public ConfigurePublicIpsOnLogicalRouterAnswer(Command command, Exception e) {
+        super(command, e);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java
index 8ee3793..c08f540 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigurePublicIpsOnLogicalRouterCommand.java
@@ -19,47 +19,45 @@ package com.cloud.agent.api;
 import java.util.List;
 
 public class ConfigurePublicIpsOnLogicalRouterCommand extends Command {
-	
-	private String logicalRouterUuid;
-	private String l3GatewayServiceUuid;
-	private List<String> publicCidrs;
-	
-	public ConfigurePublicIpsOnLogicalRouterCommand(String logicalRouterUuid,
-			String l3GatewayServiceUuid,
-			List<String> publicCidrs) {
-		super();
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.publicCidrs = publicCidrs;
-		this.l3GatewayServiceUuid = l3GatewayServiceUuid;
-	}
 
-	public String getLogicalRouterUuid() {
-		return logicalRouterUuid;
-	}
-
-	public void setLogicalRouterUuid(String logicalRouterUuid) {
-		this.logicalRouterUuid = logicalRouterUuid;
-	}
-	
-	public String getL3GatewayServiceUuid() {
-		return l3GatewayServiceUuid;
-	}
-
-	public void setL3GatewayServiceUuid(String l3GatewayServiceUuid) {
-		this.l3GatewayServiceUuid = l3GatewayServiceUuid;
-	}
-
-	public List<String> getPublicCidrs() {
-		return publicCidrs;
-	}
-
-	public void setPublicCidrs(List<String> publicCidrs) {
-		this.publicCidrs = publicCidrs;
-	}
-
-	@Override
-	public boolean executeInSequence() {
-		return false;
-	}
+    private String logicalRouterUuid;
+    private String l3GatewayServiceUuid;
+    private List<String> publicCidrs;
+
+    public ConfigurePublicIpsOnLogicalRouterCommand(String logicalRouterUuid, String l3GatewayServiceUuid, List<String> publicCidrs) {
+        super();
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.publicCidrs = publicCidrs;
+        this.l3GatewayServiceUuid = l3GatewayServiceUuid;
+    }
+
+    public String getLogicalRouterUuid() {
+        return logicalRouterUuid;
+    }
+
+    public void setLogicalRouterUuid(String logicalRouterUuid) {
+        this.logicalRouterUuid = logicalRouterUuid;
+    }
+
+    public String getL3GatewayServiceUuid() {
+        return l3GatewayServiceUuid;
+    }
+
+    public void setL3GatewayServiceUuid(String l3GatewayServiceUuid) {
+        this.l3GatewayServiceUuid = l3GatewayServiceUuid;
+    }
+
+    public List<String> getPublicCidrs() {
+        return publicCidrs;
+    }
+
+    public void setPublicCidrs(List<String> publicCidrs) {
+        this.publicCidrs = publicCidrs;
+    }
+
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java
index 463dd46..caab316 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterAnswer.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,27 +17,25 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class ConfigureStaticNatRulesOnLogicalRouterAnswer extends Answer {
 
-	/**
-	 * @param command
-	 * @param success
-	 * @param details
-	 */
-	public ConfigureStaticNatRulesOnLogicalRouterAnswer(Command command,
-			boolean success, String details) {
-		super(command, success, details);
-	}
+    /**
+     * @param command
+     * @param success
+     * @param details
+     */
+    public ConfigureStaticNatRulesOnLogicalRouterAnswer(Command command, boolean success, String details) {
+        super(command, success, details);
+    }
 
-	/**
-	 * @param command
-	 * @param e
-	 */
-	public ConfigureStaticNatRulesOnLogicalRouterAnswer(Command command,
-			Exception e) {
-		super(command, e);
-	}
+    /**
+     * @param command
+     * @param e
+     */
+    public ConfigureStaticNatRulesOnLogicalRouterAnswer(Command command, Exception e) {
+        super(command, e);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java
index 960f609..5f79ffc 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/ConfigureStaticNatRulesOnLogicalRouterCommand.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -21,43 +21,43 @@ import java.util.List;
 import com.cloud.agent.api.to.StaticNatRuleTO;
 
 /**
- * 
+ *
  */
 public class ConfigureStaticNatRulesOnLogicalRouterCommand extends Command {
-	
-	private String logicalRouterUuid;
-	private List<StaticNatRuleTO> rules;
-
-	public ConfigureStaticNatRulesOnLogicalRouterCommand(
-			String logicalRouterUuid, List<StaticNatRuleTO> rules) {
-		super();
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.rules = rules;
-
-	}
-
-	public String getLogicalRouterUuid() {
-		return logicalRouterUuid;
-	}
-
-	public void setLogicalRouterUuid(String logicalRouterUuid) {
-		this.logicalRouterUuid = logicalRouterUuid;
-	}
-
-	public List<StaticNatRuleTO> getRules() {
-		return rules;
-	}
-
-	public void setRules(List<StaticNatRuleTO> rules) {
-		this.rules = rules;
-	}
-
-	/* (non-Javadoc)
-	 * @see com.cloud.agent.api.Command#executeInSequence()
-	 */
-	@Override
-	public boolean executeInSequence() {
-		return false;
-	}
+
+    private String logicalRouterUuid;
+    private List<StaticNatRuleTO> rules;
+
+    public ConfigureStaticNatRulesOnLogicalRouterCommand(String logicalRouterUuid, List<StaticNatRuleTO> rules) {
+        super();
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.rules = rules;
+
+    }
+
+    public String getLogicalRouterUuid() {
+        return logicalRouterUuid;
+    }
+
+    public void setLogicalRouterUuid(String logicalRouterUuid) {
+        this.logicalRouterUuid = logicalRouterUuid;
+    }
+
+    public List<StaticNatRuleTO> getRules() {
+        return rules;
+    }
+
+    public void setRules(List<StaticNatRuleTO> rules) {
+        this.rules = rules;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.cloud.agent.api.Command#executeInSequence()
+     */
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java
index 4a09e44..72a275b 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterAnswer.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,7 +17,7 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class CreateLogicalRouterAnswer extends Answer {
 
@@ -26,9 +26,9 @@ public class CreateLogicalRouterAnswer extends Answer {
     public CreateLogicalRouterAnswer(Command command, boolean success,
             String details, String logicalRouterUuid) {
         super(command, success, details);
-        this._logicalRouterUuid = logicalRouterUuid;
+        _logicalRouterUuid = logicalRouterUuid;
     }
-    
+
     public CreateLogicalRouterAnswer(Command command, Exception e) {
         super(command, e);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java
index 57440df..1f3f24e 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalRouterCommand.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,99 +17,99 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class CreateLogicalRouterCommand extends Command {
-	private String _gatewayServiceUuid;
-	private String _logicalSwitchUuid;
-	private long _vlanId;
-	private String _name;
-	private String _ownerName;
-	private String _publicIpCidr;
-	private String _publicNextHop;
-	private String _internalIpCidr;
-	
-	public CreateLogicalRouterCommand(String gatewayServiceUuid, long vlanId,
-			String logicalSwitchUuid, String name, 
-			String publicIpCidr, String publicNextHop, 
-			String internalIpCidr, String ownerName) {
-		super();
-		this._gatewayServiceUuid = gatewayServiceUuid;
-		this._logicalSwitchUuid = logicalSwitchUuid;
-		this._vlanId = vlanId;
-		this._name = name;
-		this._ownerName = ownerName;
-		this._publicIpCidr = publicIpCidr;
-		this._publicNextHop = publicNextHop;
-		this._internalIpCidr = internalIpCidr;
-	}
-	
+    private String _gatewayServiceUuid;
+    private String _logicalSwitchUuid;
+    private long _vlanId;
+    private String _name;
+    private String _ownerName;
+    private String _publicIpCidr;
+    private String _publicNextHop;
+    private String _internalIpCidr;
+
+    public CreateLogicalRouterCommand(String gatewayServiceUuid, long vlanId,
+            String logicalSwitchUuid, String name,
+            String publicIpCidr, String publicNextHop,
+            String internalIpCidr, String ownerName) {
+        super();
+        _gatewayServiceUuid = gatewayServiceUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _vlanId = vlanId;
+        _name = name;
+        _ownerName = ownerName;
+        _publicIpCidr = publicIpCidr;
+        _publicNextHop = publicNextHop;
+        _internalIpCidr = internalIpCidr;
+    }
+
     @Override
     public boolean executeInSequence() {
         return false;
     }
 
-	public String getGatewayServiceUuid() {
-		return _gatewayServiceUuid;
-	}
-
-	public void setGatewayServiceUuid(String gatewayServiceUuid) {
-		this._gatewayServiceUuid = gatewayServiceUuid;
-	}
-	
-	public String getLogicalSwitchUuid() {
-		return _logicalSwitchUuid;
-	}
-	
-	public void setLogicalSwitchUuid(String logicalSwitchUuid) {
-		_logicalSwitchUuid = logicalSwitchUuid;
-	}
-
-	public long getVlanId() {
-		return _vlanId;
-	}
-
-	public void setVlanId(long vlanId) {
-		this._vlanId = vlanId;
-	}
-
-	public String getName() {
-		return _name;
-	}
-
-	public void setName(String name) {
-		this._name = name;
-	}
-
-	public String getOwnerName() {
-		return _ownerName;
-	}
-
-	public void setOwnerName(String ownerName) {
-		this._ownerName = ownerName;
-	}
-
-	public String getPublicIpCidr() {
-		return _publicIpCidr;
-	}
-
-	public void setPublicIpCidr(String publicIpCidr) {
-		this._publicIpCidr = publicIpCidr;
-	}
-
-	public String getInternalIpCidr() {
-		return _internalIpCidr;
-	}
-
-	public void setInternalIpCidr(String internalIpCidr) {
-		this._internalIpCidr = internalIpCidr;
-	}
-	
-	public String getPublicNextHop() {
-		return _publicNextHop;
-	}
-	
-	public void setPublicNextHop(String publicNextHop) {
-		this._publicNextHop = publicNextHop;
-	}
+    public String getGatewayServiceUuid() {
+        return _gatewayServiceUuid;
+    }
+
+    public void setGatewayServiceUuid(String gatewayServiceUuid) {
+        _gatewayServiceUuid = gatewayServiceUuid;
+    }
+
+    public String getLogicalSwitchUuid() {
+        return _logicalSwitchUuid;
+    }
+
+    public void setLogicalSwitchUuid(String logicalSwitchUuid) {
+        _logicalSwitchUuid = logicalSwitchUuid;
+    }
+
+    public long getVlanId() {
+        return _vlanId;
+    }
+
+    public void setVlanId(long vlanId) {
+        _vlanId = vlanId;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+
+    public String getOwnerName() {
+        return _ownerName;
+    }
+
+    public void setOwnerName(String ownerName) {
+        _ownerName = ownerName;
+    }
+
+    public String getPublicIpCidr() {
+        return _publicIpCidr;
+    }
+
+    public void setPublicIpCidr(String publicIpCidr) {
+        _publicIpCidr = publicIpCidr;
+    }
+
+    public String getInternalIpCidr() {
+        return _internalIpCidr;
+    }
+
+    public void setInternalIpCidr(String internalIpCidr) {
+        _internalIpCidr = internalIpCidr;
+    }
+
+    public String getPublicNextHop() {
+        return _publicNextHop;
+    }
+
+    public void setPublicNextHop(String publicNextHop) {
+        _publicNextHop = publicNextHop;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java
index d8c864d..753edec 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchAnswer.java
@@ -22,9 +22,9 @@ public class CreateLogicalSwitchAnswer extends Answer {
     public CreateLogicalSwitchAnswer(Command command, boolean success,
             String details, String logicalSwitchUuid) {
         super(command, success, details);
-        this._logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
     }
-    
+
     public CreateLogicalSwitchAnswer(Command command, Exception e) {
         super(command, e);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java
index 83b03bc..b2a5aaf 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchCommand.java
@@ -17,17 +17,17 @@
 package com.cloud.agent.api;
 
 public class CreateLogicalSwitchCommand extends Command {
-    
+
     private String _transportUuid;
     private String _transportType;
     private String _name;
     private String _ownerName;
 
     public CreateLogicalSwitchCommand(String transportUuid, String transportType, String name, String ownerName) {
-        this._transportUuid = transportUuid;
-        this._transportType = transportType;
-        this._name = name;
-        this._ownerName = ownerName;
+        _transportUuid = transportUuid;
+        _transportType = transportType;
+        _name = name;
+        _ownerName = ownerName;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java
index 6c6ce77..8fa7927 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortAnswer.java
@@ -22,9 +22,9 @@ public class CreateLogicalSwitchPortAnswer extends Answer {
     public CreateLogicalSwitchPortAnswer(Command command, boolean success,
             String details, String localSwitchPortUuid) {
         super(command, success, details);
-        this._logicalSwitchPortUuid = localSwitchPortUuid;
+        _logicalSwitchPortUuid = localSwitchPortUuid;
     }
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwitchPortUuid;
     }
@@ -32,5 +32,5 @@ public class CreateLogicalSwitchPortAnswer extends Answer {
     public CreateLogicalSwitchPortAnswer(Command command, Exception e) {
         super(command, e);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java
index 5a28432..fe3f683 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/CreateLogicalSwitchPortCommand.java
@@ -21,15 +21,15 @@ public class CreateLogicalSwitchPortCommand extends Command {
     private String _attachmentUuid;
     private String _ownerName;
     private String _nicName;
-    
+
     public CreateLogicalSwitchPortCommand(String logicalSwitchUuid, String attachmentUuid, String ownerName, String nicName) {
-        this._logicalSwitchUuid = logicalSwitchUuid;
-        this._attachmentUuid = attachmentUuid;
-        this._ownerName = ownerName;
-        this._nicName = nicName;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _attachmentUuid = attachmentUuid;
+        _ownerName = ownerName;
+        _nicName = nicName;
     }
-    
-    
+
+
     public String getLogicalSwitchUuid() {
         return _logicalSwitchUuid;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java
index 8a6bb9f..db07547 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterAnswer.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,10 +17,10 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class DeleteLogicalRouterAnswer extends Answer {
-	
+
     public DeleteLogicalRouterAnswer(Command command, boolean success,
             String details) {
         super(command, success, details);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java
index 4799f9e..96e2cb9 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalRouterCommand.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,25 +17,26 @@
 package com.cloud.agent.api;
 
 /**
- * 
+ *
  */
 public class DeleteLogicalRouterCommand extends Command {
-	
-	private String _logicalRouterUuid;
-	
-	public DeleteLogicalRouterCommand(String logicalRouterUuid) {
-		this._logicalRouterUuid = logicalRouterUuid;
-	}
 
-	/* (non-Javadoc)
-	 * @see com.cloud.agent.api.Command#executeInSequence()
-	 */
-	@Override
-	public boolean executeInSequence() {
-		return false;
-	}
+    private String _logicalRouterUuid;
+
+    public DeleteLogicalRouterCommand(String logicalRouterUuid) {
+        _logicalRouterUuid = logicalRouterUuid;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.cloud.agent.api.Command#executeInSequence()
+     */
+    @Override
+    public boolean executeInSequence() {
+        return false;
+    }
 
-	public String getLogicalRouterUuid() {
-		return _logicalRouterUuid;
-	}
+    public String getLogicalRouterUuid() {
+        return _logicalRouterUuid;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java
index ce6b82b..25aa339 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchCommand.java
@@ -17,11 +17,11 @@
 package com.cloud.agent.api;
 
 public class DeleteLogicalSwitchCommand extends Command {
-    
+
     private String _logicalSwitchUuid;
-    
+
     public DeleteLogicalSwitchCommand(String logicalSwitchUuid) {
-        this._logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java
index aad6eea..e91a032 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/DeleteLogicalSwitchPortCommand.java
@@ -19,16 +19,16 @@ package com.cloud.agent.api;
 public class DeleteLogicalSwitchPortCommand extends Command {
     private String _logicalSwitchUuid;
     private String _logicalSwithPortUuid;
-    
+
     public DeleteLogicalSwitchPortCommand(String logicalSwitchUuid, String logicalSwitchPortUuid) {
-        this._logicalSwitchUuid = logicalSwitchUuid;
-        this._logicalSwithPortUuid = logicalSwitchPortUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwithPortUuid = logicalSwitchPortUuid;
     }
-    
+
     public String getLogicalSwitchUuid() {
         return _logicalSwitchUuid;
     }
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwithPortUuid;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java
index f54bd85..edc0c5f 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortAnswer.java
@@ -22,9 +22,9 @@ public class FindLogicalSwitchPortAnswer extends Answer {
     public FindLogicalSwitchPortAnswer(Command command, boolean success,
             String details, String localSwitchPortUuid) {
         super(command, success, details);
-        this._logicalSwitchPortUuid = localSwitchPortUuid;
+        _logicalSwitchPortUuid = localSwitchPortUuid;
     }
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwitchPortUuid;
     }
@@ -32,5 +32,5 @@ public class FindLogicalSwitchPortAnswer extends Answer {
     public FindLogicalSwitchPortAnswer(Command command, Exception e) {
         super(command, e);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java
index cccce67..b737c50 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/FindLogicalSwitchPortCommand.java
@@ -17,25 +17,25 @@
 package com.cloud.agent.api;
 
 public class FindLogicalSwitchPortCommand extends Command {
-	private String _logicalSwitchUuid;
+    private String _logicalSwitchUuid;
     private String _logicalSwitchPortUuid;
-    
+
     public FindLogicalSwitchPortCommand(String logicalSwitchUuid, String logicalSwitchPortUuid) {
-    	this._logicalSwitchUuid = logicalSwitchUuid;
-        this._logicalSwitchPortUuid = logicalSwitchPortUuid;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwitchPortUuid = logicalSwitchPortUuid;
     }
-    
-    
+
+
     public String getLogicalSwitchUuid() {
         return _logicalSwitchUuid;
     }
 
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwitchPortUuid;
     }
 
-    
+
     @Override
     public boolean executeInSequence() {
         return false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java
index 3b7fbf7..f4c4130 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortAnswer.java
@@ -22,9 +22,9 @@ public class UpdateLogicalSwitchPortAnswer extends Answer {
     public UpdateLogicalSwitchPortAnswer(Command command, boolean success,
             String details, String localSwitchPortUuid) {
         super(command, success, details);
-        this._logicalSwitchPortUuid = localSwitchPortUuid;
+        _logicalSwitchPortUuid = localSwitchPortUuid;
     }
-    
+
     public String getLogicalSwitchPortUuid() {
         return _logicalSwitchPortUuid;
     }
@@ -32,5 +32,5 @@ public class UpdateLogicalSwitchPortAnswer extends Answer {
     public UpdateLogicalSwitchPortAnswer(Command command, Exception e) {
         super(command, e);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java
index 83ae231..1b8b590 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/agent/api/UpdateLogicalSwitchPortCommand.java
@@ -22,16 +22,16 @@ public class UpdateLogicalSwitchPortCommand extends Command {
     private String _attachmentUuid;
     private String _ownerName;
     private String _nicName;
-    
+
     public UpdateLogicalSwitchPortCommand(String logicalSwitchPortUuid, String logicalSwitchUuid, String attachmentUuid, String ownerName, String nicName) {
-        this._logicalSwitchUuid = logicalSwitchUuid;
-        this._logicalSwitchPortUuid = logicalSwitchPortUuid;
-        this._attachmentUuid = attachmentUuid;
-        this._ownerName = ownerName;
-        this._nicName = nicName;
+        _logicalSwitchUuid = logicalSwitchUuid;
+        _logicalSwitchPortUuid = logicalSwitchPortUuid;
+        _attachmentUuid = attachmentUuid;
+        _ownerName = ownerName;
+        _nicName = nicName;
     }
-    
-    
+
+
     public String getLogicalSwitchUuid() {
         return _logicalSwitchUuid;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
index 7f0d87c..937b665 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/AddNiciraNvpDeviceCmd.java
@@ -18,12 +18,15 @@ package com.cloud.api.commands;
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.api.*;
-import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
-
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 import org.apache.cloudstack.context.CallContext;
 
 import com.cloud.api.response.NiciraNvpDeviceResponse;
@@ -42,7 +45,7 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
     private static final Logger s_logger = Logger.getLogger(AddNiciraNvpDeviceCmd.class.getName());
     private static final String s_name = "addniciranvpdeviceresponse";
     @Inject NiciraNvpElementService _niciraNvpElementService;
-    
+
     /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
@@ -56,16 +59,16 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
 
     @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required = true, description="Credentials to access the Nicira Controller API")
     private String username;
-    
+
     @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required = true, description="Credentials to access the Nicira Controller API")
     private String password;
-    
+
     @Parameter(name=ApiConstants.NICIRA_NVP_TRANSPORT_ZONE_UUID, type=CommandType.STRING, required = true, description="The Transportzone UUID configured on the Nicira Controller")
     private String transportzoneuuid;
-    
+
     @Parameter(name=ApiConstants.NICIRA_NVP_GATEWAYSERVICE_UUID, type=CommandType.STRING, required = false, description="The L3 Gateway Service UUID configured on the Nicira Controller")
     private String l3gatewayserviceuuid;
-    
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -85,13 +88,13 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
     public String getPassword() {
         return password;
     }
-    
+
     public String getTransportzoneUuid() {
         return transportzoneuuid;
     }
-    
+
     public String getL3GatewayServiceUuid() {
-    	return l3gatewayserviceuuid;
+        return l3gatewayserviceuuid;
     }
 
     /////////////////////////////////////////////////////
@@ -106,7 +109,7 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
                 NiciraNvpDeviceResponse response = _niciraNvpElementService.createNiciraNvpDeviceResponse(niciraNvpDeviceVO);
                 response.setObjectName("niciranvpdevice");
                 response.setResponseName(getCommandName());
-                this.setResponseObject(response);
+                setResponseObject(response);
             } else {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Nicira NVP device due to internal error.");
             }
@@ -116,7 +119,7 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
         }
     }
- 
+
     @Override
     public String getCommandName() {
         return s_name;
@@ -127,13 +130,13 @@ public class AddNiciraNvpDeviceCmd extends BaseAsyncCmd {
         return CallContext.current().getCallingAccount().getId();
     }
 
-	@Override
-	public String getEventType() {
-		return EventTypes.EVENT_EXTERNAL_NVP_CONTROLLER_ADD;
-	}
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_EXTERNAL_NVP_CONTROLLER_ADD;
+    }
 
-	@Override
-	public String getEventDescription() {
-		return "Adding a Nicira Nvp Controller";
-	}
+    @Override
+    public String getEventDescription() {
+        return "Adding a Nicira Nvp Controller";
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
index 948f1bf..6eb6764 100755
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/DeleteNiciraNvpDeviceCmd.java
@@ -18,20 +18,18 @@ package com.cloud.api.commands;
 
 import javax.inject.Inject;
 
-import com.cloud.api.response.NiciraNvpDeviceResponse;
-
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.context.CallContext;
 
+import com.cloud.api.response.NiciraNvpDeviceResponse;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -74,7 +72,7 @@ public class DeleteNiciraNvpDeviceCmd extends BaseAsyncCmd {
             if (result) {
                 SuccessResponse response = new SuccessResponse(getCommandName());
                 response.setResponseName(getCommandName());
-                this.setResponseObject(response);
+                setResponseObject(response);
             } else {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Nicira device.");
             }
@@ -95,14 +93,14 @@ public class DeleteNiciraNvpDeviceCmd extends BaseAsyncCmd {
         return CallContext.current().getCallingAccount().getId();
     }
 
-	@Override
-	public String getEventType() {
-		return EventTypes.EVENT_EXTERNAL_NVP_CONTROLLER_DELETE;
-	}
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_EXTERNAL_NVP_CONTROLLER_DELETE;
+    }
 
-	@Override
-	public String getEventDescription() {
-		return "Deleting Nicira Nvp Controller";
-	}
+    @Override
+    public String getEventDescription() {
+        return "Deleting Nicira Nvp Controller";
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java
index e224cea..53203a7 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDeviceNetworksCmd.java
@@ -21,18 +21,18 @@ import java.util.List;
 
 import javax.inject.Inject;
 
-import com.cloud.api.response.NiciraNvpDeviceResponse;
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.NetworkResponse;
+
+import com.cloud.api.response.NiciraNvpDeviceResponse;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
@@ -85,7 +85,7 @@ public class ListNiciraNvpDeviceNetworksCmd extends BaseListCmd {
 
             response.setResponses(networkResponses);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         }  catch (InvalidParameterValueException invalidParamExcp) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
         } catch (CloudRuntimeException runtimeExcp) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java
index 81cbb23..3e02e19 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java
@@ -21,17 +21,17 @@ import java.util.List;
 
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseListCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
-import org.apache.log4j.Logger;
 
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.response.ListResponse;
 import com.cloud.api.response.NiciraNvpDeviceResponse;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -48,7 +48,7 @@ public class ListNiciraNvpDevicesCmd extends BaseListCmd {
     private static final String s_name = "listniciranvpdeviceresponse";
     @Inject NiciraNvpElementService _niciraNvpElementService;
 
-   /////////////////////////////////////////////////////
+    /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
@@ -92,7 +92,7 @@ public class ListNiciraNvpDevicesCmd extends BaseListCmd {
 
             response.setResponses(niciraDevicesResponse);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         }  catch (InvalidParameterValueException invalidParamExcp) {
             throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
         } catch (CloudRuntimeException runtimeExcp) {
@@ -104,5 +104,5 @@ public class ListNiciraNvpDevicesCmd extends BaseListCmd {
     public String getCommandName() {
         return s_name;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java
index 097ecd9..d6085e2 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/api/response/NiciraNvpDeviceResponse.java
@@ -16,13 +16,15 @@
 // under the License.
 package com.cloud.api.response;
 
-import com.cloud.network.NiciraNvpDeviceVO;
-import org.apache.cloudstack.api.ApiConstants;
-import com.cloud.serializer.Param;
 import com.google.gson.annotations.SerializedName;
+
+import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseResponse;
 import org.apache.cloudstack.api.EntityReference;
 
+import com.cloud.network.NiciraNvpDeviceVO;
+import com.cloud.serializer.Param;
+
 @EntityReference(value=NiciraNvpDeviceVO.class)
 public class NiciraNvpDeviceResponse extends BaseResponse {
     @SerializedName(ApiConstants.NICIRA_NVP_DEVICE_ID) @Param(description="device id of the Nicire Nvp")
@@ -47,7 +49,7 @@ public class NiciraNvpDeviceResponse extends BaseResponse {
     private String l3GatewayServiceUuid;
 
     public void setId(String nvpDeviceId) {
-        this.id = nvpDeviceId;
+        id = nvpDeviceId;
     }
 
     public void setPhysicalNetworkId(String physicalNetworkId) {
@@ -62,18 +64,16 @@ public class NiciraNvpDeviceResponse extends BaseResponse {
         this.deviceName = deviceName;
     }
 
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
 
+    public void setTransportZoneUuid(String transportZoneUuid) {
+        this.transportZoneUuid = transportZoneUuid;
+    }
 
-	public void setHostName(String hostName) {
-		this.hostName = hostName;
-	}
-
-	public void setTransportZoneUuid(String transportZoneUuid) {
-		this.transportZoneUuid = transportZoneUuid;
-	}
-
-	public void setL3GatewayServiceUuid(String l3GatewayServiceUuid) {
-		this.l3GatewayServiceUuid = l3GatewayServiceUuid;
-	}
+    public void setL3GatewayServiceUuid(String l3GatewayServiceUuid) {
+        this.l3GatewayServiceUuid = l3GatewayServiceUuid;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java
index a1097b9..3832123 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpDeviceVO.java
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.network;
 
-import org.apache.cloudstack.api.InternalIdentity;
-
 import java.util.UUID;
 
 import javax.persistence.Column;
@@ -27,6 +25,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.api.InternalIdentity;
+
 @Entity
 @Table(name="external_nicira_nvp_devices")
 public class NiciraNvpDeviceVO implements InternalIdentity {
@@ -35,25 +35,25 @@ public class NiciraNvpDeviceVO implements InternalIdentity {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name="id")
     private long id;
-    
+
     @Column(name="uuid")
     private String uuid;
-    
+
     @Column(name="host_id")
     private long hostId;
-    
+
     @Column(name="physical_network_id")
     private long physicalNetworkId;
-    
+
     @Column(name="provider_name")
     private String providerName;
-    
+
     @Column(name="device_name")
     private String deviceName;
 
-    
+
     public NiciraNvpDeviceVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public NiciraNvpDeviceVO(long hostId, long physicalNetworkId,
@@ -63,13 +63,14 @@ public class NiciraNvpDeviceVO implements InternalIdentity {
         this.physicalNetworkId = physicalNetworkId;
         this.providerName = providerName;
         this.deviceName = deviceName;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
+    @Override
     public long getId() {
         return id;
     }
-    
+
     public String getUuid() {
         return uuid;
     }
@@ -93,5 +94,5 @@ public class NiciraNvpDeviceVO implements InternalIdentity {
     public String getDeviceName() {
         return deviceName;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java
index 4c948cc..d9dbb02 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpNicMappingVO.java
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.network;
 
-import org.apache.cloudstack.api.InternalIdentity;
-
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -25,6 +23,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.api.InternalIdentity;
+
 @Entity
 @Table(name="nicira_nvp_nic_map")
 public class NiciraNvpNicMappingVO implements InternalIdentity {
@@ -36,16 +36,16 @@ public class NiciraNvpNicMappingVO implements InternalIdentity {
 
     @Column(name="logicalswitch")
     private String logicalSwitchUuid;
-    
+
     @Column(name="logicalswitchport")
     private String logicalSwitchPortUuid;
-    
+
     @Column(name="nic")
     private String nicUuid;
-    
-    public NiciraNvpNicMappingVO () {    
+
+    public NiciraNvpNicMappingVO () {
     }
-    
+
     public NiciraNvpNicMappingVO (String logicalSwitchUuid, String logicalSwitchPortUuid, String nicUuid) {
         this.logicalSwitchUuid = logicalSwitchUuid;
         this.logicalSwitchPortUuid = logicalSwitchPortUuid;
@@ -76,8 +76,9 @@ public class NiciraNvpNicMappingVO implements InternalIdentity {
         this.nicUuid = nicUuid;
     }
 
+    @Override
     public long getId() {
         return id;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java
index ced880f..1e2a831 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/NiciraNvpRouterMappingVO.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -16,8 +16,6 @@
 // under the License.
 package com.cloud.network;
 
-import org.apache.cloudstack.api.InternalIdentity;
-
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -25,57 +23,59 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.api.InternalIdentity;
+
 @Entity
 @Table(name="nicira_nvp_router_map")
 public class NiciraNvpRouterMappingVO implements InternalIdentity {
-	//FIXME the ddl for this table should be in one of the upgrade scripts
-	@Id
-	@GeneratedValue(strategy = GenerationType.IDENTITY)
-	@Column(name="id")
-	private long id;
-	
-	@Column(name="logicalrouter_uuid")
-	private String logicalRouterUuid;
-	
-	@Column(name="network_id")
-	private long networkId;
-	
-	public NiciraNvpRouterMappingVO() {
-	}
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="logicalrouter_uuid")
+    private String logicalRouterUuid;
+
+    @Column(name="network_id")
+    private long networkId;
+
+    public NiciraNvpRouterMappingVO() {
+    }
+
+    public NiciraNvpRouterMappingVO(String logicalRouterUuid, long networkId) {
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.networkId = networkId;
+    }
+
+    public NiciraNvpRouterMappingVO(long id, String logicalRouterUuid, long networkId) {
+        this.id = id;
+        this.logicalRouterUuid = logicalRouterUuid;
+        this.networkId = networkId;
+    }
 
-	public NiciraNvpRouterMappingVO(String logicalRouterUuid, long networkId) {
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.networkId = networkId;
-	}
-	
-	public NiciraNvpRouterMappingVO(long id, String logicalRouterUuid, long networkId) {
-		this.id = id;
-		this.logicalRouterUuid = logicalRouterUuid;
-		this.networkId = networkId;
-	}
+    @Override
+    public long getId() {
+        return id;
+    }
 
-	public long getId() {
-		return id;
-	}
+    public void setId(long id) {
+        this.id = id;
+    }
 
-	public void setId(long id) {
-		this.id = id;
-	}
+    public String getLogicalRouterUuid() {
+        return logicalRouterUuid;
+    }
 
-	public String getLogicalRouterUuid() {
-		return logicalRouterUuid;
-	}
+    public void setLogicalRouterUuid(String logicalRouterUuid) {
+        this.logicalRouterUuid = logicalRouterUuid;
+    }
 
-	public void setLogicalRouterUuid(String logicalRouterUuid) {
-		this.logicalRouterUuid = logicalRouterUuid;
-	}
+    public long getNetworkId() {
+        return networkId;
+    }
 
-	public long getNetworkId() {
-		return networkId;
-	}
+    public void setNetworkId(long networkId) {
+        this.networkId = networkId;
+    }
 
-	public void setNetworkId(long networkId) {
-		this.networkId = networkId;
-	}
-	
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java
index 62662c5..5e07246 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpDaoImpl.java
@@ -31,10 +31,10 @@ import com.cloud.utils.db.SearchCriteria.Op;
 @Component
 @Local(value=NiciraNvpDao.class)
 public class NiciraNvpDaoImpl extends GenericDaoBase<NiciraNvpDeviceVO, Long>
-        implements NiciraNvpDao {
-    
+implements NiciraNvpDao {
+
     protected final SearchBuilder<NiciraNvpDeviceVO> physicalNetworkIdSearch;
-    
+
     public NiciraNvpDaoImpl() {
         physicalNetworkIdSearch = createSearchBuilder();
         physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), Op.EQ);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java
index b463fe8..f693dcb 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDao.java
@@ -21,9 +21,12 @@ import com.cloud.utils.db.GenericDao;
 
 public interface NiciraNvpNicMappingDao extends GenericDao<NiciraNvpNicMappingVO, Long> {
 
-    /** find the mapping for a nic 
-     * @param nicUuid the Uuid of a nic attached to a logical switch port
-     * @return NiciraNvpNicMapping for this nic uuid or null if it does not exist
+    /**
+     * find the mapping for a nic
+     * @param nicUuid
+     *            the Uuid of a nic attached to a logical switch port
+     * @return NiciraNvpNicMapping for this nic uuid or null if it does not
+     *         exist
      */
     public NiciraNvpNicMappingVO findByNicUuid(String nicUuid);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java
index b40aad4..1a0fcd1 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpNicMappingDaoImpl.java
@@ -29,16 +29,16 @@ import com.cloud.utils.db.SearchCriteria.Op;
 @Component
 @Local(value=NiciraNvpNicMappingDao.class)
 public class NiciraNvpNicMappingDaoImpl extends
-        GenericDaoBase<NiciraNvpNicMappingVO, Long> implements NiciraNvpNicMappingDao {
+GenericDaoBase<NiciraNvpNicMappingVO, Long> implements NiciraNvpNicMappingDao {
 
     protected final SearchBuilder<NiciraNvpNicMappingVO> nicSearch;
-    
+
     public NiciraNvpNicMappingDaoImpl() {
         nicSearch = createSearchBuilder();
         nicSearch.and("nicUuid", nicSearch.entity().getNicUuid(), Op.EQ);
         nicSearch.done();
     }
-    
+
     @Override
     public NiciraNvpNicMappingVO findByNicUuid(String nicUuid) {
         SearchCriteria<NiciraNvpNicMappingVO> sc = nicSearch.create();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java
index c6c58c8..e822ebd 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDao.java
@@ -21,5 +21,5 @@ import com.cloud.utils.db.GenericDao;
 
 public interface NiciraNvpRouterMappingDao extends GenericDao<NiciraNvpRouterMappingVO, Long> {
 
-	public NiciraNvpRouterMappingVO findByNetworkId(long id);
+    public NiciraNvpRouterMappingVO findByNetworkId(long id);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java
index d3192ec..dc41f57 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/dao/NiciraNvpRouterMappingDaoImpl.java
@@ -30,20 +30,19 @@ import com.cloud.utils.db.SearchCriteria.Op;
 @Local(value=NiciraNvpRouterMappingDao.class)
 public class NiciraNvpRouterMappingDaoImpl extends GenericDaoBase<NiciraNvpRouterMappingVO, Long> implements NiciraNvpRouterMappingDao {
 
-	protected final SearchBuilder<NiciraNvpRouterMappingVO> networkSearch;
-	
-	public NiciraNvpRouterMappingDaoImpl() {
-		networkSearch = createSearchBuilder();
-		networkSearch.and("network_id", networkSearch.entity().getNetworkId(), Op.EQ);
-		networkSearch.done();
-	}
-	
-	@Override
-	public NiciraNvpRouterMappingVO findByNetworkId(long id) {
-		SearchCriteria<NiciraNvpRouterMappingVO> sc = networkSearch.create();
-		sc.setParameters("network_id", id);
-		return findOneBy(sc);
-	}
-	
+    protected final SearchBuilder<NiciraNvpRouterMappingVO> networkSearch;
+
+    public NiciraNvpRouterMappingDaoImpl() {
+        networkSearch = createSearchBuilder();
+        networkSearch.and("network_id", networkSearch.entity().getNetworkId(), Op.EQ);
+        networkSearch.done();
+    }
+
+    @Override
+    public NiciraNvpRouterMappingVO findByNetworkId(long id) {
+        SearchCriteria<NiciraNvpRouterMappingVO> sc = networkSearch.create();
+        sc.setParameters("network_id", id);
+        return findOneBy(sc);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
index ef8ec86..3e9e16a 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/element/NiciraNvpElement.java
@@ -30,6 +30,7 @@ import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
 
@@ -128,9 +129,9 @@ import com.cloud.vm.dao.NicDao;
         SourceNatServiceProvider.class, StaticNatServiceProvider.class,
         PortForwardingServiceProvider.class, IpDeployer.class} )
 public class NiciraNvpElement extends AdapterBase implements
-        ConnectivityProvider, SourceNatServiceProvider,
-        PortForwardingServiceProvider, StaticNatServiceProvider,
-        NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
+ConnectivityProvider, SourceNatServiceProvider,
+PortForwardingServiceProvider, StaticNatServiceProvider,
+NiciraNvpElementService, ResourceStateAdapter, IpDeployer {
     private static final Logger s_logger = Logger
             .getLogger(NiciraNvpElement.class);
 
@@ -217,8 +218,8 @@ public class NiciraNvpElement extends AdapterBase implements
     @Override
     public boolean implement(Network network, NetworkOffering offering,
             DeployDestination dest, ReservationContext context)
-            throws ConcurrentOperationException, ResourceUnavailableException,
-            InsufficientCapacityException {
+                    throws ConcurrentOperationException, ResourceUnavailableException,
+                    InsufficientCapacityException {
         s_logger.debug("entering NiciraNvpElement implement function for network "
                 + network.getDisplayText()
                 + " (state "
@@ -247,17 +248,6 @@ public class NiciraNvpElement extends AdapterBase implements
 
         Account owner = context.getAccount();
 
-        /**
-         * Lock the network as we might need to do multiple operations that
-         * should be done only once.
-         */
-//		Network lock = _networkDao.acquireInLockTable(network.getId(),
-//				_networkModel.getNetworkLockTimeout());
-//		if (lock == null) {
-//			throw new ConcurrentOperationException("Unable to lock network "
-//					+ network.getId());
-//		}
-
         // Implement SourceNat immediately as we have al the info already
         if (_networkModel.isProviderSupportServiceInNetwork(
                 network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
@@ -277,9 +267,9 @@ public class NiciraNvpElement extends AdapterBase implements
                     BroadcastDomainType.getValue(network.getBroadcastUri()),
                     "router-" + network.getDisplayText(), publicCidr,
                     sourceNatIp.getGateway(), internalCidr, context
-                            .getDomain().getName()
-                            + "-"
-                            + context.getAccount().getAccountName());
+                    .getDomain().getName()
+                    + "-"
+                    + context.getAccount().getAccountName());
             CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer)_agentMgr
                     .easySend(niciraNvpHost.getId(), cmd);
             if (answer.getResult() == false) {
@@ -343,7 +333,7 @@ public class NiciraNvpElement extends AdapterBase implements
                         BroadcastDomainType.getValue(network.getBroadcastUri()),
                         nicVO.getUuid(), context.getDomain().getName() + "-"
                                 + context.getAccount().getAccountName(),
-                        nic.getName());
+                                nic.getName());
                 _agentMgr.easySend(niciraNvpHost.getId(), cmd);
                 return true;
             } else {
@@ -489,7 +479,7 @@ public class NiciraNvpElement extends AdapterBase implements
     @Override
     public boolean shutdownProviderInstances(
             PhysicalNetworkServiceProvider provider, ReservationContext context)
-            throws ConcurrentOperationException, ResourceUnavailableException {
+                    throws ConcurrentOperationException, ResourceUnavailableException {
         // Nothing to do here.
         return true;
     }
@@ -618,7 +608,7 @@ public class NiciraNvpElement extends AdapterBase implements
                                 physicalNetworkId, ntwkSvcProvider.getProviderName(),
                                 deviceName);
                         _niciraNvpDao.persist(niciraNvpDevice);
-        
+
                         DetailVO detail = new DetailVO(host.getId(),
                                 "niciranvpdeviceid", String.valueOf(niciraNvpDevice
                                         .getId()));
@@ -818,7 +808,7 @@ public class NiciraNvpElement extends AdapterBase implements
     @Override
     public boolean applyIps(Network network,
             List<? extends PublicIpAddress> ipAddress, Set<Service> services)
-            throws ResourceUnavailableException {
+                    throws ResourceUnavailableException {
         if (services.contains(Service.SourceNat)) {
             // Only if we need to provide SourceNat we need to configure the logical router
             // SourceNat is required for StaticNat and PortForwarding
@@ -869,7 +859,7 @@ public class NiciraNvpElement extends AdapterBase implements
     @Override
     public boolean applyStaticNats(Network network,
             List<? extends StaticNat> rules)
-            throws ResourceUnavailableException {
+                    throws ResourceUnavailableException {
         if (!canHandle(network, Service.StaticNat)) {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
index 51c59bf..7057915 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java
@@ -62,7 +62,6 @@ import com.cloud.user.Account;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
 @Local(value = NetworkGuru.class)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java
index 10890d5..2914d35 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/ControlClusterStatus.java
@@ -17,66 +17,68 @@
 package com.cloud.network.nicira;
 
 public class ControlClusterStatus {
-	private String cluster_status;
-	private Stats node_stats;
-	private Stats lqueue_stats;
-	private Stats lport_stats;
-	private Stats lrouterport_stats;
-	private Stats lswitch_stats;
-	private Stats zone_stats;
-	private Stats lrouter_stats;
-	private Stats security_profile_stats;
-	
-	public String getClusterStatus() {
-		return cluster_status;
-	}
+    private String cluster_status;
+    private Stats node_stats;
+    private Stats lqueue_stats;
+    private Stats lport_stats;
+    private Stats lrouterport_stats;
+    private Stats lswitch_stats;
+    private Stats zone_stats;
+    private Stats lrouter_stats;
+    private Stats security_profile_stats;
 
-	public Stats getNodeStats() {
-		return node_stats;
-	}
+    public String getClusterStatus() {
+        return cluster_status;
+    }
 
-	public Stats getLqueueStats() {
-		return lqueue_stats;
-	}
+    public Stats getNodeStats() {
+        return node_stats;
+    }
 
-	public Stats getLportStats() {
-		return lport_stats;
-	}
+    public Stats getLqueueStats() {
+        return lqueue_stats;
+    }
 
-	public Stats getLrouterportStats() {
-		return lrouterport_stats;
-	}
+    public Stats getLportStats() {
+        return lport_stats;
+    }
 
-	public Stats getLswitchStats() {
-		return lswitch_stats;
-	}
+    public Stats getLrouterportStats() {
+        return lrouterport_stats;
+    }
 
-	public Stats getZoneStats() {
-		return zone_stats;
-	}
+    public Stats getLswitchStats() {
+        return lswitch_stats;
+    }
 
-	public Stats getLrouterStats() {
-		return lrouter_stats;
-	}
+    public Stats getZoneStats() {
+        return zone_stats;
+    }
 
-	public Stats getSecurityProfileStats() {
-		return security_profile_stats;
-	}
+    public Stats getLrouterStats() {
+        return lrouter_stats;
+    }
 
-	public class Stats {
-		private int error_state_count;
-		private int registered_count;
-		private int active_count;
-		
-		public int getErrorStateCount() {
-			return error_state_count;
-		}
-		public int getRegisteredCount() {
-			return registered_count;
-		}
-		public int getActiveCount() {
-			return active_count;
-		}
-		
-	}
+    public Stats getSecurityProfileStats() {
+        return security_profile_stats;
+    }
+
+    public class Stats {
+        private int error_state_count;
+        private int registered_count;
+        private int active_count;
+
+        public int getErrorStateCount() {
+            return error_state_count;
+        }
+
+        public int getRegisteredCount() {
+            return registered_count;
+        }
+
+        public int getActiveCount() {
+            return active_count;
+        }
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java
index 20afea9..d149c4b 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java
@@ -19,7 +19,7 @@ package com.cloud.network.nicira;
 public class DestinationNatRule extends NatRule {
     private String toDestinationIpAddress;
     private Integer toDestinationPort;
-    
+
     public DestinationNatRule() {
         setType("DestinationNatRule");
     }
@@ -28,17 +28,14 @@ public class DestinationNatRule extends NatRule {
         return toDestinationIpAddress;
     }
 
-
     public void setToDestinationIpAddress(String toDestinationIpAddress) {
         this.toDestinationIpAddress = toDestinationIpAddress;
     }
 
-
     public Integer getToDestinationPort() {
         return toDestinationPort;
     }
 
-
     public void setToDestinationPort(Integer toDestinationPort) {
         this.toDestinationPort = toDestinationPort;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java
index 8b807fd..96d1991 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/L3GatewayAttachment.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,36 +17,36 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class L3GatewayAttachment extends Attachment {
-	private String l3_gateway_service_uuid;
-	private String type = "L3GatewayAttachment";
-	private Long vlan_id;
-	
-	public L3GatewayAttachment(String l3_gateway_service_uuid) {
-		this.l3_gateway_service_uuid = l3_gateway_service_uuid;
-	}
-	
-	public L3GatewayAttachment(String l3_gateway_service_uuid, long vlan_id) {
-		this.l3_gateway_service_uuid = l3_gateway_service_uuid;
-		this.vlan_id = vlan_id;
-	}
-	
-	public String getL3GatewayServiceUuid() {
-		return l3_gateway_service_uuid;
-	}
-	
-	public void setL3GatewayServiceUuid(String l3_gateway_service_uuid) {
-		this.l3_gateway_service_uuid = l3_gateway_service_uuid;
-	}
-	
-	public long getVlanId() {
-		return vlan_id;
-	}
-	
-	public void setVlanId(long vlan_id) {
-		this.vlan_id = vlan_id;
-	}
+    private String l3_gateway_service_uuid;
+    private String type = "L3GatewayAttachment";
+    private Long vlan_id;
+
+    public L3GatewayAttachment(String l3_gateway_service_uuid) {
+        this.l3_gateway_service_uuid = l3_gateway_service_uuid;
+    }
+
+    public L3GatewayAttachment(String l3_gateway_service_uuid, long vlan_id) {
+        this.l3_gateway_service_uuid = l3_gateway_service_uuid;
+        this.vlan_id = vlan_id;
+    }
+
+    public String getL3GatewayServiceUuid() {
+        return l3_gateway_service_uuid;
+    }
+
+    public void setL3GatewayServiceUuid(String l3_gateway_service_uuid) {
+        this.l3_gateway_service_uuid = l3_gateway_service_uuid;
+    }
+
+    public long getVlanId() {
+        return vlan_id;
+    }
+
+    public void setVlanId(long vlan_id) {
+        this.vlan_id = vlan_id;
+    }
 
 }


[51/56] [abbrv] Fix checkstyle errors in Nicira NVP plugin

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
index 897ee06..088cefc 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterConfig.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -19,39 +19,39 @@ package com.cloud.network.nicira;
 import java.util.List;
 
 /**
- * 
+ *
  */
 public class LogicalRouterConfig {
-	private String display_name;
-	private RoutingConfig routing_config;
-	private String type = "LogicalRouterConfig";
-	private String uuid;
+    private String display_name;
+    private RoutingConfig routing_config;
+    private String type = "LogicalRouterConfig";
+    private String uuid;
     private List<NiciraNvpTag> tags;
-	
-	public RoutingConfig getRoutingConfig() {
-		return routing_config;
-	}
-	
-	public void setRoutingConfig(RoutingConfig routing_config) {
-		this.routing_config = routing_config;
-	}
-	
-	public String getDisplayName() {
-		return display_name;
-	}
-	
-	public void setDisplayName(String display_name) {
-		this.display_name = display_name;
-	}
-	
+
+    public RoutingConfig getRoutingConfig() {
+        return routing_config;
+    }
+
+    public void setRoutingConfig(RoutingConfig routing_config) {
+        this.routing_config = routing_config;
+    }
+
+    public String getDisplayName() {
+        return display_name;
+    }
+
+    public void setDisplayName(String display_name) {
+        this.display_name = display_name;
+    }
+
     public String getUuid() {
         return uuid;
     }
-    
+
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
-    
+
     public List<NiciraNvpTag> getTags() {
         return tags;
     }
@@ -59,6 +59,5 @@ public class LogicalRouterConfig {
     public void setTags(List<NiciraNvpTag> tags) {
         this.tags = tags;
     }
-	
-	
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
index 196106d..112825d 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalRouterPort.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -19,72 +19,72 @@ package com.cloud.network.nicira;
 import java.util.List;
 
 /**
- * 
+ *
  */
 public class LogicalRouterPort {
-	private String display_name;
-	private List<NiciraNvpTag> tags;
-	private Integer portno;
-	private boolean admin_status_enabled;
-	private List<String> ip_addresses;
-	private String mac_address;
-	private String type = "LogicalRouterPortConfig";
-	private String uuid;
-	
-	public int getPortno() {
-		return portno;
-	}
-	
-	public void setPortno(int portno) {
-		this.portno = portno;
-	}
-	
-	public boolean isAdminStatusEnabled() {
-		return admin_status_enabled;
-	}
-	
-	public void setAdminStatusEnabled(boolean admin_status_enabled) {
-		this.admin_status_enabled = admin_status_enabled;
-	}
-	
-	public List<String> getIpAddresses() {
-		return ip_addresses;
-	}
-	
-	public void setIpAddresses(List<String> ip_addresses) {
-		this.ip_addresses = ip_addresses;
-	}
-	
-	public String getMacAddress() {
-		return mac_address;
-	}
-	
-	public void setMacAddress(String mac_address) {
-		this.mac_address = mac_address;
-	}
-	
-	public String getDisplayName() {
-		return display_name;
-	}
-
-	public void setDisplayName(String display_name) {
-		this.display_name = display_name;
-	}
-
-	public List<NiciraNvpTag> getTags() {
-		return tags;
-	}
-
-	public void setTags(List<NiciraNvpTag> tags) {
-		this.tags = tags;
-	}
-
-	public String getUuid() {
-		return uuid;
-	}
-
-	public void setUuid(String uuid) {
-		this.uuid = uuid;
-	}
+    private String display_name;
+    private List<NiciraNvpTag> tags;
+    private Integer portno;
+    private boolean admin_status_enabled;
+    private List<String> ip_addresses;
+    private String mac_address;
+    private String type = "LogicalRouterPortConfig";
+    private String uuid;
+
+    public int getPortno() {
+        return portno;
+    }
+
+    public void setPortno(int portno) {
+        this.portno = portno;
+    }
+
+    public boolean isAdminStatusEnabled() {
+        return admin_status_enabled;
+    }
+
+    public void setAdminStatusEnabled(boolean admin_status_enabled) {
+        this.admin_status_enabled = admin_status_enabled;
+    }
+
+    public List<String> getIpAddresses() {
+        return ip_addresses;
+    }
+
+    public void setIpAddresses(List<String> ip_addresses) {
+        this.ip_addresses = ip_addresses;
+    }
+
+    public String getMacAddress() {
+        return mac_address;
+    }
+
+    public void setMacAddress(String mac_address) {
+        this.mac_address = mac_address;
+    }
+
+    public String getDisplayName() {
+        return display_name;
+    }
+
+    public void setDisplayName(String display_name) {
+        this.display_name = display_name;
+    }
+
+    public List<NiciraNvpTag> getTags() {
+        return tags;
+    }
+
+    public void setTags(List<NiciraNvpTag> tags) {
+        this.tags = tags;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
index f565189..f022ff7 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitch.java
@@ -29,51 +29,51 @@ public class LogicalSwitch {
     //private RequestQueryParameters _query;
     //private LogicalSwitchRelations _relations;
     private String _schema;
-    
+
     public String getDisplay_name() {
         return display_name;
     }
-    
+
     public void setDisplay_name(String display_name) {
         this.display_name = display_name;
     }
-    
+
     public boolean isPort_isolation_enabled() {
         return port_isolation_enabled;
     }
-    
+
     public void setPort_isolation_enabled(boolean port_isolation_enabled) {
         this.port_isolation_enabled = port_isolation_enabled;
     }
-    
+
     public String getType() {
         return type;
     }
-    
+
     public void setType(String type) {
         this.type = type;
     }
-    
+
     public String getUuid() {
         return uuid;
     }
-    
+
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
-    
+
     public String get_href() {
         return _href;
     }
-    
+
     public void set_href(String _href) {
         this._href = _href;
     }
-    
+
     public String get_schema() {
         return _schema;
     }
-    
+
     public void set_schema(String _schema) {
         this._schema = _schema;
     }
@@ -93,6 +93,6 @@ public class LogicalSwitch {
     public void setTransport_zones(List<TransportZoneBinding> transport_zones) {
         this.transport_zones = transport_zones;
     }
-    
-    
+
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
index c571458..aaf5494 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/LogicalSwitchPort.java
@@ -29,7 +29,7 @@ public class LogicalSwitchPort {
     private List<String> mirror_targets;
     private String type;
     private String uuid;
-    
+
     public LogicalSwitchPort() {
         super();
     }
@@ -113,5 +113,5 @@ public class LogicalSwitchPort {
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java
index f777782..e437344 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,131 +17,117 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class Match {
-	private Integer protocol;
-	private String source_ip_addresses;
-	private String destination_ip_addresses;
-	private Integer source_port;
-	private Integer destination_port;
-	private String ethertype = "IPv4";
-	
-	public Integer getProtocol() {
-		return protocol;
-	}
-	
-	public void setProtocol(Integer protocol) {
-		this.protocol = protocol;
-	}
-	
-	public Integer getSourcePort() {
-		return source_port;
-	}
-	
-	public void setSourcePort(Integer source_port) {
-		this.source_port = source_port;
-	}
-		
-	public Integer getDestinationPort() {
-		return destination_port;
-	}
-	
-	public void setDestinationPort(Integer destination_port) {
-		this.destination_port = destination_port;
-	}
-		
-	public String getEthertype() {
-		return ethertype;
-	}
-	
-	public void setEthertype(String ethertype) {
-		this.ethertype = ethertype;
-	}
-
-	public String getSourceIpAddresses() {
-		return source_ip_addresses;
-	}
-
-	public void setSourceIpAddresses(String source_ip_addresses) {
-		this.source_ip_addresses = source_ip_addresses;
-	}
-
-	public String getDestinationIpAddresses() {
-		return destination_ip_addresses;
-	}
-
-	public void setDestinationIpAddresses(String destination_ip_addresses) {
-		this.destination_ip_addresses = destination_ip_addresses;
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime
-				* result
-				+ ((destination_ip_addresses == null) ? 0
-						: destination_ip_addresses.hashCode());
-		result = prime
-				* result
-				+ ((destination_port == null) ? 0 : destination_port
-						.hashCode());
-		result = prime * result
-				+ ((ethertype == null) ? 0 : ethertype.hashCode());
-		result = prime * result
-				+ ((protocol == null) ? 0 : protocol.hashCode());
-		result = prime
-				* result
-				+ ((source_ip_addresses == null) ? 0 : source_ip_addresses
-						.hashCode());
-		result = prime * result
-				+ ((source_port == null) ? 0 : source_port.hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		Match other = (Match) obj;
-		if (destination_ip_addresses == null) {
-			if (other.destination_ip_addresses != null)
-				return false;
-		} else if (!destination_ip_addresses
-				.equals(other.destination_ip_addresses))
-			return false;
-		if (destination_port == null) {
-			if (other.destination_port != null)
-				return false;
-		} else if (!destination_port.equals(other.destination_port))
-			return false;
-		if (ethertype == null) {
-			if (other.ethertype != null)
-				return false;
-		} else if (!ethertype.equals(other.ethertype))
-			return false;
-		if (protocol == null) {
-			if (other.protocol != null)
-				return false;
-		} else if (!protocol.equals(other.protocol))
-			return false;
-		if (source_ip_addresses == null) {
-			if (other.source_ip_addresses != null)
-				return false;
-		} else if (!source_ip_addresses.equals(other.source_ip_addresses))
-			return false;
-		if (source_port == null) {
-			if (other.source_port != null)
-				return false;
-		} else if (!source_port.equals(other.source_port))
-			return false;
-		return true;
-	}
-	
-	
+    private Integer protocol;
+    private String source_ip_addresses;
+    private String destination_ip_addresses;
+    private Integer source_port;
+    private Integer destination_port;
+    private String ethertype = "IPv4";
+
+    public Integer getProtocol() {
+        return protocol;
+    }
+
+    public void setProtocol(Integer protocol) {
+        this.protocol = protocol;
+    }
+
+    public Integer getSourcePort() {
+        return source_port;
+    }
+
+    public void setSourcePort(Integer source_port) {
+        this.source_port = source_port;
+    }
+
+    public Integer getDestinationPort() {
+        return destination_port;
+    }
+
+    public void setDestinationPort(Integer destination_port) {
+        this.destination_port = destination_port;
+    }
+
+    public String getEthertype() {
+        return ethertype;
+    }
+
+    public void setEthertype(String ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    public String getSourceIpAddresses() {
+        return source_ip_addresses;
+    }
+
+    public void setSourceIpAddresses(String source_ip_addresses) {
+        this.source_ip_addresses = source_ip_addresses;
+    }
+
+    public String getDestinationIpAddresses() {
+        return destination_ip_addresses;
+    }
+
+    public void setDestinationIpAddresses(String destination_ip_addresses) {
+        this.destination_ip_addresses = destination_ip_addresses;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((destination_ip_addresses == null) ? 0 : destination_ip_addresses.hashCode());
+        result = prime * result + ((destination_port == null) ? 0 : destination_port.hashCode());
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
+        result = prime * result + ((source_ip_addresses == null) ? 0 : source_ip_addresses.hashCode());
+        result = prime * result + ((source_port == null) ? 0 : source_port.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Match other = (Match) obj;
+        if (destination_ip_addresses == null) {
+            if (other.destination_ip_addresses != null)
+                return false;
+        } else if (!destination_ip_addresses.equals(other.destination_ip_addresses))
+            return false;
+        if (destination_port == null) {
+            if (other.destination_port != null)
+                return false;
+        } else if (!destination_port.equals(other.destination_port))
+            return false;
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        if (protocol == null) {
+            if (other.protocol != null)
+                return false;
+        } else if (!protocol.equals(other.protocol))
+            return false;
+        if (source_ip_addresses == null) {
+            if (other.source_ip_addresses != null)
+                return false;
+        } else if (!source_ip_addresses.equals(other.source_ip_addresses))
+            return false;
+        if (source_port == null) {
+            if (other.source_port != null)
+                return false;
+        } else if (!source_port.equals(other.source_port))
+            return false;
+        return true;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java
index 93de51e..f33f249 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -19,7 +19,7 @@ package com.cloud.network.nicira;
 import java.util.UUID;
 
 /**
- * 
+ *
  */
 public abstract class NatRule {
     protected Match match;
@@ -53,15 +53,15 @@ public abstract class NatRule {
     public void setType(String type) {
         this.type = type;
     }
-    
+
     public int getOrder() {
         return order;
     }
-    
+
     public void setOrder(int order) {
         this.order = order;
     }
-    
+
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -101,7 +101,7 @@ public abstract class NatRule {
             return false;
         return true;
     }
-    
+
     public boolean equalsIgnoreUuid(Object obj) {
         if (this == obj)
             return true;
@@ -124,6 +124,6 @@ public abstract class NatRule {
             return false;
         return true;
     }
-    
+
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
index 12fa6c0..ea69a09 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java
@@ -75,103 +75,103 @@ public class NiciraNvpApi {
     private static final Logger s_logger = Logger.getLogger(NiciraNvpApi.class);
     private final static String _protocol = "https";
     private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
-    
+
     private String _name;
     private String _host;
     private String _adminuser;
     private String _adminpass;
-    
+
     private HttpClient _client;
     private String _nvpversion;
-    
+
     private Gson _gson;
-    
+
     /* This factory method is protected so we can extend this
      * in the unittests.
      */
     protected HttpClient createHttpClient() {
-    	return new HttpClient(s_httpClientManager);
+        return new HttpClient(s_httpClientManager);
     }
-    
+
     protected HttpMethod createMethod(String type, String uri) throws NiciraNvpApiException {
-    	String url;
+        String url;
         try {
             url = new URL(_protocol, _host, uri).toString();
         } catch (MalformedURLException e) {
             s_logger.error("Unable to build Nicira API URL", e);
             throw new NiciraNvpApiException("Unable to build Nicira API URL", e);
         }
-        
+
         if ("post".equalsIgnoreCase(type)) {
-        	return new PostMethod(url);    	
+            return new PostMethod(url);
         }
         else if ("get".equalsIgnoreCase(type)) {
-        	return new GetMethod(url);
+            return new GetMethod(url);
         }
         else if ("delete".equalsIgnoreCase(type)) {
-        	return new DeleteMethod(url);
+            return new DeleteMethod(url);
         }
         else if ("put".equalsIgnoreCase(type)) {
-        	return new PutMethod(url);
+            return new PutMethod(url);
         }
         else {
-        	throw new NiciraNvpApiException("Requesting unknown method type");
+            throw new NiciraNvpApiException("Requesting unknown method type");
         }
     }
 
     public NiciraNvpApi() {
         _client = createHttpClient();
         _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
-        
-        try {             
+
+        try {
             // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
             Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), 443));
         } catch (IOException e) {
             s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e);
         }
-        
+
         _gson = new GsonBuilder()
-                .registerTypeAdapter(NatRule.class, new NatRuleAdapter())
-                .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
-                .create();
-        
+        .registerTypeAdapter(NatRule.class, new NatRuleAdapter())
+        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
+        .create();
+
     }
-    
+
     public void setControllerAddress(String address) {
-    	this._host = address;
+        _host = address;
     }
-    
+
     public void setAdminCredentials(String username, String password) {
-    	this._adminuser = username;
-    	this._adminpass = password;
+        _adminuser = username;
+        _adminpass = password;
     }
-    
+
     /**
-     * Logs into the Nicira API. The cookie is stored in the <code>_authcookie<code> variable.
+     * Logs into the Nicira API. The cookie is stored in the
+     * <code>_authcookie<code> variable.
      * <p>
      * The method returns false if the login failed or the connection could not be made.
-     * 
      */
     protected void login() throws NiciraNvpApiException {
         String url;
-        
+
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-        
+
         try {
             url = new URL(_protocol, _host, "/ws.v1/login").toString();
         } catch (MalformedURLException e) {
             s_logger.error("Unable to build Nicira API URL", e);
             throw new NiciraNvpApiException("Unable to build Nicira API URL", e);
         }
-        
+
         PostMethod pm = new PostMethod(url);
         pm.addParameter("username", _adminuser);
         pm.addParameter("password", _adminpass);
-        
+
         try {
             _client.executeMethod(pm);
         } catch (HttpException e) {
@@ -181,25 +181,25 @@ public class NiciraNvpApi {
         } finally {
             pm.releaseConnection();
         }
-        
+
         if (pm.getStatusCode() != HttpStatus.SC_OK) {
             s_logger.error("Nicira NVP API login failed : " + pm.getStatusText());
             throw new NiciraNvpApiException("Nicira NVP API login failed " + pm.getStatusText());
         }
-        
+
         // Extract the version for later use
         if (pm.getResponseHeader("Server") != null) {
             _nvpversion = pm.getResponseHeader("Server").getValue();
             s_logger.debug("NVP Controller reports version " + _nvpversion);
         }
-        
+
         // Success; the cookie required for login is kept in _client
     }
-    
+
     public LogicalSwitch createLogicalSwitch(LogicalSwitch logicalSwitch) throws NiciraNvpApiException {
         String uri = "/ws.v1/lswitch";
         LogicalSwitch createdLogicalSwitch = executeCreateObject(logicalSwitch, new TypeToken<LogicalSwitch>(){}.getType(), uri, Collections.<String,String>emptyMap());
-        
+
         return createdLogicalSwitch;
     }
 
@@ -207,11 +207,11 @@ public class NiciraNvpApi {
         String uri = "/ws.v1/lswitch/" + uuid;
         executeDeleteObject(uri);
     }
-    
+
     public LogicalSwitchPort createLogicalSwitchPort(String logicalSwitchUuid, LogicalSwitchPort logicalSwitchPort) throws NiciraNvpApiException {
         String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport";
         LogicalSwitchPort createdLogicalSwitchPort = executeCreateObject(logicalSwitchPort, new TypeToken<LogicalSwitchPort>(){}.getType(), uri, Collections.<String,String>emptyMap());;
-        
+
         return createdLogicalSwitchPort;
     }
 
@@ -219,28 +219,28 @@ public class NiciraNvpApi {
         String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid + "/attachment";
         executeUpdateObject(attachment, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void deleteLogicalSwitchPort(String logicalSwitchUuid, String logicalSwitchPortUuid) throws NiciraNvpApiException {
         String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport/" + logicalSwitchPortUuid;
         executeDeleteObject(uri);
     }
-    
+
     public String findLogicalSwitchPortUuidByVifAttachmentUuid(String logicalSwitchUuid, String vifAttachmentUuid) throws NiciraNvpApiException {
         String uri = "/ws.v1/lswitch/" + logicalSwitchUuid + "/lport";
         Map<String,String> params = new HashMap<String,String>();
         params.put("attachment_vif_uuid", vifAttachmentUuid);
         params.put("fields", "uuid");
-            
+
         NiciraNvpList<LogicalSwitchPort> lspl = executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>(){}.getType(), uri, params);
-                
+
         if (lspl == null || lspl.getResultCount() != 1) {
             throw new NiciraNvpApiException("Unexpected response from API");
         }
-        
+
         LogicalSwitchPort lsp = lspl.getResults().get(0);
         return lsp.getUuid();
     }
-    
+
     public ControlClusterStatus getControlClusterStatus() throws NiciraNvpApiException {
         String uri = "/ws.v1/control-cluster/status";
         ControlClusterStatus ccs = executeRetrieveObject(new TypeToken<ControlClusterStatus>(){}.getType(), uri, null);
@@ -253,118 +253,118 @@ public class NiciraNvpApi {
         Map<String,String> params = new HashMap<String,String>();
         params.put("uuid", logicalSwitchPortUuid);
         params.put("fields", "uuid");
-            
+
         NiciraNvpList<LogicalSwitchPort> lspl = executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalSwitchPort>>(){}.getType(), uri, params);
-                
+
         if (lspl == null ) {
             throw new NiciraNvpApiException("Unexpected response from API");
         }
-        
+
         return lspl;
     }
-    
+
     public LogicalRouterConfig createLogicalRouter(LogicalRouterConfig logicalRouterConfig) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter";
-    	
-    	LogicalRouterConfig lrc = executeCreateObject(logicalRouterConfig, new TypeToken<LogicalRouterConfig>(){}.getType(), uri, Collections.<String,String>emptyMap());
-    	
-    	return lrc;
+        String uri = "/ws.v1/lrouter";
+
+        LogicalRouterConfig lrc = executeCreateObject(logicalRouterConfig, new TypeToken<LogicalRouterConfig>(){}.getType(), uri, Collections.<String,String>emptyMap());
+
+        return lrc;
     }
 
     public void deleteLogicalRouter(String logicalRouterUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
-    	
-    	executeDeleteObject(uri);
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
+
+        executeDeleteObject(uri);
     }
-    
+
     public LogicalRouterPort createLogicalRouterPort(String logicalRouterUuid, LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
-    	
-    	LogicalRouterPort lrp = executeCreateObject(logicalRouterPort, new TypeToken<LogicalRouterPort>(){}.getType(), uri, Collections.<String,String>emptyMap());
-    	return lrp;    	
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
+
+        LogicalRouterPort lrp = executeCreateObject(logicalRouterPort, new TypeToken<LogicalRouterPort>(){}.getType(), uri, Collections.<String,String>emptyMap());
+        return lrp;
     }
-    
+
     public void deleteLogicalRouterPort(String logicalRouterUuid, String logicalRouterPortUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPortUuid;
-    	
-    	executeDeleteObject(uri);
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPortUuid;
+
+        executeDeleteObject(uri);
     }
 
     public void modifyLogicalRouterPort(String logicalRouterUuid, LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPort.getUuid();
-    	
-    	executeUpdateObject(logicalRouterPort, uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" +  logicalRouterPort.getUuid();
+
+        executeUpdateObject(logicalRouterPort, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void modifyLogicalRouterPortAttachment(String logicalRouterUuid, String logicalRouterPortUuid, Attachment attachment) throws NiciraNvpApiException {
         String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport/" + logicalRouterPortUuid + "/attachment";
         executeUpdateObject(attachment, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public NatRule createLogicalRouterNatRule(String logicalRouterUuid, NatRule natRule) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat";
-    	
-    	return executeCreateObject(natRule, new TypeToken<NatRule>(){}.getType(), uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat";
+
+        return executeCreateObject(natRule, new TypeToken<NatRule>(){}.getType(), uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void modifyLogicalRouterNatRule(String logicalRouterUuid, NatRule natRule) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat/" + natRule.getUuid();
-    	
-    	executeUpdateObject(natRule, uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat/" + natRule.getUuid();
+
+        executeUpdateObject(natRule, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void deleteLogicalRouterNatRule(String logicalRouterUuid, UUID natRuleUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat/" + natRuleUuid.toString();
-    	
-    	executeDeleteObject(uri);
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat/" + natRuleUuid.toString();
+
+        executeDeleteObject(uri);
     }
-    
+
     public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceAndVlanId(String logicalRouterUuid, String gatewayServiceUuid, long vlanId) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
         Map<String,String> params = new HashMap<String,String>();
         params.put("attachment_gwsvc_uuid", gatewayServiceUuid);
         params.put("attachment_vlan", "0");
         params.put("fields","*");
-        
+
         return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>(){}.getType(), uri, params);
     }
-    
+
     public LogicalRouterConfig findOneLogicalRouterByUuid(String logicalRouterUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
-    	
-    	return executeRetrieveObject(new TypeToken<LogicalRouterConfig>(){}.getType(), uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid;
+
+        return executeRetrieveObject(new TypeToken<LogicalRouterConfig>(){}.getType(), uri, Collections.<String,String>emptyMap());
     }
-    
+
     public void updateLogicalRouterPortConfig(String logicalRouterUuid, LogicalRouterPort logicalRouterPort) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport" + logicalRouterPort.getUuid();
-    	
-    	executeUpdateObject(logicalRouterPort, uri, Collections.<String,String>emptyMap());
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport" + logicalRouterPort.getUuid();
+
+        executeUpdateObject(logicalRouterPort, uri, Collections.<String,String>emptyMap());
     }
-    
+
     public NiciraNvpList<NatRule> findNatRulesByLogicalRouterUuid(String logicalRouterUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat";
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat";
         Map<String,String> params = new HashMap<String,String>();
         params.put("fields","*");
-        
-    	return executeRetrieveObject(new TypeToken<NiciraNvpList<NatRule>>(){}.getType(), uri, params);
+
+        return executeRetrieveObject(new TypeToken<NiciraNvpList<NatRule>>(){}.getType(), uri, params);
     }
-    
+
     public NiciraNvpList<LogicalRouterPort> findLogicalRouterPortByGatewayServiceUuid(String logicalRouterUuid, String l3GatewayServiceUuid) throws NiciraNvpApiException {
-    	String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
-    	Map<String,String> params = new HashMap<String,String>();
-    	params.put("fields", "*");
-    	params.put("attachment_gwsvc_uuid", l3GatewayServiceUuid);
-    	
-    	return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>(){}.getType(), uri, params);
-    }
-    
+        String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/lport";
+        Map<String,String> params = new HashMap<String,String>();
+        params.put("fields", "*");
+        params.put("attachment_gwsvc_uuid", l3GatewayServiceUuid);
+
+        return executeRetrieveObject(new TypeToken<NiciraNvpList<LogicalRouterPort>>(){}.getType(), uri, params);
+    }
+
     protected <T> void executeUpdateObject(T newObject, String uri, Map<String,String> parameters) throws NiciraNvpApiException {
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-        
+
         PutMethod pm = (PutMethod) createMethod("put", uri);
         pm.setRequestHeader("Content-Type", "application/json");
         try {
@@ -373,9 +373,9 @@ public class NiciraNvpApi {
         } catch (UnsupportedEncodingException e) {
             throw new NiciraNvpApiException("Failed to encode json request body", e);
         }
-                
+
         executeMethod(pm);
-        
+
         if (pm.getStatusCode() != HttpStatus.SC_OK) {
             String errorMessage = responseToErrorMessage(pm);
             pm.releaseConnection();
@@ -384,14 +384,14 @@ public class NiciraNvpApi {
         }
         pm.releaseConnection();
     }
-    
+
     protected <T> T executeCreateObject(T newObject, Type returnObjectType, String uri, Map<String,String> parameters) throws NiciraNvpApiException {
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-        
+
         PostMethod pm = (PostMethod) createMethod("post", uri);
         pm.setRequestHeader("Content-Type", "application/json");
         try {
@@ -400,16 +400,16 @@ public class NiciraNvpApi {
         } catch (UnsupportedEncodingException e) {
             throw new NiciraNvpApiException("Failed to encode json request body", e);
         }
-                
+
         executeMethod(pm);
-        
+
         if (pm.getStatusCode() != HttpStatus.SC_CREATED) {
             String errorMessage = responseToErrorMessage(pm);
             pm.releaseConnection();
             s_logger.error("Failed to create object : " + errorMessage);
             throw new NiciraNvpApiException("Failed to create object : " + errorMessage);
         }
-        
+
         T result;
         try {
             result = (T)_gson.fromJson(pm.getResponseBodyAsString(), TypeToken.get(newObject.getClass()).getType());
@@ -418,22 +418,22 @@ public class NiciraNvpApi {
         } finally {
             pm.releaseConnection();
         }
-        
-        return result;        
+
+        return result;
     }
-    
+
     protected void executeDeleteObject(String uri) throws NiciraNvpApiException {
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-           
+
         DeleteMethod dm = (DeleteMethod) createMethod("delete", uri);
         dm.setRequestHeader("Content-Type", "application/json");
-                
+
         executeMethod(dm);
-        
+
         if (dm.getStatusCode() != HttpStatus.SC_NO_CONTENT) {
             String errorMessage = responseToErrorMessage(dm);
             dm.releaseConnection();
@@ -442,33 +442,33 @@ public class NiciraNvpApi {
         }
         dm.releaseConnection();
     }
-    
+
     protected <T> T executeRetrieveObject(Type returnObjectType, String uri, Map<String,String> parameters) throws NiciraNvpApiException {
         if (_host == null || _host.isEmpty() ||
-        		_adminuser == null || _adminuser.isEmpty() ||
-        		_adminpass == null || _adminpass.isEmpty()) {
-        	throw new NiciraNvpApiException("Hostname/credentials are null or empty");
+                _adminuser == null || _adminuser.isEmpty() ||
+                _adminpass == null || _adminpass.isEmpty()) {
+            throw new NiciraNvpApiException("Hostname/credentials are null or empty");
         }
-            
+
         GetMethod gm = (GetMethod) createMethod("get", uri);
         gm.setRequestHeader("Content-Type", "application/json");
         if (parameters != null && !parameters.isEmpty()) {
-	        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
-	        for (Entry<String,String> e : parameters.entrySet()) {
-	            nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
-	        }
-	        gm.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
+            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(parameters.size());
+            for (Entry<String,String> e : parameters.entrySet()) {
+                nameValuePairs.add(new NameValuePair(e.getKey(), e.getValue()));
+            }
+            gm.setQueryString(nameValuePairs.toArray(new NameValuePair[0]));
         }
-                
+
         executeMethod(gm);
-        
+
         if (gm.getStatusCode() != HttpStatus.SC_OK) {
             String errorMessage = responseToErrorMessage(gm);
             gm.releaseConnection();
             s_logger.error("Failed to retrieve object : " + errorMessage);
             throw new NiciraNvpApiException("Failed to retrieve object : " + errorMessage);
         }
-            
+
         T returnValue;
         try {
             returnValue = (T)_gson.fromJson(gm.getResponseBodyAsString(), returnObjectType);
@@ -480,7 +480,7 @@ public class NiciraNvpApi {
         }
         return returnValue;
     }
-    
+
     protected void executeMethod(HttpMethodBase method) throws NiciraNvpApiException {
         try {
             _client.executeMethod(method);
@@ -497,13 +497,13 @@ public class NiciraNvpApi {
         } catch (IOException e) {
             s_logger.error("IOException caught while trying to connect to the Nicira NVP Controller", e);
             method.releaseConnection();
-            throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e);            
+            throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e);
         }
     }
-    
+
     private String responseToErrorMessage(HttpMethodBase method) {
         assert method.isRequestSent() : "no use getting an error message unless the request is sent";
-        
+
         if ("text/html".equals(method.getResponseHeader("Content-Type").getValue())) {
             // The error message is the response content
             // Safety margin of 1024 characters, anything longer is probably useless
@@ -514,38 +514,41 @@ public class NiciraNvpApi {
                 s_logger.debug("Error while loading response body", e);
             }
         }
-        
+
         // The default
         return method.getStatusText();
     }
-    
-    /* The Nicira controller uses a self-signed certificate. The 
+
+    /* The Nicira controller uses a self-signed certificate. The
      * TrustingProtocolSocketFactory will accept any provided
-     * certificate when making an SSL connection to the SDN 
+     * certificate when making an SSL connection to the SDN
      * Manager
      */
     private class TrustingProtocolSocketFactory implements SecureProtocolSocketFactory {
 
         private SSLSocketFactory ssf;
-        
+
         public TrustingProtocolSocketFactory() throws IOException {
             // Create a trust manager that does not validate certificate chains
             TrustManager[] trustAllCerts = new TrustManager[] {
-                new X509TrustManager() {
-                    public X509Certificate[] getAcceptedIssuers() {
-                        return null;
-                    }
-         
-                    public void checkClientTrusted(X509Certificate[] certs, String authType) {
-                        // Trust always
-                    }
-         
-                    public void checkServerTrusted(X509Certificate[] certs, String authType) {
-                        // Trust always
+                    new X509TrustManager() {
+                        @Override
+                        public X509Certificate[] getAcceptedIssuers() {
+                            return null;
+                        }
+
+                        @Override
+                        public void checkClientTrusted(X509Certificate[] certs, String authType) {
+                            // Trust always
+                        }
+
+                        @Override
+                        public void checkServerTrusted(X509Certificate[] certs, String authType) {
+                            // Trust always
+                        }
                     }
-                }
             };
-         
+
             try {
                 // Install the all-trusting trust manager
                 SSLContext sc = SSLContext.getInstance("SSL");
@@ -557,10 +560,10 @@ public class NiciraNvpApi {
                 throw new IOException(e);
             }
         }
-        
+
         @Override
         public Socket createSocket(String host, int port) throws IOException,
-                UnknownHostException {
+        UnknownHostException {
             return ssf.createSocket(host, port);
         }
 
@@ -592,21 +595,19 @@ public class NiciraNvpApi {
             }
         }
 
-        
+
     }
-    
+
     public static class NatRuleAdapter implements JsonDeserializer<NatRule> {
 
         @Override
         public NatRule deserialize(JsonElement jsonElement, Type type,
                 JsonDeserializationContext context) throws JsonParseException {
             JsonObject jsonObject = jsonElement.getAsJsonObject();
-            NatRule natRule = null;
-            
             if (!jsonObject.has("type")) {
                 throw new JsonParseException("Deserializing as a NatRule, but no type present in the json object");
             }
-            
+
             String natRuleType = jsonObject.get("type").getAsString();
             if ("SourceNatRule".equals(natRuleType)) {
                 return context.deserialize(jsonElement, SourceNatRule.class);
@@ -614,7 +615,7 @@ public class NiciraNvpApi {
             else if ("DestinationNatRule".equals(natRuleType)) {
                 return context.deserialize(jsonElement, DestinationNatRule.class);
             }
-            
+
             throw new JsonParseException("Failed to deserialize type \"" + natRuleType + "\"");
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java
index c97e40e..9d78e84 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpList.java
@@ -37,9 +37,9 @@ public class NiciraNvpList<T> {
     public void setResultCount(int result_count) {
         this.result_count = result_count;
     }
-    
+
     public boolean isEmpty() {
-    	return result_count == 0;
+        return result_count == 0;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java
index 157c3b5..a5dd3bd 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpTag.java
@@ -22,9 +22,9 @@ public class NiciraNvpTag {
     private static final Logger s_logger = Logger.getLogger(NiciraNvpTag.class);
     private String scope;
     private String tag;
-    
+
     public NiciraNvpTag() {}
-    
+
     public NiciraNvpTag(String scope, String tag) {
         this.scope = scope;
         if (tag.length() > 40) {
@@ -34,19 +34,19 @@ public class NiciraNvpTag {
             this.tag = tag;
         }
     }
-    
+
     public String getScope() {
         return scope;
     }
-    
+
     public void setScope(String scope) {
         this.scope = scope;
     }
-    
+
     public String getTag() {
         return tag;
     }
-    
+
     public void setTag(String tag) {
         if (tag.length() > 40) {
             s_logger.warn("tag \"" + tag + "\" too long, truncating to 40 characters");
@@ -55,5 +55,5 @@ public class NiciraNvpTag {
             this.tag = tag;
         }
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java
index e57c249..137f071 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/PatchAttachment.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,23 +17,22 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class PatchAttachment extends Attachment {
-	private final String type = "PatchAttachment";
-	private String peer_port_uuid;
-	
-	public PatchAttachment(String peerPortUuid) {
-		this.peer_port_uuid = peerPortUuid;
-	}
+    private final String type = "PatchAttachment";
+    private String peer_port_uuid;
+
+    public PatchAttachment(String peerPortUuid) {
+        peer_port_uuid = peerPortUuid;
+    }
+
+    public String getPeerPortUuid() {
+        return peer_port_uuid;
+    }
 
-	public String getPeerPortUuid() {
-		return peer_port_uuid;
-	}
+    public void setPeerPortUuid(String peerPortUuid) {
+        peer_port_uuid = peerPortUuid;
+    }
 
-	public void setPeerPortUuid(String peerPortUuid) {
-		this.peer_port_uuid = peerPortUuid;
-	}
-	
-	
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java
index c018af3..a204e55 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/RouterNextHop.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,22 +17,22 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class RouterNextHop {
-	private String gateway_ip_address;
-	private String type = "RouterNextHop";
-	
-	public RouterNextHop(String gatewayIpAddress) {
-		this.gateway_ip_address = gatewayIpAddress;
-	}
-		
-	public String getGatewayIpAddress() {
-		return gateway_ip_address;
-	}
-	
-	public void setGatewayIpAddress(String gateway_ip_address) {
-		this.gateway_ip_address = gateway_ip_address;
-	}
-		
+    private String gateway_ip_address;
+    private String type = "RouterNextHop";
+
+    public RouterNextHop(String gatewayIpAddress) {
+        gateway_ip_address = gatewayIpAddress;
+    }
+
+    public String getGatewayIpAddress() {
+        return gateway_ip_address;
+    }
+
+    public void setGatewayIpAddress(String gateway_ip_address) {
+        this.gateway_ip_address = gateway_ip_address;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
index b4eda44..1228deb 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplictRoutingConfig.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -17,22 +17,22 @@
 package com.cloud.network.nicira;
 
 /**
- * 
+ *
  */
 public class SingleDefaultRouteImplictRoutingConfig extends RoutingConfig {
-	public RouterNextHop default_route_next_hop;
-	public String type = "SingleDefaultRouteImplicitRoutingConfig";
-	
-	public SingleDefaultRouteImplictRoutingConfig(RouterNextHop routerNextHop) {
-		default_route_next_hop = routerNextHop;
-	}
-	
-	public RouterNextHop getDefaultRouteNextHop() {
-		return default_route_next_hop;
-	}
-	
-	public void setDefaultRouteNextHop(RouterNextHop default_route_next_hop) {
-		this.default_route_next_hop = default_route_next_hop;
-	}
-	
+    public RouterNextHop default_route_next_hop;
+    public String type = "SingleDefaultRouteImplicitRoutingConfig";
+
+    public SingleDefaultRouteImplictRoutingConfig(RouterNextHop routerNextHop) {
+        default_route_next_hop = routerNextHop;
+    }
+
+    public RouterNextHop getDefaultRouteNextHop() {
+        return default_route_next_hop;
+    }
+
+    public void setDefaultRouteNextHop(RouterNextHop default_route_next_hop) {
+        this.default_route_next_hop = default_route_next_hop;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java
index 4132da4..910f830 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java
@@ -20,7 +20,7 @@ public class SourceNatRule extends NatRule {
     private String toSourceIpAddressMax;
     private String toSourceIpAddressMin;
     private Integer toSourcePort;
-    
+
     public SourceNatRule() {
         setType("SourceNatRule");
     }
@@ -119,5 +119,5 @@ public class SourceNatRule extends NatRule {
             return false;
         return true;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java
index e55d759..9c5f44d 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/TransportZoneBinding.java
@@ -19,9 +19,9 @@ package com.cloud.network.nicira;
 public class TransportZoneBinding {
     private String zone_uuid;
     private String transport_type;
-    
+
     public TransportZoneBinding() {}
-    
+
     public TransportZoneBinding(String zone_uuid, String transport_type) {
         this.zone_uuid = zone_uuid;
         this.transport_type = transport_type;
@@ -42,5 +42,5 @@ public class TransportZoneBinding {
     public void setTransport_type(String transport_type) {
         this.transport_type = transport_type;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
index dc87a5a..3a0b5f3 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/VifAttachment.java
@@ -19,12 +19,12 @@ package com.cloud.network.nicira;
 public class VifAttachment extends Attachment {
     private final String type = "VifAttachment";
     private String vif_uuid;
-    
+
     public VifAttachment() {
     }
-    
+
     public VifAttachment(String vifUuid) {
-        this.vif_uuid = vifUuid;
+        vif_uuid = vifUuid;
     }
 
     public String getVif_uuid() {
@@ -38,5 +38,5 @@ public class VifAttachment extends Attachment {
     public String getType() {
         return type;
     }
-    
+
 }


[13/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs
new file mode 100755
index 0000000..ab23386
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs
@@ -0,0 +1,2070 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
+    // An Early Bound class generated for the WMI class.Msvm_ExternalEthernetPort
+    public class ExternalEthernetPort : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Msvm_ExternalEthernetPort";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public ExternalEthernetPort() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public ExternalEthernetPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(null, new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public ExternalEthernetPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public ExternalEthernetPort(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public ExternalEthernetPort(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public ExternalEthernetPort(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsActiveMaximumTransmissionUnitNull {
+            get {
+                if ((curObj["ActiveMaximumTransmissionUnit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong ActiveMaximumTransmissionUnit {
+            get {
+                if ((curObj["ActiveMaximumTransmissionUnit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["ActiveMaximumTransmissionUnit"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] AdditionalAvailability {
+            get {
+                return ((ushort[])(curObj["AdditionalAvailability"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutoSenseNull {
+            get {
+                if ((curObj["AutoSense"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutoSense {
+            get {
+                if ((curObj["AutoSense"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutoSense"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAvailabilityNull {
+            get {
+                if ((curObj["Availability"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort Availability {
+            get {
+                if ((curObj["Availability"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["Availability"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] AvailableRequestedStates {
+            get {
+                return ((ushort[])(curObj["AvailableRequestedStates"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] Capabilities {
+            get {
+                return ((ushort[])(curObj["Capabilities"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] CapabilityDescriptions {
+            get {
+                return ((string[])(curObj["CapabilityDescriptions"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCommunicationStatusNull {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort CommunicationStatus {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["CommunicationStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string CreationClassName {
+            get {
+                return ((string)(curObj["CreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDetailedStatusNull {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DetailedStatus {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DetailedStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string DeviceID {
+            get {
+                return ((string)(curObj["DeviceID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] EnabledCapabilities {
+            get {
+                return ((ushort[])(curObj["EnabledCapabilities"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledDefaultNull {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledDefault {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledDefault"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledState {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsErrorClearedNull {
+            get {
+                if ((curObj["ErrorCleared"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool ErrorCleared {
+            get {
+                if ((curObj["ErrorCleared"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["ErrorCleared"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ErrorDescription {
+            get {
+                return ((string)(curObj["ErrorDescription"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFullDuplexNull {
+            get {
+                if ((curObj["FullDuplex"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool FullDuplex {
+            get {
+                if ((curObj["FullDuplex"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["FullDuplex"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHealthStateNull {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HealthState {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HealthState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] IdentifyingDescriptions {
+            get {
+                return ((string[])(curObj["IdentifyingDescriptions"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInstallDateNull {
+            get {
+                if ((curObj["InstallDate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime InstallDate {
+            get {
+                if ((curObj["InstallDate"] != null)) {
+                    return ToDateTime(((string)(curObj["InstallDate"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsIsBoundNull {
+            get {
+                if ((curObj["IsBound"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("If this property is true, then this Ethernet port can be connected to the switche" +
+            "s and thus can provide connectivity to virtual machine. If this property is fals" +
+            "e, then this Ethernet is not being used by the virtual machine networking archit" +
+            "ecture.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool IsBound {
+            get {
+                if ((curObj["IsBound"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["IsBound"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLastErrorCodeNull {
+            get {
+                if ((curObj["LastErrorCode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint LastErrorCode {
+            get {
+                if ((curObj["LastErrorCode"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["LastErrorCode"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLinkTechnologyNull {
+            get {
+                if ((curObj["LinkTechnology"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort LinkTechnology {
+            get {
+                if ((curObj["LinkTechnology"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["LinkTechnology"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxDataSizeNull {
+            get {
+                if ((curObj["MaxDataSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint MaxDataSize {
+            get {
+                if ((curObj["MaxDataSize"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["MaxDataSize"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxQuiesceTimeNull {
+            get {
+                if ((curObj["MaxQuiesceTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxQuiesceTime {
+            get {
+                if ((curObj["MaxQuiesceTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxQuiesceTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxSpeedNull {
+            get {
+                if ((curObj["MaxSpeed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxSpeed {
+            get {
+                if ((curObj["MaxSpeed"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxSpeed"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] NetworkAddresses {
+            get {
+                return ((string[])(curObj["NetworkAddresses"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOperatingStatusNull {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort OperatingStatus {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["OperatingStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] OperationalStatus {
+            get {
+                return ((ushort[])(curObj["OperationalStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] OtherEnabledCapabilities {
+            get {
+                return ((string[])(curObj["OtherEnabledCapabilities"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherEnabledState {
+            get {
+                return ((string)(curObj["OtherEnabledState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] OtherIdentifyingInfo {
+            get {
+                return ((string[])(curObj["OtherIdentifyingInfo"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherLinkTechnology {
+            get {
+                return ((string)(curObj["OtherLinkTechnology"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherNetworkPortType {
+            get {
+                return ((string)(curObj["OtherNetworkPortType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherPortType {
+            get {
+                return ((string)(curObj["OtherPortType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PermanentAddress {
+            get {
+                return ((string)(curObj["PermanentAddress"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPortNumberNull {
+            get {
+                if ((curObj["PortNumber"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PortNumber {
+            get {
+                if ((curObj["PortNumber"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PortNumber"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPortTypeNull {
+            get {
+                if ((curObj["PortType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PortType {
+            get {
+                if ((curObj["PortType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PortType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] PowerManagementCapabilities {
+            get {
+                return ((ushort[])(curObj["PowerManagementCapabilities"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPowerManagementSupportedNull {
+            get {
+                if ((curObj["PowerManagementSupported"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool PowerManagementSupported {
+            get {
+                if ((curObj["PowerManagementSupported"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["PowerManagementSupported"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPowerOnHoursNull {
+            get {
+                if ((curObj["PowerOnHours"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PowerOnHours {
+            get {
+                if ((curObj["PowerOnHours"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PowerOnHours"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPrimaryStatusNull {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PrimaryStatus {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PrimaryStatus"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRequestedSpeedNull {
+            get {
+                if ((curObj["RequestedSpeed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong RequestedSpeed {
+            get {
+                if ((curObj["RequestedSpeed"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["RequestedSpeed"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRequestedStateNull {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort RequestedState {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["RequestedState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSpeedNull {
+            get {
+                if ((curObj["Speed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Speed {
+            get {
+                if ((curObj["Speed"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Speed"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Status {
+            get {
+                return ((string)(curObj["Status"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] StatusDescriptions {
+            get {
+                return ((string[])(curObj["StatusDescriptions"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsStatusInfoNull {
+            get {
+                if ((curObj["StatusInfo"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort StatusInfo {
+            get {
+                if ((curObj["StatusInfo"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["StatusInfo"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSupportedMaximumTransmissionUnitNull {
+            get {
+                if ((curObj["SupportedMaximumTransmissionUnit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong SupportedMaximumTransmissionUnit {
+            get {
+                if ((curObj["SupportedMaximumTransmissionUnit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["SupportedMaximumTransmissionUnit"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemCreationClassName {
+            get {
+                return ((string)(curObj["SystemCreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemName {
+            get {
+                return ((string)(curObj["SystemName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimeOfLastStateChangeNull {
+            get {
+                if ((curObj["TimeOfLastStateChange"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime TimeOfLastStateChange {
+            get {
+                if ((curObj["TimeOfLastStateChange"] != null)) {
+                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTotalPowerOnHoursNull {
+            get {
+                if ((curObj["TotalPowerOnHours"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong TotalPowerOnHours {
+            get {
+                if ((curObj["TotalPowerOnHours"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["TotalPowerOnHours"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTransitioningToStateNull {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort TransitioningToState {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["TransitioningToState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsUsageRestrictionNull {
+            get {
+                if ((curObj["UsageRestriction"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort UsageRestriction {
+            get {
+                if ((curObj["UsageRestriction"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["UsageRestriction"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeActiveMaximumTransmissionUnit() {
+            if ((this.IsActiveMaximumTransmissionUnitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutoSense() {
+            if ((this.IsAutoSenseNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAvailability() {
+            if ((this.IsAvailabilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCommunicationStatus() {
+            if ((this.IsCommunicationStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDetailedStatus() {
+            if ((this.IsDetailedStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledDefault() {
+            if ((this.IsEnabledDefaultNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledState() {
+            if ((this.IsEnabledStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeErrorCleared() {
+            if ((this.IsErrorClearedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeFullDuplex() {
+            if ((this.IsFullDuplexNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHealthState() {
+            if ((this.IsHealthStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        // Converts a given datetime in DMTF format to System.DateTime object.
+        static System.DateTime ToDateTime(string dmtfDate) {
+            System.DateTime initializer = System.DateTime.MinValue;
+            int year = initializer.Year;
+            int month = initializer.Month;
+            int day = initializer.Day;
+            int hour = initializer.Hour;
+            int minute = initializer.Minute;
+            int second = initializer.Second;
+            long ticks = 0;
+            string dmtf = dmtfDate;
+            System.DateTime datetime = System.DateTime.MinValue;
+            string tempString = string.Empty;
+            if ((dmtf == null)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length == 0)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length != 25)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            try {
+                tempString = dmtf.Substring(0, 4);
+                if (("****" != tempString)) {
+                    year = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(4, 2);
+                if (("**" != tempString)) {
+                    month = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(6, 2);
+                if (("**" != tempString)) {
+                    day = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(8, 2);
+                if (("**" != tempString)) {
+                    hour = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(10, 2);
+                if (("**" != tempString)) {
+                    minute = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(12, 2);
+                if (("**" != tempString)) {
+                    second = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(15, 6);
+                if (("******" != tempString)) {
+                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
+                }
+                if (((((((((year < 0) 
+                            || (month < 0)) 
+                            || (day < 0)) 
+                            || (hour < 0)) 
+                            || (minute < 0)) 
+                            || (minute < 0)) 
+                            || (second < 0)) 
+                            || (ticks < 0))) {
+                    throw new System.ArgumentOutOfRangeException();
+                }
+            }
+            catch (System.Exception e) {
+                throw new System.ArgumentOutOfRangeException(null, e.Message);
+            }
+            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
+            datetime = datetime.AddTicks(ticks);
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
+            int UTCOffset = 0;
+            int OffsetToBeAdjusted = 0;
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            tempString = dmtf.Substring(22, 3);
+            if ((tempString != "******")) {
+                tempString = dmtf.Substring(21, 4);
+                try {
+                    UTCOffset = int.Parse(tempString);
+                }
+                catch (System.Exception e) {
+                    throw new System.ArgumentOutOfRangeException(null, e.Message);
+                }
+                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
+                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
+            }
+            return datetime;
+        }
+        
+        // Converts a given System.DateTime object to DMTF datetime format.
+        static string ToDmtfDateTime(System.DateTime date) {
+            string utcString = string.Empty;
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            if ((System.Math.Abs(OffsetMins) > 999)) {
+                date = date.ToUniversalTime();
+                utcString = "+000";
+            }
+            else {
+                if ((tickOffset.Ticks >= 0)) {
+                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
+                }
+                else {
+                    string strTemp = ((long)(OffsetMins)).ToString();
+                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
+                }
+            }
+            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ".");
+            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
+            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
+                        * 1000) 
+                        / System.TimeSpan.TicksPerMillisecond)));
+            string strMicrosec = ((long)(microsec)).ToString();
+            if ((strMicrosec.Length > 6)) {
+                strMicrosec = strMicrosec.Substring(0, 6);
+            }
+            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
+            return dmtfDateTime;
+        }
+        
+        private bool ShouldSerializeInstallDate() {
+            if ((this.IsInstallDateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeIsBound() {
+            if ((this.IsIsBoundNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLastErrorCode() {
+            if ((this.IsLastErrorCodeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLinkTechnology() {
+            if ((this.IsLinkTechnologyNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxDataSize() {
+            if ((this.IsMaxDataSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxQuiesceTime() {
+            if ((this.IsMaxQuiesceTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxSpeed() {
+            if ((this.IsMaxSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOperatingStatus() {
+            if ((this.IsOperatingStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePortNumber() {
+            if ((this.IsPortNumberNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePortType() {
+            if ((this.IsPortTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePowerManagementSupported() {
+            if ((this.IsPowerManagementSupportedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePowerOnHours() {
+            if ((this.IsPowerOnHoursNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePrimaryStatus() {
+            if ((this.IsPrimaryStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRequestedSpeed() {
+            if ((this.IsRequestedSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRequestedState() {
+            if ((this.IsRequestedStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSpeed() {
+            if ((this.IsSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeStatusInfo() {
+            if ((this.IsStatusInfoNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSupportedMaximumTransmissionUnit() {
+            if ((this.IsSupportedMaximumTransmissionUnitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimeOfLastStateChange() {
+            if ((this.IsTimeOfLastStateChangeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTotalPowerOnHours() {
+            if ((this.IsTotalPowerOnHoursNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTransitioningToState() {
+            if ((this.IsTransitioningToStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeUsageRestriction() {
+            if ((this.IsUsageRestrictionNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_ExternalEthernetPort";
+            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static ExternalEthernetPortCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static ExternalEthernetPortCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static ExternalEthernetPortCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static ExternalEthernetPortCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_ExternalEthernetPort";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new ExternalEthernetPortCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static ExternalEthernetPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ExternalEthernetPort", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new ExternalEthernetPortCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static ExternalEthernetPort CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new ExternalEthernetPort(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public uint EnableDevice(bool Enabled) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice");
+                inParams["Enabled"] = ((bool)(Enabled));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint OnlineDevice(bool Online) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice");
+                inParams["Online"] = ((bool)(Online));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint QuiesceDevice(bool Quiesce) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice");
+                inParams["Quiesce"] = ((bool)(Quiesce));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
+                inParams["RequestedState"] = ((ushort)(RequestedState));
+                inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint Reset() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint RestoreProperties() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint SaveProperties() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint SetPowerState(ushort PowerState, System.DateTime Time) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState");
+                inParams["PowerState"] = ((ushort)(PowerState));
+                inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class ExternalEthernetPortCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public ExternalEthernetPortCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new ExternalEthernetPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new ExternalEthernetPortEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class ExternalEthernetPortEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public ExternalEthernetPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new ExternalEthernetPort(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[33/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ImageManagementService.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ImageManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ImageManagementService.cs
deleted file mode 100644
index 0b8962d..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ImageManagementService.cs
+++ /dev/null
@@ -1,1401 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION
-{
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_ImageManagementService
-    public class ImageManagementService : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_ImageManagementService";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public ImageManagementService() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public ImageManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public ImageManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public ImageManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public ImageManagementService(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public ImageManagementService(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public ImageManagementService(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerContact {
-            get {
-                return ((string)(curObj["PrimaryOwnerContact"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerName {
-            get {
-                return ((string)(curObj["PrimaryOwnerName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsStartedNull {
-            get {
-                if ((curObj["Started"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool Started {
-            get {
-                if ((curObj["Started"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["Started"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string StartMode {
-            get {
-                return ((string)(curObj["StartMode"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeStarted() {
-            if ((this.IsStartedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_ImageManagementService";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static ImageManagementServiceCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static ImageManagementServiceCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static ImageManagementServiceCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static ImageManagementServiceCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_ImageManagementService";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new ImageManagementServiceCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ImageManagementService", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new ImageManagementServiceCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static ImageManagementService CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new ImageManagementService(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint CompactVirtualHardDisk(string Path, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CompactVirtualHardDisk");
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CompactVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ConvertVirtualHardDisk(string DestinationPath, string SourcePath, ushort Type, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ConvertVirtualHardDisk");
-                inParams["DestinationPath"] = ((string)(DestinationPath));
-                inParams["SourcePath"] = ((string)(SourcePath));
-                inParams["Type"] = ((ushort)(Type));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ConvertVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateDifferencingVirtualHardDisk(string ParentPath, string Path, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateDifferencingVirtualHardDisk");
-                inParams["ParentPath"] = ((string)(ParentPath));
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateDifferencingVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateDynamicVirtualHardDisk(ulong MaxInternalSize, string Path, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateDynamicVirtualHardDisk");
-                inParams["MaxInternalSize"] = ((ulong)(MaxInternalSize));
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateDynamicVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateFixedVirtualHardDisk(ulong MaxInternalSize, string Path, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateFixedVirtualHardDisk");
-                inParams["MaxInternalSize"] = ((ulong)(MaxInternalSize));
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateFixedVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateVirtualFloppyDisk(string Path, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateVirtualFloppyDisk");
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateVirtualFloppyDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ExpandVirtualHardDisk(ulong MaxInternalSize, string Path, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ExpandVirtualHardDisk");
-                inParams["MaxInternalSize"] = ((ulong)(MaxInternalSize));
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ExpandVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint GetVirtualHardDiskInfo(string Path, out string Info, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualHardDiskInfo");
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualHardDiskInfo", inParams, null);
-                Info = System.Convert.ToString(outParams.Properties["Info"].Value);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Info = null;
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint MergeVirtualHardDisk(string DestinationPath, string SourcePath, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("MergeVirtualHardDisk");
-                inParams["DestinationPath"] = ((string)(DestinationPath));
-                inParams["SourcePath"] = ((string)(SourcePath));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("MergeVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint Mount(string Path, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("Mount");
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Mount", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ReconnectParentVirtualHardDisk(string ChildPath, bool Force, string ParentPath, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ReconnectParentVirtualHardDisk");
-                inParams["ChildPath"] = ((string)(ChildPath));
-                inParams["Force"] = ((bool)(Force));
-                inParams["ParentPath"] = ((string)(ParentPath));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ReconnectParentVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint StartService() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint StopService() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint Unmount(string Path) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("Unmount");
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Unmount", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ValidateVirtualHardDisk(string Path, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ValidateVirtualHardDisk");
-                inParams["Path"] = ((string)(Path));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ValidateVirtualHardDisk", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class ImageManagementServiceCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public ImageManagementServiceCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new ImageManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new ImageManagementServiceEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class ImageManagementServiceEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public ImageManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new ImageManagementService(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


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

Posted by bf...@apache.org.
Application context files so that hyperv guru and discoverer can be loaded. Also made changes
to hyperv pom.xml to make sure the resources are picked up at build time.


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

Branch: refs/heads/ui-restyle
Commit: a196fbc8369d19c4f6615e74d382175dad27e23f
Parents: d14592f
Author: Devdeep Singh <de...@gmail.com>
Authored: Mon Nov 4 11:34:46 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Mon Nov 4 18:48:54 2013 +0530

----------------------------------------------------------------------
 client/pom.xml                                  |  6 -----
 plugins/hypervisors/hyperv/pom.xml              |  3 +++
 .../cloudstack/hyperv-compute/module.properties | 18 ++++++++++++++
 .../spring-hyperv-compute-context.xml           | 24 +++++++++++++++++++
 .../hyperv-discoverer/module.properties         | 18 ++++++++++++++
 .../spring-hyperv-discoverer-context.xml        | 25 ++++++++++++++++++++
 plugins/pom.xml                                 | 11 ---------
 7 files changed, 88 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a196fbc8/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 6c2ecb9..54cb667 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -160,12 +160,6 @@
       <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-hypervisor-hyperv</artifactId>
       <version>${project.version}</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.mortbay.jetty</groupId>
-          <artifactId>servlet-api</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a196fbc8/plugins/hypervisors/hyperv/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/pom.xml b/plugins/hypervisors/hyperv/pom.xml
index 042d3aa..19aa28a 100644
--- a/plugins/hypervisors/hyperv/pom.xml
+++ b/plugins/hypervisors/hyperv/pom.xml
@@ -60,6 +60,9 @@
     <testSourceDirectory>test</testSourceDirectory>
     <resources>
       <resource>
+        <directory>resources</directory>
+      </resource>
+      <resource>
         <directory>conf</directory>
       </resource>
     </resources>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a196fbc8/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-compute/module.properties
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-compute/module.properties b/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-compute/module.properties
new file mode 100644
index 0000000..439b7d5
--- /dev/null
+++ b/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-compute/module.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+name=hyperv-compute
+parent=compute
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a196fbc8/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-compute/spring-hyperv-compute-context.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-compute/spring-hyperv-compute-context.xml b/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-compute/spring-hyperv-compute-context.xml
new file mode 100644
index 0000000..6352161
--- /dev/null
+++ b/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-compute/spring-hyperv-compute-context.xml
@@ -0,0 +1,24 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+    license agreements. See the NOTICE file distributed with this work for additional 
+    information regarding copyright ownership. The ASF licenses this file to 
+    you under the Apache License, Version 2.0 (the "License"); you may not use 
+    this file except in compliance with the License. You may obtain a copy of 
+    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+    by applicable law or agreed to in writing, software distributed under the 
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+    OF ANY KIND, either express or implied. See the License for the specific 
+    language governing permissions and limitations under the License. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:aop="http://www.springframework.org/schema/aop"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+    <bean id="HypervGuru" class="com.cloud.hypervisor.hyperv.guru.HypervGuru">
+        <property name="name" value="HypervGuru" />
+    </bean>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a196fbc8/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-discoverer/module.properties
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-discoverer/module.properties b/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-discoverer/module.properties
new file mode 100644
index 0000000..be51dd6
--- /dev/null
+++ b/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-discoverer/module.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+name=hyperv-discoverer
+parent=discoverer
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a196fbc8/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-discoverer/spring-hyperv-discoverer-context.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-discoverer/spring-hyperv-discoverer-context.xml b/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-discoverer/spring-hyperv-discoverer-context.xml
new file mode 100644
index 0000000..ee394f0
--- /dev/null
+++ b/plugins/hypervisors/hyperv/resources/META-INF/cloudstack/hyperv-discoverer/spring-hyperv-discoverer-context.xml
@@ -0,0 +1,25 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+    license agreements. See the NOTICE file distributed with this work for additional 
+    information regarding copyright ownership. The ASF licenses this file to 
+    you under the Apache License, Version 2.0 (the "License"); you may not use 
+    this file except in compliance with the License. You may obtain a copy of 
+    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+    by applicable law or agreed to in writing, software distributed under the 
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+    OF ANY KIND, either express or implied. See the License for the specific 
+    language governing permissions and limitations under the License. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+    xmlns:aop="http://www.springframework.org/schema/aop"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+    <bean id="HypervServerDiscoverer"
+        class="com.cloud.hypervisor.hyperv.discoverer.HypervServerDiscoverer">
+        <property name="name" value="Hyper-V Agent" />
+    </bean>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a196fbc8/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index a707719..4f193bc 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -121,17 +121,6 @@
       </modules>
     </profile>
     <profile>
-      <id>hyperV</id>
-      <activation>
-        <property>
-          <name>hyperV</name>
-        </property>
-      </activation>
-      <modules>
- 	   <module>hypervisors/hyperv</module>
-      </modules>
-    </profile>
-    <profile>
       <id>f5</id>
       <activation>
         <property>


[38/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
index c66c616..fab1b82 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
@@ -1,1149 +1,1147 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-using System;
-using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION;
-using System.Management;
-using Newtonsoft.Json.Linq;
-using Newtonsoft.Json;
-using System.IO;
-using log4net;
-using HypervResource;
-using CloudStack.Plugin.AgentShell;
-using System.Collections.Generic;
-using System.Xml;
-using Xunit;
-
-namespace ServerResource.Tests
-{
-    public class HypervResourceControllerTest
-    {
-        protected static string testCifsUrl = AgentSettings.Default.testCifsUrl;
-        protected static string testCifsPath = AgentSettings.Default.testCifsPath;
-        protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress;
-        protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName;
-        protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName;
-        protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName;
-        protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt;
-        protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2";
-        protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool");
-        protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary");
-
-        // TODO: differentiate between NFS and HTTP template URLs.
-        protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx";
-        protected static String testSampleTemplateURL = testSampleTemplateUUID;
-
-        // test volumes are both a minimal size vhdx.  Changing the extension to .vhd makes on corrupt.
-        protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx";
-        protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd";
-        protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx";
-        protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp";
-        protected static String testSampleVolumeWorkingURIJSON;
-        protected static String testSampleVolumeCorruptURIJSON;
-        protected static String testSampleVolumeTempURIJSON;
-
-        protected static String testSampleTemplateURLJSON;
-        protected static String testLocalStorePathJSON;
-
-        protected static WmiCalls wmiCalls = new WmiCalls();
-        protected static WmiCallsV2 wmiCallsV2 = new WmiCallsV2();
-
-        private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceControllerTest));
-
-        /// <summary>
-        /// Test WmiCalls to which incoming HTTP POST requests are dispatched.
-        /// 
-        /// TODO: revise beyond first approximation
-        /// First approximation is a quick port of the existing Java tests for Hyper-V server resource.
-        /// A second approximation would use the AgentShell settings files directly.
-        /// A third approximation would look to invoke ServerResource methods via an HTTP request
-        /// </summary>
-        public HypervResourceControllerTest()
-        {
-            AgentService.ConfigServerResource();
-            HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address;
-            HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask;
-            HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress;
-            HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress;
-            HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask;
-
-
-            // Used to create existing StoragePool in preparation for the ModifyStoragePool
-            testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString();
-
-            // Make sure secondary store is available.
-            string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath);
-            s_logger.Info("Test secondary storage in " + fullPath);
-            DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath);
-            if (!testSecondarStoreDir.Exists)
-            {
-                try
-                {
-                    testSecondarStoreDir.Create();
-                }
-                catch (System.IO.IOException ex)
-                {
-                    throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message);
-                }
-            }
-
-            // Convert to secondary storage string to canonical path
-            testSecondaryStoreLocalPath = testSecondarStoreDir.FullName;
-            AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath;
-
-            // Make sure local primary storage is available
-            DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath);
-            Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName);
-
-            // Convert to local primary storage string to canonical path
-            testLocalStorePath = testPoolDir.FullName;
-            AgentSettings.Default.local_storage_path = testLocalStorePath;
-
-            // Clean up old test files in local storage folder
-            FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID));
-            Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName);
-
-
-            // Delete all temporary files in local folder save the testVolWorks
-            foreach (var file in testPoolDir.GetFiles())
-            {
-                if (file.FullName == testVolWorks.FullName)
-                {
-                    continue;
-                }
-                file.Delete();
-                file.Refresh();
-                Assert.False(file.Exists, "removed file from previous test called " + file.FullName);
-            }
-
-            // Recreate starting point files for test, and record JSON encoded paths for each ...
-            testSampleVolumeTempURIJSON = CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleVolumeTempUUID);
-            s_logger.Info("Created " + testSampleVolumeTempURIJSON);
-            testSampleVolumeCorruptURIJSON = CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleVolumeCorruptUUID);
-            s_logger.Info("Created " + testSampleVolumeCorruptURIJSON);
-            CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleTemplateUUID);
-            testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID);
-            s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage.");
-
-            // ... including a secondary storage template:
-            CreateTestDiskImageFromExistingImage(testVolWorks, testSecondarStoreDir.FullName, "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx");
-            s_logger.Info("Created " + "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx" + " in secondary (NFS) storage.");
-
-
-            // Capture other JSON encoded paths
-            testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName);
-            testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath);
-
-            // TODO: may need to initialise the server resource in future.
-            //    s_hypervresource.initialize();
-
-            // Verify sample template is in place storage pool
-            s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON
-                      + " sample template at " + testSampleTemplateURLJSON);
-        }
-
-        private String CreateTestDiskImageFromExistingImage(FileInfo srcFile,
-        String dstPath,
-        String dstFileName)
-        {
-            var newFullname = Path.Combine(dstPath, dstFileName);
-            var newFileInfo = new FileInfo(newFullname);
-            if (!newFileInfo.Exists)
-            {
-                newFileInfo = srcFile.CopyTo(newFullname);
-            }
-            newFileInfo.Refresh();
-            Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName);
-
-            return JsonConvert.SerializeObject(newFileInfo.FullName);
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void TestPrimaryStorageDownloadCommandHTTP()
-        {
-            string downloadURI = "https://s3-eu-west-1.amazonaws.com/cshv3eu/SmallDisk.vhdx";
-            corePrimaryStorageDownloadCommandTestCycle(downloadURI);
-        }
-
-        private void corePrimaryStorageDownloadCommandTestCycle(string downloadURI)
-        {
-            // Arrange
-            HypervResourceController rsrcServer = new HypervResourceController();
-            dynamic jsonPSDCmd = JsonConvert.DeserializeObject(samplePrimaryDownloadCommand());
-            jsonPSDCmd.url = downloadURI;
-
-            // Act
-            dynamic jsonResult = rsrcServer.PrimaryStorageDownloadCommand(jsonPSDCmd);
-
-            // Assert
-            JObject ansAsProperty = jsonResult[0];
-            dynamic ans = ansAsProperty.GetValue(CloudStackTypes.PrimaryStorageDownloadAnswer);
-            Assert.True((bool)ans.result, "PrimaryStorageDownloadCommand did not succeed " + ans.details);
-
-            // Test that URL of downloaded template works for file creation.
-            dynamic jsonCreateCmd = JsonConvert.DeserializeObject(CreateCommandSample());
-            jsonCreateCmd.templateUrl = ans.installPath;
-            dynamic jsonAns2 = rsrcServer.CreateCommand(jsonCreateCmd);
-            JObject ansAsProperty2 = jsonAns2[0];
-            dynamic ans2 = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
-
-            Assert.True((bool)ans2.result, (string)ans2.details);
-
-            FileInfo newFile = new FileInfo((string)ans2.volume.path);
-            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
-            newFile.Delete();
-        }
-
-        private string samplePrimaryDownloadCommand()
-        {
-            String cmdJson = "{\"localPath\":" + testLocalStorePathJSON +
-                    ",\"poolUuid\":\"" + testLocalStoreUUID + "\",\"poolId\":201," +
-                    "\"secondaryStorageUrl\":\"nfs://10.70.176.36/mnt/cshv3/secondarystorage\"," +
-                    "\"primaryStorageUrl\":\"nfs://" + HypervResourceController.config.StorageIpAddress + "E:\\\\Disks\\\\Disks\"," +
-                    "\"url\":\"nfs://10.70.176.36/mnt/cshv3/secondarystorage/template/tmpl//2/204//af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx\"," +
-                    "\"format\":\"VHDX\",\"accountId\":2,\"name\":\"204-2-5a1db1ac-932b-3e7e-a0e8-5684c72cb862\"" +
-                    ",\"contextMap\":{},\"wait\":10800}";
-            return cmdJson;
-        }
-
-        public string CreateCommandSample()
-        {
-            String sample = "{\"volId\":17,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" +
-                            ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," +
-                            "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-15\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," +
-                            "\"volumeId\":17,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"wait\":0}";
-            return sample;
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void TestDestroyCommand()
-        {
-            // Arrange
-            String sampleVolume = getSampleVolumeObjectTO();
-            String destoryCmd = //"{\"volume\":" + getSampleVolumeObjectTO() + "}";
-                            "{\"volume\":{\"name\":\"" + testSampleVolumeTempUUIDNoExt
-                                    + "\",\"storagePoolType\":\"Filesystem\","
-                                    + "\"mountPoint\":"
-                                    + testLocalStorePathJSON
-                                   + ",\"path\":" + testSampleVolumeTempURIJSON
-                                    + ",\"storagePoolUuid\":\"" + testLocalStoreUUID
-                                    + "\","
-                                    + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}";
-
-            HypervResourceController rsrcServer = new HypervResourceController();
-            dynamic jsonDestoryCmd = JsonConvert.DeserializeObject(destoryCmd);
-
-            // Act
-            dynamic destoryAns = rsrcServer.DestroyCommand(jsonDestoryCmd);
-
-            // Assert
-            JObject ansAsProperty2 = destoryAns[0];
-            dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.Answer);
-            String path = jsonDestoryCmd.volume.path;
-            Assert.True((bool)ans.result, "DestroyCommand did not succeed " + ans.details);
-            Assert.True(!File.Exists(path), "Failed to delete file " + path);
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void TestCreateCommand()
-        {
-            // TODO: Need sample to update the test.
-            // Arrange
-            String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" +
-                            ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," +
-                            "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," +
-                            "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}";
-            dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd);
-            HypervResourceController rsrcServer = new HypervResourceController();
-
-            Assert.True(Directory.Exists(testLocalStorePath));
-            string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON));
-            Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath);
-            int fileCount = Directory.GetFiles(testLocalStorePath).Length;
-            s_logger.Debug(" test local store has " + fileCount + "files");
-
-            // Act
-            // Test requires there to be a template at the tempalteUrl, which is its location in the local file system.
-            dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd);
-
-            JObject ansAsProperty2 = jsonResult[0];
-            dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
-            Assert.NotNull(ans);
-            Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result);
-            Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1);
-            FileInfo newFile = new FileInfo((string)ans.volume.path);
-            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
-            newFile.Delete();
-        }
-
-        /// <summary>
-        /// Possible additional tests:  place an ISO in the drive
-        /// </summary>
-        [Fact(Skip="these are functional tests")]
-        public void TestStartStopCommand()
-        {
-            string vmName = TestStartCommand();
-            TestStopCommand(vmName);
-        }
-
-        public static String getSamplePrimaryDataStoreInfo()
-        {
-            String samplePrimaryDataStoreInfo =
-            "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" +
-                "{\"uuid\":\"" + testLocalStoreUUID + "\"," +
-                "\"id\":201," +
-                "\"host\":\"" + testPrimaryDataStoreHost + "\"," +
-                "\"type\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
-                "\"poolType\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
-                "\"path\":" + testLocalStorePathJSON + "," +
-                "\"port\":0}" +
-            "}";
-            return samplePrimaryDataStoreInfo;
-        }
-
-        public static String getSampleVolumeObjectTO()
-        {
-            String sampleVolumeObjectTO =
-                    "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" +
-                        "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," +
-                        "\"volumeType\":\"ROOT\"," +
-                        "\"format\":\"VHDX\"," +
-                        "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
-                        "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," +
-                        "\"size\":52428800," +
-                        "\"volumeId\":10," +
-                //                            "\"vmName\":\"i-3-5-VM\"," +  // TODO: do we have to fill in the vmName?
-                        "\"accountId\":3,\"id\":10}" +
-                    "}";  // end of destTO 
-            return sampleVolumeObjectTO;
-        }
-
-        public static String getSampleStartCommand()
-        {
-            String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," +
-                                "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," +
-                                "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," +
-                                "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," +
-                                "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" +
-                            ",\"disks\":[" +
-                               "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," +
-                               "{\"diskSeq\":1,\"type\":\"ISO\"}" +
-                            "]," +
-                            "\"nics\":[" +
-                                    "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," +
-                                    "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," +
-                                    "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," +
-                                    "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" +
-                            "]},\"contextMap\":{},\"wait\":0}";
-            return sample;
-        }
-
-
-        [Fact(Skip="these are functional tests")]
-        public void TestCopyCommandFromCifs()
-        {
-            // Arrange
-            string sampleCopyCommandForTemplateDownload =
-            #region string_literal
-                // org.apache.cloudstack.storage.command.CopyCommand
-                "{\"srcTO\":" +
-                  "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
-                    "{\"path\":\"" + testCifsPath + "\"," +
-                     "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
-                     "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
-                     "\"id\":206," +
-                     "\"format\":\"VHDX\"," +
-                     "\"accountId\":2," +
-                     "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
-                     "\"hvm\":true," +
-                     "\"displayText\":\"OS031\"," +
-                     "\"imageDataStore\":" +
-                       "{\"com.cloud.agent.api.to.NfsTO\":" +
-                         "{\"_url\":\"" + testCifsUrl + "\"," + // Unique item here
-                         "\"_role\":\"Image\"}" +
-                       "}," + // end of imageDataStore
-                     "\"hypervisorType\":\"Hyperv\"," +
-                     "\"name\":\"" + testS3TemplateName + "\"}" +
-                  "}," + // end of srcTO
-                 "\"destTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
-                        "{" +
-                        "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
-                        "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
-                        "\"id\":206," +
-                        "\"format\":\"VHDX\"," +
-                        "\"accountId\":2," +
-                        "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
-                        "\"hvm\":true," +
-                        "\"displayText\":\"Test of CIFS Download\"," +
-                        "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore
-                        "\"name\":\"" + testS3TemplateName + "\"," +
-                        "\"hypervisorType\":\"Hyperv\"}" +
-                    "}," +// end of destTO
-                "\"wait\":10800}"; // end of CopyCommand
-            #endregion
-
-            HypervResourceController rsrcServer;
-            dynamic jsonDownloadCopyCmd;
-            string dwnldDest;
-            dynamic jsonCloneCopyCmd;
-            string newVolName;
-            CopyCommandTestSetupCifs(null, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName);
-
-            // Act & Assert
-            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
-
-            // Repeat to verify ability to detect existing file.
-            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
-
-            File.Delete(dwnldDest);
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void TestCopyCommand()
-        {
-            // Arrange
-            string sampleCopyCommandToCreateVolumeFromTemplate =
-            #region string_literal
-                // org.apache.cloudstack.storage.command.CopyCommand
-                "{\"srcTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
-                        "{" +
-                        "\"origUrl\":\"http://people.apache.org/~bhaisaab/vms/ttylinux_pv.vhd\"," +
-                        "\"uuid\":\"9873f1c0-bdcc-11e2-8baa-ea85dab5fcd0\"," +
-                        "\"id\":5," +
-                        "\"format\":\"VHDX\"," +
-                        "\"accountId\":1," +
-                        "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
-                        "\"hvm\":false," +
-                        "\"displayText\":\"tiny Linux\"," +
-                        "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
-                        "\"name\":\"" + testS3TemplateName + "\"}" +
-                    "}," +  // end of srcTO
-                "\"destTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" +
-                        "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," +
-                        "\"volumeType\":\"ROOT\"," +
-                        "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
-                        "\"name\":\"ROOT-5\"," +
-                        "\"size\":52428800," +
-                        "\"volumeId\":10," +
-                        "\"vmName\":\"i-3-5-VM\"," +
-                        "\"accountId\":3," +
-                        "\"id\":10 }" +
-                    "}," +  // end of destTO 
-                "\"wait\":0}"; // end of Copy Command
-            #endregion
-            //"name":"ROOT-8","size":140616708,"volumeId":8,"vmName":"s-8-VM","accountId":1,"id":8}},"contextMap":{},"wait":0}
-
-            string sampleCopyCommandForTemplateDownload =
-            #region string_literal
-                // org.apache.cloudstack.storage.command.CopyCommand
-                "{\"srcTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
-                        "{\"path\":\"" + testS3TemplateName + ".vhdx" + "\"," +
-                        "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
-                        "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
-                        "\"id\":206," +
-                        "\"format\":\"VHDX\"," +
-                        "\"accountId\":2," +
-                        "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
-                        "\"hvm\":true," +
-                        "\"displayText\":\"OS031\"," +
-                        "\"imageDataStore\":" +
-                            "{\"com.cloud.agent.api.to.S3TO\":" +
-                                "{\"id\":1," +
-                                "\"uuid\":\"95a64c8f-2128-4502-b5b4-0d7aa77406d2\"," +
-                                "\"accessKey\":\"" + AgentSettings.Default.testS3AccessKey + "\"," +
-                                "\"secretKey\":\"" + AgentSettings.Default.testS3SecretKey + "\"," +
-                                "\"endPoint\":\"" + AgentSettings.Default.testS3Endpoint + "\"," +
-                                "\"bucketName\":\"" + AgentSettings.Default.testS3Bucket + "\"," +
-                                "\"httpsFlag\":false," +
-                                "\"created\":\"May 19, 2013 4:17:25 PM\"}" +
-                                "}," + // end of imageDataStore
-                        "\"name\":\"" + testS3TemplateName + "\"}" +
-                     "}," + // end of srcTO
-                 "\"destTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
-                        "{" +
-                        "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
-                        "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
-                        "\"id\":206," +
-                        "\"format\":\"VHDX\"," +
-                        "\"accountId\":2," +
-                        "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
-                        "\"hvm\":true," +
-                        "\"displayText\":\"OS031\"," +
-                        "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore
-                        "\"name\":\"" + testS3TemplateName + "\"}" +
-                    "}," +// end of destTO
-                "\"wait\":10800}"; // end of CopyCommand
-            #endregion
-
-            HypervResourceController rsrcServer;
-            dynamic jsonDownloadCopyCmd;
-            string dwnldDest;
-            dynamic jsonCloneCopyCmd;
-            string newVolName;
-            CopyCommandTestSetup(sampleCopyCommandToCreateVolumeFromTemplate, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName);
-
-            // Act & Assert
-            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
-            CreateVolumeFromTemplate(rsrcServer, jsonCloneCopyCmd, newVolName);
-
-            // Repeat to verify ability to detect existing file.
-            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
-
-            File.Delete(dwnldDest);
-            File.Delete(newVolName);
-        }
-
-        private static void CreateVolumeFromTemplate(HypervResourceController rsrcServer, dynamic jsonCloneCopyCmd, string newVolName)
-        {
-            dynamic copyResult = rsrcServer.CopyCommand(jsonCloneCopyCmd);
-
-            // Assert
-            Assert.NotNull(copyResult[0][CloudStackTypes.CopyCmdAnswer]);
-            Assert.True((bool)copyResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + copyResult[0][CloudStackTypes.CopyCmdAnswer].details);
-            Assert.True(File.Exists(newVolName), "CopyCommand failed to generate " + newVolName);
-        }
-
-        private static void DownloadTemplateToPrimaryStorage(HypervResourceController rsrcServer, dynamic jsonDownloadCopyCmd, string dwnldDest)
-        {
-            dynamic dwnldResult = rsrcServer.CopyCommand(jsonDownloadCopyCmd);
-
-            // Assert
-            Assert.NotNull(dwnldResult[0][CloudStackTypes.CopyCmdAnswer]);
-            Assert.True((bool)dwnldResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + dwnldResult[0][CloudStackTypes.CopyCmdAnswer].details);
-            Assert.True(File.Exists(dwnldDest), "CopyCommand failed to generate " + dwnldDest);
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void TestCopyCommandBz2Img()
-        {
-            // Arrange
-            string sampleCopyCommandToCreateVolumeFromTemplate =
-            #region string_literal
-                // org.apache.cloudstack.storage.command.CopyCommand
-                "{\"srcTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
-                        "{" +
-                        "\"origUrl\":\"http://people.apache.org/~bhaisaab/vms/ttylinux_pv.vhd\"," +
-                        "\"uuid\":\"9873f1c0-bdcc-11e2-8baa-ea85dab5fcd0\"," +
-                        "\"id\":5," +
-                        "\"format\":\"VHD\"," +
-                        "\"accountId\":1," +
-                        "\"checksum\":\"f613f38c96bf039f2e5cbf92fa8ad4f8\"," +
-                        "\"hvm\":false," +
-                        "\"displayText\":\"tiny Linux\"," +
-                        "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
-                        "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" +
-                    "}," +  // end of srcTO
-                "\"destTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" +
-                        "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," +
-                        "\"volumeType\":\"ROOT\"," +
-                        "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
-                        "\"name\":\"ROOT-5\"," +
-                        "\"size\":52428800," +
-                        "\"volumeId\":10," +
-                        "\"vmName\":\"i-3-5-VM\"," +
-                        "\"accountId\":1," +
-                        "\"id\":10}" +
-                    "}," +  // end of destTO 
-                "\"wait\":0}"; // end of Copy Command
-            #endregion
-
-            string sampleCopyCommandForTemplateDownload =
-            #region string_literal
-                // org.apache.cloudstack.storage.command.CopyCommand
-                "{\"srcTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
-                        "{\"path\":\"" + testSystemVMTemplateName + "\"," +
-                        "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
-                        "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
-                        "\"id\":206," +
-                        "\"format\":\"VHD\"," +
-                        "\"accountId\":1," +
-                        "\"checksum\": \"f613f38c96bf039f2e5cbf92fa8ad4f8\"," +
-                        "\"hvm\":true," +
-                        "\"displayText\":\"OS031\"," +
-                        "\"imageDataStore\":" +
-                            "{\"com.cloud.agent.api.to.S3TO\":" +
-                                "{\"id\":1," +
-                                "\"uuid\":\"95a64c8f-2128-4502-b5b4-0d7aa77406d2\"," +
-                                "\"accessKey\":\"" + AgentSettings.Default.testS3AccessKey + "\"," +
-                                "\"secretKey\":\"" + AgentSettings.Default.testS3SecretKey + "\"," +
-                                "\"endPoint\":\"" + AgentSettings.Default.testS3Endpoint + "\"," +
-                                "\"bucketName\":\"" + AgentSettings.Default.testS3Bucket + "\"," +
-                                "\"httpsFlag\":false," +
-                                "\"created\":\"May 19, 2013 4:17:25 PM\"}" +
-                                "}," + // end of imageDataStore
-                        "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" +
-                     "}," + // end of srcTO
-                 "\"destTO\":" +
-                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
-                        "{" +
-                        "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
-                        "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
-                        "\"id\":206," +
-                        "\"format\":\"VHD\"," +
-                        "\"accountId\":1," +
-                        "\"checksum\": \"f613f38c96bf039f2e5cbf92fa8ad4f8\"," +
-                        "\"hvm\":true," +
-                        "\"displayText\":\"OS031\"," +
-                        "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore
-                        "\"name\":\"" + testSystemVMTemplateNameNoExt + "\"}" +
-                    "}," +// end of destTO
-                "\"wait\":10800}"; // end of CopyCommand
-            #endregion
-
-            HypervResourceController rsrcServer;
-            dynamic jsonDownloadCopyCmd;
-            string dwnldDest;
-            dynamic jsonCloneCopyCmd;
-            string newVolName;
-            CopyCommandTestSetup(sampleCopyCommandToCreateVolumeFromTemplate, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName);
-
-            // Act & Assert
-            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
-            CreateVolumeFromTemplate(rsrcServer, jsonCloneCopyCmd, newVolName);
-
-            File.Delete(dwnldDest);
-            File.Delete(newVolName);
-        }
-
-        private static void CopyCommandTestSetup(string sampleCopyCommandToCreateVolumeFromTemplate, string sampleCopyCommandForTemplateDownload, out HypervResourceController rsrcServer, out dynamic jsonDownloadCopyCmd, out string dwnldDest, out dynamic jsonCloneCopyCmd, out string newVolName)
-        {
-            rsrcServer = new HypervResourceController();
-            jsonDownloadCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandForTemplateDownload);
-            TemplateObjectTO dwnldTemplate = TemplateObjectTO.ParseJson(jsonDownloadCopyCmd.destTO);
-            dwnldDest = dwnldTemplate.FullFileName;
-
-            jsonCloneCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandToCreateVolumeFromTemplate);
-            VolumeObjectTO newVol = VolumeObjectTO.ParseJson(jsonCloneCopyCmd.destTO);
-            newVol.format = dwnldTemplate.format;
-            newVolName = dwnldTemplate.FullFileName;
-
-            if (File.Exists(dwnldDest))
-            {
-                File.Delete(dwnldDest);
-            }
-            if (File.Exists(newVolName))
-            {
-                File.Delete(newVolName);
-            }
-        }
-
-        private static void CopyCommandTestSetupCifs(string sampleCopyCommandToCreateVolumeFromTemplate, string sampleCopyCommandForTemplateDownload, out HypervResourceController rsrcServer, out dynamic jsonDownloadCopyCmd, out string dwnldDest, out dynamic jsonCloneCopyCmd, out string newVolName)
-        {
-            rsrcServer = new HypervResourceController();
-            jsonDownloadCopyCmd = JsonConvert.DeserializeObject(sampleCopyCommandForTemplateDownload);
-            TemplateObjectTO dwnldTemplate = TemplateObjectTO.ParseJson(jsonDownloadCopyCmd.destTO);
-            dwnldDest = dwnldTemplate.FullFileName;
-
-            if (File.Exists(dwnldDest))
-            {
-                File.Delete(dwnldDest);
-            }
-            newVolName = null;
-            jsonCloneCopyCmd = null;
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void TestModifyStoragePoolCommand()
-        {
-            // Create dummy folder
-            String folderName = Path.Combine(".", "Dummy");
-            if (!Directory.Exists(folderName))
-            {
-                Directory.CreateDirectory(folderName);
-            }
-
-            var pool = new
-            {  // From java class StorageFilerTO
-                type = Enum.GetName(typeof(StoragePoolType), StoragePoolType.Filesystem),
-                host = "127.0.0.1",
-                port = -1,
-                path = folderName,
-                uuid = Guid.NewGuid().ToString(),
-                userInfo = string.Empty // Used in future to hold credential
-            };
-
-            var cmd = new
-            {
-                add = true,
-                pool = pool,
-                localPath = folderName
-            };
-            JToken tok = JToken.FromObject(cmd);
-            HypervResourceController controller = new HypervResourceController();
-
-            // Act
-            dynamic jsonResult = controller.ModifyStoragePoolCommand(tok);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.ModifyStoragePoolAnswer];
-            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds
-
-            // Clean up
-            var cmd2 = new
-            {
-                pool = pool,
-                localPath = folderName
-            };
-            JToken tok2 = JToken.FromObject(cmd);
-
-            // Act
-            dynamic jsonResult2 = controller.DeleteStoragePoolCommand(tok2);
-
-            // Assert
-            dynamic ans2 = jsonResult2[0][CloudStackTypes.Answer];
-            Assert.True((bool)ans2.result, (string)ans2.details);  // always succeeds
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void CreateStoragePoolCommand()
-        {
-            var cmd = new { localPath = "NULL" };
-            JToken tok = JToken.FromObject(cmd);
-            HypervResourceController controller = new HypervResourceController();
-
-            // Act
-            dynamic jsonResult = controller.CreateStoragePoolCommand(tok);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.Answer];
-            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void MaintainCommand()
-        {
-            // Omit HostEnvironment object, as this is a series of settings currently not used.
-            var cmd = new { };
-            JToken tok = JToken.FromObject(cmd);
-            HypervResourceController controller = new HypervResourceController();
-
-            // Act
-            dynamic jsonResult = controller.MaintainCommand(tok);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.MaintainAnswer];
-            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void SetupCommand()
-        {
-            // Omit HostEnvironment object, as this is a series of settings currently not used.
-            var cmd = new { multipath = false, needSetup = true };
-            JToken tok = JToken.FromObject(cmd);
-            HypervResourceController controller = new HypervResourceController();
-
-            // Act
-            dynamic jsonResult = controller.SetupCommand(tok);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.SetupAnswer];
-            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void TestPassingUserdataToVm()
-        {
-            // Sample data
-            String key = "cloudstack-vm-userdata";
-            String value = "username=root;password=1pass@word1";
-
-            // Find the VM
-            List<String> vmNames = wmiCallsV2.GetVmElementNames();
-
-            // Get associated WMI object
-            var vm = wmiCallsV2.GetComputerSystem(AgentSettings.Default.testKvpVmName);
-
-            // Get existing KVP
-            var vmSettings = wmiCallsV2.GetVmSettings(vm);
-            var kvpInfo = wmiCallsV2.GetKvpSettings(vmSettings);
-
-            // HostExchangesItems are embedded objects in the sense that the object value is stored and not a reference to the object.
-            string[] kvpProps = kvpInfo.HostExchangeItems;
-
-            // If the value already exists, delete it
-            foreach (var item in kvpProps)
-            {
-                String wmiObjectXml = item;
-                String existingKey;
-                String existingValue;
-                ParseKVP(wmiObjectXml, out existingKey, out existingValue);
-
-                if (existingKey == key)
-                {
-                    wmiCallsV2.DeleteHostKvpItem(vm, existingKey);
-                    break;
-                }
-            }
-
-            // Add new user data
-            wmiCallsV2.AddUserData(vm, value);
-
-            // 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;
-
-            // If the value already exists, delete it
-            bool userDataInPlace = false;
-            foreach (var item in kvpProps)
-            {
-                String wmiObjectXml = item;
-                String existingKey;
-                String existingValue;
-                ParseKVP(wmiObjectXml, out existingKey, out existingValue);
-
-                if (existingKey == key && existingValue == value)
-                {
-//                    wmiCallsV2.DeleteHostKvpItem(vm, existingKey);
-                    userDataInPlace = true;
-                    break;
-                }
-            }
-
-            Assert.True(userDataInPlace, "User data key / value did no save properly");
-        }
-
-        private static void ParseKVP(String wmiObjectXml, out String existingKey, out String existingValue)
-        {
-            // Reference:  http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/12/05/enumerating-parent-kvp-data.aspx
-
-            // Create XML parser
-            var xmlDoc = new XmlDocument();
-
-            // Load WMI object
-            xmlDoc.LoadXml(wmiObjectXml);
-
-            // Use xpath to get name and value
-            var namePropXpath = "/INSTANCE/PROPERTY[@NAME='Name']/VALUE";
-            var nameNode = xmlDoc.SelectSingleNode(namePropXpath);
-            existingKey = nameNode.InnerText;
-            var dataPropXpath = "/INSTANCE/PROPERTY[@NAME='Data']/VALUE";
-            var dataNode = xmlDoc.SelectSingleNode(dataPropXpath);
-            existingValue = dataNode.InnerText;
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void GetVmStatsCommandFail()
-        {
-            // Use WMI to find existing VMs
-            List<String> vmNames = new List<String>();
-            vmNames.Add("FakeVM");
-
-            var cmd = new
-            {
-                hostGuid = "FAKEguid",
-                hostName = AgentSettings.Default.host,
-                vmNames = vmNames
-            };
-            JToken tok = JToken.FromObject(cmd);
-            HypervResourceController controller = new HypervResourceController();
-
-            // Act
-            dynamic jsonResult = controller.GetVmStatsCommand(tok);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer];
-            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds, fake VM means no answer for the named VM
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void GetVmStatsCommand()
-        {
-            // Use WMI to find existing VMs
-            List<String> vmNames = wmiCalls.GetVmElementNames();
-
-            var cmd = new
-            {
-                hostGuid = "FAKEguid",
-                hostName = AgentSettings.Default.host,
-                vmNames = vmNames
-            };
-            JToken tok = JToken.FromObject(cmd);
-            HypervResourceController controller = new HypervResourceController();
-
-            // Act
-            dynamic jsonResult = controller.GetVmStatsCommand(tok);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer];
-            Assert.True((bool)ans.result, (string)ans.details);
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void GetStorageStatsCommand()
-        {
-            // TODO:  Update sample data to unsure it is using correct info.
-            String sample = String.Format(
-            #region string_literal
-"{{\"" +
-                "id\":{0}," +
-                "\"localPath\":{1}," +
-                "\"pooltype\":\"Filesystem\"," +
-                "\"contextMap\":{{}}," +
-                "\"wait\":0}}",
-                JsonConvert.SerializeObject(AgentSettings.Default.testLocalStoreUUID),
-                JsonConvert.SerializeObject(AgentSettings.Default.testLocalStorePath)
-                );
-            #endregion
-            var cmd = JsonConvert.DeserializeObject(sample);
-            JToken tok = JToken.FromObject(cmd);
-            HypervResourceController controller = new HypervResourceController();
-
-            // Act
-            dynamic jsonResult = controller.GetStorageStatsCommand(tok);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.GetStorageStatsAnswer];
-            Assert.True((bool)ans.result, (string)ans.details);
-            Assert.True((long)ans.used <= (long)ans.capacity);  // TODO: verify that capacity is indeed capacity and not used.
-        }
-
-        // TODO: can we speed up this command?  The logic takes over a second.
-        [Fact(Skip="these are functional tests")]
-        public void GetHostStatsCommand()
-        {
-            // Arrange
-            long hostIdVal = 5;
-            HypervResourceController controller = new HypervResourceController();
-            string sample = string.Format(
-            #region string_literal
-"{{" +
-                    "\"hostGuid\":\"B4AE5970-FCBF-4780-9F8A-2D2E04FECC34-HypervResource\"," +
-                    "\"hostName\":\"CC-SVR11\"," +
-                    "\"hostId\":{0}," +
-                    "\"contextMap\":{{}}," +
-                    "\"wait\":0}}",
-                    JsonConvert.SerializeObject(hostIdVal));
-            #endregion
-            var cmd = JsonConvert.DeserializeObject(sample);
-            JToken tok = JToken.FromObject(cmd);
-
-            // Act
-            dynamic jsonResult = controller.GetHostStatsCommand(tok);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.GetHostStatsAnswer];
-            Assert.True((bool)ans.result);
-            Assert.True(hostIdVal == (long)ans.hostStats.hostId);
-            Assert.True(0.0 < (double)ans.hostStats.totalMemoryKBs);
-            Assert.True(0.0 < (double)ans.hostStats.freeMemoryKBs);
-            Assert.True(0.0 <= (double)ans.hostStats.networkReadKBs);
-            Assert.True(0.0 <= (double)ans.hostStats.networkWriteKBs);
-            Assert.True(0.0 <= (double)ans.hostStats.cpuUtilization);
-            Assert.True(100.0 >= (double)ans.hostStats.cpuUtilization);
-            Assert.True("host".Equals((string)ans.hostStats.entityType));
-            Assert.True(String.IsNullOrEmpty((string)ans.details));
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void GetHostStatsCommandFail()
-        {
-            // Arrange
-            HypervResourceController controller = new HypervResourceController();
-            var cmd = new { GetHostStatsCommand = new { hostId = "badvalueType" } };
-            JToken tokFail = JToken.FromObject(cmd);
-
-            // Act
-            dynamic jsonResult = controller.GetHostStatsCommand(tokFail);
-
-            // Assert
-            dynamic ans = jsonResult[0][CloudStackTypes.GetHostStatsAnswer];
-            Assert.False((bool)ans.result);
-            Assert.Null((string)ans.hostStats);
-            Assert.NotNull(ans.details);
-        }
-
-        [Fact(Skip="these are functional tests")]
-        public void TestStartupCommand()
-        {
-            // Arrange
-            HypervResourceController controller = new HypervResourceController();
-            String sampleStartupRoutingCommand =
-            #region string_literal
- "[{\"" + CloudStackTypes.StartupRoutingCommand + "\":{" +
-                    "\"cpus\":0," +
-                    "\"speed\":0," +
-                    "\"memory\":0," +
-                    "\"dom0MinMemory\":0," +
-                    "\"poolSync\":false," +
-                    "\"vms\":{}," +
-                    "\"hypervisorType\":\"Hyperv\"," +
-                    "\"hostDetails\":{" +
-                    "\"com.cloud.network.Networks.RouterPrivateIpStrategy\":\"HostLocal\"" +
-                    "}," +
-                    "\"type\":\"Routing\"," +
-                    "\"dataCenter\":\"1\"," +
-                    "\"pod\":\"1\"," +
-                    "\"cluster\":\"1\"," +
-                    "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," +
-                    "\"name\":\"localhost\"," +
-                    "\"version\":\"4.2.0\"," +
-                    "\"privateIpAddress\":\"1\"," +
-                    "\"storageIpAddress\":\"1\"," +
-                    "\"contextMap\":{}," +
-                    "\"wait\":0}}]";
-            #endregion
-
-            uint cores;
-            uint mhz;
-            wmiCalls.GetProcessorResources(out cores, out mhz);
-            ulong memory_mb;
-            ulong freememory;
-            wmiCalls.GetMemoryResources(out memory_mb, out freememory);
-            memory_mb *= 1024;
-            long capacityBytes;
-            long availableBytes;
-            HypervResourceController.GetCapacityForLocalPath(wmiCalls.GetDefaultVirtualDiskFolder(),
-                    out capacityBytes, out availableBytes);
-            var DefaultVirtualDiskFolder = JsonConvert.SerializeObject(wmiCalls.GetDefaultVirtualDiskFolder());
-            string expected =
-            #region string_literal
-                    "[{\"" + CloudStackTypes.StartupRoutingCommand + "\":{" +
-                        "\"cpus\":" + cores + "," +
-                        "\"speed\":" + mhz + "," +
-                        "\"memory\":" + memory_mb + "," +
-                        "\"dom0MinMemory\":" + (AgentSettings.Default.dom0MinMemory * 1024 * 1024) + "," +
-                        "\"poolSync\":false," +
-                        "\"vms\":{}," +
-                        "\"hypervisorType\":\"Hyperv\"," +
-                        "\"hostDetails\":{" +
-                        "\"com.cloud.network.Networks.RouterPrivateIpStrategy\":\"HostLocal\"" +
-                        "}," +
-                        "\"type\":\"Routing\"," +
-                        "\"dataCenter\":\"1\"," +
-                        "\"pod\":\"1\"," +
-                        "\"cluster\":\"1\"," +
-                        "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," +
-                        "\"name\":\"localhost\"," +
-                        "\"version\":\"4.2.0\"," +
-                        "\"privateIpAddress\":\"" + AgentSettings.Default.private_ip_address + "\"," +
-                        "\"storageIpAddress\":\"" + AgentSettings.Default.private_ip_address + "\"," +
-                        "\"contextMap\":{}," +
-                        "\"wait\":0," +
-                        "\"privateNetmask\":\"" + AgentSettings.Default.private_ip_netmask + "\"," +
-                        "\"privateMacAddress\":\"" + AgentSettings.Default.private_mac_address + "\"," +
-                        "\"storageNetmask\":\"" + AgentSettings.Default.private_ip_netmask + "\"," +
-                        "\"storageMacAddress\":\"" + AgentSettings.Default.private_mac_address + "\"," +
-                        "\"gatewayIpAddress\":\"" + AgentSettings.Default.gateway_ip_address + "\"" +
-                        ",\"caps\":\"hvm\"" +
-                        "}}," +
-                        "{\"com.cloud.agent.api.StartupStorageCommand\":{" +
-                        "\"poolInfo\":{" +
-                            "\"uuid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," +
-                            "\"host\":\"" + AgentSettings.Default.private_ip_address + "\"," +
-                            "\"localPath\":" + DefaultVirtualDiskFolder + "," +
-                            "\"hostPath\":" + DefaultVirtualDiskFolder + "," +
-                            "\"poolType\":\"Filesystem\"," +
-                            "\"capacityBytes\":" + capacityBytes + "," +
-                            "\"availableBytes\":" + availableBytes + "," +
-                            "\"details\":null" +
-                        "}," +
-                        "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\"," +
-                        "\"dataCenter\":\"1\"," +
-                        "\"resourceType\":\"STORAGE_POOL\"" +
-                        "}}]";
-            #endregion
-
-            dynamic jsonArray = JsonConvert.DeserializeObject(sampleStartupRoutingCommand);
-
-            // Act
-            dynamic jsonResult = controller.StartupCommand(jsonArray);
-
-            // Assert
-            string actual = JsonConvert.SerializeObject(jsonResult);
-            Assert.Equal(expected, actual);
-        }
-
-
-        private static string TestStartCommand()
-        {
-            // Arrange
-            HypervResourceController rsrcServer = new HypervResourceController();
-            String sample = getSampleStartCommand();
-
-
-            dynamic jsonStartCmd = JsonConvert.DeserializeObject(sample);
-
-            // Act
-            dynamic startAns = rsrcServer.StartCommand(jsonStartCmd);
-
-            // Assert
-            Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]);
-            Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details);
-            string vmCmdName = jsonStartCmd.vm.name.Value;
-            var vm = wmiCalls.GetComputerSystem(vmCmdName);
-            VirtualSystemSettingData vmSettings = wmiCalls.GetVmSettings(vm);
-            MemorySettingData memSettings = wmiCalls.GetMemSettings(vmSettings);
-            ProcessorSettingData procSettings = wmiCalls.GetProcSettings(vmSettings);
-            dynamic jsonObj = JsonConvert.DeserializeObject(sample);
-            var vmInfo = jsonObj.vm;
-            string vmName = vmInfo.name;
-            var nicInfo = vmInfo.nics;
-            int vcpus = vmInfo.cpus;
-            int memSize = vmInfo.maxRam / 1048576;
-            Assert.True((long)memSettings.VirtualQuantity == memSize);
-            Assert.True((long)memSettings.Reservation == memSize);
-            Assert.True((long)memSettings.Limit == memSize);
-            Assert.True((int)procSettings.VirtualQuantity == vcpus);
-            Assert.True((int)procSettings.Reservation == vcpus);
-            Assert.True((int)procSettings.Limit == 100000);
-
-            // examine NIC
-            SyntheticEthernetPortSettingData[] nicSettingsViaVm = wmiCalls.GetEthernetPorts(vm);
-            Assert.True(nicSettingsViaVm.Length > 0, "Should be at least one ethernet port on VM");
-            string expectedMac = (string)jsonStartCmd.vm.nics[0].mac;
-            string strippedExpectedMac = expectedMac.Replace(":", string.Empty);
-            Assert.Equal(nicSettingsViaVm[0].Address.ToLower(), strippedExpectedMac.ToLower());
-
-            // Assert switchport has correct VLAN 
-            SwitchPort[] switchPorts = wmiCalls.GetSwitchPorts(vm);
-            VirtualSwitchManagementService vmNetMgmtSvc = wmiCalls.GetVirtualSwitchManagementService();
-            VLANEndpointSettingData vlanSettings = wmiCalls.GetVlanEndpointSettings(vmNetMgmtSvc, switchPorts[0].Path);
-            string isolationUri = (string)jsonStartCmd.vm.nics[0].isolationUri;
-            string vlan = isolationUri.Replace("vlan://", string.Empty);
-            Assert.Equal(vlanSettings.AccessVLAN.ToString(), vlan);
-
-            return vmName;
-        }
-
-        private static void TestStopCommand(string vmName)
-        {
-            // Arrange
-            HypervResourceController rsrcServer = new HypervResourceController();
-            String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\",\"contextMap\":{},\"wait\":0}";
-            dynamic jsonStopCmd = JsonConvert.DeserializeObject(sampleStop);
-
-            // Act
-            dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd);
-
-            // Assert VM is gone!
-            Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]);
-            Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details);
-            var finalVm = wmiCalls.GetComputerSystem(vmName);
-            Assert.True(wmiCalls.GetComputerSystem(vmName) == null);
-        }
-    }
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+using System;
+using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION;
+using System.Management;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System.IO;
+using log4net;
+using HypervResource;
+using CloudStack.Plugin.AgentShell;
+using System.Collections.Generic;
+using System.Xml;
+using Xunit;
+
+namespace ServerResource.Tests
+{
+    public class HypervResourceControllerTest
+    {
+        protected static string testCifsUrl = AgentSettings.Default.testCifsUrl;
+        protected static string testCifsPath = AgentSettings.Default.testCifsPath;
+        protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress;
+        protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName;
+        protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName;
+        protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName;
+        protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt;
+        protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2";
+        protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool");
+        protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary");
+
+        // TODO: differentiate between NFS and HTTP template URLs.
+        protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx";
+        protected static String testSampleTemplateURL = testSampleTemplateUUID;
+
+        // test volumes are both a minimal size vhdx.  Changing the extension to .vhd makes on corrupt.
+        protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx";
+        protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd";
+        protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx";
+        protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp";
+        protected static String testSampleVolumeWorkingURIJSON;
+        protected static String testSampleVolumeCorruptURIJSON;
+        protected static String testSampleVolumeTempURIJSON;
+
+        protected static String testSampleTemplateURLJSON;
+        protected static String testLocalStorePathJSON;
+
+        protected static WmiCallsV2 wmiCallsV2 = new WmiCallsV2();
+
+        private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceControllerTest));
+
+        /// <summary>
+        /// Test WmiCalls to which incoming HTTP POST requests are dispatched.
+        /// 
+        /// TODO: revise beyond first approximation
+        /// First approximation is a quick port of the existing Java tests for Hyper-V server resource.
+        /// A second approximation would use the AgentShell settings files directly.
+        /// A third approximation would look to invoke ServerResource methods via an HTTP request
+        /// </summary>
+        public HypervResourceControllerTest()
+        {
+            AgentService.ConfigServerResource();
+            HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address;
+            HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask;
+            HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress;
+            HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress;
+            HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask;
+
+
+            // Used to create existing StoragePool in preparation for the ModifyStoragePool
+            testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString();
+
+            // Make sure secondary store is available.
+            string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath);
+            s_logger.Info("Test secondary storage in " + fullPath);
+            DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath);
+            if (!testSecondarStoreDir.Exists)
+            {
+                try
+                {
+                    testSecondarStoreDir.Create();
+                }
+                catch (System.IO.IOException ex)
+                {
+                    throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message);
+                }
+            }
+
+            // Convert to secondary storage string to canonical path
+            testSecondaryStoreLocalPath = testSecondarStoreDir.FullName;
+            AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath;
+
+            // Make sure local primary storage is available
+            DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath);
+            Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName);
+
+            // Convert to local primary storage string to canonical path
+            testLocalStorePath = testPoolDir.FullName;
+            AgentSettings.Default.local_storage_path = testLocalStorePath;
+
+            // Clean up old test files in local storage folder
+            FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID));
+            Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName);
+
+
+            // Delete all temporary files in local folder save the testVolWorks
+            foreach (var file in testPoolDir.GetFiles())
+            {
+                if (file.FullName == testVolWorks.FullName)
+                {
+                    continue;
+                }
+                file.Delete();
+                file.Refresh();
+                Assert.False(file.Exists, "removed file from previous test called " + file.FullName);
+            }
+
+            // Recreate starting point files for test, and record JSON encoded paths for each ...
+            testSampleVolumeTempURIJSON = CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleVolumeTempUUID);
+            s_logger.Info("Created " + testSampleVolumeTempURIJSON);
+            testSampleVolumeCorruptURIJSON = CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleVolumeCorruptUUID);
+            s_logger.Info("Created " + testSampleVolumeCorruptURIJSON);
+            CreateTestDiskImageFromExistingImage(testVolWorks, testLocalStorePath, testSampleTemplateUUID);
+            testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID);
+            s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage.");
+
+            // ... including a secondary storage template:
+            CreateTestDiskImageFromExistingImage(testVolWorks, testSecondarStoreDir.FullName, "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx");
+            s_logger.Info("Created " + "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx" + " in secondary (NFS) storage.");
+
+
+            // Capture other JSON encoded paths
+            testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName);
+            testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath);
+
+            // TODO: may need to initialise the server resource in future.
+            //    s_hypervresource.initialize();
+
+            // Verify sample template is in place storage pool
+            s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON
+                      + " sample template at " + testSampleTemplateURLJSON);
+        }
+
+        private String CreateTestDiskImageFromExistingImage(FileInfo srcFile,
+        String dstPath,
+        String dstFileName)
+        {
+            var newFullname = Path.Combine(dstPath, dstFileName);
+            var newFileInfo = new FileInfo(newFullname);
+            if (!newFileInfo.Exists)
+            {
+                newFileInfo = srcFile.CopyTo(newFullname);
+            }
+            newFileInfo.Refresh();
+            Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName);
+
+            return JsonConvert.SerializeObject(newFileInfo.FullName);
+        }
+
+        [Fact(Skip="these are functional tests")]
+        public void TestPrimaryStorageDownloadCommandHTTP()
+        {
+            string downloadURI = "https://s3-eu-west-1.amazonaws.com/cshv3eu/SmallDisk.vhdx";
+            corePrimaryStorageDownloadCommandTestCycle(downloadURI);
+        }
+
+        private void corePrimaryStorageDownloadCommandTestCycle(string downloadURI)
+        {
+            // Arrange
+            HypervResourceController rsrcServer = new HypervResourceController();
+            dynamic jsonPSDCmd = JsonConvert.DeserializeObject(samplePrimaryDownloadCommand());
+            jsonPSDCmd.url = downloadURI;
+
+            // Act
+            dynamic jsonResult = rsrcServer.PrimaryStorageDownloadCommand(jsonPSDCmd);
+
+            // Assert
+            JObject ansAsProperty = jsonResult[0];
+            dynamic ans = ansAsProperty.GetValue(CloudStackTypes.PrimaryStorageDownloadAnswer);
+            Assert.True((bool)ans.result, "PrimaryStorageDownloadCommand did not succeed " + ans.details);
+
+            // Test that URL of downloaded template works for file creation.
+            dynamic jsonCreateCmd = JsonConvert.DeserializeObject(CreateCommandSample());
+            jsonCreateCmd.templateUrl = ans.installPath;
+            dynamic jsonAns2 = rsrcServer.CreateCommand(jsonCreateCmd);
+            JObject ansAsProperty2 = jsonAns2[0];
+            dynamic ans2 = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
+
+            Assert.True((bool)ans2.result, (string)ans2.details);
+
+            FileInfo newFile = new FileInfo((string)ans2.volume.path);
+            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
+            newFile.Delete();
+        }
+
+        private string samplePrimaryDownloadCommand()
+        {
+            String cmdJson = "{\"localPath\":" + testLocalStorePathJSON +
+                    ",\"poolUuid\":\"" + testLocalStoreUUID + "\",\"poolId\":201," +
+                    "\"secondaryStorageUrl\":\"nfs://10.70.176.36/mnt/cshv3/secondarystorage\"," +
+                    "\"primaryStorageUrl\":\"nfs://" + HypervResourceController.config.StorageIpAddress + "E:\\\\Disks\\\\Disks\"," +
+                    "\"url\":\"nfs://10.70.176.36/mnt/cshv3/secondarystorage/template/tmpl//2/204//af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx\"," +
+                    "\"format\":\"VHDX\",\"accountId\":2,\"name\":\"204-2-5a1db1ac-932b-3e7e-a0e8-5684c72cb862\"" +
+                    ",\"contextMap\":{},\"wait\":10800}";
+            return cmdJson;
+        }
+
+        public string CreateCommandSample()
+        {
+            String sample = "{\"volId\":17,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" +
+                            ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," +
+                            "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-15\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," +
+                            "\"volumeId\":17,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"wait\":0}";
+            return sample;
+        }
+
+        [Fact(Skip="these are functional tests")]
+        public void TestDestroyCommand()
+        {
+            // Arrange
+            String sampleVolume = getSampleVolumeObjectTO();
+            String destoryCmd = //"{\"volume\":" + getSampleVolumeObjectTO() + "}";
+                            "{\"volume\":{\"name\":\"" + testSampleVolumeTempUUIDNoExt
+                                    + "\",\"storagePoolType\":\"Filesystem\","
+                                    + "\"mountPoint\":"
+                                    + testLocalStorePathJSON
+                                   + ",\"path\":" + testSampleVolumeTempURIJSON
+                                    + ",\"storagePoolUuid\":\"" + testLocalStoreUUID
+                                    + "\","
+                                    + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}";
+
+            HypervResourceController rsrcServer = new HypervResourceController();
+            dynamic jsonDestoryCmd = JsonConvert.DeserializeObject(destoryCmd);
+
+            // Act
+            dynamic destoryAns = rsrcServer.DestroyCommand(jsonDestoryCmd);
+
+            // Assert
+            JObject ansAsProperty2 = destoryAns[0];
+            dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.Answer);
+            String path = jsonDestoryCmd.volume.path;
+            Assert.True((bool)ans.result, "DestroyCommand did not succeed " + ans.details);
+            Assert.True(!File.Exists(path), "Failed to delete file " + path);
+        }
+
+        [Fact(Skip="these are functional tests")]
+        public void TestCreateCommand()
+        {
+            // TODO: Need sample to update the test.
+            // Arrange
+            String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" +
+                            ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," +
+                            "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," +
+                            "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}";
+            dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd);
+            HypervResourceController rsrcServer = new HypervResourceController();
+
+            Assert.True(Directory.Exists(testLocalStorePath));
+            string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON));
+            Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath);
+            int fileCount = Directory.GetFiles(testLocalStorePath).Length;
+            s_logger.Debug(" test local store has " + fileCount + "files");
+
+            // Act
+            // Test requires there to be a template at the tempalteUrl, which is its location in the local file system.
+            dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd);
+
+            JObject ansAsProperty2 = jsonResult[0];
+            dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
+            Assert.NotNull(ans);
+            Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result);
+            Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1);
+            FileInfo newFile = new FileInfo((string)ans.volume.path);
+            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
+            newFile.Delete();
+        }
+
+        /// <summary>
+        /// Possible additional tests:  place an ISO in the drive
+        /// </summary>
+        [Fact(Skip="these are functional tests")]
+        public void TestStartStopCommand()
+        {
+            string vmName = TestStartCommand();
+            TestStopCommand(vmName);
+        }
+
+        public static String getSamplePrimaryDataStoreInfo()
+        {
+            String samplePrimaryDataStoreInfo =
+            "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" +
+                "{\"uuid\":\"" + testLocalStoreUUID + "\"," +
+                "\"id\":201," +
+                "\"host\":\"" + testPrimaryDataStoreHost + "\"," +
+                "\"type\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
+                "\"poolType\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
+                "\"path\":" + testLocalStorePathJSON + "," +
+                "\"port\":0}" +
+            "}";
+            return samplePrimaryDataStoreInfo;
+        }
+
+        public static String getSampleVolumeObjectTO()
+        {
+            String sampleVolumeObjectTO =
+                    "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" +
+                        "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," +
+                        "\"volumeType\":\"ROOT\"," +
+                        "\"format\":\"VHDX\"," +
+                        "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
+                        "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," +
+                        "\"size\":52428800," +
+                        "\"volumeId\":10," +
+                //                            "\"vmName\":\"i-3-5-VM\"," +  // TODO: do we have to fill in the vmName?
+                        "\"accountId\":3,\"id\":10}" +
+                    "}";  // end of destTO 
+            return sampleVolumeObjectTO;
+        }
+
+        public static String getSampleStartCommand()
+        {
+            String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," +
+                                "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," +
+                                "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," +
+                                "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," +
+                                "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" +
+                            ",\"disks\":[" +
+                               "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," +
+                               "{\"diskSeq\":1,\"type\":\"ISO\"}" +
+                            "]," +
+                            "\"nics\":[" +
+                                    "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," +
+                                    "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," +
+                                    "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," +
+                                    "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" +
+                            "]},\"contextMap\":{},\"wait\":0}";
+            return sample;
+        }
+
+
+        [Fact(Skip="these are functional tests")]
+        public void TestCopyCommandFromCifs()
+        {
+            // Arrange
+            string sampleCopyCommandForTemplateDownload =
+            #region string_literal
+                // org.apache.cloudstack.storage.command.CopyCommand
+                "{\"srcTO\":" +
+                  "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
+                    "{\"path\":\"" + testCifsPath + "\"," +
+                     "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
+                     "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
+                     "\"id\":206," +
+                     "\"format\":\"VHDX\"," +
+                     "\"accountId\":2," +
+                     "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
+                     "\"hvm\":true," +
+                     "\"displayText\":\"OS031\"," +
+                     "\"imageDataStore\":" +
+                       "{\"com.cloud.agent.api.to.NfsTO\":" +
+                         "{\"_url\":\"" + testCifsUrl + "\"," + // Unique item here
+                         "\"_role\":\"Image\"}" +
+                       "}," + // end of imageDataStore
+                     "\"hypervisorType\":\"Hyperv\"," +
+                     "\"name\":\"" + testS3TemplateName + "\"}" +
+                  "}," + // end of srcTO
+                 "\"destTO\":" +
+                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
+                        "{" +
+                        "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
+                        "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
+                        "\"id\":206," +
+                        "\"format\":\"VHDX\"," +
+                        "\"accountId\":2," +
+                        "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
+                        "\"hvm\":true," +
+                        "\"displayText\":\"Test of CIFS Download\"," +
+                        "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore
+                        "\"name\":\"" + testS3TemplateName + "\"," +
+                        "\"hypervisorType\":\"Hyperv\"}" +
+                    "}," +// end of destTO
+                "\"wait\":10800}"; // end of CopyCommand
+            #endregion
+
+            HypervResourceController rsrcServer;
+            dynamic jsonDownloadCopyCmd;
+            string dwnldDest;
+            dynamic jsonCloneCopyCmd;
+            string newVolName;
+            CopyCommandTestSetupCifs(null, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName);
+
+            // Act & Assert
+            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
+
+            // Repeat to verify ability to detect existing file.
+            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
+
+            File.Delete(dwnldDest);
+        }
+
+        [Fact(Skip="these are functional tests")]
+        public void TestCopyCommand()
+        {
+            // Arrange
+            string sampleCopyCommandToCreateVolumeFromTemplate =
+            #region string_literal
+                // org.apache.cloudstack.storage.command.CopyCommand
+                "{\"srcTO\":" +
+                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
+                        "{" +
+                        "\"origUrl\":\"http://people.apache.org/~bhaisaab/vms/ttylinux_pv.vhd\"," +
+                        "\"uuid\":\"9873f1c0-bdcc-11e2-8baa-ea85dab5fcd0\"," +
+                        "\"id\":5," +
+                        "\"format\":\"VHDX\"," +
+                        "\"accountId\":1," +
+                        "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
+                        "\"hvm\":false," +
+                        "\"displayText\":\"tiny Linux\"," +
+                        "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
+                        "\"name\":\"" + testS3TemplateName + "\"}" +
+                    "}," +  // end of srcTO
+                "\"destTO\":" +
+                    "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" +
+                        "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," +
+                        "\"volumeType\":\"ROOT\"," +
+                        "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
+                        "\"name\":\"ROOT-5\"," +
+                        "\"size\":52428800," +
+                        "\"volumeId\":10," +
+                        "\"vmName\":\"i-3-5-VM\"," +
+                        "\"accountId\":3," +
+                        "\"id\":10 }" +
+                    "}," +  // end of destTO 
+                "\"wait\":0}"; // end of Copy Command
+            #endregion
+            //"name":"ROOT-8","size":140616708,"volumeId":8,"vmName":"s-8-VM","accountId":1,"id":8}},"contextMap":{},"wait":0}
+
+            string sampleCopyCommandForTemplateDownload =
+            #region string_literal
+                // org.apache.cloudstack.storage.command.CopyCommand
+                "{\"srcTO\":" +
+                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
+                        "{\"path\":\"" + testS3TemplateName + ".vhdx" + "\"," +
+                        "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
+                        "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
+                        "\"id\":206," +
+                        "\"format\":\"VHDX\"," +
+                        "\"accountId\":2," +
+                        "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
+                        "\"hvm\":true," +
+                        "\"displayText\":\"OS031\"," +
+                        "\"imageDataStore\":" +
+                            "{\"com.cloud.agent.api.to.S3TO\":" +
+                                "{\"id\":1," +
+                                "\"uuid\":\"95a64c8f-2128-4502-b5b4-0d7aa77406d2\"," +
+                                "\"accessKey\":\"" + AgentSettings.Default.testS3AccessKey + "\"," +
+                                "\"secretKey\":\"" + AgentSettings.Default.testS3SecretKey + "\"," +
+                                "\"endPoint\":\"" + AgentSettings.Default.testS3Endpoint + "\"," +
+                                "\"bucketName\":\"" + AgentSettings.Default.testS3Bucket + "\"," +
+                                "\"httpsFlag\":false," +
+                                "\"created\":\"May 19, 2013 4:17:25 PM\"}" +
+                                "}," + // end of imageDataStore
+                        "\"name\":\"" + testS3TemplateName + "\"}" +
+                     "}," + // end of srcTO
+                 "\"destTO\":" +
+                    "{\"org.apache.cloudstack.storage.to.TemplateObjectTO\":" +
+                        "{" +
+                        "\"origUrl\":\"http://10.147.28.7/templates/5d67394c-4efd-4b62-966b-51aa53b35277.vhd.bz2\"," +
+                        "\"uuid\":\"7e4ca941-cb1b-4113-ab9e-043960d0fb10\"," +
+                        "\"id\":206," +
+                        "\"format\":\"VHDX\"," +
+                        "\"accountId\":2," +
+                        "\"checksum\":\"4b31e2846cc67fc10ea7281986519a54\"," +
+                        "\"hvm\":true," +
+                        "\"displayText\":\"OS031\"," +
+                        "\"imageDataStore\":" + getSamplePrimaryDataStoreInfo() + "," + // end of imageDataStore
+                        "\"name\":\"" + testS3TemplateName + "\"}" +
+                    "}," +// end of destTO
+                "\"wait\":10800}"; // end of CopyCommand
+            #endregion
+
+            HypervResourceController rsrcServer;
+            dynamic jsonDownloadCopyCmd;
+            string dwnldDest;
+            dynamic jsonCloneCopyCmd;
+            string newVolName;
+            CopyCommandTestSetup(sampleCopyCommandToCreateVolumeFromTemplate, sampleCopyCommandForTemplateDownload, out rsrcServer, out jsonDownloadCopyCmd, out dwnldDest, out jsonCloneCopyCmd, out newVolName);
+
+            // Act & Assert
+            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
+            CreateVolumeFromTemplate(rsrcServer, jsonCloneCopyCmd, newVolName);
+
+            // Repeat to verify ability to detect existing file.
+            DownloadTemplateToPrimaryStorage(rsrcServer, jsonDownloadCopyCmd, dwnldDest);
+
+            File.Delete(dwnldDest);
+            File.Delete(newVolName);
+        }
+
+        private static void CreateVolumeFromTemplate(HypervResourceController rsrcServer, dynamic jsonCloneCopyCmd, string newVolName)
+        {
+            dynamic copyResult = rsrcServer.CopyComma

<TRUNCATED>

[14/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs
new file mode 100755
index 0000000..5478235
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs
@@ -0,0 +1,1005 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_EthernetSwitchPortVlanSettingData
+    public class EthernetSwitchPortVlanSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_EthernetSwitchPortVlanSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public EthernetSwitchPortVlanSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public EthernetSwitchPortVlanSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(EthernetSwitchPortVlanSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public EthernetSwitchPortVlanSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetSwitchPortVlanSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public EthernetSwitchPortVlanSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public EthernetSwitchPortVlanSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public EthernetSwitchPortVlanSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public EthernetSwitchPortVlanSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public EthernetSwitchPortVlanSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public EthernetSwitchPortVlanSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAccessVlanIdNull {
+            get {
+                if ((curObj["AccessVlanId"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The vlan ID in access mode.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort AccessVlanId {
+            get {
+                if ((curObj["AccessVlanId"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["AccessVlanId"]));
+            }
+            set {
+                curObj["AccessVlanId"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNativeVlanIdNull {
+            get {
+                if ((curObj["NativeVlanId"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The vlan ID in trunk mode.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort NativeVlanId {
+            get {
+                if ((curObj["NativeVlanId"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["NativeVlanId"]));
+            }
+            set {
+                curObj["NativeVlanId"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOperationModeNull {
+            get {
+                if ((curObj["OperationMode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The vlan operation modes.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public OperationModeValues OperationMode {
+            get {
+                if ((curObj["OperationMode"] == null)) {
+                    return ((OperationModeValues)(System.Convert.ToInt32(0)));
+                }
+                return ((OperationModeValues)(System.Convert.ToInt32(curObj["OperationMode"])));
+            }
+            set {
+                if ((OperationModeValues.NULL_ENUM_VALUE == value)) {
+                    curObj["OperationMode"] = null;
+                }
+                else {
+                    curObj["OperationMode"] = value;
+                }
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPrimaryVlanIdNull {
+            get {
+                if ((curObj["PrimaryVlanId"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The primary vlan ID in private mode.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PrimaryVlanId {
+            get {
+                if ((curObj["PrimaryVlanId"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PrimaryVlanId"]));
+            }
+            set {
+                curObj["PrimaryVlanId"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The prune vlan ID bitmap in trunk mode.")]
+        public ushort[] PruneVlanIdArray {
+            get {
+                return ((ushort[])(curObj["PruneVlanIdArray"]));
+            }
+            set {
+                curObj["PruneVlanIdArray"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPvlanModeNull {
+            get {
+                if ((curObj["PvlanMode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The private vlan modes.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public PvlanModeValues PvlanMode {
+            get {
+                if ((curObj["PvlanMode"] == null)) {
+                    return ((PvlanModeValues)(System.Convert.ToInt32(0)));
+                }
+                return ((PvlanModeValues)(System.Convert.ToInt32(curObj["PvlanMode"])));
+            }
+            set {
+                if ((PvlanModeValues.NULL_ENUM_VALUE == value)) {
+                    curObj["PvlanMode"] = null;
+                }
+                else {
+                    curObj["PvlanMode"] = value;
+                }
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSecondaryVlanIdNull {
+            get {
+                if ((curObj["SecondaryVlanId"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The secondary vlan ID in private mode.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort SecondaryVlanId {
+            get {
+                if ((curObj["SecondaryVlanId"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["SecondaryVlanId"]));
+            }
+            set {
+                curObj["SecondaryVlanId"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The secondary vlan ID bitmap in private mode.")]
+        public ushort[] SecondaryVlanIdArray {
+            get {
+                return ((ushort[])(curObj["SecondaryVlanIdArray"]));
+            }
+            set {
+                curObj["SecondaryVlanIdArray"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The trunk vlan ID bitmap in trunk mode.")]
+        public ushort[] TrunkVlanIdArray {
+            get {
+                return ((ushort[])(curObj["TrunkVlanIdArray"]));
+            }
+            set {
+                curObj["TrunkVlanIdArray"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAccessVlanId() {
+            if ((this.IsAccessVlanIdNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetAccessVlanId() {
+            curObj["AccessVlanId"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeNativeVlanId() {
+            if ((this.IsNativeVlanIdNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetNativeVlanId() {
+            curObj["NativeVlanId"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeOperationMode() {
+            if ((this.IsOperationModeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetOperationMode() {
+            curObj["OperationMode"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializePrimaryVlanId() {
+            if ((this.IsPrimaryVlanIdNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetPrimaryVlanId() {
+            curObj["PrimaryVlanId"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetPruneVlanIdArray() {
+            curObj["PruneVlanIdArray"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializePvlanMode() {
+            if ((this.IsPvlanModeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetPvlanMode() {
+            curObj["PvlanMode"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeSecondaryVlanId() {
+            if ((this.IsSecondaryVlanIdNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetSecondaryVlanId() {
+            curObj["SecondaryVlanId"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetSecondaryVlanIdArray() {
+            curObj["SecondaryVlanIdArray"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetTrunkVlanIdArray() {
+            curObj["TrunkVlanIdArray"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetSwitchPortVlanSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static EthernetSwitchPortVlanSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_EthernetSwitchPortVlanSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new EthernetSwitchPortVlanSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetSwitchPortVlanSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new EthernetSwitchPortVlanSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static EthernetSwitchPortVlanSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new EthernetSwitchPortVlanSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public enum OperationModeValues {
+            
+            Access = 1,
+            
+            Trunk = 2,
+            
+            Private = 3,
+            
+            NULL_ENUM_VALUE = 0,
+        }
+        
+        public enum PvlanModeValues {
+            
+            Isolated = 1,
+            
+            Community = 2,
+            
+            Promiscuous = 3,
+            
+            NULL_ENUM_VALUE = 0,
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class EthernetSwitchPortVlanSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public EthernetSwitchPortVlanSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new EthernetSwitchPortVlanSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new EthernetSwitchPortVlanSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class EthernetSwitchPortVlanSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public EthernetSwitchPortVlanSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new EthernetSwitchPortVlanSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[37/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
index 2e7a93c..de35f68 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
@@ -1,136 +1,136 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>
-    </ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{925FD1DE-6211-4E10-9949-3751B8ABDF59}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>ServerResource.Tests</RootNamespace>
-    <AssemblyName>ServerResource.Tests</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
-    <RestorePackages>true</RestorePackages>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTestsDebug|AnyCPU'">
-    <DebugSymbols>true</DebugSymbols>
-    <OutputPath>bin\NoUnitTestsDebug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <DebugType>full</DebugType>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTests|AnyCPU'">
-    <OutputPath>bin\NoUnitTests\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <Optimize>true</Optimize>
-    <DebugType>pdbonly</DebugType>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-  </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>
-    <Reference Include="log4net">
-      <HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
-    </Reference>
-    <Reference Include="Microsoft.CSharp" />    
-    <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.ComponentModel.DataAnnotations" />
-    <Reference Include="System.Configuration" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Management" />
-    <Reference Include="System.ServiceProcess" />
-    <Reference Include="System.Web" />
-    <Reference Include="System.Web.ApplicationServices" />
-    <Reference Include="System.Web.Extensions" />
-    <Reference Include="System.Web.Abstractions" />
-    <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
-    <Reference Include="System.Web.Routing" />
-    <Reference Include="System.Xml" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Net.Http">
-    </Reference>    
-    <Reference Include="xunit">
-      <HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
-    </Reference>
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="HypervResourceController1Test.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <!--<Compile Include="HypervResourceControllerTest.cs" /> -->
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="App.config">
-      <SubType>Designer</SubType>
-    </Content>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="packages.config">
-      <SubType>Designer</SubType>
-    </None>
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\AgentShell\AgentShell.csproj">
-      <Project>{9060b539-62d0-4e71-a6c6-5944828774e9}</Project>
-      <Name>AgentShell</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\HypervResource\HypervResource.csproj">
-      <Project>{c963dfff-65ba-4e71-ada5-526a4da4e0b2}</Project>
-      <Name>HypervResource</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\WmiWrappers\WmiWrappers.csproj">
-      <Project>{db824727-bdc3-437c-a364-7a811d8a160f}</Project>
-      <Name>WmiWrappers</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>
+    </ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{925FD1DE-6211-4E10-9949-3751B8ABDF59}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>ServerResource.Tests</RootNamespace>
+    <AssemblyName>ServerResource.Tests</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTestsDebug|AnyCPU'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\NoUnitTestsDebug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTests|AnyCPU'">
+    <OutputPath>bin\NoUnitTests\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </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>
+    <Reference Include="log4net">
+      <HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.CSharp" />
+    <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.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Management" />
+    <Reference Include="System.ServiceProcess" />
+    <Reference Include="System.Web" />
+    <Reference Include="System.Web.ApplicationServices" />
+    <Reference Include="System.Web.Extensions" />
+    <Reference Include="System.Web.Abstractions" />
+    <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="System.Web.Routing" />
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Net.Http">
+    </Reference>
+    <Reference Include="xunit">
+      <HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="HypervResourceController1Test.cs" />
+    <Compile Include="HypervResourceControllerTest.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <!--<Compile Include="HypervResourceControllerTest.cs" /> -->
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="App.config">
+      <SubType>Designer</SubType>
+    </Content>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config">
+      <SubType>Designer</SubType>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\AgentShell\AgentShell.csproj">
+      <Project>{9060b539-62d0-4e71-a6c6-5944828774e9}</Project>
+      <Name>AgentShell</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\HypervResource\HypervResource.csproj">
+      <Project>{c963dfff-65ba-4e71-ada5-526a4da4e0b2}</Project>
+      <Name>HypervResource</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\WmiWrappers\WmiWrappers.csproj">
+      <Project>{db824727-bdc3-437c-a364-7a811d8a160f}</Project>
+      <Name>WmiWrappers</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>
   <Target Name="AfterBuild">
   </Target>
-  -->
-  <UsingTask AssemblyFile="..\packages\xunit.1.9.2\lib\net20\xunit.runner.msbuild.dll"
-           TaskName="Xunit.Runner.MSBuild.xunit" />
-  <Target Name="AfterBuild">
-    <Xunit.Runner.MSBuild.xunit Assembly="..\ServerResource.Tests\bin\Debug\ServerResource.Tests.dll" />
-  </Target>
-</Project>
+  -->
+  <UsingTask AssemblyFile="..\packages\xunit.1.9.2\lib\net20\xunit.runner.msbuild.dll" TaskName="Xunit.Runner.MSBuild.xunit" />
+  <Target Name="AfterBuild">
+    <Xunit.Runner.MSBuild.xunit Assembly="..\ServerResource.Tests\bin\Debug\ServerResource.Tests.dll" />
+  </Target>
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ComputerSystem.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ComputerSystem.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ComputerSystem.cs
deleted file mode 100644
index 082db9d..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ComputerSystem.cs
+++ /dev/null
@@ -1,1298 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_ComputerSystem
-    public class ComputerSystem : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_ComputerSystem";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public ComputerSystem() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public ComputerSystem(string keyCreationClassName, string keyName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(ComputerSystem.ConstructPath(keyCreationClassName, keyName)), null);
-        }
-        
-        public ComputerSystem(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ComputerSystem.ConstructPath(keyCreationClassName, keyName)), null);
-        }
-        
-        public ComputerSystem(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public ComputerSystem(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public ComputerSystem(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public ComputerSystem(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public ComputerSystem(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public ComputerSystem(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("An array of NUMA nodes that are currently assigned to the virtual machine.")]
-        public ushort[] AssignedNumaNodeList {
-            get {
-                return ((ushort[])(curObj["AssignedNumaNodeList"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] Dedicated {
-            get {
-                return ((ushort[])(curObj["Dedicated"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] IdentifyingDescriptions {
-            get {
-                return ((string[])(curObj["IdentifyingDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string NameFormat {
-            get {
-                return ((string)(curObj["NameFormat"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsOnTimeInMillisecondsNull {
-            get {
-                if ((curObj["OnTimeInMilliseconds"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"For the virtual system, this property describes the total up time, in milliseconds, since the machine was last turned on, reset, or restored. This time excludes the time the virtual system was in the paused state. For the host system, this property is set to NULL.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong OnTimeInMilliseconds {
-            get {
-                if ((curObj["OnTimeInMilliseconds"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["OnTimeInMilliseconds"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherDedicatedDescriptions {
-            get {
-                return ((string[])(curObj["OtherDedicatedDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherIdentifyingInfo {
-            get {
-                return ((string[])(curObj["OtherIdentifyingInfo"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] PowerManagementCapabilities {
-            get {
-                return ((ushort[])(curObj["PowerManagementCapabilities"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerContact {
-            get {
-                return ((string)(curObj["PrimaryOwnerContact"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerName {
-            get {
-                return ((string)(curObj["PrimaryOwnerName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProcessIDNull {
-            get {
-                if ((curObj["ProcessID"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The identifier of the process under which this virtual machine is running. This v" +
-            "alue can be used to uniquely identify the instance of Vmwp.exe on the system tha" +
-            "t is running the virtual machine.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint ProcessID {
-            get {
-                if ((curObj["ProcessID"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["ProcessID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsResetCapabilityNull {
-            get {
-                if ((curObj["ResetCapability"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ResetCapability {
-            get {
-                if ((curObj["ResetCapability"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ResetCapability"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] Roles {
-            get {
-                return ((string[])(curObj["Roles"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastConfigurationChangeNull {
-            get {
-                if ((curObj["TimeOfLastConfigurationChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The date and time when the virtual machine configuration file was last modified. " +
-            "The configuration file is modified during certain virtual machine operations, as" +
-            " well as when any of the virtual machine or device settings are added, modified," +
-            " or removed.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastConfigurationChange {
-            get {
-                if ((curObj["TimeOfLastConfigurationChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastConfigurationChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeOnTimeInMilliseconds() {
-            if ((this.IsOnTimeInMillisecondsNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProcessID() {
-            if ((this.IsProcessIDNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeResetCapability() {
-            if ((this.IsResetCapabilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastConfigurationChange() {
-            if ((this.IsTimeOfLastConfigurationChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName) {
-            string strPath = "ROOT\\virtualization:Msvm_ComputerSystem";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static ComputerSystemCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static ComputerSystemCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static ComputerSystemCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static ComputerSystemCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_ComputerSystem";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new ComputerSystemCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static ComputerSystemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ComputerSystem", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new ComputerSystemCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static ComputerSystem CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new ComputerSystem(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-
-        public uint RequestStateChange(UInt16 RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job)
-        {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((UInt16)(RequestedState));
-                inParams["TimeoutPeriod"] = null; // "0"; // ToDmtfTimeInterval(TimeoutPeriod);
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SetPowerState(uint PowerState, System.DateTime Time) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState");
-                inParams["PowerState"] = ((uint)(PowerState));
-                inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class ComputerSystemCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public ComputerSystemCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new ComputerSystem(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new ComputerSystemEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class ComputerSystemEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public ComputerSystemEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new ComputerSystem(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


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

Posted by bf...@apache.org.
Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better
to be on v2 namespace.


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

Branch: refs/heads/ui-restyle
Commit: 1601498bd7370759bcc1e008ea148655565594ee
Parents: 36b8b35
Author: Donal Lafferty <do...@citrix.com>
Authored: Wed Oct 30 10:23:40 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Mon Nov 4 18:48:54 2013 +0530

----------------------------------------------------------------------
 .../HypervResource/HypervResource.csproj        |  206 +-
 .../HypervResource/HypervResourceController.cs  | 2965 +++++++++---------
 .../HypervResource/IWmiCallsV2.cs               |   72 +-
 .../ServerResource/HypervResource/WmiCalls.cs   | 1419 ---------
 .../ServerResource/HypervResource/WmiCallsV2.cs | 1576 +++++++++-
 .../HypervResourceController1Test.cs            |  641 ++--
 .../HypervResourceControllerTest.cs             | 2296 +++++++-------
 .../ServerResource.Tests.csproj                 |  260 +-
 .../ROOT.virtualization.Msvm_ComputerSystem.cs  | 1298 --------
 .../ROOT.virtualization.Msvm_ConcreteJob.cs     | 1665 ----------
 ....virtualization.Msvm_ExternalEthernetPort.cs | 1996 ------------
 .../ROOT.virtualization.Msvm_IDEController.cs   | 1610 ----------
 ...irtualization.Msvm_ImageManagementService.cs | 1401 ---------
 ...OOT.virtualization.Msvm_MemorySettingData.cs | 1083 -------
 ....virtualization.Msvm_ProcessorSettingData.cs | 1190 -------
 ...zation.Msvm_ResourceAllocationSettingData.cs |  976 ------
 ...OT.virtualization.Msvm_SummaryInformation.cs | 1184 -------
 ...OOT.virtualization.Msvm_SwitchLANEndpoint.cs | 1342 --------
 .../ROOT.virtualization.Msvm_SwitchPort.cs      | 1708 ----------
 ...virtualization.Msvm_SyntheticEthernetPort.cs | 1960 ------------
 ...ion.Msvm_SyntheticEthernetPortSettingData.cs | 1010 ------
 .../ROOT.virtualization.Msvm_VLANEndpoint.cs    | 1390 --------
 ...rtualization.Msvm_VLANEndpointSettingData.cs |  885 ------
 .../ROOT.virtualization.Msvm_VirtualSwitch.cs   | 1305 --------
 ...ation.Msvm_VirtualSwitchManagementService.cs | 1379 --------
 ...ation.Msvm_VirtualSystemGlobalSettingData.cs | 1513 ---------
 ...ation.Msvm_VirtualSystemManagementService.cs | 1731 ----------
 ...VirtualSystemManagementServiceSettingData.cs |  731 -----
 ...tualization.Msvm_VirtualSystemSettingData.cs | 1206 -------
 .../ROOT.virtualization.Msvm_VmLANEndpoint.cs   | 1342 --------
 ...OOT.virtualization.v2.Msvm_ComputerSystem.cs |   13 +-
 ...v2.Msvm_EthernetPortAllocationSettingData.cs | 1147 +++++++
 ...virtualization.v2.Msvm_EthernetSwitchPort.cs | 2102 +++++++++++++
 ...v2.Msvm_EthernetSwitchPortVlanSettingData.cs | 1005 ++++++
 ...rtualization.v2.Msvm_ExternalEthernetPort.cs | 2070 ++++++++++++
 ...ualization.v2.Msvm_ImageManagementService.cs | 1508 +++++++++
 ...rtualization.v2.Msvm_KvpExchangeComponent.cs |    5 +-
 .../ROOT.virtualization.v2.Msvm_LANEndpoint.cs  | 1405 +++++++++
 ....virtualization.v2.Msvm_MemorySettingData.cs | 1146 +++++++
 ...rtualization.v2.Msvm_ProcessorSettingData.cs | 1117 +++++++
 ...ion.v2.Msvm_ResourceAllocationSettingData.cs |  993 ++++++
 ...tion.v2.Msvm_StorageAllocationSettingData.cs | 1197 +++++++
 ...virtualization.v2.Msvm_SummaryInformation.cs | 1520 +++++++++
 ....v2.Msvm_SyntheticEthernetPortSettingData.cs | 1066 +++++++
 ...tualization.v2.Msvm_VirtualEthernetSwitch.cs | 1369 ++++++++
 ...vm_VirtualEthernetSwitchManagementService.cs | 1498 +++++++++
 ...zation.v2.Msvm_VirtualHardDiskSettingData.cs | 1034 ++++++
 ...on.v2.Msvm_VirtualSystemManagementService.cs |  143 +-
 ...VirtualSystemManagementServiceSettingData.cs | 1583 +++++-----
 .../WmiWrappers/WmiWrappers.csproj              |  368 ++-
 50 files changed, 25977 insertions(+), 35652 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/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 ed22a7a..05a0f51 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
@@ -1,105 +1,103 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>HypervResource</RootNamespace>
-    <AssemblyName>HypervResource</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
-    <RestorePackages>true</RestorePackages>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTestsDebug|AnyCPU'">
-    <DebugSymbols>true</DebugSymbols>
-    <OutputPath>bin\NoUnitTestsDebug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <DebugType>full</DebugType>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTests|AnyCPU'">
-    <OutputPath>bin\NoUnitTests\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <Optimize>true</Optimize>
-    <DebugType>pdbonly</DebugType>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-  </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>
-    <Reference Include="log4net">
-      <HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
-    </Reference>
-    <Reference Include="Newtonsoft.Json">
-      <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Management" />
-    <Reference Include="System.Net.Http" />
-    <Reference Include="System.Web" />
-    <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </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" />
-    <Compile Include="Utils.cs" />
-    <Compile Include="WmiCalls.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="packages.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\WmiWrappers\WmiWrappers.csproj">
-      <Project>{db824727-bdc3-437c-a364-7a811d8a160f}</Project>
-      <Name>WmiWrappers</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>HypervResource</RootNamespace>
+    <AssemblyName>HypervResource</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTestsDebug|AnyCPU'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\NoUnitTestsDebug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NoUnitTests|AnyCPU'">
+    <OutputPath>bin\NoUnitTests\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </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>
+    <Reference Include="log4net">
+      <HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Management" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Web" />
+    <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CloudStackTypes.cs" />
+    <Compile Include="IWmiCallsV2.cs" />
+    <Compile Include="WmiCallsV2.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="HypervResourceController.cs" />
+    <Compile Include="Utils.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\WmiWrappers\WmiWrappers.csproj">
+      <Project>{db824727-bdc3-437c-a364-7a811d8a160f}</Project>
+      <Name>WmiWrappers</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
 </Project>
\ No newline at end of file


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

Posted by bf...@apache.org.
Add checkstyle to the build process and enable it for the Nicira NVP plugin


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

Branch: refs/heads/ui-restyle
Commit: f39b6b2c56596f5bd2328c89e402893aa279ce10
Parents: a196fbc
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Mon Nov 4 15:22:12 2013 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Mon Nov 4 15:24:54 2013 +0100

----------------------------------------------------------------------
 parents/checkstyle/pom.xml                      |  7 ++++
 .../src/main/resources/tooling/checkstyle.xml   | 21 ++++++++++++
 plugins/network-elements/nicira-nvp/pom.xml     | 35 ++++++++++++++++++++
 pom.xml                                         |  2 ++
 4 files changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f39b6b2c/parents/checkstyle/pom.xml
----------------------------------------------------------------------
diff --git a/parents/checkstyle/pom.xml b/parents/checkstyle/pom.xml
new file mode 100644
index 0000000..245631b
--- /dev/null
+++ b/parents/checkstyle/pom.xml
@@ -0,0 +1,7 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <name>Apache CloudStack Checkstyle Configuration</name>
+  <groupId>org.apache.cloudstack</groupId>
+  <artifactId>checkstyle</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f39b6b2c/parents/checkstyle/src/main/resources/tooling/checkstyle.xml
----------------------------------------------------------------------
diff --git a/parents/checkstyle/src/main/resources/tooling/checkstyle.xml b/parents/checkstyle/src/main/resources/tooling/checkstyle.xml
new file mode 100644
index 0000000..8465383
--- /dev/null
+++ b/parents/checkstyle/src/main/resources/tooling/checkstyle.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<module name="Checker">
+    <module name="FileTabCharacter">
+        <property name="eachLine" value="true"/>
+    </module>
+
+    <module name="RegexpSingleline">
+        <!-- \s matches whitespace character, $ matches end of line. -->
+        <property name="format" value="\s+$"/>
+        <property name="message" value="Line has trailing spaces."/>
+    </module>
+    <module name="TreeWalker">
+       <module name="RedundantImport"/>
+       <module name="UnusedImports"/>
+    </module>
+
+</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f39b6b2c/plugins/network-elements/nicira-nvp/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml
index 5030ddf..5c65e6a 100644
--- a/plugins/network-elements/nicira-nvp/pom.xml
+++ b/plugins/network-elements/nicira-nvp/pom.xml
@@ -26,4 +26,39 @@
     <version>4.3.0-SNAPSHOT</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${cs.checkstyle.version}</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.cloudstack</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <failsOnError>true</failsOnError>
+          <configLocation>tooling/checkstyle.xml</configLocation>
+          <consoleOutput>true</consoleOutput>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <sourceDirectory>${project.basedir}</sourceDirectory>
+          <includes>**\/*.java,**\/*.xml,**\/*.ini,**\/*.sh,**\/*.bat</includes>
+          <excludes>**\/target\/,**\/bin\/</excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f39b6b2c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 82ee75d..b8b2a37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,6 +86,7 @@
     <cs.target.dir>target</cs.target.dir>
     <cs.daemon.version>1.0.10</cs.daemon.version>
     <cs.jna.version>4.0.0</cs.jna.version>
+    <cs.checkstyle.version>2.10</cs.checkstyle.version>
   </properties>
 
   <distributionManagement>
@@ -174,6 +175,7 @@
     <module>services</module>
     <module>maven-standard</module>
     <module>quickcloud</module>
+    <module>parents/checkstyle</module>
   </modules>
 
   <dependencyManagement>


[12/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ImageManagementService.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ImageManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ImageManagementService.cs
new file mode 100755
index 0000000..b7ec9ed
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ImageManagementService.cs
@@ -0,0 +1,1508 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
+    // An Early Bound class generated for the WMI class.Msvm_ImageManagementService
+    public class ImageManagementService : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Msvm_ImageManagementService";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public ImageManagementService() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public ImageManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(null, new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public ImageManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public ImageManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public ImageManagementService(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public ImageManagementService(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public ImageManagementService(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] AvailableRequestedStates {
+            get {
+                return ((ushort[])(curObj["AvailableRequestedStates"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCommunicationStatusNull {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort CommunicationStatus {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["CommunicationStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string CreationClassName {
+            get {
+                return ((string)(curObj["CreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDetailedStatusNull {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DetailedStatus {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DetailedStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledDefaultNull {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledDefault {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledDefault"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledState {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHealthStateNull {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HealthState {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HealthState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInstallDateNull {
+            get {
+                if ((curObj["InstallDate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime InstallDate {
+            get {
+                if ((curObj["InstallDate"] != null)) {
+                    return ToDateTime(((string)(curObj["InstallDate"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOperatingStatusNull {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort OperatingStatus {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["OperatingStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] OperationalStatus {
+            get {
+                return ((ushort[])(curObj["OperationalStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherEnabledState {
+            get {
+                return ((string)(curObj["OtherEnabledState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PrimaryOwnerContact {
+            get {
+                return ((string)(curObj["PrimaryOwnerContact"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PrimaryOwnerName {
+            get {
+                return ((string)(curObj["PrimaryOwnerName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPrimaryStatusNull {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PrimaryStatus {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PrimaryStatus"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRequestedStateNull {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort RequestedState {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["RequestedState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsStartedNull {
+            get {
+                if ((curObj["Started"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool Started {
+            get {
+                if ((curObj["Started"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["Started"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string StartMode {
+            get {
+                return ((string)(curObj["StartMode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Status {
+            get {
+                return ((string)(curObj["Status"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] StatusDescriptions {
+            get {
+                return ((string[])(curObj["StatusDescriptions"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemCreationClassName {
+            get {
+                return ((string)(curObj["SystemCreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemName {
+            get {
+                return ((string)(curObj["SystemName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimeOfLastStateChangeNull {
+            get {
+                if ((curObj["TimeOfLastStateChange"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime TimeOfLastStateChange {
+            get {
+                if ((curObj["TimeOfLastStateChange"] != null)) {
+                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTransitioningToStateNull {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort TransitioningToState {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["TransitioningToState"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCommunicationStatus() {
+            if ((this.IsCommunicationStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDetailedStatus() {
+            if ((this.IsDetailedStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledDefault() {
+            if ((this.IsEnabledDefaultNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledState() {
+            if ((this.IsEnabledStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHealthState() {
+            if ((this.IsHealthStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        // Converts a given datetime in DMTF format to System.DateTime object.
+        static System.DateTime ToDateTime(string dmtfDate) {
+            System.DateTime initializer = System.DateTime.MinValue;
+            int year = initializer.Year;
+            int month = initializer.Month;
+            int day = initializer.Day;
+            int hour = initializer.Hour;
+            int minute = initializer.Minute;
+            int second = initializer.Second;
+            long ticks = 0;
+            string dmtf = dmtfDate;
+            System.DateTime datetime = System.DateTime.MinValue;
+            string tempString = string.Empty;
+            if ((dmtf == null)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length == 0)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length != 25)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            try {
+                tempString = dmtf.Substring(0, 4);
+                if (("****" != tempString)) {
+                    year = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(4, 2);
+                if (("**" != tempString)) {
+                    month = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(6, 2);
+                if (("**" != tempString)) {
+                    day = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(8, 2);
+                if (("**" != tempString)) {
+                    hour = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(10, 2);
+                if (("**" != tempString)) {
+                    minute = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(12, 2);
+                if (("**" != tempString)) {
+                    second = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(15, 6);
+                if (("******" != tempString)) {
+                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
+                }
+                if (((((((((year < 0) 
+                            || (month < 0)) 
+                            || (day < 0)) 
+                            || (hour < 0)) 
+                            || (minute < 0)) 
+                            || (minute < 0)) 
+                            || (second < 0)) 
+                            || (ticks < 0))) {
+                    throw new System.ArgumentOutOfRangeException();
+                }
+            }
+            catch (System.Exception e) {
+                throw new System.ArgumentOutOfRangeException(null, e.Message);
+            }
+            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
+            datetime = datetime.AddTicks(ticks);
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
+            int UTCOffset = 0;
+            int OffsetToBeAdjusted = 0;
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            tempString = dmtf.Substring(22, 3);
+            if ((tempString != "******")) {
+                tempString = dmtf.Substring(21, 4);
+                try {
+                    UTCOffset = int.Parse(tempString);
+                }
+                catch (System.Exception e) {
+                    throw new System.ArgumentOutOfRangeException(null, e.Message);
+                }
+                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
+                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
+            }
+            return datetime;
+        }
+        
+        // Converts a given System.DateTime object to DMTF datetime format.
+        static string ToDmtfDateTime(System.DateTime date) {
+            string utcString = string.Empty;
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            if ((System.Math.Abs(OffsetMins) > 999)) {
+                date = date.ToUniversalTime();
+                utcString = "+000";
+            }
+            else {
+                if ((tickOffset.Ticks >= 0)) {
+                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
+                }
+                else {
+                    string strTemp = ((long)(OffsetMins)).ToString();
+                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
+                }
+            }
+            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ".");
+            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
+            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
+                        * 1000) 
+                        / System.TimeSpan.TicksPerMillisecond)));
+            string strMicrosec = ((long)(microsec)).ToString();
+            if ((strMicrosec.Length > 6)) {
+                strMicrosec = strMicrosec.Substring(0, 6);
+            }
+            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
+            return dmtfDateTime;
+        }
+        
+        private bool ShouldSerializeInstallDate() {
+            if ((this.IsInstallDateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOperatingStatus() {
+            if ((this.IsOperatingStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePrimaryStatus() {
+            if ((this.IsPrimaryStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRequestedState() {
+            if ((this.IsRequestedStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeStarted() {
+            if ((this.IsStartedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimeOfLastStateChange() {
+            if ((this.IsTimeOfLastStateChangeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTransitioningToState() {
+            if ((this.IsTransitioningToStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_ImageManagementService";
+            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static ImageManagementServiceCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static ImageManagementServiceCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static ImageManagementServiceCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static ImageManagementServiceCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_ImageManagementService";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new ImageManagementServiceCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static ImageManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ImageManagementService", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new ImageManagementServiceCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static ImageManagementService CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new ImageManagementService(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public uint AttachVirtualHardDisk(bool AssignDriveLetter, string Path, bool ReadOnly, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("AttachVirtualHardDisk");
+                inParams["AssignDriveLetter"] = ((bool)(AssignDriveLetter));
+                inParams["Path"] = ((string)(Path));
+                inParams["ReadOnly"] = ((bool)(ReadOnly));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AttachVirtualHardDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint CompactVirtualHardDisk(ushort Mode, string Path, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("CompactVirtualHardDisk");
+                inParams["Mode"] = ((ushort)(Mode));
+                inParams["Path"] = ((string)(Path));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CompactVirtualHardDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint ConvertVirtualHardDisk(string SourcePath, string VirtualDiskSettingData, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ConvertVirtualHardDisk");
+                inParams["SourcePath"] = ((string)(SourcePath));
+                inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ConvertVirtualHardDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint CreateVirtualFloppyDisk(string Path, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("CreateVirtualFloppyDisk");
+                inParams["Path"] = ((string)(Path));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateVirtualFloppyDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint CreateVirtualHardDisk(string VirtualDiskSettingData, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("CreateVirtualHardDisk");
+                inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateVirtualHardDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint GetVirtualHardDiskSettingData(string Path, out System.Management.ManagementPath Job, out string SettingData) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualHardDiskSettingData");
+                inParams["Path"] = ((string)(Path));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualHardDiskSettingData", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                SettingData = System.Convert.ToString(outParams.Properties["SettingData"].Value);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                SettingData = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint GetVirtualHardDiskState(string Path, out System.Management.ManagementPath Job, out string State) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualHardDiskState");
+                inParams["Path"] = ((string)(Path));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualHardDiskState", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                State = System.Convert.ToString(outParams.Properties["State"].Value);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                State = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint MergeVirtualHardDisk(string DestinationPath, string SourcePath, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("MergeVirtualHardDisk");
+                inParams["DestinationPath"] = ((string)(DestinationPath));
+                inParams["SourcePath"] = ((string)(SourcePath));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("MergeVirtualHardDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
+                inParams["RequestedState"] = ((ushort)(RequestedState));
+                inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint ResizeVirtualHardDisk(ulong MaxInternalSize, string Path, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ResizeVirtualHardDisk");
+                inParams["MaxInternalSize"] = ((ulong)(MaxInternalSize));
+                inParams["Path"] = ((string)(Path));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ResizeVirtualHardDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint SetParentVirtualHardDisk(string ChildPath, bool IgnoreIDMismatch, string LeafPath, string ParentPath, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("SetParentVirtualHardDisk");
+                inParams["ChildPath"] = ((string)(ChildPath));
+                inParams["IgnoreIDMismatch"] = ((bool)(IgnoreIDMismatch));
+                inParams["LeafPath"] = ((string)(LeafPath));
+                inParams["ParentPath"] = ((string)(ParentPath));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetParentVirtualHardDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint SetVirtualHardDiskSettingData(string VirtualDiskSettingData, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("SetVirtualHardDiskSettingData");
+                inParams["VirtualDiskSettingData"] = ((string)(VirtualDiskSettingData));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetVirtualHardDiskSettingData", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint StartService() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint StopService() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint ValidateVirtualHardDisk(string Path, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ValidateVirtualHardDisk");
+                inParams["Path"] = ((string)(Path));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ValidateVirtualHardDisk", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class ImageManagementServiceCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public ImageManagementServiceCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new ImageManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new ImageManagementServiceEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class ImageManagementServiceEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public ImageManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new ImageManagementService(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs
index 187699d..4ca4d50 100755
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs
@@ -1311,8 +1311,9 @@
                 inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
                 Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                if ((outParams.Properties["Job"] != null))
+                {
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }


[30/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ResourceAllocationSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ResourceAllocationSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ResourceAllocationSettingData.cs
deleted file mode 100644
index 28e7696..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ResourceAllocationSettingData.cs
+++ /dev/null
@@ -1,976 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // An Early Bound class generated for the WMI class.Msvm_ResourceAllocationSettingData
-    public class ResourceAllocationSettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_ResourceAllocationSettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public ResourceAllocationSettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public ResourceAllocationSettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(ResourceAllocationSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ResourceAllocationSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public ResourceAllocationSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public ResourceAllocationSettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public ResourceAllocationSettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public ResourceAllocationSettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Address {
-            get {
-                return ((string)(curObj["Address"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string AllocationUnits {
-            get {
-                return ((string)(curObj["AllocationUnits"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticAllocationNull {
-            get {
-                if ((curObj["AutomaticAllocation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutomaticAllocation {
-            get {
-                if ((curObj["AutomaticAllocation"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutomaticAllocation"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticDeallocationNull {
-            get {
-                if ((curObj["AutomaticDeallocation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutomaticDeallocation {
-            get {
-                if ((curObj["AutomaticDeallocation"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutomaticDeallocation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] Connection {
-            get {
-                return ((string[])(curObj["Connection"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsConsumerVisibilityNull {
-            get {
-                if ((curObj["ConsumerVisibility"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ConsumerVisibility {
-            get {
-                if ((curObj["ConsumerVisibility"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ConsumerVisibility"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] HostResource {
-            get {
-                return ((string[])(curObj["HostResource"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLimitNull {
-            get {
-                if ((curObj["Limit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Limit {
-            get {
-                if ((curObj["Limit"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Limit"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMappingBehaviorNull {
-            get {
-                if ((curObj["MappingBehavior"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort MappingBehavior {
-            get {
-                if ((curObj["MappingBehavior"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["MappingBehavior"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherResourceType {
-            get {
-                return ((string)(curObj["OtherResourceType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Parent {
-            get {
-                return ((string)(curObj["Parent"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PoolID {
-            get {
-                return ((string)(curObj["PoolID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsReservationNull {
-            get {
-                if ((curObj["Reservation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Reservation {
-            get {
-                if ((curObj["Reservation"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Reservation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ResourceSubType {
-            get {
-                return ((string)(curObj["ResourceSubType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsResourceTypeNull {
-            get {
-                if ((curObj["ResourceType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ResourceType {
-            get {
-                if ((curObj["ResourceType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ResourceType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVirtualQuantityNull {
-            get {
-                if ((curObj["VirtualQuantity"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong VirtualQuantity {
-            get {
-                if ((curObj["VirtualQuantity"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["VirtualQuantity"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. These values are only used if the ResourceType property is set to 6 (Parallel SCSI HBA) and the ResourceSubType property is set to ""Microsoft Synthetic SCSI Controller"". This property is set to ""GUID"".
-This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class.
-Windows Server 2008:  The VirtualSystemIdentifiers property is not supported until Windows Server 2008 R2.")]
-        public string[] VirtualSystemIdentifiers {
-            get {
-                return ((string[])(curObj["VirtualSystemIdentifiers"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsWeightNull {
-            get {
-                if ((curObj["Weight"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint Weight {
-            get {
-                if ((curObj["Weight"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["Weight"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticAllocation() {
-            if ((this.IsAutomaticAllocationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticDeallocation() {
-            if ((this.IsAutomaticDeallocationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeConsumerVisibility() {
-            if ((this.IsConsumerVisibilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLimit() {
-            if ((this.IsLimitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMappingBehavior() {
-            if ((this.IsMappingBehaviorNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeReservation() {
-            if ((this.IsReservationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeResourceType() {
-            if ((this.IsResourceTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeVirtualQuantity() {
-            if ((this.IsVirtualQuantityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeWeight() {
-            if ((this.IsWeightNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_ResourceAllocationSettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static ResourceAllocationSettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static ResourceAllocationSettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static ResourceAllocationSettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static ResourceAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_ResourceAllocationSettingData";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new ResourceAllocationSettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ResourceAllocationSettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new ResourceAllocationSettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static ResourceAllocationSettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new ResourceAllocationSettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class ResourceAllocationSettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public ResourceAllocationSettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new ResourceAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new ResourceAllocationSettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class ResourceAllocationSettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public ResourceAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new ResourceAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[42/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/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 809894d..55c37f3 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -1,1502 +1,1463 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-using Amazon;
-using Amazon.S3;
-using Amazon.S3.Model;
-using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION;
-using log4net;
-using Microsoft.CSharp.RuntimeBinder;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
-using System.Security.Cryptography;
-using System.Security.Principal;
-using System.Web.Http;
-
-namespace HypervResource
-{
-
-    public struct HypervResourceControllerConfig
-    {
-        private string privateIpAddress;
-        private static ILog logger = LogManager.GetLogger(typeof(HypervResourceControllerConfig));
-
-        public string PrivateIpAddress
-        {
-            get
-            {
-                return privateIpAddress;
-            }
-            set
-            {
-                ValidateIpAddress(value);
-                privateIpAddress = value;
-                System.Net.NetworkInformation.NetworkInterface nic = HypervResourceController.GetNicInfoFromIpAddress(privateIpAddress, out PrivateNetmask);
-                PrivateMacAddress = nic.GetPhysicalAddress().ToString();
-            }
-        }
-
-        private static void ValidateIpAddress(string value)
-        {
-            // Convert to IP address
-            IPAddress ipAddress;
-            if (!IPAddress.TryParse(value, out ipAddress))
-            {
-                String errMsg = "Invalid PrivateIpAddress: " + value;
-                logger.Error(errMsg);
-                throw new ArgumentException(errMsg);
-            }
-        }
-        public string GatewayIpAddress;
-        public string PrivateMacAddress;
-        public string PrivateNetmask;
-        public string StorageNetmask;
-        public string StorageMacAddress;
-        public string StorageIpAddress;
-        public long RootDeviceReservedSpaceBytes;
-        public string RootDeviceName;
-        public ulong ParentPartitionMinMemoryMb;
-        public string LocalSecondaryStoragePath;
-        public string systemVmIso;
-    }
-
-    /// <summary>
-    /// Supports one HTTP GET and multiple HTTP POST URIs
-    /// </summary>
-    /// <remarks>
-    /// <para>
-    /// POST takes dynamic to allow it to receive JSON without concern for what is the underlying object.
-    /// E.g. http://stackoverflow.com/questions/14071715/passing-dynamic-json-object-to-web-api-newtonsoft-example 
-    /// and http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object
-    /// Use ActionName attribute to allow multiple POST URLs, one for each supported command
-    /// E.g. http://stackoverflow.com/a/12703423/939250
-    /// Strictly speaking, this goes against the purpose of an ApiController, which is to provide one GET/POST/PUT/DELETE, etc.
-    /// However, it reduces the amount of code by removing the need for a switch according to the incoming command type.
-    /// http://weblogs.asp.net/fredriknormen/archive/2012/06/11/asp-net-web-api-exception-handling.aspx
-    /// </para>
-    /// <para>
-    /// Exceptions handled on command by command basis rather than globally to allow details of the command
-    /// to be reflected in the response.  Default error handling is in the catch for Exception, but
-    /// other exception types may be caught where the feedback would be different.
-    /// NB: global alternatives discussed at 
-    /// http://weblogs.asp.net/fredriknormen/archive/2012/06/11/asp-net-web-api-exception-handling.aspx
-    /// </para>
-    /// </remarks>
-    public class HypervResourceController : ApiController
-    {
-        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()
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                return "HypervResource controller running, use POST to send JSON encoded RPCs"; ;
-            }
-        }
-
-        /// <summary>
-        /// NOP - placeholder for future setup, e.g. delete existing VMs or Network ports 
-        /// POST api/HypervResource/SetupCommand
-        /// </summary>
-        /// <param name="cmd"></param>
-        /// <returns></returns>
-        /// TODO: produce test
-        [HttpPost]
-        [ActionName(CloudStackTypes.SetupCommand)]
-        public JContainer SetupCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                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 = result,
-                    details = "success - NOP",
-                    _reconnect = false
-                };
-
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.SetupAnswer);
-            }
-        }
-
-        // POST api/HypervResource/AttachCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.AttachCommand)]
-        public JContainer AttachCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.AttachCommand + cmd.ToString());
-
-                string details = null;
-                bool result = false;
-
-                try
-                {
-                    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);
-
-                    result = true;
-                }
-                catch (Exception sysEx)
-                {
-                    details = CloudStackTypes.AttachCommand + " failed due to " + sysEx.Message;
-                    logger.Error(details, sysEx);
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details
-                };
-
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.AttachAnswer);
-            }
-        }
-
-        // POST api/HypervResource/DetachCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.DettachCommand)]
-        public JContainer DetachCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.DettachCommand + cmd.ToString());
-
-                string details = null;
-                bool result = false;
-
-                try
-                {
-                    string vmName = (string)cmd.vmName;
-                    result = true;
-                }
-                catch (Exception sysEx)
-                {
-                    details = CloudStackTypes.DettachCommand + " failed due to " + sysEx.Message;
-                    logger.Error(details, sysEx);
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details
-                };
-
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.DettachAnswer);
-            }
-        }
-
-        // POST api/HypervResource/DestroyCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.DestroyCommand)]
-        public JContainer DestroyCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.DestroyCommand + cmd.ToString());
-
-                string details = null;
-                bool result = false;
-
-                try
-                {
-                    // Assert
-                    String errMsg = "No 'volume' details in " + CloudStackTypes.DestroyCommand + " " + cmd.ToString();
-                    if (cmd.volume == null)
-                    {
-                        logger.Error(errMsg);
-                        throw new ArgumentException(errMsg);
-                    }
-
-                    // Assert
-                    errMsg = "No valide path in DestroyCommand in " + CloudStackTypes.DestroyCommand + " " + (String)cmd.ToString();
-                    if (cmd.volume.path == null)
-                    {
-                        logger.Error(errMsg);
-                        throw new ArgumentException(errMsg);
-                    }
-
-                    String path = (string)cmd.volume.path;
-                    if (!File.Exists(path))
-                    {
-                        logger.Info(CloudStackTypes.DestroyCommand + ", but volume at pass already deleted " + path);
-                    }
-
-                    // TODO: will we have to detach volume?
-                    string vmName = (string)cmd.vmName;
-                    if (!string.IsNullOrEmpty(vmName) && File.Exists(path))
-                    {
-                        var imgmgr = wmiCalls.GetImageManagementService();
-                        var returncode = imgmgr.Unmount(path);
-                        if (returncode != ReturnCode.Completed)
-                        {
-                            details = "Could not detach driver from vm " + vmName + " for drive " + path;
-                            logger.Error(details);
-                        }
-                    }
-
-                    File.Delete(path);
-                    result = true;
-                }
-                catch (Exception sysEx)
-                {
-                    details = CloudStackTypes.DestroyCommand + " failed due to " + sysEx.Message;
-                    logger.Error(details, sysEx);
-                }
-
-                object ansContent = new
-                    {
-                        result = result,
-                        details = details
-                    };
-
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
-            }
-        }
-
-        private static JArray ReturnCloudStackTypedJArray(object ansContent, string ansType)
-        {
-            JObject ansObj = Utils.CreateCloudStackObject(ansType, ansContent);
-            JArray answer = new JArray(ansObj);
-            logger.Info(ansObj.ToString());
-            return answer;
-        }
-
-        // POST api/HypervResource/CreateCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.CreateCommand)]
-        public JContainer CreateCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.CreateCommand + cmd.ToString());
-
-                string details = null;
-                bool result = false;
-                VolumeInfo volume = new VolumeInfo();
-
-                try
-                {
-                    string diskType = cmd.diskCharacteristics.type;
-                    ulong disksize = cmd.diskCharacteristics.size;
-                    string templateUri = cmd.templateUrl;
-
-                    // assert: valid storagepool?
-                    string poolTypeStr = cmd.pool.type;
-                    string poolLocalPath = cmd.pool.path;
-                    string poolUuid = cmd.pool.uuid;
-                    string newVolPath = null;
-                    long volId = cmd.volId;
-                    string newVolName = null;
-
-                    if (ValidStoragePool(poolTypeStr, poolLocalPath, poolUuid, ref details))
-                    {
-                        // No template URI?  Its a blank disk.
-                        if (string.IsNullOrEmpty(templateUri))
-                        {
-                            // assert
-                            VolumeType volType;
-                            if (!Enum.TryParse<VolumeType>(diskType, out volType) && volType != VolumeType.DATADISK)
-                            {
-                                details = "Cannot create volumes of type " + (string.IsNullOrEmpty(diskType) ? "NULL" : diskType);
-                            }
-                            else
-                            {
-                                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);
-                                if (File.Exists(newVolPath))
-                                {
-                                    result = true;
-                                }
-                                else
-                                {
-                                    details = "Failed to create DATADISK with name " + newVolName;
-                                }
-                            }
-                        }
-                        else
-                        {
-                            // TODO:  Does this always work, or do I need to download template at times?
-                            if (templateUri.Contains("/") || templateUri.Contains("\\"))
-                            {
-                                details = "Problem with templateURL " + templateUri +
-                                                " the URL should be volume UUID in primary storage created by previous PrimaryStorageDownloadCommand";
-                                logger.Error(details);
-                            }
-                            else
-                            {
-                                logger.Debug("Template's name in primary store should be " + templateUri);
-                                //            HypervPhysicalDisk BaseVol = primaryPool.getPhysicalDisk(tmplturl);
-                                FileInfo srcFileInfo = new FileInfo(templateUri);
-                                newVolName = Guid.NewGuid() + srcFileInfo.Extension;
-                                newVolPath = Path.Combine(poolLocalPath, newVolName);
-                                logger.Debug("New volume will be at " + newVolPath);
-                                string oldVolPath = Path.Combine(poolLocalPath, templateUri);
-                                File.Copy(oldVolPath, newVolPath);
-                                if (File.Exists(newVolPath))
-                                {
-                                    result = true;
-                                }
-                                else
-                                {
-                                    details = "Failed to create DATADISK with name " + newVolName;
-                                }
-                            }
-                            volume = new VolumeInfo(
-                                      volId, diskType,
-                                    poolTypeStr, poolUuid, newVolName,
-                                    newVolPath, newVolPath, (long)disksize, null);
-                        }
-                    }
-                }
-                catch (Exception sysEx)
-                {
-                    // TODO: consider this as model for error processing in all commands
-                    details = CloudStackTypes.CreateCommand + " failed due to " + sysEx.Message;
-                    logger.Error(details, sysEx);
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details,
-                    volume = volume
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CreateAnswer);
-            }
-        }
-
-        // POST api/HypervResource/PrimaryStorageDownloadCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.PrimaryStorageDownloadCommand)]
-        public JContainer PrimaryStorageDownloadCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.PrimaryStorageDownloadCommand + cmd.ToString());
-                string details = null;
-                bool result = false;
-                long size = 0;
-                string newCopyFileName = null;
-
-                string poolLocalPath = cmd.localPath;
-                string poolUuid = cmd.poolUuid;
-                if (!Directory.Exists(poolLocalPath))
-                {
-                    details = "None existent local path " + poolLocalPath;
-                }
-                else
-                {
-                    // Compose name for downloaded file.
-                    string sourceUrl = cmd.url;
-                    if (sourceUrl.ToLower().EndsWith(".vhd"))
-                    {
-                        newCopyFileName = Guid.NewGuid() + ".vhd";
-                    }
-                    if (sourceUrl.ToLower().EndsWith(".vhdx"))
-                    {
-                        newCopyFileName = Guid.NewGuid() + ".vhdx";
-                    }
-
-                    // assert
-                    if (newCopyFileName == null)
-                    {
-                        details = CloudStackTypes.PrimaryStorageDownloadCommand + " Invalid file extension for hypervisor type in source URL " + sourceUrl;
-                        logger.Error(details);
-                    }
-                    else
-                    {
-                        try
-                        {
-                            FileInfo newFile;
-                            if (CopyURI(sourceUrl, newCopyFileName, poolLocalPath, out newFile, ref details))
-                            {
-                                size = newFile.Length;
-                                result = true;
-                            }
-                        }
-                        catch (System.Exception ex)
-                        {
-                            details = CloudStackTypes.PrimaryStorageDownloadCommand + " Cannot download source URL " + sourceUrl + " due to " + ex.Message;
-                            logger.Error(details, ex);
-                        }
-                    }
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details,
-                    templateSize = size,
-                    installPath = newCopyFileName
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.PrimaryStorageDownloadAnswer);
-            }
-        }
-
-        private static bool ValidStoragePool(string poolTypeStr, string poolLocalPath, string poolUuid, ref string details)
-        {
-            StoragePoolType poolType;
-            if (!Enum.TryParse<StoragePoolType>(poolTypeStr, out poolType) || poolType != StoragePoolType.Filesystem)
-            {
-                details = "Primary storage pool " + poolUuid + " type " + poolType + " local path " + poolLocalPath + " has invalid StoragePoolType";
-                logger.Error(details);
-                return false;
-            }
-            else if (!Directory.Exists(poolLocalPath))
-            {
-                details = "Primary storage pool " + poolUuid + " type " + poolType + " local path " + poolLocalPath + " has invalid local path";
-                logger.Error(details);
-                return false;
-            }
-            return true;
-        }
-
-        /// <summary>
-        /// Exceptions to watch out for:
-        /// Exceptions related to URI creation
-        /// System.SystemException
-        /// +-System.ArgumentNullException
-        /// +-System.FormatException
-        ///   +-System.UriFormatException
-        ///
-        /// Exceptions related to NFS URIs
-        /// System.SystemException
-        /// +-System.NotSupportedException
-        /// +-System.ArgumentException
-        /// +-System.ArgumentNullException
-        ///   +-System.Security.SecurityException;
-        /// +-System.UnauthorizedAccessException
-        /// +-System.IO.IOException
-        ///   +-System.IO.PathTooLongException
-        ///   
-        /// Exceptions related to HTTP URIs
-        /// System.SystemException
-        /// +-System.InvalidOperationException
-        ///    +-System.Net.WebException
-        /// +-System.NotSupportedException
-        /// +-System.ArgumentNullException
-        /// </summary>
-        /// <param name="sourceUri"></param>
-        /// <param name="newCopyFileName"></param>
-        /// <param name="poolLocalPath"></param>
-        /// <returns></returns>
-        private bool CopyURI(string sourceUri, string newCopyFileName, string poolLocalPath, out FileInfo newFile, ref string details)
-        {
-            Uri source = new Uri(sourceUri);
-            String destFilePath = Path.Combine(poolLocalPath, newCopyFileName);
-            string[] pathSegments = source.Segments;
-            String templateUUIDandExtension = pathSegments[pathSegments.Length - 1];
-            newFile = new FileInfo(destFilePath);
-
-            // NFS URI assumed to already be mounted locally.  Mount location given by settings.
-            if (source.Scheme.ToLower().Equals("nfs"))
-            {
-                String srcDiskPath = Path.Combine(HypervResourceController.config.LocalSecondaryStoragePath, templateUUIDandExtension);
-                String taskMsg = "Copy NFS url in " + sourceUri + " at " + srcDiskPath + " to pool " + poolLocalPath;
-                logger.Debug(taskMsg);
-                File.Copy(srcDiskPath, destFilePath);
-            }
-            else if (source.Scheme.ToLower().Equals("http") || source.Scheme.ToLower().Equals("https"))
-            {
-                System.Net.WebClient webclient = new WebClient();
-                webclient.DownloadFile(source, destFilePath);
-            }
-            else
-            {
-                details = "Unsupported URI scheme " + source.Scheme.ToLower() + " in source URI " + sourceUri;
-                logger.Error(details);
-                return false;
-            }
-
-            if (!File.Exists(destFilePath))
-            {
-                details = "Filed to copy " + sourceUri + " to primary pool destination " + destFilePath;
-                logger.Error(details);
-                return false;
-            }
-            return true;
-        }
-
-        // POST api/HypervResource/CheckHealthCommand
-        // TODO: create test
-        [HttpPost]
-        [ActionName(CloudStackTypes.CheckHealthCommand)]
-        public JContainer CheckHealthCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.CheckHealthCommand + cmd.ToString());
-                object ansContent = new
-                {
-                    result = true,
-                    details = "resource is alive"
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CheckHealthAnswer);
-            }
-        }
-
-        // POST api/HypervResource/CheckSshCommand
-        // TODO: create test
-        [HttpPost]
-        [ActionName(CloudStackTypes.CheckSshCommand)]
-        public JContainer CheckSshCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.CheckSshCommand + cmd.ToString());
-                object ansContent = new
-                {
-                    result = true,
-                    details = "NOP, TODO: implement properly"
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CheckSshAnswer);
-            }
-        }
-
-        // POST api/HypervResource/CheckVirtualMachineCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.CheckVirtualMachineCommand)]
-        public JContainer CheckVirtualMachineCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.CheckVirtualMachineCommand + cmd.ToString());
-                string details = null;
-                bool result = false;
-                string vmName = cmd.vmName;
-                string state = null;
-
-                // TODO: Look up the VM, convert Hyper-V state to CloudStack version.
-                var sys = wmiCalls.GetComputerSystem(vmName);
-                if (sys == null)
-                {
-                    details = CloudStackTypes.CheckVirtualMachineCommand + " requested unknown VM " + vmName;
-                    logger.Error(details);
-                }
-                else
-                {
-                    state = EnabledState.ToString(sys.EnabledState);
-                    result = true;
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details,
-                    state = state
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CheckVirtualMachineAnswer);
-            }
-        }
-
-        // POST api/HypervResource/DeleteStoragePoolCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.DeleteStoragePoolCommand)]
-        public JContainer DeleteStoragePoolCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.DeleteStoragePoolCommand + cmd.ToString());
-                object ansContent = new
-                {
-                    result = true,
-                    details = "Current implementation does not delete local path corresponding to storage pool!"
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
-            }
-        }
-
-        /// <summary>
-        /// NOP - legacy command -
-        /// POST api/HypervResource/CreateStoragePoolCommand
-        /// </summary>
-        /// <param name="cmd"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [ActionName(CloudStackTypes.CreateStoragePoolCommand)]
-        public JContainer CreateStoragePoolCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.CreateStoragePoolCommand + cmd.ToString());
-                object ansContent = new
-                {
-                    result = true,
-                    details = "success - NOP"
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
-            }
-        }
-
-        // POST api/HypervResource/ModifyStoragePoolCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.ModifyStoragePoolCommand)]
-        public JContainer ModifyStoragePoolCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.ModifyStoragePoolCommand + cmd.ToString());
-                string details = null;
-                string localPath;
-                object ansContent;
-
-                bool result = ValidateStoragePoolCommand(cmd, out localPath, ref details);
-                if (!result)
-                {
-                    ansContent = new
-                        {
-                            result = result,
-                            details = details
-                        };
-                    return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
-                }
-
-                var tInfo = new Dictionary<string, string>();
-                long capacityBytes;
-                long availableBytes;
-                GetCapacityForLocalPath(localPath, out capacityBytes, out availableBytes);
-
-                String uuid = null;
-                var poolInfo = new
-                {
-                    uuid = uuid,
-                    host = cmd.pool.host,
-                    localPath = cmd.pool.host,
-                    hostPath = cmd.localPath,
-                    poolType = cmd.pool.type,
-                    capacityBytes = capacityBytes,
-                    availableBytes = availableBytes
-                };
-
-                ansContent = new
-                    {
-                        result = result,
-                        details = details,
-                        templateInfo = tInfo,
-                        poolInfo = poolInfo
-                    };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.ModifyStoragePoolAnswer);
-            }
-        }
-
-        private bool ValidateStoragePoolCommand(dynamic cmd, out string localPath, ref string details)
-        {
-            dynamic pool = cmd.pool;
-            string poolTypeStr = pool.type;
-            StoragePoolType poolType;
-            localPath = cmd.localPath;
-            if (!Enum.TryParse<StoragePoolType>(poolTypeStr, out poolType) || poolType != StoragePoolType.Filesystem)
-            {
-                details = "Request to create / modify unsupported pool type: " + (poolTypeStr == null ? "NULL" : poolTypeStr) + "in cmd " + JsonConvert.SerializeObject(cmd);
-                logger.Error(details);
-                return false;
-            }
-            if (!Directory.Exists(localPath))
-            {
-                details = "Request to create / modify unsupported StoragePoolType.Filesystem with non-existent path:" + (localPath == null ? "NULL" : localPath) + "in cmd " + JsonConvert.SerializeObject(cmd);
-                logger.Error(details);
-                return false;
-            }
-            return true;
-        }
-
-
-        // POST api/HypervResource/CleanupNetworkRulesCmd
-        [HttpPost]
-        [ActionName(CloudStackTypes.CleanupNetworkRulesCmd)]
-        public JContainer CleanupNetworkRulesCmd([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.CleanupNetworkRulesCmd + cmd.ToString());
-                object ansContent = new
-                 {
-                     result = false,
-                     details = "nothing to cleanup in our current implementation"
-                 };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
-            }
-        }
-
-        // POST api/HypervResource/CheckNetworkCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.CheckNetworkCommand)]
-        public JContainer CheckNetworkCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.CheckNetworkCommand + cmd.ToString());
-                object ansContent = new
-                {
-                    result = true,
-                    details = (string)null
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CheckNetworkAnswer);
-            }
-        }
-
-        // POST api/HypervResource/ReadyCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.ReadyCommand)]
-        public JContainer ReadyCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.ReadyCommand + cmd.ToString());
-                object ansContent = new
-                {
-                    result = true,
-                    details = (string)null
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.ReadyAnswer);
-            }
-
-        }
-
-        // POST api/HypervResource/StartCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.StartCommand)]
-        public JContainer StartCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.StartCommand + cmd.ToString()); // TODO: Security hole? VM data printed to log
-                string details = null;
-                bool result = false;
-
-                try
-                {
-                    wmiCalls.DeployVirtualMachine(cmd, systemVmIso);
-                    result = true;
-                }
-                catch (Exception wmiEx)
-                {
-                    details = CloudStackTypes.StartCommand + " fail on exception" + wmiEx.Message;
-                    logger.Error(details, wmiEx);
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details,
-                    vm = cmd.vm
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.StartAnswer);
-            }
-        }
-
-        // POST api/HypervResource/StopCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.StopCommand)]
-        public JContainer StopCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.StopCommand + cmd.ToString());
-                string details = null;
-                bool result = false;
-
-                try
-                {
-                    wmiCalls.DestroyVm(cmd);
-                    result = true;
-                }
-                catch (Exception wmiEx)
-                {
-                    details = CloudStackTypes.StopCommand + " fail on exception" + wmiEx.Message;
-                    logger.Error(details, wmiEx);
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details,
-                    vm = cmd.vm
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.StopAnswer);
-            }
-        }
-
-        // POST api/HypervResource/MaintainCommand
-        // TODO: should this be a NOP?
-        [HttpPost]
-        [ActionName(CloudStackTypes.MaintainCommand)]
-        public JContainer MaintainCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.MaintainCommand + cmd.ToString());
-
-                object ansContent = new
-                {
-                    result = true,
-                    details = "success - NOP for MaintainCommand",
-                    _reconnect = false
-                };
-
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.MaintainAnswer);
-            }
-        }
-
-        // POST api/HypervResource/PingRoutingCommand
-        // TODO: should this be a NOP?
-        [HttpPost]
-        [ActionName(CloudStackTypes.PingRoutingCommand)]
-        public JContainer PingRoutingCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.PingRoutingCommand + cmd.ToString());
-
-                object ansContent = new
-                {
-                    result = true,
-                    details = "success - NOP for PingRoutingCommand",
-                    _reconnect = false
-                };
-
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
-            }
-        }
-
-        // POST api/HypervResource/PingCommand
-        // TODO: should this be a NOP?
-        [HttpPost]
-        [ActionName(CloudStackTypes.PingCommand)]
-        public JContainer PingCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.PingCommand + cmd.ToString());
-
-                object ansContent = new
-                {
-                    result = true,
-                    details = "success - NOP for PingCommand",
-                    _reconnect = false
-                };
-
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
-            }
-        }
-
-        // POST api/HypervResource/GetVmStatsCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.GetVmStatsCommand)]
-        public JContainer GetVmStatsCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.GetVmStatsCommand + cmd.ToString());
-                bool result = false;
-                string details = null;
-                JArray vmNamesJson = cmd.vmNames;
-                string[] vmNames = vmNamesJson.ToObject<string[]>();
-                Dictionary<string, VmStatsEntry> vmProcessorInfo = new Dictionary<string, VmStatsEntry>(vmNames.Length);
-
-                var vmsToInspect = new List<System.Management.ManagementPath>();
-                foreach (var vmName in vmNames)
-                {
-                    var sys = wmiCalls.GetComputerSystem(vmName);
-                    if (sys == null)
-                    {
-                        logger.InfoFormat("GetVmStatsCommand requested unknown VM {0}", vmNames);
-                        continue;
-                    }
-                    var sysInfo = wmiCalls.GetVmSettings(sys);
-                    vmsToInspect.Add(sysInfo.Path);
-                }
-
-                // Process info available from WMI, 
-                // See http://msdn.microsoft.com/en-us/library/cc160706%28v=vs.85%29.aspx
-                uint[] requestedInfo = new uint[] {
-                    0, // Name
-                    1, // ElementName
-                    4, // Number of processes
-                    101 // ProcessorLoad
-                };
-
-                System.Management.ManagementBaseObject[] sysSummary;
-                var vmsvc = wmiCalls.GetVirtualisationSystemManagementService();
-                System.Management.ManagementPath[] vmPaths = vmsToInspect.ToArray();
-                vmsvc.GetSummaryInformation(requestedInfo, vmPaths, out sysSummary);
-
-                foreach (var summary in sysSummary)
-                {
-                    var summaryInfo = new CloudStack.Plugin.AgentShell.ROOT.VIRTUALIZATION.SummaryInformation(summary);
-
-                    logger.Debug("VM " + summaryInfo.Name + "(elementName " + summaryInfo.ElementName + ") has " +
-                                    summaryInfo.NumberOfProcessors + " CPUs, and load of " + summaryInfo.ProcessorLoad);
-                    var vmInfo = new VmStatsEntry
-                    {
-                        cpuUtilization = summaryInfo.ProcessorLoad,
-                        numCPUs = summaryInfo.NumberOfProcessors,
-                        networkReadKBs = 1,
-                        networkWriteKBs = 1,
-                        entityType = "vm"
-                    };
-                    vmProcessorInfo.Add(summaryInfo.ElementName, vmInfo);
-                }
-
-                // TODO: Network usage comes from Performance Counter API; however it is only available in kb/s, and not in total terms.
-                // Curious about these?  Use perfmon to inspect them, e.g. http://msdn.microsoft.com/en-us/library/xhcx5a20%28v=vs.100%29.aspx
-                // Recent post on these counter at http://blogs.technet.com/b/cedward/archive/2011/07/19/hyper-v-networking-optimizations-part-6-of-6-monitoring-hyper-v-network-consumption.aspx
-                result = true;
-
-                object ansContent = new
-                {
-                    vmInfos = vmProcessorInfo,
-                    result = result,
-                    details = details,
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.GetVmStatsAnswer);
-            }
-        }
-
-        // POST api/HypervResource/StartupCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.CopyCommand)]
-        public JContainer CopyCommand(dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                // Log command *after* we've removed security details from the command.
-
-                bool result = false;
-                string details = null;
-                object newData = null;
-
-                try
-                {
-                    dynamic timeout = cmd.wait;  // TODO: Useful?
-
-                    TemplateObjectTO srcTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.srcTO);
-                    TemplateObjectTO destTemplateObjectTO = TemplateObjectTO.ParseJson(cmd.destTO);
-                    VolumeObjectTO destVolumeObjectTO = VolumeObjectTO.ParseJson(cmd.destTO);
-
-                    logger.Info(CloudStackTypes.CopyCommand + cmd.ToString());
-
-                    // Already exists?
-                    if (destTemplateObjectTO != null &&
-                        File.Exists(destTemplateObjectTO.FullFileName) &&
-                        !String.IsNullOrEmpty(destTemplateObjectTO.checksum))
-                    {
-                        // 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?
-                    if (!result)
-                    {
-                        // Create local copy of a template?
-                        if (srcTemplateObjectTO != null && destTemplateObjectTO != null)
-                        {
-                            // S3 download to primary storage?
-                            // NFS provider download to primary storage?
-                            if ((srcTemplateObjectTO.s3DataStoreTO != null || srcTemplateObjectTO.nfsDataStoreTO != null) && destTemplateObjectTO.primaryDataStore != null)
-                            {
-                                string destFile = destTemplateObjectTO.FullFileName;
-
-                                if (File.Exists(destFile))
-                                {
-                                    logger.Info("Deleting existing file " + destFile);
-                                    File.Delete(destFile);
-                                }
-
-                                if (srcTemplateObjectTO.s3DataStoreTO != null)
-                                {
-                                    // Download from S3 to destination data storage
-                                    DownloadS3ObjectToFile(srcTemplateObjectTO.path, srcTemplateObjectTO.s3DataStoreTO, destFile);
-                                }
-                                else if (srcTemplateObjectTO.nfsDataStoreTO != null)
-                                {
-                                    // Download from S3 to destination data storage
-                                    Utils.DownloadCifsFileToLocalFile(srcTemplateObjectTO.path, srcTemplateObjectTO.nfsDataStoreTO, destFile);
-                                }
-
-                                // Uncompress, as required
-                                if (srcTemplateObjectTO.path.EndsWith(".bz2"))
-                                {
-                                    String uncompressedFile = destFile + ".tmp";
-                                    String compressedFile = destFile;
-                                    using (var uncompressedOutStrm = new FileStream(uncompressedFile, FileMode.CreateNew, FileAccess.Write))
-                                    {
-                                        using (var compressedInStrm = new FileStream(destFile, FileMode.Open, FileAccess.Read))
-                                        {
-                                            using (var bz2UncompressorStrm = new Ionic.BZip2.BZip2InputStream(compressedInStrm, true) /* outer 'using' statement will close FileStream*/ )
-                                            {
-                                                int count = 0;
-                                                int bufsize = 1024 * 1024;
-                                                byte[] buf = new byte[bufsize];
-
-                                                // EOF returns -1, see http://dotnetzip.codeplex.com/workitem/16069 
-                                                while (0 < (count = bz2UncompressorStrm.Read(buf, 0, bufsize)))
-                                                {
-                                                    uncompressedOutStrm.Write(buf, 0, count);
-                                                }
-                                            }
-                                        }
-                                    }
-                                    File.Delete(compressedFile);
-                                    File.Move(uncompressedFile, compressedFile);
-                                    if (File.Exists(uncompressedFile))
-                                    {
-                                        String errMsg = "Extra file left around called " + uncompressedFile + " when creating " + destFile;
-                                        logger.Error(errMsg);
-                                        throw new IOException(errMsg);
-                                    }
-                                }
-
-                                // assert
-                                if (!File.Exists(destFile))
-                                {
-                                    String errMsg = "Failed to create " + destFile + " , because the file is missing";
-                                    logger.Error(errMsg);
-                                    throw new IOException(errMsg);
-                                }
-
-                                newData = cmd.destTO;
-                                result = true;
-                            }
-                            else
-                            {
-                                details = "Data store combination not supported";
-                            }
-                        }
-                        // Create volume from a template?
-                        else if (srcTemplateObjectTO != null && destVolumeObjectTO != null)
-                        {
-                            if (destVolumeObjectTO.format == null)
-                            {
-                                destVolumeObjectTO.format = srcTemplateObjectTO.format;
-                            }
-                            string destFile = destVolumeObjectTO.FullFileName;
-                            string srcFile = srcTemplateObjectTO.FullFileName;
-
-                            if (!File.Exists(srcFile))
-                            {
-                                details = "Local template file missing from " + srcFile;
-                            }
-                            else
-                            {
-                                if (File.Exists(destFile))
-                                {
-                                    logger.Info("Deleting existing file " + destFile);
-                                    File.Delete(destFile);
-                                }
-
-                                // TODO: thin provision instead of copying the full file.
-                                File.Copy(srcFile, destFile);
-                                newData = cmd.destTO;
-                                result = true;
-                            }
-                        }
-                        else
-                        {
-                            details = "Data store combination not supported";
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    // Test by providing wrong key
-                    details = CloudStackTypes.CopyCommand + " failed on exception, " + ex.Message;
-                    logger.Error(details, ex);
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details,
-                    newData = cmd.destTO 
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CopyCmdAnswer);
-            }
-        }
-
-        private static bool VerifyChecksum(string destFile, string checksum)
-        {
-            string localChecksum = BitConverter.ToString(CalcFileChecksum(destFile)).Replace("-", "").ToLower();
-            logger.Debug("Checksum of " + destFile + " is " + checksum);
-            if (checksum.Equals(localChecksum))
-            {
-                return true;
-            }
-            return false;
-        }
-
-        /// <summary>
-        /// Match implmentation of DownloadManagerImpl.computeCheckSum
-        /// </summary>
-        /// <param name="destFile"></param>
-        /// <returns></returns>
-        private static byte[] CalcFileChecksum(string destFile)
-        {
-            // TODO:  Add unit test to verify that checksum algorithm has not changed.
-            using (MD5 md5 = MD5.Create())
-            {
-                using (FileStream stream = File.OpenRead(destFile))
-                {
-                    return md5.ComputeHash(stream);
-                }
-            }
-        }
-
-        private static void DownloadS3ObjectToFile(string srcObjectKey, S3TO srcS3TO, string destFile)
-        {
-            AmazonS3Config S3Config = new AmazonS3Config
-            {
-                ServiceURL = srcS3TO.endpoint,
-                CommunicationProtocol = Amazon.S3.Model.Protocol.HTTP
-            };
-
-            if (srcS3TO.httpsFlag)
-            {
-                S3Config.CommunicationProtocol = Protocol.HTTPS;
-            }
-
-            try
-            {
-                using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(srcS3TO.accessKey, srcS3TO.secretKey, S3Config))
-                {
-                    GetObjectRequest getObjectRequest = new GetObjectRequest().WithBucketName(srcS3TO.bucketName).WithKey(srcObjectKey);
-
-                    using (S3Response getObjectResponse = client.GetObject(getObjectRequest))
-                    {
-                        using (Stream s = getObjectResponse.ResponseStream)
-                        {
-                            using (FileStream fs = new FileStream(destFile, FileMode.Create, FileAccess.Write))
-                            {
-                                byte[] data = new byte[524288];
-                                int bytesRead = 0;
-                                do
-                                {
-                                    bytesRead = s.Read(data, 0, data.Length);
-                                    fs.Write(data, 0, bytesRead);
-                                }
-                                while (bytesRead > 0);
-                                fs.Flush();
-                            }
-                        }
-                    }
-                }
-            }
-            catch (Exception ex)
-            {
-                string errMsg = "Download from S3 url" + srcS3TO.endpoint + " said: " + ex.Message;
-                logger.Error(errMsg, ex);
-                throw new Exception(errMsg, ex);
-            }
-        }
-
-        // POST api/HypervResource/GetStorageStatsCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.GetStorageStatsCommand)]
-        public JContainer GetStorageStatsCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.GetStorageStatsCommand + cmd.ToString());
-                bool result = false;
-                string details = null;
-                long capacity = 0;
-                long available = 0;
-                long used = 0;
-                try
-                {
-                    string localPath = (string)cmd.localPath;
-                    GetCapacityForLocalPath(localPath, out capacity, out available);
-                    used = capacity - available;
-                    result = true;
-                    logger.Debug(CloudStackTypes.GetStorageStatsCommand + " set used bytes to " + used);
-                }
-                catch (Exception ex)
-                {
-                    details = CloudStackTypes.GetStorageStatsCommand + " failed on exception" + ex.Message;
-                    logger.Error(details, ex);
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    details = details,
-                    capacity = capacity,
-                    used = used
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.GetStorageStatsAnswer);
-            }
-        }
-
-        // POST api/HypervResource/GetHostStatsCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.GetHostStatsCommand)]
-        public JContainer GetHostStatsCommand([FromBody]dynamic cmd)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(CloudStackTypes.GetHostStatsCommand + cmd.ToString());
-                bool result = false;
-                string details = null;
-                object hostStats = null;
-
-                var entityType = "host";
-                ulong totalMemoryKBs;
-                ulong freeMemoryKBs;
-                double networkReadKBs;
-                double networkWriteKBs;
-                double cpuUtilization;
-
-                try
-                {
-                    long hostId = (long)cmd.hostId;
-                    wmiCalls.GetMemoryResources(out totalMemoryKBs, out freeMemoryKBs);
-                    wmiCalls.GetProcessorUsageInfo(out cpuUtilization);
-
-                    // TODO: can we assume that the host has only one adaptor?
-                    string tmp;
-                    var privateNic = GetNicInfoFromIpAddress(config.PrivateIpAddress, out tmp);
-                    var nicStats = privateNic.GetIPv4Statistics();  //TODO: add IPV6 support, currentl
-                    networkReadKBs = nicStats.BytesReceived;
-                    networkWriteKBs = nicStats.BytesSent;
-
-                    // Generate GetHostStatsAnswer
-                    hostStats = new
-                    {
-                        hostId = hostId,
-                        entityType = entityType,
-                        cpuUtilization = cpuUtilization,
-                        networkReadKBs = networkReadKBs,
-                        networkWriteKBs = networkWriteKBs,
-                        totalMemoryKBs = (double)totalMemoryKBs,
-                        freeMemoryKBs = (double)freeMemoryKBs
-                    };
-                    result = true;
-                }
-                catch (Exception ex)
-                {
-                    details = CloudStackTypes.GetHostStatsCommand + " failed on exception" + ex.Message;
-                    logger.Error(details, ex);
-                }
-
-                object ansContent = new
-                {
-                    result = result,
-                    hostStats = hostStats,
-                    details = details
-                };
-                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.GetHostStatsAnswer);
-            }
-        }
-
-        // POST api/HypervResource/StartupCommand
-        [HttpPost]
-        [ActionName(CloudStackTypes.StartupCommand)]
-        public JContainer StartupCommand([FromBody]dynamic cmdArray)
-        {
-            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
-            {
-                logger.Info(cmdArray.ToString());
-                // Log agent configuration
-                logger.Info("Agent StartupRoutingCommand received " + cmdArray.ToString());
-                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.caps = "hvm";
-
-                // Detect CPUs, speed, memory
-                uint cores;
-                uint mhz;
-                wmiCalls.GetProcessorResources(out cores, out mhz);
-                strtRouteCmd.cpus = cores;
-                strtRouteCmd.speed = mhz;
-                ulong memoryKBs;
-                ulong 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
-                strtRouteCmd.dom0MinMemory = config.ParentPartitionMinMemoryMb * 1024 * 1024;  // Convert to bytes
-
-                // Insert storage pool details.
-                //
-                // 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();
-                if (localStoragePath != null)
-                {
-                    // GUID arbitrary.  Host agents deals with storage pool in terms of localStoragePath.
-                    // We use HOST guid.
-                    string poolGuid = strtRouteCmd.guid;
-
-                    if (poolGuid == null)
-                    {
-                        poolGuid = Guid.NewGuid().ToString();
-                        logger.InfoFormat("Setting Startup StoragePool GUID to " + poolGuid);
-                    }
-                    else
-                    {
-                        logger.InfoFormat("Setting Startup StoragePool GUID same as HOST, i.e. " + poolGuid);
-                    }
-
-                    long capacity;
-                    long available;
-                    GetCapacityForLocalPath(localStoragePath, out capacity, out available);
-
-                    logger.Debug(CloudStackTypes.StartupStorageCommand + " set available bytes to " + available);
-
-                    string ipAddr = strtRouteCmd.privateIpAddress;
-                    StoragePoolInfo pi = new StoragePoolInfo(
-                        poolGuid.ToString(),
-                        ipAddr,
-                        localStoragePath,
-                        localStoragePath,
-                        StoragePoolType.Filesystem.ToString(),
-                        capacity,
-                        available);
-
-                    // Build StartupStorageCommand using an anonymous type
-                    // See http://stackoverflow.com/a/6029228/939250
-                    object ansContent = new
-                    {
-                        poolInfo = pi,
-                        guid = pi.uuid,
-                        dataCenter = strtRouteCmd.dataCenter,
-                        resourceType = StorageResourceType.STORAGE_POOL.ToString()  // TODO: check encoding
-                    };
-                    JObject ansObj = Utils.CreateCloudStackObject(CloudStackTypes.StartupStorageCommand, ansContent);
-                    cmdArray.Add(ansObj);
-                }
-
-                // Convert result to array for type correctness?
-                logger.Info(CloudStackTypes.StartupCommand + " result is " + cmdArray.ToString());
-                return cmdArray;
-            }
-        }
-
-        public static System.Net.NetworkInformation.NetworkInterface GetNicInfoFromIpAddress(string ipAddress, out string subnet)
-        {
-            System.Net.NetworkInformation.NetworkInterface[] nics = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
-            foreach (var nic in nics)
-            {
-                subnet = null;
-                // TODO: use to remove NETMASK and MAC from the config file, and to validate the IPAddress.
-                var nicProps = nic.GetIPProperties();
-                bool found = false;
-                foreach (var addr in nicProps.UnicastAddresses)
-                {
-                    if (addr.Address.Equals(IPAddress.Parse(ipAddress)))
-                    {
-                        subnet = addr.IPv4Mask.ToString();
-                        found = true;
-                    }
-                }
-                if (!found)
-                {
-                    continue;
-                }
-                return nic;
-            }
-            throw new ArgumentException("No NIC for ipAddress " + ipAddress);
-        }
-
-        public static void GetCapacityForLocalPath(string localStoragePath, out long capacityBytes, out long availableBytes)
-        {
-            // NB: DriveInfo does not work for remote folders (http://stackoverflow.com/q/1799984/939250)
-            // DriveInfo requires a driver letter...
-            string fullPath = Path.GetFullPath(localStoragePath);
-            System.IO.DriveInfo poolInfo = new System.IO.DriveInfo(fullPath);
-            capacityBytes = poolInfo.TotalSize;
-            availableBytes = poolInfo.AvailableFreeSpace;
-
-            // Don't allow all of the Root Device to be used for virtual disks
-            if (poolInfo.RootDirectory.Name.ToLower().Equals(config.RootDeviceName))
-            {
-                availableBytes -= config.RootDeviceReservedSpaceBytes;
-                availableBytes = availableBytes > 0 ? availableBytes : 0;
-                capacityBytes -= config.RootDeviceReservedSpaceBytes;
-                capacityBytes = capacityBytes > 0 ? capacityBytes : 0;
-            }
-        }
-    }
-}
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+using Amazon;
+using Amazon.S3;
+using Amazon.S3.Model;
+using log4net;
+using Microsoft.CSharp.RuntimeBinder;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Security.Cryptography;
+using System.Security.Principal;
+using System.Web.Http;
+
+namespace HypervResource
+{
+
+    public struct HypervResourceControllerConfig
+    {
+        private string privateIpAddress;
+        private static ILog logger = LogManager.GetLogger(typeof(HypervResourceControllerConfig));
+
+        public string PrivateIpAddress
+        {
+            get
+            {
+                return privateIpAddress;
+            }
+            set
+            {
+                ValidateIpAddress(value);
+                privateIpAddress = value;
+                System.Net.NetworkInformation.NetworkInterface nic = HypervResourceController.GetNicInfoFromIpAddress(privateIpAddress, out PrivateNetmask);
+                PrivateMacAddress = nic.GetPhysicalAddress().ToString();
+            }
+        }
+
+        private static void ValidateIpAddress(string value)
+        {
+            // Convert to IP address
+            IPAddress ipAddress;
+            if (!IPAddress.TryParse(value, out ipAddress))
+            {
+                String errMsg = "Invalid PrivateIpAddress: " + value;
+                logger.Error(errMsg);
+                throw new ArgumentException(errMsg);
+            }
+        }
+        public string GatewayIpAddress;
+        public string PrivateMacAddress;
+        public string PrivateNetmask;
+        public string StorageNetmask;
+        public string StorageMacAddress;
+        public string StorageIpAddress;
+        public long RootDeviceReservedSpaceBytes;
+        public string RootDeviceName;
+        public ulong ParentPartitionMinMemoryMb;
+        public string LocalSecondaryStoragePath;
+        public string systemVmIso;
+    }
+
+    /// <summary>
+    /// Supports one HTTP GET and multiple HTTP POST URIs
+    /// </summary>
+    /// <remarks>
+    /// <para>
+    /// POST takes dynamic to allow it to receive JSON without concern for what is the underlying object.
+    /// E.g. http://stackoverflow.com/questions/14071715/passing-dynamic-json-object-to-web-api-newtonsoft-example 
+    /// and http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object
+    /// Use ActionName attribute to allow multiple POST URLs, one for each supported command
+    /// E.g. http://stackoverflow.com/a/12703423/939250
+    /// Strictly speaking, this goes against the purpose of an ApiController, which is to provide one GET/POST/PUT/DELETE, etc.
+    /// However, it reduces the amount of code by removing the need for a switch according to the incoming command type.
+    /// http://weblogs.asp.net/fredriknormen/archive/2012/06/11/asp-net-web-api-exception-handling.aspx
+    /// </para>
+    /// <para>
+    /// Exceptions handled on command by command basis rather than globally to allow details of the command
+    /// to be reflected in the response.  Default error handling is in the catch for Exception, but
+    /// other exception types may be caught where the feedback would be different.
+    /// NB: global alternatives discussed at 
+    /// http://weblogs.asp.net/fredriknormen/archive/2012/06/11/asp-net-web-api-exception-handling.aspx
+    /// </para>
+    /// </remarks>
+    public class HypervResourceController : ApiController
+    {
+        public static void Configure(HypervResourceControllerConfig config)
+        {
+            HypervResourceController.config = config;
+            wmiCallsV2 = new WmiCallsV2();
+        }
+
+        public static HypervResourceControllerConfig config = new HypervResourceControllerConfig();
+
+        private static ILog logger = LogManager.GetLogger(typeof(HypervResourceController));
+        private static string systemVmIso;
+
+        public static void Initialize()
+        {
+        }
+
+        public static IWmiCallsV2 wmiCallsV2 { get; set;}
+
+        // GET api/HypervResource
+        public string Get()
+        {
+            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
+            {
+                return "HypervResource controller running, use POST to send JSON encoded RPCs"; ;
+            }
+        }
+
+        /// <summary>
+        /// NOP - placeholder for future setup, e.g. delete existing VMs or Network ports 
+        /// POST api/HypervResource/SetupCommand
+        /// </summary>
+        /// <param name="cmd"></param>
+        /// <returns></returns>
+        /// TODO: produce test
+        [HttpPost]
+        [ActionName(CloudStackTypes.SetupCommand)]
+        public JContainer SetupCommand([FromBody]dynamic cmd)
+        {
+            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
+            {
+                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 = result,
+                    details = "success - NOP",
+                    _reconnect = false
+                };
+
+                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.SetupAnswer);
+            }
+        }
+
+        // POST api/HypervResource/AttachCommand
+        [HttpPost]
+        [ActionName(CloudStackTypes.AttachCommand)]
+        public JContainer AttachCommand([FromBody]dynamic cmd)
+        {
+            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
+            {
+                logger.Info(CloudStackTypes.AttachCommand + cmd.ToString());
+
+                string details = null;
+                bool result = false;
+
+                try
+                {
+                    string vmName = (string)cmd.vmName;
+                    // TODO: remove absolute path
+                    string isoPath = "\\\\10.102.192.150\\SMB-Share\\202-2-305ed1f7-1be8-345e-86c3-a976f7f57f10.iso";
+                    wmiCallsV2.AttachIso(vmName, isoPath);
+
+                    result = true;
+                }
+                catch (Exception sysEx)
+                {
+                    details = CloudStackTypes.AttachCommand + " failed due to " + sysEx.Message;
+                    logger.Error(details, sysEx);
+                }
+
+                object ansContent = new
+                {
+                    result = result,
+                    details = details
+                };
+
+                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.AttachAnswer);
+            }
+        }
+
+        // POST api/HypervResource/DetachCommand
+        [HttpPost]
+        [ActionName(CloudStackTypes.DettachCommand)]
+        public JContainer DetachCommand([FromBody]dynamic cmd)
+        {
+            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
+            {
+                logger.Info(CloudStackTypes.DettachCommand + cmd.ToString());
+
+                string details = null;
+                bool result = false;
+
+                try
+                {
+                    string vmName = (string)cmd.vmName;
+                    result = true;
+                }
+                catch (Exception sysEx)
+                {
+                    details = CloudStackTypes.DettachCommand + " failed due to " + sysEx.Message;
+                    logger.Error(details, sysEx);
+                }
+
+                object ansContent = new
+                {
+                    result = result,
+                    details = details
+                };
+
+                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.DettachAnswer);
+            }
+        }
+
+        // POST api/HypervResource/DestroyCommand
+        [HttpPost]
+        [ActionName(CloudStackTypes.DestroyCommand)]
+        public JContainer DestroyCommand([FromBody]dynamic cmd)
+        {
+            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
+            {
+                logger.Info(CloudStackTypes.DestroyCommand + cmd.ToString());
+
+                string details = null;
+                bool result = false;
+
+                try
+                {
+                    // Assert
+                    String errMsg = "No 'volume' details in " + CloudStackTypes.DestroyCommand + " " + cmd.ToString();
+                    if (cmd.volume == null)
+                    {
+                        logger.Error(errMsg);
+                        throw new ArgumentException(errMsg);
+                    }
+
+                    // Assert
+                    errMsg = "No valide path in DestroyCommand in " + CloudStackTypes.DestroyCommand + " " + (String)cmd.ToString();
+                    if (cmd.volume.path == null)
+                    {
+                        logger.Error(errMsg);
+                        throw new ArgumentException(errMsg);
+                    }
+
+                    String path = (string)cmd.volume.path;
+                    if (!File.Exists(path))
+                    {
+                        logger.Info(CloudStackTypes.DestroyCommand + ", but volume at pass already deleted " + path);
+                    }
+
+                    string vmName = (string)cmd.vmName;
+                    if (!string.IsNullOrEmpty(vmName) && File.Exists(path))
+                    {
+                        // Make sure that this resource is removed from the VM
+                        wmiCallsV2.DetachDisk(vmName, path);
+                    }
+
+                    File.Delete(path);
+                    result = true;
+                }
+                catch (Exception sysEx)
+                {
+                    details = CloudStackTypes.DestroyCommand + " failed due to " + sysEx.Message;
+                    logger.Error(details, sysEx);
+                }
+
+                object ansContent = new
+                    {
+                        result = result,
+                        details = details
+                    };
+
+                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.Answer);
+            }
+        }
+
+        private static JArray ReturnCloudStackTypedJArray(object ansContent, string ansType)
+        {
+            JObject ansObj = Utils.CreateCloudStackObject(ansType, ansContent);
+            JArray answer = new JArray(ansObj);
+            logger.Info(ansObj.ToString());
+            return answer;
+        }
+
+        // POST api/HypervResource/CreateCommand
+        [HttpPost]
+        [ActionName(CloudStackTypes.CreateCommand)]
+        public JContainer CreateCommand([FromBody]dynamic cmd)
+        {
+            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
+            {
+                logger.Info(CloudStackTypes.CreateCommand + cmd.ToString());
+
+                string details = null;
+                bool result = false;
+                VolumeInfo volume = new VolumeInfo();
+
+                try
+                {
+                    string diskType = cmd.diskCharacteristics.type;
+                    ulong disksize = cmd.diskCharacteristics.size;
+                    string templateUri = cmd.templateUrl;
+
+                    // assert: valid storagepool?
+                    string poolTypeStr = cmd.pool.type;
+                    string poolLocalPath = cmd.pool.path;
+                    string poolUuid = cmd.pool.uuid;
+                    string newVolPath = null;
+                    long volId = cmd.volId;
+                    string newVolName = null;
+
+                    if (ValidStoragePool(poolTypeStr, poolLocalPath, poolUuid, ref details))
+                    {
+                        // No template URI?  Its a blank disk.
+                        if (string.IsNullOrEmpty(templateUri))
+                        {
+                            // assert
+                            VolumeType volType;
+                            if (!Enum.TryParse<VolumeType>(diskType, out volType) && volType != VolumeType.DATADISK)
+                            {
+                                details = "Cannot create volumes of type " + (string.IsNullOrEmpty(diskType) ? "NULL" : diskType);
+                            }
+                            else
+                            {
+                                newVolName = cmd.diskCharacteristics.name;
+                                newVolPath = Path.Combine(poolLocalPath, newVolName, diskType.ToLower());
+                                // TODO: make volume format and block size configurable
+                                wmiCallsV2.CreateDynamicVirtualHardDisk(disksize, newVolPath);
+                                if (File.Exists(newVolPath))
+                                {
+                                    result = true;
+                                }
+                                else
+                                {
+                                    details = "Failed to create DATADISK with name " + newVolName;
+                                }
+                            }
+                        }
+                        else
+                        {
+                            // TODO:  Does this always work, or do I need to download template at times?
+                            if (templateUri.Contains("/") || templateUri.Contains("\\"))
+                            {
+                                details = "Problem with templateURL " + templateUri +
+                                                " the URL should be volume UUID in primary storage created by previous PrimaryStorageDownloadCommand";
+                                logger.Error(details);
+                            }
+                            else
+                            {
+                                logger.Debug("Template's name in primary store should be " + templateUri);
+                                //            HypervPhysicalDisk BaseVol = primaryPool.getPhysicalDisk(tmplturl);
+                                FileInfo srcFileInfo = new FileInfo(templateUri);
+                                newVolName = Guid.NewGuid() + srcFileInfo.Extension;
+                                newVolPath = Path.Combine(poolLocalPath, newVolName);
+                                logger.Debug("New volume will be at " + newVolPath);
+                                string oldVolPath = Path.Combine(poolLocalPath, templateUri);
+                                File.Copy(oldVolPath, newVolPath);
+                                if (File.Exists(newVolPath))
+                                {
+                                    result = true;
+                                }
+                                else
+                                {
+                                    details = "Failed to create DATADISK with name " + newVolName;
+                                }
+                            }
+                            volume = new VolumeInfo(
+                                      volId, diskType,
+                                    poolTypeStr, poolUuid, newVolName,
+                                    newVolPath, newVolPath, (long)disksize, null);
+                        }
+                    }
+                }
+                catch (Exception sysEx)
+                {
+                    // TODO: consider this as model for error processing in all commands
+                    details = CloudStackTypes.CreateCommand + " failed due to " + sysEx.Message;
+                    logger.Error(details, sysEx);
+                }
+
+                object ansContent = new
+                {
+                    result = result,
+                    details = details,
+                    volume = volume
+                };
+                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CreateAnswer);
+            }
+        }
+
+        // POST api/HypervResource/PrimaryStorageDownloadCommand
+        [HttpPost]
+        [ActionName(CloudStackTypes.PrimaryStorageDownloadCommand)]
+        public JContainer PrimaryStorageDownloadCommand([FromBody]dynamic cmd)
+        {
+            using (log4net.NDC.Push(Guid.NewGuid().ToString()))
+            {
+                logger.Info(CloudStackTypes.PrimaryStorageDownloadCommand + cmd.ToString());
+                string details = null;
+                bool result = false;
+                long size = 0;
+                string newCopyFileName = null;
+
+                string poolLocalPath = cmd.localPath;
+                string poolUuid = cmd.poolUuid;
+                if (!Directory.Exists(poolLocalPath))
+                {
+                    details = "None existent local path " + poolLocalPath;
+                }
+                else
+                {
+                    // Compose name for downloaded file.
+                    string sourceUrl = cmd.url;
+                    if (sourceUrl.ToLower().EndsWith(".vhd"))
+                    {
+                        newCopyFileName = Guid.NewGuid() + ".vhd";
+                    }
+                    if (sourceUrl.ToLower().EndsWith(".vhdx"))
+                    {
+                        newCopyFileName = Guid.NewGuid() + ".vhdx";
+                    }
+
+                    // assert
+                    if (newCopyFileName == null)
+                    {
+                        details = CloudStackTypes.PrimaryStorageDownloadCommand + " Invalid file extension for hypervisor type in source URL " + sourceUrl;
+                        logger.Error(details);
+                    }
+                    else
+                    {
+                        try
+                        {
+                            FileInfo newFile;
+                            if (CopyURI(sourceUrl, newCopyFileName, poolLocalPath, out newFile, ref details))
+                            {
+                                size = newFile.Length;
+                                result = true;
+                            }
+                        }
+                        catch (System.Exception ex)
+                        {
+                            details = CloudStackTypes.PrimaryStorageDownloadCommand + " Cannot download source URL " + sourceUrl + " due to " + ex.Message;
+                            logger.Error(details, ex);
+                        }
+                    }
+                }
+
+                object ansContent = new
+                {
+                    result = result,
+                    details = details,
+                    templateSize = size,
+                    installPath = newCopyFileName
+                };
+                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.PrimaryStorageDownloadAnswer);
+            }
+        }
+
+        private static bool ValidStoragePool(string poolTypeStr, string poolLocalPath, string poolUuid, ref string details)
+        {
+            StoragePoolType poolType;
+            if (!Enum.TryParse<StoragePoolType>(poolTypeStr, out poolType) || poolType != StoragePoolType.Filesystem)
+            {
+                details = "Primary storage pool " + poolUuid + " type " + poolType + " local path " + poolLocalPath + " has invalid StoragePoolType";
+                logger.Error(details);
+                return false;
+            }
+            else if (!Directory.Exists(poolLocalPath))
+            {
+                details = "Primary storage pool " + poolUuid + " type " + poolType + " local path " + poolLocalPath + " has invalid local path";
+                logger.Error(details);
+                return false;
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// Exceptions to watch out for:
+        /// Exceptions related to URI creation
+        /// System.SystemException
+        /// +-System.ArgumentNullException
+        /// +-System.FormatException
+        ///   +-System.UriFormatException
+        ///
+        /// Exceptions related to NFS URIs
+        /// System.SystemException
+        /// +-System.NotSupportedException
+        /// +-System.ArgumentException
+        /// +-System.ArgumentNullException
+        ///   +-System.Security.SecurityException;
+        /// +-System.UnauthorizedAccessException
+        /// +-System.IO.IOException
+        ///   +-System.IO.PathTooLongException
+        ///   
+        /// Exceptions related to HTTP U

<TRUNCATED>

[11/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_LANEndpoint.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_LANEndpoint.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_LANEndpoint.cs
new file mode 100755
index 0000000..eb660b4
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_LANEndpoint.cs
@@ -0,0 +1,1405 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
+    // An Early Bound class generated for the WMI class.Msvm_LANEndpoint
+    public class LANEndpoint : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_LANEndpoint";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public LANEndpoint() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public LANEndpoint(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(null, new System.Management.ManagementPath(LANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public LANEndpoint(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(LANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public LANEndpoint(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public LANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public LANEndpoint(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public LANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public LANEndpoint(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public LANEndpoint(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] AliasAddresses {
+            get {
+                return ((string[])(curObj["AliasAddresses"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] AvailableRequestedStates {
+            get {
+                return ((ushort[])(curObj["AvailableRequestedStates"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCommunicationStatusNull {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort CommunicationStatus {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["CommunicationStatus"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConnectedNull {
+            get {
+                if ((curObj["Connected"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("This property is set to TRUE if the LAN endpoint is connected to a switch port.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool Connected {
+            get {
+                if ((curObj["Connected"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["Connected"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string CreationClassName {
+            get {
+                return ((string)(curObj["CreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDetailedStatusNull {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DetailedStatus {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DetailedStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledDefaultNull {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledDefault {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledDefault"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledState {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] GroupAddresses {
+            get {
+                return ((string[])(curObj["GroupAddresses"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHealthStateNull {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HealthState {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HealthState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInstallDateNull {
+            get {
+                if ((curObj["InstallDate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime InstallDate {
+            get {
+                if ((curObj["InstallDate"] != null)) {
+                    return ToDateTime(((string)(curObj["InstallDate"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string LANID {
+            get {
+                return ((string)(curObj["LANID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLANTypeNull {
+            get {
+                if ((curObj["LANType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort LANType {
+            get {
+                if ((curObj["LANType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["LANType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string MACAddress {
+            get {
+                return ((string)(curObj["MACAddress"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxDataSizeNull {
+            get {
+                if ((curObj["MaxDataSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint MaxDataSize {
+            get {
+                if ((curObj["MaxDataSize"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["MaxDataSize"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string NameFormat {
+            get {
+                return ((string)(curObj["NameFormat"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOperatingStatusNull {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort OperatingStatus {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["OperatingStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] OperationalStatus {
+            get {
+                return ((ushort[])(curObj["OperationalStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherEnabledState {
+            get {
+                return ((string)(curObj["OtherEnabledState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherLANType {
+            get {
+                return ((string)(curObj["OtherLANType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherTypeDescription {
+            get {
+                return ((string)(curObj["OtherTypeDescription"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPrimaryStatusNull {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PrimaryStatus {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PrimaryStatus"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsProtocolIFTypeNull {
+            get {
+                if ((curObj["ProtocolIFType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ProtocolIFType {
+            get {
+                if ((curObj["ProtocolIFType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ProtocolIFType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsProtocolTypeNull {
+            get {
+                if ((curObj["ProtocolType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ProtocolType {
+            get {
+                if ((curObj["ProtocolType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ProtocolType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRequestedStateNull {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort RequestedState {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["RequestedState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Status {
+            get {
+                return ((string)(curObj["Status"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] StatusDescriptions {
+            get {
+                return ((string[])(curObj["StatusDescriptions"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemCreationClassName {
+            get {
+                return ((string)(curObj["SystemCreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemName {
+            get {
+                return ((string)(curObj["SystemName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimeOfLastStateChangeNull {
+            get {
+                if ((curObj["TimeOfLastStateChange"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime TimeOfLastStateChange {
+            get {
+                if ((curObj["TimeOfLastStateChange"] != null)) {
+                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTransitioningToStateNull {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort TransitioningToState {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["TransitioningToState"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCommunicationStatus() {
+            if ((this.IsCommunicationStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConnected() {
+            if ((this.IsConnectedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDetailedStatus() {
+            if ((this.IsDetailedStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledDefault() {
+            if ((this.IsEnabledDefaultNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledState() {
+            if ((this.IsEnabledStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHealthState() {
+            if ((this.IsHealthStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        // Converts a given datetime in DMTF format to System.DateTime object.
+        static System.DateTime ToDateTime(string dmtfDate) {
+            System.DateTime initializer = System.DateTime.MinValue;
+            int year = initializer.Year;
+            int month = initializer.Month;
+            int day = initializer.Day;
+            int hour = initializer.Hour;
+            int minute = initializer.Minute;
+            int second = initializer.Second;
+            long ticks = 0;
+            string dmtf = dmtfDate;
+            System.DateTime datetime = System.DateTime.MinValue;
+            string tempString = string.Empty;
+            if ((dmtf == null)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length == 0)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length != 25)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            try {
+                tempString = dmtf.Substring(0, 4);
+                if (("****" != tempString)) {
+                    year = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(4, 2);
+                if (("**" != tempString)) {
+                    month = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(6, 2);
+                if (("**" != tempString)) {
+                    day = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(8, 2);
+                if (("**" != tempString)) {
+                    hour = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(10, 2);
+                if (("**" != tempString)) {
+                    minute = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(12, 2);
+                if (("**" != tempString)) {
+                    second = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(15, 6);
+                if (("******" != tempString)) {
+                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
+                }
+                if (((((((((year < 0) 
+                            || (month < 0)) 
+                            || (day < 0)) 
+                            || (hour < 0)) 
+                            || (minute < 0)) 
+                            || (minute < 0)) 
+                            || (second < 0)) 
+                            || (ticks < 0))) {
+                    throw new System.ArgumentOutOfRangeException();
+                }
+            }
+            catch (System.Exception e) {
+                throw new System.ArgumentOutOfRangeException(null, e.Message);
+            }
+            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
+            datetime = datetime.AddTicks(ticks);
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
+            int UTCOffset = 0;
+            int OffsetToBeAdjusted = 0;
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            tempString = dmtf.Substring(22, 3);
+            if ((tempString != "******")) {
+                tempString = dmtf.Substring(21, 4);
+                try {
+                    UTCOffset = int.Parse(tempString);
+                }
+                catch (System.Exception e) {
+                    throw new System.ArgumentOutOfRangeException(null, e.Message);
+                }
+                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
+                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
+            }
+            return datetime;
+        }
+        
+        // Converts a given System.DateTime object to DMTF datetime format.
+        static string ToDmtfDateTime(System.DateTime date) {
+            string utcString = string.Empty;
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            if ((System.Math.Abs(OffsetMins) > 999)) {
+                date = date.ToUniversalTime();
+                utcString = "+000";
+            }
+            else {
+                if ((tickOffset.Ticks >= 0)) {
+                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
+                }
+                else {
+                    string strTemp = ((long)(OffsetMins)).ToString();
+                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
+                }
+            }
+            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ".");
+            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
+            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
+                        * 1000) 
+                        / System.TimeSpan.TicksPerMillisecond)));
+            string strMicrosec = ((long)(microsec)).ToString();
+            if ((strMicrosec.Length > 6)) {
+                strMicrosec = strMicrosec.Substring(0, 6);
+            }
+            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
+            return dmtfDateTime;
+        }
+        
+        private bool ShouldSerializeInstallDate() {
+            if ((this.IsInstallDateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLANType() {
+            if ((this.IsLANTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxDataSize() {
+            if ((this.IsMaxDataSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOperatingStatus() {
+            if ((this.IsOperatingStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePrimaryStatus() {
+            if ((this.IsPrimaryStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeProtocolIFType() {
+            if ((this.IsProtocolIFTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeProtocolType() {
+            if ((this.IsProtocolTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRequestedState() {
+            if ((this.IsRequestedStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimeOfLastStateChange() {
+            if ((this.IsTimeOfLastStateChangeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTransitioningToState() {
+            if ((this.IsTransitioningToStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_LANEndpoint";
+            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static LANEndpointCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static LANEndpointCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static LANEndpointCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static LANEndpointCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_LANEndpoint";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new LANEndpointCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_LANEndpoint", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new LANEndpointCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static LANEndpoint CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new LANEndpoint(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
+                inParams["RequestedState"] = ((ushort)(RequestedState));
+                inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class LANEndpointCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public LANEndpointCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new LANEndpoint(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new LANEndpointEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class LANEndpointEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public LANEndpointEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new LANEndpoint(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[22/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitch.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitch.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitch.cs
deleted file mode 100644
index 4d56445..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitch.cs
+++ /dev/null
@@ -1,1305 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_VirtualSwitch
-    public class VirtualSwitch : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_VirtualSwitch";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VirtualSwitch() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VirtualSwitch(string keyCreationClassName, string keyName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSwitch.ConstructPath(keyCreationClassName, keyName)), null);
-        }
-        
-        public VirtualSwitch(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSwitch.ConstructPath(keyCreationClassName, keyName)), null);
-        }
-        
-        public VirtualSwitch(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VirtualSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VirtualSwitch(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VirtualSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VirtualSwitch(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VirtualSwitch(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] Dedicated {
-            get {
-                return ((ushort[])(curObj["Dedicated"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] IdentifyingDescriptions {
-            get {
-                return ((string[])(curObj["IdentifyingDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxChimneyOffloadsNull {
-            get {
-                if ((curObj["MaxChimneyOffloads"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The maximum number of Chimney offloads allowed for a port on this switch.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint MaxChimneyOffloads {
-            get {
-                if ((curObj["MaxChimneyOffloads"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["MaxChimneyOffloads"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxVMQOffloadsNull {
-            get {
-                if ((curObj["MaxVMQOffloads"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The maximum number of VM queue (VMQ) offloads allowed for a port on this switch.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint MaxVMQOffloads {
-            get {
-                if ((curObj["MaxVMQOffloads"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["MaxVMQOffloads"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string NameFormat {
-            get {
-                return ((string)(curObj["NameFormat"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsNumLearnableAddressesNull {
-            get {
-                if ((curObj["NumLearnableAddresses"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The number of learnable addresses for this switch.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint NumLearnableAddresses {
-            get {
-                if ((curObj["NumLearnableAddresses"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["NumLearnableAddresses"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherDedicatedDescriptions {
-            get {
-                return ((string[])(curObj["OtherDedicatedDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherIdentifyingInfo {
-            get {
-                return ((string[])(curObj["OtherIdentifyingInfo"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] PowerManagementCapabilities {
-            get {
-                return ((ushort[])(curObj["PowerManagementCapabilities"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerContact {
-            get {
-                return ((string)(curObj["PrimaryOwnerContact"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerName {
-            get {
-                return ((string)(curObj["PrimaryOwnerName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsResetCapabilityNull {
-            get {
-                if ((curObj["ResetCapability"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ResetCapability {
-            get {
-                if ((curObj["ResetCapability"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ResetCapability"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] Roles {
-            get {
-                return ((string[])(curObj["Roles"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The authorization manager scope for the switch service.")]
-        public string ScopeOfResidence {
-            get {
-                return ((string)(curObj["ScopeOfResidence"]));
-            }
-            set {
-                curObj["ScopeOfResidence"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxChimneyOffloads() {
-            if ((this.IsMaxChimneyOffloadsNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxVMQOffloads() {
-            if ((this.IsMaxVMQOffloadsNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeNumLearnableAddresses() {
-            if ((this.IsNumLearnableAddressesNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeResetCapability() {
-            if ((this.IsResetCapabilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetScopeOfResidence() {
-            curObj["ScopeOfResidence"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName) {
-            string strPath = "ROOT\\virtualization:Msvm_VirtualSwitch";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VirtualSwitchCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VirtualSwitchCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VirtualSwitchCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VirtualSwitchCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VirtualSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VirtualSwitch";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VirtualSwitchCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VirtualSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VirtualSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VirtualSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSwitch", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VirtualSwitchCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VirtualSwitch CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VirtualSwitch(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SetPowerState(uint PowerState, System.DateTime Time) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState");
-                inParams["PowerState"] = ((uint)(PowerState));
-                inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VirtualSwitchCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VirtualSwitchCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VirtualSwitch(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VirtualSwitchEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VirtualSwitchEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VirtualSwitchEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VirtualSwitch(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[10/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MemorySettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MemorySettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MemorySettingData.cs
new file mode 100755
index 0000000..378fc8a
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MemorySettingData.cs
@@ -0,0 +1,1146 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_MemorySettingData
+    public class MemorySettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_MemorySettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public MemorySettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public MemorySettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(MemorySettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public MemorySettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(MemorySettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public MemorySettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public MemorySettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public MemorySettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public MemorySettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public MemorySettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public MemorySettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Address {
+            get {
+                return ((string)(curObj["Address"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AddressOnParent {
+            get {
+                return ((string)(curObj["AddressOnParent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AllocationUnits {
+            get {
+                return ((string)(curObj["AllocationUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticAllocationNull {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticAllocation {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticAllocation"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticDeallocationNull {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticDeallocation {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticDeallocation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] Connection {
+            get {
+                return ((string[])(curObj["Connection"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConsumerVisibilityNull {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ConsumerVisibility {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ConsumerVisibility"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDynamicMemoryEnabledNull {
+            get {
+                if ((curObj["DynamicMemoryEnabled"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates if dynamic memory is enabled.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool DynamicMemoryEnabled {
+            get {
+                if ((curObj["DynamicMemoryEnabled"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["DynamicMemoryEnabled"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] HostResource {
+            get {
+                return ((string[])(curObj["HostResource"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsIsVirtualizedNull {
+            get {
+                if ((curObj["IsVirtualized"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Indicates whether this device is virtualized or passed through, possibly using partitioning. When set to False, the underlying or host resource is utilized. At least one item shall be present in the DeviceID property. When set to True, the resource is virtualized and may not map directly to an underlying/host resource. Some implementations may support specific assignment for virtualized resources, in which case the host resource(s) are exposed using the DeviceID property. This property is always set to True.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool IsVirtualized {
+            get {
+                if ((curObj["IsVirtualized"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["IsVirtualized"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLimitNull {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Limit {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Limit"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMappingBehaviorNull {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort MappingBehavior {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["MappingBehavior"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxMemoryBlocksPerNumaNodeNull {
+            get {
+                if ((curObj["MaxMemoryBlocksPerNumaNode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum amount of memory that can be observed within the VM as belonging to a" +
+            " single NUMA node.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxMemoryBlocksPerNumaNode {
+            get {
+                if ((curObj["MaxMemoryBlocksPerNumaNode"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxMemoryBlocksPerNumaNode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherResourceType {
+            get {
+                return ((string)(curObj["OtherResourceType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Parent {
+            get {
+                return ((string)(curObj["Parent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PoolID {
+            get {
+                return ((string)(curObj["PoolID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReservationNull {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Reservation {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Reservation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ResourceSubType {
+            get {
+                return ((string)(curObj["ResourceSubType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsResourceTypeNull {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ResourceType {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ResourceType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSwapFilesInUseNull {
+            get {
+                if ((curObj["SwapFilesInUse"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates if smart paging is active.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool SwapFilesInUse {
+            get {
+                if ((curObj["SwapFilesInUse"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["SwapFilesInUse"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTargetMemoryBufferNull {
+            get {
+                if ((curObj["TargetMemoryBuffer"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint TargetMemoryBuffer {
+            get {
+                if ((curObj["TargetMemoryBuffer"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["TargetMemoryBuffer"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVirtualQuantityNull {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong VirtualQuantity {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["VirtualQuantity"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string VirtualQuantityUnits {
+            get {
+                return ((string)(curObj["VirtualQuantityUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsWeightNull {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint Weight {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["Weight"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticAllocation() {
+            if ((this.IsAutomaticAllocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticDeallocation() {
+            if ((this.IsAutomaticDeallocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConsumerVisibility() {
+            if ((this.IsConsumerVisibilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDynamicMemoryEnabled() {
+            if ((this.IsDynamicMemoryEnabledNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeIsVirtualized() {
+            if ((this.IsIsVirtualizedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLimit() {
+            if ((this.IsLimitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMappingBehavior() {
+            if ((this.IsMappingBehaviorNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxMemoryBlocksPerNumaNode() {
+            if ((this.IsMaxMemoryBlocksPerNumaNodeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeReservation() {
+            if ((this.IsReservationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeResourceType() {
+            if ((this.IsResourceTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSwapFilesInUse() {
+            if ((this.IsSwapFilesInUseNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTargetMemoryBuffer() {
+            if ((this.IsTargetMemoryBufferNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVirtualQuantity() {
+            if ((this.IsVirtualQuantityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeWeight() {
+            if ((this.IsWeightNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_MemorySettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static MemorySettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static MemorySettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static MemorySettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static MemorySettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_MemorySettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new MemorySettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_MemorySettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new MemorySettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static MemorySettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new MemorySettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class MemorySettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public MemorySettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new MemorySettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new MemorySettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class MemorySettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public MemorySettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new MemorySettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[28/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchLANEndpoint.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchLANEndpoint.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchLANEndpoint.cs
deleted file mode 100644
index 75d20ca..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchLANEndpoint.cs
+++ /dev/null
@@ -1,1342 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_SwitchLANEndpoint
-    public class SwitchLANEndpoint : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_SwitchLANEndpoint";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public SwitchLANEndpoint() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public SwitchLANEndpoint(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(SwitchLANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public SwitchLANEndpoint(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(SwitchLANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public SwitchLANEndpoint(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public SwitchLANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public SwitchLANEndpoint(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public SwitchLANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public SwitchLANEndpoint(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public SwitchLANEndpoint(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] AliasAddresses {
-            get {
-                return ((string[])(curObj["AliasAddresses"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsBroadcastResetSupportedNull {
-            get {
-                if ((curObj["BroadcastResetSupported"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool BroadcastResetSupported {
-            get {
-                if ((curObj["BroadcastResetSupported"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["BroadcastResetSupported"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsConnectedNull {
-            get {
-                if ((curObj["Connected"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("This property is set to TRUE if the LAN endpoint is connected to a switch port.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool Connected {
-            get {
-                if ((curObj["Connected"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["Connected"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] GroupAddresses {
-            get {
-                return ((string[])(curObj["GroupAddresses"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string LANID {
-            get {
-                return ((string)(curObj["LANID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLANTypeNull {
-            get {
-                if ((curObj["LANType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort LANType {
-            get {
-                if ((curObj["LANType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["LANType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string MACAddress {
-            get {
-                return ((string)(curObj["MACAddress"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxDataSizeNull {
-            get {
-                if ((curObj["MaxDataSize"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint MaxDataSize {
-            get {
-                if ((curObj["MaxDataSize"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["MaxDataSize"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string NameFormat {
-            get {
-                return ((string)(curObj["NameFormat"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherLANType {
-            get {
-                return ((string)(curObj["OtherLANType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherTypeDescription {
-            get {
-                return ((string)(curObj["OtherTypeDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolIFTypeNull {
-            get {
-                if ((curObj["ProtocolIFType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolIFType {
-            get {
-                if ((curObj["ProtocolIFType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolIFType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolTypeNull {
-            get {
-                if ((curObj["ProtocolType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolType {
-            get {
-                if ((curObj["ProtocolType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeBroadcastResetSupported() {
-            if ((this.IsBroadcastResetSupportedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeConnected() {
-            if ((this.IsConnectedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLANType() {
-            if ((this.IsLANTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxDataSize() {
-            if ((this.IsMaxDataSizeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProtocolIFType() {
-            if ((this.IsProtocolIFTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProtocolType() {
-            if ((this.IsProtocolTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_SwitchLANEndpoint";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static SwitchLANEndpointCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static SwitchLANEndpointCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static SwitchLANEndpointCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static SwitchLANEndpointCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static SwitchLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_SwitchLANEndpoint";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new SwitchLANEndpointCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static SwitchLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static SwitchLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static SwitchLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SwitchLANEndpoint", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new SwitchLANEndpointCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static SwitchLANEndpoint CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new SwitchLANEndpoint(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint BroadcastReset() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("BroadcastReset", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class SwitchLANEndpointCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public SwitchLANEndpointCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new SwitchLANEndpoint(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new SwitchLANEndpointEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class SwitchLANEndpointEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public SwitchLANEndpointEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new SwitchLANEndpoint(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[31/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ProcessorSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ProcessorSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ProcessorSettingData.cs
deleted file mode 100644
index 1b22931..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ProcessorSettingData.cs
+++ /dev/null
@@ -1,1190 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // An Early Bound class generated for the WMI class.Msvm_ProcessorSettingData
-    public class ProcessorSettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_ProcessorSettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public ProcessorSettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public ProcessorSettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(ProcessorSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public ProcessorSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ProcessorSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public ProcessorSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public ProcessorSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public ProcessorSettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public ProcessorSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public ProcessorSettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public ProcessorSettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Address {
-            get {
-                return ((string)(curObj["Address"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string AllocationUnits {
-            get {
-                return ((string)(curObj["AllocationUnits"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticAllocationNull {
-            get {
-                if ((curObj["AutomaticAllocation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutomaticAllocation {
-            get {
-                if ((curObj["AutomaticAllocation"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutomaticAllocation"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticDeallocationNull {
-            get {
-                if ((curObj["AutomaticDeallocation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutomaticDeallocation {
-            get {
-                if ((curObj["AutomaticDeallocation"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutomaticDeallocation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] Connection {
-            get {
-                return ((string[])(curObj["Connection"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsConsumerVisibilityNull {
-            get {
-                if ((curObj["ConsumerVisibility"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ConsumerVisibility {
-            get {
-                if ((curObj["ConsumerVisibility"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ConsumerVisibility"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Address or other identifying information to uniquely name the logical device.\n Th" +
-            "is property is always set to \"Microsoft:GUID\".")]
-        public string DeviceID {
-            get {
-                return ((string)(curObj["DeviceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The format of the corresponding device ID, or the supported device IDs when used " +
-            "to represent a capability.\nThis property is not used.")]
-        public string DeviceIDFormat {
-            get {
-                return ((string)(curObj["DeviceIDFormat"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] HostResource {
-            get {
-                return ((string[])(curObj["HostResource"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsIsVirtualizedNull {
-            get {
-                if ((curObj["IsVirtualized"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Indicates whether this device is virtualized or passed through, possibly using partitioning. When set to False, the underlying or host resource is utilized. At least one item shall be present in the DeviceID property. When set to True, the resource is virtualized and may not map directly to an underlying/host resource. Some implementations may support specific assignment for virtualized resources, in which case the host resource(s) are exposed using the DeviceID property. This property is set to True.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool IsVirtualized {
-            get {
-                if ((curObj["IsVirtualized"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["IsVirtualized"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLimitNull {
-            get {
-                if ((curObj["Limit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Limit {
-            get {
-                if ((curObj["Limit"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Limit"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLimitCPUIDNull {
-            get {
-                if ((curObj["LimitCPUID"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Indicates whether the virtual machine should lower the CPU identifier. Some older operating systems may require you to limit processor functionality in this way in order to run.
-This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool LimitCPUID {
-            get {
-                if ((curObj["LimitCPUID"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["LimitCPUID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLimitProcessorFeaturesNull {
-            get {
-                if ((curObj["LimitProcessorFeatures"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Indicates whether the VM should limit the CPU features exposed to the operating system. Limiting the processor features enables the VM to be migrated to different host computer systems with different processors. Migrating VMs between computers with processors from different vendors is not supported.
-Windows Server 2008:  The LimitProcessorFeatures property is not supported until Windows Server 2008 R2.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool LimitProcessorFeatures {
-            get {
-                if ((curObj["LimitProcessorFeatures"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["LimitProcessorFeatures"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMappingBehaviorNull {
-            get {
-                if ((curObj["MappingBehavior"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort MappingBehavior {
-            get {
-                if ((curObj["MappingBehavior"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["MappingBehavior"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherResourceType {
-            get {
-                return ((string)(curObj["OtherResourceType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Parent {
-            get {
-                return ((string)(curObj["Parent"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PoolID {
-            get {
-                return ((string)(curObj["PoolID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProcessorsPerSocketNull {
-            get {
-                if ((curObj["ProcessorsPerSocket"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The number of processors, or cores, configured for each socket in the virtual sys" +
-            "tem.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProcessorsPerSocket {
-            get {
-                if ((curObj["ProcessorsPerSocket"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProcessorsPerSocket"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsReservationNull {
-            get {
-                if ((curObj["Reservation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Reservation {
-            get {
-                if ((curObj["Reservation"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Reservation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ResourceSubType {
-            get {
-                return ((string)(curObj["ResourceSubType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsResourceTypeNull {
-            get {
-                if ((curObj["ResourceType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ResourceType {
-            get {
-                if ((curObj["ResourceType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ResourceType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsSocketCountNull {
-            get {
-                if ((curObj["SocketCount"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The number of processor sockets in the virtual machine. The total number of proce" +
-            "ssors is the value of this property times the value of the ProcessorsPerSocket p" +
-            "roperty.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort SocketCount {
-            get {
-                if ((curObj["SocketCount"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["SocketCount"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsThreadsEnabledNull {
-            get {
-                if ((curObj["ThreadsEnabled"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Indicates whether hardware threads should be visible to the virtual system. If th" +
-            "e physical processor does not support hardware threads, this value has no effect" +
-            " in the virtual system.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool ThreadsEnabled {
-            get {
-                if ((curObj["ThreadsEnabled"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["ThreadsEnabled"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVirtualQuantityNull {
-            get {
-                if ((curObj["VirtualQuantity"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong VirtualQuantity {
-            get {
-                if ((curObj["VirtualQuantity"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["VirtualQuantity"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsWeightNull {
-            get {
-                if ((curObj["Weight"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint Weight {
-            get {
-                if ((curObj["Weight"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["Weight"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticAllocation() {
-            if ((this.IsAutomaticAllocationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticDeallocation() {
-            if ((this.IsAutomaticDeallocationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeConsumerVisibility() {
-            if ((this.IsConsumerVisibilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeIsVirtualized() {
-            if ((this.IsIsVirtualizedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLimit() {
-            if ((this.IsLimitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLimitCPUID() {
-            if ((this.IsLimitCPUIDNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLimitProcessorFeatures() {
-            if ((this.IsLimitProcessorFeaturesNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMappingBehavior() {
-            if ((this.IsMappingBehaviorNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProcessorsPerSocket() {
-            if ((this.IsProcessorsPerSocketNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeReservation() {
-            if ((this.IsReservationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeResourceType() {
-            if ((this.IsResourceTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeSocketCount() {
-            if ((this.IsSocketCountNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeThreadsEnabled() {
-            if ((this.IsThreadsEnabledNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeVirtualQuantity() {
-            if ((this.IsVirtualQuantityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeWeight() {
-            if ((this.IsWeightNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_ProcessorSettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static ProcessorSettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static ProcessorSettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static ProcessorSettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static ProcessorSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_ProcessorSettingData";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new ProcessorSettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ProcessorSettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new ProcessorSettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static ProcessorSettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new ProcessorSettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class ProcessorSettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public ProcessorSettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new ProcessorSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new ProcessorSettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class ProcessorSettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public ProcessorSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new ProcessorSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[07/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SummaryInformation.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SummaryInformation.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SummaryInformation.cs
new file mode 100755
index 0000000..1a3a21a
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SummaryInformation.cs
@@ -0,0 +1,1520 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
+    // 
+    // 
+    // 
+    // 
+    // If the embedded property is strongly typed then, to strongly type the property to the type of
+    // the embedded object, you have to do the following things.
+    // 	1. Generate Managed class for the WMI class of the embedded property. This can be done with MgmtClassGen.exe tool or from Server Explorer.
+    // 	2. Include the namespace of the generated class.
+    // 	3. Change the property get/set functions so as return the instance of the Managed class.
+    // Below is a sample code.
+    // 
+    // VB Code
+    // 
+    // 
+    // 
+    // Property name
+    // Managed class name of Embedded Property
+    // 
+    // 
+    // 
+    // 
+    // 
+    // 
+    // C# Code
+    // 
+    // 
+    // 
+    // Managed class name of Embedded property
+    // Property name
+    // 
+    // 
+    // 
+    // 
+    // 
+    // 
+    // 
+    // 
+    // 
+    // 
+    // An Early Bound class generated for the WMI class.Msvm_SummaryInformation
+    public class SummaryInformation : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Msvm_SummaryInformation";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public SummaryInformation() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public SummaryInformation(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public SummaryInformation(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public SummaryInformation(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public SummaryInformation(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public SummaryInformation(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public SummaryInformation(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The identifier of the physical graphics processing unit (GPU) allocated to this v" +
+            "irtual machine (VM). This property only applies to VMs that use RemoteFX.")]
+        public string AllocatedGPU {
+            get {
+                return ((string)(curObj["AllocatedGPU"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsApplicationHealthNull {
+            get {
+                if ((curObj["ApplicationHealth"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The current application health status for the virtual system. This property may be one of the following values: ""OK""; ""Application Critical""; ""Disabled"".For more information, see the documentation for the StatusDescriptions property of the Msvm_HeartbeatComponent class. This property is not valid for instances of Msvm_SummaryInformation representing a virtual system snapshot.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ApplicationHealthValues ApplicationHealth {
+            get {
+                if ((curObj["ApplicationHealth"] == null)) {
+                    return ((ApplicationHealthValues)(System.Convert.ToInt32(0)));
+                }
+                return ((ApplicationHealthValues)(System.Convert.ToInt32(curObj["ApplicationHealth"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("An array of Msvm_ConcreteJob instances representing any asynchronous operations r" +
+            "elated to the virtual system which are currently executing. This property is not" +
+            " valid for instances of Msvm_SummaryInformation representing a virtual system sn" +
+            "apshot.")]
+        public System.Management.ManagementBaseObject[] AsynchronousTasks {
+            get {
+                return ((System.Management.ManagementBaseObject[])(curObj["AsynchronousTasks"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAvailableMemoryBufferNull {
+            get {
+                if ((curObj["AvailableMemoryBuffer"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The available memory buffer percentage in the virtual system.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public int AvailableMemoryBuffer {
+            get {
+                if ((curObj["AvailableMemoryBuffer"] == null)) {
+                    return System.Convert.ToInt32(0);
+                }
+                return ((int)(curObj["AvailableMemoryBuffer"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCreationTimeNull {
+            get {
+                if ((curObj["CreationTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The time at which the virtual system or snapshot was created.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime CreationTime {
+            get {
+                if ((curObj["CreationTime"] != null)) {
+                    return ToDateTime(((string)(curObj["CreationTime"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The friendly name for the virtual system or snapshot.")]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The current state of the virtual system or snapshot.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledState {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The name of the guest operating system, if available. If this information is not " +
+            "available, the value of this property is NULL. This property is not valid for in" +
+            "stances of Msvm_SummaryInformation representing a virtual system snapshot.")]
+        public string GuestOperatingSystem {
+            get {
+                return ((string)(curObj["GuestOperatingSystem"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHealthStateNull {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The current health state for the virtual system. This property is not valid for i" +
+            "nstances of Msvm_SummaryInformation representing a virtual system snapshot.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HealthState {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HealthState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHeartbeatNull {
+            get {
+                if ((curObj["Heartbeat"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The current heartbeat status for the virtual system. This property may be one of the following values: ""OK""; ""Error""; ""No Contact""; or ""Lost Communication"". For more information, see the documentation for the StatusDescriptions property of the Msvm_HeartbeatComponent class. This property is not valid for instances of Msvm_SummaryInformation representing a virtual system snapshot.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort Heartbeat {
+            get {
+                if ((curObj["Heartbeat"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["Heartbeat"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsIntegrationServicesVersionStateNull {
+            get {
+                if ((curObj["IntegrationServicesVersionState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Whether or not the integration services installed in the virtual machine are up t" +
+            "o date")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public IntegrationServicesVersionStateValues IntegrationServicesVersionState {
+            get {
+                if ((curObj["IntegrationServicesVersionState"] == null)) {
+                    return ((IntegrationServicesVersionStateValues)(System.Convert.ToInt32(3)));
+                }
+                return ((IntegrationServicesVersionStateValues)(System.Convert.ToInt32(curObj["IntegrationServicesVersionState"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMemoryAvailableNull {
+            get {
+                if ((curObj["MemoryAvailable"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The memory available percentage in the virtual system.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public int MemoryAvailable {
+            get {
+                if ((curObj["MemoryAvailable"] == null)) {
+                    return System.Convert.ToInt32(0);
+                }
+                return ((int)(curObj["MemoryAvailable"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMemorySpansPhysicalNumaNodesNull {
+            get {
+                if ((curObj["MemorySpansPhysicalNumaNodes"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates whether or not the memory of the one or more of the virtual non-uniform" +
+            " memory access (NUMA) nodes of the virtual machine spans multiple physical NUMA " +
+            "nodes of the hosting computer system.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool MemorySpansPhysicalNumaNodes {
+            get {
+                if ((curObj["MemorySpansPhysicalNumaNodes"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["MemorySpansPhysicalNumaNodes"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMemoryUsageNull {
+            get {
+                if ((curObj["MemoryUsage"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The current memory usage of the virtual system. This property is not valid for in" +
+            "stances of Msvm_SummaryInformation representing a virtual system snapshot.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MemoryUsage {
+            get {
+                if ((curObj["MemoryUsage"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MemoryUsage"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The unique name for the virtual system or snapshot.")]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The notes associated with the virtual system or snapshot.")]
+        public string Notes {
+            get {
+                return ((string)(curObj["Notes"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNumberOfProcessorsNull {
+            get {
+                if ((curObj["NumberOfProcessors"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The total number of virtual processors allocated to the virtual system or snapsho" +
+            "t.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort NumberOfProcessors {
+            get {
+                if ((curObj["NumberOfProcessors"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["NumberOfProcessors"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The current status of the element.")]
+        public ushort[] OperationalStatus {
+            get {
+                return ((ushort[])(curObj["OperationalStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("A string that describes the enabled or disabled state of the element when the Ena" +
+            "bledState property is set to 1 (\"Other\"). This property must be set to null when" +
+            " EnabledState is any value other than 1.")]
+        public string OtherEnabledState {
+            get {
+                return ((string)(curObj["OtherEnabledState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsProcessorLoadNull {
+            get {
+                if ((curObj["ProcessorLoad"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The current processor usage of the virtual system. This property is not valid for" +
+            " instances of Msvm_SummaryInformation representing a virtual system snapshot.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ProcessorLoad {
+            get {
+                if ((curObj["ProcessorLoad"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ProcessorLoad"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("An array of the previous 100 samples of the processor usage for the virtual syste" +
+            "m. This property is not valid for instances of Msvm_SummaryInformation represent" +
+            "ing a virtual system snapshot.")]
+        public ushort[] ProcessorLoadHistory {
+            get {
+                return ((ushort[])(curObj["ProcessorLoadHistory"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReplicationHealthNull {
+            get {
+                if ((curObj["ReplicationHealth"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Replication health for the virtual machine.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ReplicationHealthValues ReplicationHealth {
+            get {
+                if ((curObj["ReplicationHealth"] == null)) {
+                    return ((ReplicationHealthValues)(System.Convert.ToInt32(4)));
+                }
+                return ((ReplicationHealthValues)(System.Convert.ToInt32(curObj["ReplicationHealth"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReplicationModeNull {
+            get {
+                if ((curObj["ReplicationMode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Identifies replication type for the virtual machine.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ReplicationModeValues ReplicationMode {
+            get {
+                if ((curObj["ReplicationMode"] == null)) {
+                    return ((ReplicationModeValues)(System.Convert.ToInt32(4)));
+                }
+                return ((ReplicationModeValues)(System.Convert.ToInt32(curObj["ReplicationMode"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReplicationStateNull {
+            get {
+                if ((curObj["ReplicationState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Replication state for the virtual machine.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ReplicationStateValues ReplicationState {
+            get {
+                if ((curObj["ReplicationState"] == null)) {
+                    return ((ReplicationStateValues)(System.Convert.ToInt32(12)));
+                }
+                return ((ReplicationStateValues)(System.Convert.ToInt32(curObj["ReplicationState"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("An array of Msvm_VirtualSystemSettingData instances representing the snapshots fo" +
+            "r the virtual system. This property is not valid for instances of Msvm_SummaryIn" +
+            "formation representing a virtual system snapshot.")]
+        public System.Management.ManagementBaseObject[] Snapshots {
+            get {
+                return ((System.Management.ManagementBaseObject[])(curObj["Snapshots"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Strings that describe the various OperationalStatus array values.")]
+        public string[] StatusDescriptions {
+            get {
+                return ((string[])(curObj["StatusDescriptions"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSwapFilesInUseNull {
+            get {
+                if ((curObj["SwapFilesInUse"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indecates if smart paging is active.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool SwapFilesInUse {
+            get {
+                if ((curObj["SwapFilesInUse"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["SwapFilesInUse"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Reference to the CIM_ComputerSystem instance representing the test replica virtua" +
+            "l system for the virtual machine. This property is not valid for instances of Ms" +
+            "vm_SummaryInformation representing a virtual system snapshot.")]
+        public System.Management.ManagementPath TestReplicaSystem {
+            get {
+                if ((curObj["TestReplicaSystem"] != null)) {
+                    return new System.Management.ManagementPath(curObj["TestReplicaSystem"].ToString());
+                }
+                return null;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("An array containing a small, thumbnail-sized image of the desktop for the virtual" +
+            " system or snapshot in RGB565 format.")]
+        public byte[] ThumbnailImage {
+            get {
+                return ((byte[])(curObj["ThumbnailImage"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsUpTimeNull {
+            get {
+                if ((curObj["UpTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The amount of time since the virtual system was last booted. This property is not" +
+            " valid for instances of Msvm_SummaryInformation representing a virtual system sn" +
+            "apshot.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong UpTime {
+            get {
+                if ((curObj["UpTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["UpTime"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeApplicationHealth() {
+            if ((this.IsApplicationHealthNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAvailableMemoryBuffer() {
+            if ((this.IsAvailableMemoryBufferNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        // Converts a given datetime in DMTF format to System.DateTime object.
+        static System.DateTime ToDateTime(string dmtfDate) {
+            System.DateTime initializer = System.DateTime.MinValue;
+            int year = initializer.Year;
+            int month = initializer.Month;
+            int day = initializer.Day;
+            int hour = initializer.Hour;
+            int minute = initializer.Minute;
+            int second = initializer.Second;
+            long ticks = 0;
+            string dmtf = dmtfDate;
+            System.DateTime datetime = System.DateTime.MinValue;
+            string tempString = string.Empty;
+            if ((dmtf == null)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length == 0)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length != 25)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            try {
+                tempString = dmtf.Substring(0, 4);
+                if (("****" != tempString)) {
+                    year = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(4, 2);
+                if (("**" != tempString)) {
+                    month = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(6, 2);
+                if (("**" != tempString)) {
+                    day = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(8, 2);
+                if (("**" != tempString)) {
+                    hour = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(10, 2);
+                if (("**" != tempString)) {
+                    minute = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(12, 2);
+                if (("**" != tempString)) {
+                    second = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(15, 6);
+                if (("******" != tempString)) {
+                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
+                }
+                if (((((((((year < 0) 
+                            || (month < 0)) 
+                            || (day < 0)) 
+                            || (hour < 0)) 
+                            || (minute < 0)) 
+                            || (minute < 0)) 
+                            || (second < 0)) 
+                            || (ticks < 0))) {
+                    throw new System.ArgumentOutOfRangeException();
+                }
+            }
+            catch (System.Exception e) {
+                throw new System.ArgumentOutOfRangeException(null, e.Message);
+            }
+            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
+            datetime = datetime.AddTicks(ticks);
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
+            int UTCOffset = 0;
+            int OffsetToBeAdjusted = 0;
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            tempString = dmtf.Substring(22, 3);
+            if ((tempString != "******")) {
+                tempString = dmtf.Substring(21, 4);
+                try {
+                    UTCOffset = int.Parse(tempString);
+                }
+                catch (System.Exception e) {
+                    throw new System.ArgumentOutOfRangeException(null, e.Message);
+                }
+                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
+                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
+            }
+            return datetime;
+        }
+        
+        // Converts a given System.DateTime object to DMTF datetime format.
+        static string ToDmtfDateTime(System.DateTime date) {
+            string utcString = string.Empty;
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            if ((System.Math.Abs(OffsetMins) > 999)) {
+                date = date.ToUniversalTime();
+                utcString = "+000";
+            }
+            else {
+                if ((tickOffset.Ticks >= 0)) {
+                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
+                }
+                else {
+                    string strTemp = ((long)(OffsetMins)).ToString();
+                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
+                }
+            }
+            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ".");
+            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
+            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
+                        * 1000) 
+                        / System.TimeSpan.TicksPerMillisecond)));
+            string strMicrosec = ((long)(microsec)).ToString();
+            if ((strMicrosec.Length > 6)) {
+                strMicrosec = strMicrosec.Substring(0, 6);
+            }
+            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
+            return dmtfDateTime;
+        }
+        
+        private bool ShouldSerializeCreationTime() {
+            if ((this.IsCreationTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledState() {
+            if ((this.IsEnabledStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHealthState() {
+            if ((this.IsHealthStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHeartbeat() {
+            if ((this.IsHeartbeatNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeIntegrationServicesVersionState() {
+            if ((this.IsIntegrationServicesVersionStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMemoryAvailable() {
+            if ((this.IsMemoryAvailableNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMemorySpansPhysicalNumaNodes() {
+            if ((this.IsMemorySpansPhysicalNumaNodesNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMemoryUsage() {
+            if ((this.IsMemoryUsageNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumberOfProcessors() {
+            if ((this.IsNumberOfProcessorsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeProcessorLoad() {
+            if ((this.IsProcessorLoadNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeReplicationHealth() {
+            if ((this.IsReplicationHealthNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeReplicationMode() {
+            if ((this.IsReplicationModeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeReplicationState() {
+            if ((this.IsReplicationStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSwapFilesInUse() {
+            if ((this.IsSwapFilesInUseNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeUpTime() {
+            if ((this.IsUpTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath() {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_SummaryInformation";
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static SummaryInformationCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static SummaryInformationCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static SummaryInformationCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static SummaryInformationCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_SummaryInformation";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new SummaryInformationCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SummaryInformation", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new SummaryInformationCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static SummaryInformation CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new SummaryInformation(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public enum ApplicationHealthValues {
+            
+            OK = 2,
+            
+            Application_Critical = 32782,
+            
+            Disabled = 32896,
+            
+            NULL_ENUM_VALUE = 0,
+        }
+        
+        public enum IntegrationServicesVersionStateValues {
+            
+            Unknown0 = 0,
+            
+            UpToDate = 1,
+            
+            Mismatch = 2,
+            
+            NULL_ENUM_VALUE = 3,
+        }
+        
+        public enum ReplicationHealthValues {
+            
+            Not_applicable = 0,
+            
+            Ok = 1,
+            
+            Warning = 2,
+            
+            Critical = 3,
+            
+            NULL_ENUM_VALUE = 4,
+        }
+        
+        public enum ReplicationModeValues {
+            
+            None = 0,
+            
+            Primary = 1,
+            
+            Recovery = 2,
+            
+            Test_Replica = 3,
+            
+            NULL_ENUM_VALUE = 4,
+        }
+        
+        public enum ReplicationStateValues {
+            
+            Disabled = 0,
+            
+            Ready_for_replication = 1,
+            
+            Waiting_to_complete_initial_replication = 2,
+            
+            Replicating = 3,
+            
+            Synced_replication_complete = 4,
+            
+            Recovered = 5,
+            
+            Committed = 6,
+            
+            Suspended = 7,
+            
+            Critical = 8,
+            
+            Waiting_to_start_resynchronization = 9,
+            
+            Resynchronizing = 10,
+            
+            Resynchronization_suspended = 11,
+            
+            NULL_ENUM_VALUE = 12,
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class SummaryInformationCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public SummaryInformationCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new SummaryInformation(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new SummaryInformationEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class SummaryInformationEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public SummaryInformationEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new SummaryInformation(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[25/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPortSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPortSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPortSettingData.cs
deleted file mode 100644
index 6edc7bd..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPortSettingData.cs
+++ /dev/null
@@ -1,1010 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // An Early Bound class generated for the WMI class.Msvm_SyntheticEthernetPortSettingData
-    public class SyntheticEthernetPortSettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_SyntheticEthernetPortSettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public SyntheticEthernetPortSettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public SyntheticEthernetPortSettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(SyntheticEthernetPortSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(SyntheticEthernetPortSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public SyntheticEthernetPortSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public SyntheticEthernetPortSettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public SyntheticEthernetPortSettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public SyntheticEthernetPortSettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Address {
-            get {
-                return ((string)(curObj["Address"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string AllocationUnits {
-            get {
-                return ((string)(curObj["AllocationUnits"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticAllocationNull {
-            get {
-                if ((curObj["AutomaticAllocation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutomaticAllocation {
-            get {
-                if ((curObj["AutomaticAllocation"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutomaticAllocation"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticDeallocationNull {
-            get {
-                if ((curObj["AutomaticDeallocation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutomaticDeallocation {
-            get {
-                if ((curObj["AutomaticDeallocation"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutomaticDeallocation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] Connection {
-            get {
-                return ((string[])(curObj["Connection"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsConsumerVisibilityNull {
-            get {
-                if ((curObj["ConsumerVisibility"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ConsumerVisibility {
-            get {
-                if ((curObj["ConsumerVisibility"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ConsumerVisibility"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] HostResource {
-            get {
-                return ((string[])(curObj["HostResource"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLimitNull {
-            get {
-                if ((curObj["Limit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Limit {
-            get {
-                if ((curObj["Limit"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Limit"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMappingBehaviorNull {
-            get {
-                if ((curObj["MappingBehavior"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort MappingBehavior {
-            get {
-                if ((curObj["MappingBehavior"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["MappingBehavior"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherResourceType {
-            get {
-                return ((string)(curObj["OtherResourceType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Parent {
-            get {
-                return ((string)(curObj["Parent"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PoolID {
-            get {
-                return ((string)(curObj["PoolID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsReservationNull {
-            get {
-                if ((curObj["Reservation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Reservation {
-            get {
-                if ((curObj["Reservation"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Reservation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ResourceSubType {
-            get {
-                return ((string)(curObj["ResourceSubType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsResourceTypeNull {
-            get {
-                if ((curObj["ResourceType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ResourceType {
-            get {
-                if ((curObj["ResourceType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ResourceType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsStaticMacAddressNull {
-            get {
-                if ((curObj["StaticMacAddress"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Indicates a static MAC address.\nThis is a read-only property, but it can be chang" +
-            "ed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManage" +
-            "mentService class.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool StaticMacAddress {
-            get {
-                if ((curObj["StaticMacAddress"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["StaticMacAddress"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVirtualQuantityNull {
-            get {
-                if ((curObj["VirtualQuantity"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong VirtualQuantity {
-            get {
-                if ((curObj["VirtualQuantity"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["VirtualQuantity"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. The indexes and values per index are defined on a per resource basis (that is, for each enumerated ResourceType value). This property is set to ""GUID"".
-This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the sd class.")]
-        public string[] VirtualSystemIdentifiers {
-            get {
-                return ((string[])(curObj["VirtualSystemIdentifiers"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsWeightNull {
-            get {
-                if ((curObj["Weight"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint Weight {
-            get {
-                if ((curObj["Weight"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["Weight"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticAllocation() {
-            if ((this.IsAutomaticAllocationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticDeallocation() {
-            if ((this.IsAutomaticDeallocationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeConsumerVisibility() {
-            if ((this.IsConsumerVisibilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLimit() {
-            if ((this.IsLimitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMappingBehavior() {
-            if ((this.IsMappingBehaviorNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeReservation() {
-            if ((this.IsReservationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeResourceType() {
-            if ((this.IsResourceTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeStaticMacAddress() {
-            if ((this.IsStaticMacAddressNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeVirtualQuantity() {
-            if ((this.IsVirtualQuantityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeWeight() {
-            if ((this.IsWeightNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_SyntheticEthernetPortSettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static SyntheticEthernetPortSettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static SyntheticEthernetPortSettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static SyntheticEthernetPortSettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static SyntheticEthernetPortSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_SyntheticEthernetPortSettingData";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new SyntheticEthernetPortSettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SyntheticEthernetPortSettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new SyntheticEthernetPortSettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static SyntheticEthernetPortSettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new SyntheticEthernetPortSettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class SyntheticEthernetPortSettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public SyntheticEthernetPortSettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new SyntheticEthernetPortSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new SyntheticEthernetPortSettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class SyntheticEthernetPortSettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public SyntheticEthernetPortSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new SyntheticEthernetPortSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[09/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs
new file mode 100755
index 0000000..e087cd1
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs
@@ -0,0 +1,1117 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_ProcessorSettingData
+    public class ProcessorSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_ProcessorSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public ProcessorSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public ProcessorSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(ProcessorSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public ProcessorSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ProcessorSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public ProcessorSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public ProcessorSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public ProcessorSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public ProcessorSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public ProcessorSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public ProcessorSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Address {
+            get {
+                return ((string)(curObj["Address"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AddressOnParent {
+            get {
+                return ((string)(curObj["AddressOnParent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AllocationUnits {
+            get {
+                return ((string)(curObj["AllocationUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticAllocationNull {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticAllocation {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticAllocation"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticDeallocationNull {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticDeallocation {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticDeallocation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] Connection {
+            get {
+                return ((string[])(curObj["Connection"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConsumerVisibilityNull {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ConsumerVisibility {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ConsumerVisibility"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] HostResource {
+            get {
+                return ((string[])(curObj["HostResource"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLimitNull {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Limit {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Limit"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLimitCPUIDNull {
+            get {
+                if ((curObj["LimitCPUID"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates whether the virtual machine should lower the CPU identifier. Some older" +
+            " operating systems may require you to limit processor functionality in this way " +
+            "in order to run.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool LimitCPUID {
+            get {
+                if ((curObj["LimitCPUID"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["LimitCPUID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLimitProcessorFeaturesNull {
+            get {
+                if ((curObj["LimitProcessorFeatures"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Indicates whether the VM should limit the CPU features exposed to the operating system. Limiting the processor features enables the VM to be migrated to different host computer systems with different processors. Migrating VMs between computers with processors from different vendors is not supported.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool LimitProcessorFeatures {
+            get {
+                if ((curObj["LimitProcessorFeatures"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["LimitProcessorFeatures"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMappingBehaviorNull {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort MappingBehavior {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["MappingBehavior"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxNumaNodesPerSocketNull {
+            get {
+                if ((curObj["MaxNumaNodesPerSocket"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum number of NUMA nodes that can be observed within the VM as belonging " +
+            "to a single processor socket.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxNumaNodesPerSocket {
+            get {
+                if ((curObj["MaxNumaNodesPerSocket"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxNumaNodesPerSocket"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxProcessorsPerNumaNodeNull {
+            get {
+                if ((curObj["MaxProcessorsPerNumaNode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum number of virtual processors that can be observed within the VM as be" +
+            "longing to a single virtual NUMA node.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxProcessorsPerNumaNode {
+            get {
+                if ((curObj["MaxProcessorsPerNumaNode"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxProcessorsPerNumaNode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherResourceType {
+            get {
+                return ((string)(curObj["OtherResourceType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Parent {
+            get {
+                return ((string)(curObj["Parent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PoolID {
+            get {
+                return ((string)(curObj["PoolID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReservationNull {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Reservation {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Reservation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ResourceSubType {
+            get {
+                return ((string)(curObj["ResourceSubType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsResourceTypeNull {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ResourceType {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ResourceType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVirtualQuantityNull {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong VirtualQuantity {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["VirtualQuantity"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string VirtualQuantityUnits {
+            get {
+                return ((string)(curObj["VirtualQuantityUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsWeightNull {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint Weight {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["Weight"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticAllocation() {
+            if ((this.IsAutomaticAllocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticDeallocation() {
+            if ((this.IsAutomaticDeallocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConsumerVisibility() {
+            if ((this.IsConsumerVisibilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLimit() {
+            if ((this.IsLimitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLimitCPUID() {
+            if ((this.IsLimitCPUIDNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLimitProcessorFeatures() {
+            if ((this.IsLimitProcessorFeaturesNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMappingBehavior() {
+            if ((this.IsMappingBehaviorNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxNumaNodesPerSocket() {
+            if ((this.IsMaxNumaNodesPerSocketNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxProcessorsPerNumaNode() {
+            if ((this.IsMaxProcessorsPerNumaNodeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeReservation() {
+            if ((this.IsReservationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeResourceType() {
+            if ((this.IsResourceTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVirtualQuantity() {
+            if ((this.IsVirtualQuantityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeWeight() {
+            if ((this.IsWeightNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_ProcessorSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static ProcessorSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static ProcessorSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static ProcessorSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static ProcessorSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_ProcessorSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new ProcessorSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static ProcessorSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ProcessorSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new ProcessorSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static ProcessorSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new ProcessorSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class ProcessorSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public ProcessorSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new ProcessorSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new ProcessorSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class ProcessorSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public ProcessorSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new ProcessorSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs
new file mode 100755
index 0000000..343e039
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs
@@ -0,0 +1,993 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2
+{
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_ResourceAllocationSettingData
+    public class ResourceAllocationSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_ResourceAllocationSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public ResourceAllocationSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public ResourceAllocationSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(ResourceAllocationSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ResourceAllocationSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public ResourceAllocationSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public ResourceAllocationSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public ResourceAllocationSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public ResourceAllocationSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Address {
+            get {
+                return ((string)(curObj["Address"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AddressOnParent {
+            get {
+                return ((string)(curObj["AddressOnParent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AllocationUnits {
+            get {
+                return ((string)(curObj["AllocationUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticAllocationNull {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticAllocation {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticAllocation"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticDeallocationNull {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticDeallocation {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticDeallocation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] Connection {
+            get {
+                return ((string[])(curObj["Connection"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConsumerVisibilityNull {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ConsumerVisibility {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ConsumerVisibility"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] HostResource {
+            get {
+                return ((string[])(curObj["HostResource"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLimitNull {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Limit {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Limit"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMappingBehaviorNull {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort MappingBehavior {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["MappingBehavior"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherResourceType {
+            get {
+                return ((string)(curObj["OtherResourceType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Parent {
+            get {
+                return ((string)(curObj["Parent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PoolID {
+            get {
+                return ((string)(curObj["PoolID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReservationNull {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Reservation {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Reservation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ResourceSubType {
+            get {
+                return ((string)(curObj["ResourceSubType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsResourceTypeNull {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ResourceType {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ResourceType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVirtualQuantityNull {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong VirtualQuantity {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["VirtualQuantity"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string VirtualQuantityUnits {
+            get {
+                return ((string)(curObj["VirtualQuantityUnits"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. These values are only used if the ResourceType property is set to 6 (Parallel SCSI HBA) and the ResourceSubType property is set to ""Microsoft Synthetic SCSI Controller"". This property is set to ""GUID"".
+This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class.
+Windows Server 2008:  The VirtualSystemIdentifiers property is not supported until Windows Server 2008 R2.")]
+        public string[] VirtualSystemIdentifiers {
+            get {
+                return ((string[])(curObj["VirtualSystemIdentifiers"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsWeightNull {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint Weight {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["Weight"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticAllocation() {
+            if ((this.IsAutomaticAllocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticDeallocation() {
+            if ((this.IsAutomaticDeallocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConsumerVisibility() {
+            if ((this.IsConsumerVisibilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLimit() {
+            if ((this.IsLimitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMappingBehavior() {
+            if ((this.IsMappingBehaviorNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeReservation() {
+            if ((this.IsReservationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeResourceType() {
+            if ((this.IsResourceTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVirtualQuantity() {
+            if ((this.IsVirtualQuantityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeWeight() {
+            if ((this.IsWeightNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_ResourceAllocationSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static ResourceAllocationSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static ResourceAllocationSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static ResourceAllocationSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static ResourceAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_ResourceAllocationSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new ResourceAllocationSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static ResourceAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ResourceAllocationSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new ResourceAllocationSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static ResourceAllocationSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new ResourceAllocationSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class ResourceAllocationSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public ResourceAllocationSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new ResourceAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new ResourceAllocationSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class ResourceAllocationSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public ResourceAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new ResourceAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[36/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ConcreteJob.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ConcreteJob.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ConcreteJob.cs
deleted file mode 100644
index 1b4e293..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ConcreteJob.cs
+++ /dev/null
@@ -1,1665 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_ConcreteJob
-    public class ConcreteJob : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        public static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_ConcreteJob";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public ConcreteJob() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public ConcreteJob(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(ConcreteJob.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public ConcreteJob(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ConcreteJob.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public ConcreteJob(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public ConcreteJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public ConcreteJob(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public ConcreteJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public ConcreteJob(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public ConcreteJob(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsCancellableNull {
-            get {
-                if ((curObj["Cancellable"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Indicates whether the job can be cancelled. The value of this property does not g" +
-            "uarantee that a request to cancel the job will succeed.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool Cancellable {
-            get {
-                if ((curObj["Cancellable"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["Cancellable"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsDeleteOnCompletionNull {
-            get {
-                if ((curObj["DeleteOnCompletion"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool DeleteOnCompletion {
-            get {
-                if ((curObj["DeleteOnCompletion"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["DeleteOnCompletion"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsElapsedTimeNull {
-            get {
-                if ((curObj["ElapsedTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.TimeSpan ElapsedTime {
-            get {
-                if ((curObj["ElapsedTime"] != null)) {
-                    return ToTimeSpan(((string)(curObj["ElapsedTime"])));
-                }
-                else {
-                    return new System.TimeSpan(0, 0, 0, 0, 0);
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsErrorCodeNull {
-            get {
-                if ((curObj["ErrorCode"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ErrorCode {
-            get {
-                if ((curObj["ErrorCode"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ErrorCode"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ErrorDescription {
-            get {
-                return ((string)(curObj["ErrorDescription"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ErrorSummaryDescription {
-            get {
-                return ((string)(curObj["ErrorSummaryDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsJobRunTimesNull {
-            get {
-                if ((curObj["JobRunTimes"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint JobRunTimes {
-            get {
-                if ((curObj["JobRunTimes"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["JobRunTimes"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsJobStateNull {
-            get {
-                if ((curObj["JobState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort JobState {
-            get {
-                if ((curObj["JobState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["JobState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string JobStatus {
-            get {
-                return ((string)(curObj["JobStatus"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLocalOrUtcTimeNull {
-            get {
-                if ((curObj["LocalOrUtcTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort LocalOrUtcTime {
-            get {
-                if ((curObj["LocalOrUtcTime"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["LocalOrUtcTime"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Notify {
-            get {
-                return ((string)(curObj["Notify"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherRecoveryAction {
-            get {
-                return ((string)(curObj["OtherRecoveryAction"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Owner {
-            get {
-                return ((string)(curObj["Owner"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPercentCompleteNull {
-            get {
-                if ((curObj["PercentComplete"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort PercentComplete {
-            get {
-                if ((curObj["PercentComplete"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["PercentComplete"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPriorityNull {
-            get {
-                if ((curObj["Priority"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint Priority {
-            get {
-                if ((curObj["Priority"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["Priority"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRecoveryActionNull {
-            get {
-                if ((curObj["RecoveryAction"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RecoveryAction {
-            get {
-                if ((curObj["RecoveryAction"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RecoveryAction"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRunDayNull {
-            get {
-                if ((curObj["RunDay"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public sbyte RunDay {
-            get {
-                if ((curObj["RunDay"] == null)) {
-                    return System.Convert.ToSByte(0);
-                }
-                return ((sbyte)(curObj["RunDay"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRunDayOfWeekNull {
-            get {
-                if ((curObj["RunDayOfWeek"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public sbyte RunDayOfWeek {
-            get {
-                if ((curObj["RunDayOfWeek"] == null)) {
-                    return System.Convert.ToSByte(0);
-                }
-                return ((sbyte)(curObj["RunDayOfWeek"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRunMonthNull {
-            get {
-                if ((curObj["RunMonth"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public byte RunMonth {
-            get {
-                if ((curObj["RunMonth"] == null)) {
-                    return System.Convert.ToByte(0);
-                }
-                return ((byte)(curObj["RunMonth"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRunStartIntervalNull {
-            get {
-                if ((curObj["RunStartInterval"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.TimeSpan RunStartInterval {
-            get {
-                if ((curObj["RunStartInterval"] != null)) {
-                    return ToTimeSpan(((string)(curObj["RunStartInterval"])));
-                }
-                else {
-                    return new System.TimeSpan(0, 0, 0, 0, 0);
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsScheduledStartTimeNull {
-            get {
-                if ((curObj["ScheduledStartTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime ScheduledStartTime {
-            get {
-                if ((curObj["ScheduledStartTime"] != null)) {
-                    return ToDateTime(((string)(curObj["ScheduledStartTime"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsStartTimeNull {
-            get {
-                if ((curObj["StartTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime StartTime {
-            get {
-                if ((curObj["StartTime"] != null)) {
-                    return ToDateTime(((string)(curObj["StartTime"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeBeforeRemovalNull {
-            get {
-                if ((curObj["TimeBeforeRemoval"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.TimeSpan TimeBeforeRemoval {
-            get {
-                if ((curObj["TimeBeforeRemoval"] != null)) {
-                    return ToTimeSpan(((string)(curObj["TimeBeforeRemoval"])));
-                }
-                else {
-                    return new System.TimeSpan(0, 0, 0, 0, 0);
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeSubmittedNull {
-            get {
-                if ((curObj["TimeSubmitted"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeSubmitted {
-            get {
-                if ((curObj["TimeSubmitted"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeSubmitted"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsUntilTimeNull {
-            get {
-                if ((curObj["UntilTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime UntilTime {
-            get {
-                if ((curObj["UntilTime"] != null)) {
-                    return ToDateTime(((string)(curObj["UntilTime"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeCancellable() {
-            if ((this.IsCancellableNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeDeleteOnCompletion() {
-            if ((this.IsDeleteOnCompletionNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        private bool ShouldSerializeElapsedTime() {
-            if ((this.IsElapsedTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeErrorCode() {
-            if ((this.IsErrorCodeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeJobRunTimes() {
-            if ((this.IsJobRunTimesNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeJobState() {
-            if ((this.IsJobStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLocalOrUtcTime() {
-            if ((this.IsLocalOrUtcTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePercentComplete() {
-            if ((this.IsPercentCompleteNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePriority() {
-            if ((this.IsPriorityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRecoveryAction() {
-            if ((this.IsRecoveryActionNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRunDay() {
-            if ((this.IsRunDayNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRunDayOfWeek() {
-            if ((this.IsRunDayOfWeekNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRunMonth() {
-            if ((this.IsRunMonthNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRunStartInterval() {
-            if ((this.IsRunStartIntervalNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeScheduledStartTime() {
-            if ((this.IsScheduledStartTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeStartTime() {
-            if ((this.IsStartTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeBeforeRemoval() {
-            if ((this.IsTimeBeforeRemovalNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeSubmitted() {
-            if ((this.IsTimeSubmittedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeUntilTime() {
-            if ((this.IsUntilTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_ConcreteJob";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static ConcreteJobCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static ConcreteJobCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static ConcreteJobCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static ConcreteJobCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_ConcreteJob";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new ConcreteJobCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static ConcreteJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_ConcreteJob", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new ConcreteJobCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static ConcreteJob CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new ConcreteJob(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint GetError(out string Error) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetError", inParams, null);
-                Error = System.Convert.ToString(outParams.Properties["Error"].Value);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Error = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint GetErrorEx(out string[] Errors) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetErrorEx", inParams, null);
-                Errors = ((string[])(outParams.Properties["Errors"].Value));
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Errors = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint KillJob(bool DeleteOnKill) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("KillJob");
-                inParams["DeleteOnKill"] = ((bool)(DeleteOnKill));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("KillJob", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class ConcreteJobCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public ConcreteJobCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new ConcreteJob(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new ConcreteJobEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class ConcreteJobEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public ConcreteJobEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new ConcreteJob(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[05/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs
new file mode 100755
index 0000000..3fb5e3c
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs
@@ -0,0 +1,1369 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
+    // An Early Bound class generated for the WMI class.Msvm_VirtualEthernetSwitch
+    public class VirtualEthernetSwitch : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_VirtualEthernetSwitch";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public VirtualEthernetSwitch() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public VirtualEthernetSwitch(string keyCreationClassName, string keyName) {
+            this.InitializeObject(null, new System.Management.ManagementPath(VirtualEthernetSwitch.ConstructPath(keyCreationClassName, keyName)), null);
+        }
+        
+        public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualEthernetSwitch.ConstructPath(keyCreationClassName, keyName)), null);
+        }
+        
+        public VirtualEthernetSwitch(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public VirtualEthernetSwitch(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public VirtualEthernetSwitch(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public VirtualEthernetSwitch(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] AvailableRequestedStates {
+            get {
+                return ((ushort[])(curObj["AvailableRequestedStates"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCommunicationStatusNull {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort CommunicationStatus {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["CommunicationStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string CreationClassName {
+            get {
+                return ((string)(curObj["CreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] Dedicated {
+            get {
+                return ((ushort[])(curObj["Dedicated"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDetailedStatusNull {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DetailedStatus {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DetailedStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledDefaultNull {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledDefault {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledDefault"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledState {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHealthStateNull {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HealthState {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HealthState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] IdentifyingDescriptions {
+            get {
+                return ((string[])(curObj["IdentifyingDescriptions"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInstallDateNull {
+            get {
+                if ((curObj["InstallDate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime InstallDate {
+            get {
+                if ((curObj["InstallDate"] != null)) {
+                    return ToDateTime(((string)(curObj["InstallDate"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxIOVOffloadsNull {
+            get {
+                if ((curObj["MaxIOVOffloads"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum number of SR-IOV Virtual Function offloads available on this switch.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint MaxIOVOffloads {
+            get {
+                if ((curObj["MaxIOVOffloads"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["MaxIOVOffloads"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxVMQOffloadsNull {
+            get {
+                if ((curObj["MaxVMQOffloads"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum number of VMQ offloads allowed for a port on this switch.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint MaxVMQOffloads {
+            get {
+                if ((curObj["MaxVMQOffloads"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["MaxVMQOffloads"]));
+            }
+            set {
+                curObj["MaxVMQOffloads"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string NameFormat {
+            get {
+                return ((string)(curObj["NameFormat"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOperatingStatusNull {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort OperatingStatus {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["OperatingStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] OperationalStatus {
+            get {
+                return ((ushort[])(curObj["OperationalStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] OtherDedicatedDescriptions {
+            get {
+                return ((string[])(curObj["OtherDedicatedDescriptions"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherEnabledState {
+            get {
+                return ((string)(curObj["OtherEnabledState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] OtherIdentifyingInfo {
+            get {
+                return ((string[])(curObj["OtherIdentifyingInfo"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] PowerManagementCapabilities {
+            get {
+                return ((ushort[])(curObj["PowerManagementCapabilities"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PrimaryOwnerContact {
+            get {
+                return ((string)(curObj["PrimaryOwnerContact"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PrimaryOwnerName {
+            get {
+                return ((string)(curObj["PrimaryOwnerName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPrimaryStatusNull {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PrimaryStatus {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PrimaryStatus"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRequestedStateNull {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort RequestedState {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["RequestedState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsResetCapabilityNull {
+            get {
+                if ((curObj["ResetCapability"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ResetCapability {
+            get {
+                if ((curObj["ResetCapability"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ResetCapability"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] Roles {
+            get {
+                return ((string[])(curObj["Roles"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Status {
+            get {
+                return ((string)(curObj["Status"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] StatusDescriptions {
+            get {
+                return ((string[])(curObj["StatusDescriptions"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimeOfLastStateChangeNull {
+            get {
+                if ((curObj["TimeOfLastStateChange"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime TimeOfLastStateChange {
+            get {
+                if ((curObj["TimeOfLastStateChange"] != null)) {
+                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTransitioningToStateNull {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort TransitioningToState {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["TransitioningToState"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCommunicationStatus() {
+            if ((this.IsCommunicationStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDetailedStatus() {
+            if ((this.IsDetailedStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledDefault() {
+            if ((this.IsEnabledDefaultNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledState() {
+            if ((this.IsEnabledStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHealthState() {
+            if ((this.IsHealthStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        // Converts a given datetime in DMTF format to System.DateTime object.
+        static System.DateTime ToDateTime(string dmtfDate) {
+            System.DateTime initializer = System.DateTime.MinValue;
+            int year = initializer.Year;
+            int month = initializer.Month;
+            int day = initializer.Day;
+            int hour = initializer.Hour;
+            int minute = initializer.Minute;
+            int second = initializer.Second;
+            long ticks = 0;
+            string dmtf = dmtfDate;
+            System.DateTime datetime = System.DateTime.MinValue;
+            string tempString = string.Empty;
+            if ((dmtf == null)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length == 0)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length != 25)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            try {
+                tempString = dmtf.Substring(0, 4);
+                if (("****" != tempString)) {
+                    year = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(4, 2);
+                if (("**" != tempString)) {
+                    month = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(6, 2);
+                if (("**" != tempString)) {
+                    day = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(8, 2);
+                if (("**" != tempString)) {
+                    hour = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(10, 2);
+                if (("**" != tempString)) {
+                    minute = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(12, 2);
+                if (("**" != tempString)) {
+                    second = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(15, 6);
+                if (("******" != tempString)) {
+                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
+                }
+                if (((((((((year < 0) 
+                            || (month < 0)) 
+                            || (day < 0)) 
+                            || (hour < 0)) 
+                            || (minute < 0)) 
+                            || (minute < 0)) 
+                            || (second < 0)) 
+                            || (ticks < 0))) {
+                    throw new System.ArgumentOutOfRangeException();
+                }
+            }
+            catch (System.Exception e) {
+                throw new System.ArgumentOutOfRangeException(null, e.Message);
+            }
+            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
+            datetime = datetime.AddTicks(ticks);
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
+            int UTCOffset = 0;
+            int OffsetToBeAdjusted = 0;
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            tempString = dmtf.Substring(22, 3);
+            if ((tempString != "******")) {
+                tempString = dmtf.Substring(21, 4);
+                try {
+                    UTCOffset = int.Parse(tempString);
+                }
+                catch (System.Exception e) {
+                    throw new System.ArgumentOutOfRangeException(null, e.Message);
+                }
+                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
+                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
+            }
+            return datetime;
+        }
+        
+        // Converts a given System.DateTime object to DMTF datetime format.
+        static string ToDmtfDateTime(System.DateTime date) {
+            string utcString = string.Empty;
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            if ((System.Math.Abs(OffsetMins) > 999)) {
+                date = date.ToUniversalTime();
+                utcString = "+000";
+            }
+            else {
+                if ((tickOffset.Ticks >= 0)) {
+                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
+                }
+                else {
+                    string strTemp = ((long)(OffsetMins)).ToString();
+                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
+                }
+            }
+            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ".");
+            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
+            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
+                        * 1000) 
+                        / System.TimeSpan.TicksPerMillisecond)));
+            string strMicrosec = ((long)(microsec)).ToString();
+            if ((strMicrosec.Length > 6)) {
+                strMicrosec = strMicrosec.Substring(0, 6);
+            }
+            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
+            return dmtfDateTime;
+        }
+        
+        private bool ShouldSerializeInstallDate() {
+            if ((this.IsInstallDateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxIOVOffloads() {
+            if ((this.IsMaxIOVOffloadsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxVMQOffloads() {
+            if ((this.IsMaxVMQOffloadsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetMaxVMQOffloads() {
+            curObj["MaxVMQOffloads"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeOperatingStatus() {
+            if ((this.IsOperatingStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePrimaryStatus() {
+            if ((this.IsPrimaryStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRequestedState() {
+            if ((this.IsRequestedStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeResetCapability() {
+            if ((this.IsResetCapabilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimeOfLastStateChange() {
+            if ((this.IsTimeOfLastStateChangeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTransitioningToState() {
+            if ((this.IsTransitioningToStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyCreationClassName, string keyName) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualEthernetSwitch";
+            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static VirtualEthernetSwitchCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static VirtualEthernetSwitchCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static VirtualEthernetSwitchCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static VirtualEthernetSwitchCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_VirtualEthernetSwitch";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new VirtualEthernetSwitchCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualEthernetSwitch", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new VirtualEthernetSwitchCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static VirtualEthernetSwitch CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new VirtualEthernetSwitch(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
+                inParams["RequestedState"] = ((ushort)(RequestedState));
+                inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint SetPowerState(uint PowerState, System.DateTime Time) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState");
+                inParams["PowerState"] = ((uint)(PowerState));
+                inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class VirtualEthernetSwitchCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public VirtualEthernetSwitchCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new VirtualEthernetSwitch(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new VirtualEthernetSwitchEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class VirtualEthernetSwitchEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public VirtualEthernetSwitchEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new VirtualEthernetSwitch(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[08/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs
new file mode 100755
index 0000000..0d0f550
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs
@@ -0,0 +1,1197 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_StorageAllocationSettingData
+    public class StorageAllocationSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Msvm_StorageAllocationSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public StorageAllocationSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public StorageAllocationSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(StorageAllocationSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public StorageAllocationSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(StorageAllocationSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public StorageAllocationSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public StorageAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public StorageAllocationSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public StorageAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public StorageAllocationSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public StorageAllocationSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAccessNull {
+            get {
+                if ((curObj["Access"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort Access {
+            get {
+                if ((curObj["Access"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["Access"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Address {
+            get {
+                return ((string)(curObj["Address"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AddressOnParent {
+            get {
+                return ((string)(curObj["AddressOnParent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AllocationUnits {
+            get {
+                return ((string)(curObj["AllocationUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticAllocationNull {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticAllocation {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticAllocation"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticDeallocationNull {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticDeallocation {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticDeallocation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] Connection {
+            get {
+                return ((string[])(curObj["Connection"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConsumerVisibilityNull {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ConsumerVisibility {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ConsumerVisibility"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string HostExtentName {
+            get {
+                return ((string)(curObj["HostExtentName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHostExtentNameFormatNull {
+            get {
+                if ((curObj["HostExtentNameFormat"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HostExtentNameFormat {
+            get {
+                if ((curObj["HostExtentNameFormat"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HostExtentNameFormat"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHostExtentNameNamespaceNull {
+            get {
+                if ((curObj["HostExtentNameNamespace"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HostExtentNameNamespace {
+            get {
+                if ((curObj["HostExtentNameNamespace"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HostExtentNameNamespace"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHostExtentStartingAddressNull {
+            get {
+                if ((curObj["HostExtentStartingAddress"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong HostExtentStartingAddress {
+            get {
+                if ((curObj["HostExtentStartingAddress"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["HostExtentStartingAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] HostResource {
+            get {
+                return ((string[])(curObj["HostResource"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHostResourceBlockSizeNull {
+            get {
+                if ((curObj["HostResourceBlockSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong HostResourceBlockSize {
+            get {
+                if ((curObj["HostResourceBlockSize"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["HostResourceBlockSize"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLimitNull {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Limit {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Limit"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMappingBehaviorNull {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort MappingBehavior {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["MappingBehavior"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherHostExtentNameFormat {
+            get {
+                return ((string)(curObj["OtherHostExtentNameFormat"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherHostExtentNameNamespace {
+            get {
+                return ((string)(curObj["OtherHostExtentNameNamespace"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherResourceType {
+            get {
+                return ((string)(curObj["OtherResourceType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Parent {
+            get {
+                return ((string)(curObj["Parent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PoolID {
+            get {
+                return ((string)(curObj["PoolID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReservationNull {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Reservation {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Reservation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ResourceSubType {
+            get {
+                return ((string)(curObj["ResourceSubType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsResourceTypeNull {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ResourceType {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ResourceType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVirtualQuantityNull {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong VirtualQuantity {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["VirtualQuantity"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string VirtualQuantityUnits {
+            get {
+                return ((string)(curObj["VirtualQuantityUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVirtualResourceBlockSizeNull {
+            get {
+                if ((curObj["VirtualResourceBlockSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong VirtualResourceBlockSize {
+            get {
+                if ((curObj["VirtualResourceBlockSize"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["VirtualResourceBlockSize"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsWeightNull {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint Weight {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["Weight"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAccess() {
+            if ((this.IsAccessNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticAllocation() {
+            if ((this.IsAutomaticAllocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticDeallocation() {
+            if ((this.IsAutomaticDeallocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConsumerVisibility() {
+            if ((this.IsConsumerVisibilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHostExtentNameFormat() {
+            if ((this.IsHostExtentNameFormatNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHostExtentNameNamespace() {
+            if ((this.IsHostExtentNameNamespaceNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHostExtentStartingAddress() {
+            if ((this.IsHostExtentStartingAddressNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHostResourceBlockSize() {
+            if ((this.IsHostResourceBlockSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLimit() {
+            if ((this.IsLimitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMappingBehavior() {
+            if ((this.IsMappingBehaviorNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeReservation() {
+            if ((this.IsReservationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeResourceType() {
+            if ((this.IsResourceTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVirtualQuantity() {
+            if ((this.IsVirtualQuantityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVirtualResourceBlockSize() {
+            if ((this.IsVirtualResourceBlockSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeWeight() {
+            if ((this.IsWeightNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_StorageAllocationSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static StorageAllocationSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static StorageAllocationSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static StorageAllocationSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static StorageAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_StorageAllocationSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new StorageAllocationSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_StorageAllocationSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new StorageAllocationSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static StorageAllocationSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new StorageAllocationSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class StorageAllocationSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public StorageAllocationSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new StorageAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new StorageAllocationSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class StorageAllocationSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public StorageAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new StorageAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[16/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs
new file mode 100755
index 0000000..7942085
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs
@@ -0,0 +1,1147 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_EthernetPortAllocationSettingData
+    public class EthernetPortAllocationSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_EthernetPortAllocationSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public EthernetPortAllocationSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public EthernetPortAllocationSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(EthernetPortAllocationSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public EthernetPortAllocationSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetPortAllocationSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public EthernetPortAllocationSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public EthernetPortAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public EthernetPortAllocationSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public EthernetPortAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public EthernetPortAllocationSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public EthernetPortAllocationSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Address {
+            get {
+                return ((string)(curObj["Address"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AddressOnParent {
+            get {
+                return ((string)(curObj["AddressOnParent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AllocationUnits {
+            get {
+                return ((string)(curObj["AllocationUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticAllocationNull {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticAllocation {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticAllocation"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticDeallocationNull {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticDeallocation {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticDeallocation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] Connection {
+            get {
+                return ((string[])(curObj["Connection"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConsumerVisibilityNull {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ConsumerVisibility {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ConsumerVisibility"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDesiredVLANEndpointModeNull {
+            get {
+                if ((curObj["DesiredVLANEndpointMode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DesiredVLANEndpointMode {
+            get {
+                if ((curObj["DesiredVLANEndpointMode"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DesiredVLANEndpointMode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"EnabledState is an integer enumeration that indicates whether the allocation request is enabled or disabled. When an allocation request is marked as Disabled (3), then the allocation is not processed. The EnabledState for an active configuration is always marked as Enabled (2).")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public EnabledStateValues EnabledState {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return ((EnabledStateValues)(System.Convert.ToInt32(0)));
+                }
+                return ((EnabledStateValues)(System.Convert.ToInt32(curObj["EnabledState"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] HostResource {
+            get {
+                return ((string[])(curObj["HostResource"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLimitNull {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Limit {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Limit"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMappingBehaviorNull {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort MappingBehavior {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["MappingBehavior"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherEndpointMode {
+            get {
+                return ((string)(curObj["OtherEndpointMode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherResourceType {
+            get {
+                return ((string)(curObj["OtherResourceType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Parent {
+            get {
+                return ((string)(curObj["Parent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PoolID {
+            get {
+                return ((string)(curObj["PoolID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The list of friendly names corresponding to each entry in the RequiredFeatures.")]
+        public string[] RequiredFeatureHints {
+            get {
+                return ((string[])(curObj["RequiredFeatureHints"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The list of feature identifers representing all the features that are required fo" +
+            "r a port.")]
+        public string[] RequiredFeatures {
+            get {
+                return ((string[])(curObj["RequiredFeatures"]));
+            }
+            set {
+                curObj["RequiredFeatures"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReservationNull {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Reservation {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Reservation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ResourceSubType {
+            get {
+                return ((string)(curObj["ResourceSubType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsResourceTypeNull {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ResourceType {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ResourceType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("This property specifies the network resource pool from which a connection will be" +
+            " allocated to test replica system when it is created.")]
+        public string TestReplicaPoolID {
+            get {
+                return ((string)(curObj["TestReplicaPoolID"]));
+            }
+            set {
+                curObj["TestReplicaPoolID"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("This property specifies the friendly name of the virtual network switch to which " +
+            "a connection will be allocated for the test replica system when it is created.")]
+        public string TestReplicaSwitchName {
+            get {
+                return ((string)(curObj["TestReplicaSwitchName"]));
+            }
+            set {
+                curObj["TestReplicaSwitchName"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVirtualQuantityNull {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong VirtualQuantity {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["VirtualQuantity"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string VirtualQuantityUnits {
+            get {
+                return ((string)(curObj["VirtualQuantityUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsWeightNull {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint Weight {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["Weight"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticAllocation() {
+            if ((this.IsAutomaticAllocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticDeallocation() {
+            if ((this.IsAutomaticDeallocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConsumerVisibility() {
+            if ((this.IsConsumerVisibilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDesiredVLANEndpointMode() {
+            if ((this.IsDesiredVLANEndpointModeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledState() {
+            if ((this.IsEnabledStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLimit() {
+            if ((this.IsLimitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMappingBehavior() {
+            if ((this.IsMappingBehaviorNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetRequiredFeatures() {
+            curObj["RequiredFeatures"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeReservation() {
+            if ((this.IsReservationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeResourceType() {
+            if ((this.IsResourceTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetTestReplicaPoolID() {
+            curObj["TestReplicaPoolID"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetTestReplicaSwitchName() {
+            curObj["TestReplicaSwitchName"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeVirtualQuantity() {
+            if ((this.IsVirtualQuantityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeWeight() {
+            if ((this.IsWeightNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetPortAllocationSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static EthernetPortAllocationSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static EthernetPortAllocationSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static EthernetPortAllocationSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static EthernetPortAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_EthernetPortAllocationSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new EthernetPortAllocationSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetPortAllocationSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new EthernetPortAllocationSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static EthernetPortAllocationSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new EthernetPortAllocationSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public enum EnabledStateValues {
+            
+            Enabled = 2,
+            
+            Disabled = 3,
+            
+            NULL_ENUM_VALUE = 0,
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class EthernetPortAllocationSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public EthernetPortAllocationSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new EthernetPortAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new EthernetPortAllocationSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class EthernetPortAllocationSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public EthernetPortAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new EthernetPortAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[23/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpointSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpointSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpointSettingData.cs
deleted file mode 100644
index faab8d4..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpointSettingData.cs
+++ /dev/null
@@ -1,885 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // An Early Bound class generated for the WMI class.Msvm_VLANEndpointSettingData
-    public class VLANEndpointSettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_VLANEndpointSettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VLANEndpointSettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VLANEndpointSettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VLANEndpointSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VLANEndpointSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VLANEndpointSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VLANEndpointSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VLANEndpointSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VLANEndpointSettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VLANEndpointSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VLANEndpointSettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VLANEndpointSettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAccessVLANNull {
-            get {
-                if ((curObj["AccessVLAN"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort AccessVLAN {
-            get {
-                if ((curObj["AccessVLAN"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["AccessVLAN"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsDefaultVLANNull {
-            get {
-                if ((curObj["DefaultVLAN"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort DefaultVLAN {
-            get {
-                if ((curObj["DefaultVLAN"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["DefaultVLAN"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsNativeVLANNull {
-            get {
-                if ((curObj["NativeVLAN"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort NativeVLAN {
-            get {
-                if ((curObj["NativeVLAN"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["NativeVLAN"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPrimaryVlanNull {
-            get {
-                if ((curObj["PrimaryVlan"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The primary Vlan if the port is in Private Vlan mode.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort PrimaryVlan {
-            get {
-                if ((curObj["PrimaryVlan"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["PrimaryVlan"]));
-            }
-            set {
-                curObj["PrimaryVlan"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] PruneEligibleVLANList {
-            get {
-                return ((ushort[])(curObj["PruneEligibleVLANList"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPVlanModeNull {
-            get {
-                if ((curObj["PVlanMode"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The private VLAN Mode mode supported by this port.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public PVlanModeValues PVlanMode {
-            get {
-                if ((curObj["PVlanMode"] == null)) {
-                    return ((PVlanModeValues)(System.Convert.ToInt32(3)));
-                }
-                return ((PVlanModeValues)(System.Convert.ToInt32(curObj["PVlanMode"])));
-            }
-            set {
-                if ((PVlanModeValues.NULL_ENUM_VALUE == value)) {
-                    curObj["PVlanMode"] = null;
-                }
-                else {
-                    curObj["PVlanMode"] = value;
-                }
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsSecondaryVlanNull {
-            get {
-                if ((curObj["SecondaryVlan"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The secondary Vlan if the port is in Private Vlan mode.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort SecondaryVlan {
-            get {
-                if ((curObj["SecondaryVlan"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["SecondaryVlan"]));
-            }
-            set {
-                curObj["SecondaryVlan"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] TrunkedVLANList {
-            get {
-                return ((ushort[])(curObj["TrunkedVLANList"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAccessVLAN() {
-            if ((this.IsAccessVLANNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeDefaultVLAN() {
-            if ((this.IsDefaultVLANNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeNativeVLAN() {
-            if ((this.IsNativeVLANNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePrimaryVlan() {
-            if ((this.IsPrimaryVlanNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetPrimaryVlan() {
-            curObj["PrimaryVlan"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializePVlanMode() {
-            if ((this.IsPVlanModeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetPVlanMode() {
-            curObj["PVlanMode"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeSecondaryVlan() {
-            if ((this.IsSecondaryVlanNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetSecondaryVlan() {
-            curObj["SecondaryVlan"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_VLANEndpointSettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VLANEndpointSettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VLANEndpointSettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VLANEndpointSettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VLANEndpointSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VLANEndpointSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VLANEndpointSettingData";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VLANEndpointSettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VLANEndpointSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VLANEndpointSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VLANEndpointSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VLANEndpointSettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VLANEndpointSettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VLANEndpointSettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VLANEndpointSettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public enum PVlanModeValues {
-            
-            Unknown0 = 0,
-            
-            Incoming = 1,
-            
-            Outgoing = 2,
-            
-            NULL_ENUM_VALUE = 3,
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VLANEndpointSettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VLANEndpointSettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VLANEndpointSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VLANEndpointSettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VLANEndpointSettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VLANEndpointSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VLANEndpointSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[20/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemGlobalSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemGlobalSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemGlobalSettingData.cs
deleted file mode 100644
index bb484c2..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemGlobalSettingData.cs
+++ /dev/null
@@ -1,1513 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_VirtualSystemGlobalSettingData
-    public class VirtualSystemGlobalSettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_VirtualSystemGlobalSettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VirtualSystemGlobalSettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VirtualSystemGlobalSettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemGlobalSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VirtualSystemGlobalSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemGlobalSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VirtualSystemGlobalSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VirtualSystemGlobalSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VirtualSystemGlobalSettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VirtualSystemGlobalSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VirtualSystemGlobalSettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VirtualSystemGlobalSettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Any additional information provided to the recovery action. The meaning of this property is defined by the action in AutomaticRecoveryAction. If AutomaticRecoveryAction is 0 (""None"") or 1 (""Restart""), this value is NULL. If AutomaticRecoveryAction is 2 (""Revert to Snapshot""), this is the object path to a snapshot that should be applied on failure of the virtual machine worker process.
-This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        public string AdditionalRecoveryInformation {
-            get {
-                return ((string)(curObj["AdditionalRecoveryInformation"]));
-            }
-            set {
-                curObj["AdditionalRecoveryInformation"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAllowFullSCSICommandSetNull {
-            get {
-                if ((curObj["AllowFullSCSICommandSet"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Indicates whether SCSI commands from the guest operating system are passed to pass-through disks. If TRUE, SCSI commands emitted by the guest operating system to pass-through disks are not filtered.It is recommended that SCSI filtering remains enabled for production deployments.
-This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.
-Windows Server 2008:  The AllowFullSCSICommandSet property is not supported.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AllowFullSCSICommandSet {
-            get {
-                if ((curObj["AllowFullSCSICommandSet"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AllowFullSCSICommandSet"]));
-            }
-            set {
-                curObj["AllowFullSCSICommandSet"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutoActivateNull {
-            get {
-                if ((curObj["AutoActivate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutoActivate {
-            get {
-                if ((curObj["AutoActivate"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutoActivate"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticRecoveryActionNull {
-            get {
-                if ((curObj["AutomaticRecoveryAction"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The action to be taken if the virtual machine worker process terminates abnormally. The default action is 1 (""Restart"").
-This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public AutomaticRecoveryActionValues AutomaticRecoveryAction {
-            get {
-                if ((curObj["AutomaticRecoveryAction"] == null)) {
-                    return ((AutomaticRecoveryActionValues)(System.Convert.ToInt32(3)));
-                }
-                return ((AutomaticRecoveryActionValues)(System.Convert.ToInt32(curObj["AutomaticRecoveryAction"])));
-            }
-            set {
-                if ((AutomaticRecoveryActionValues.NULL_ENUM_VALUE == value)) {
-                    curObj["AutomaticRecoveryAction"] = null;
-                }
-                else {
-                    curObj["AutomaticRecoveryAction"] = value;
-                }
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticShutdownActionNull {
-            get {
-                if ((curObj["AutomaticShutdownAction"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The action to take when the host is shut down. The default action is 1 (\"Save Sta" +
-            "te\").\nThis is a read-only property, but it can be changed using the ModifyVirtua" +
-            "lSystem method of the Msvm_VirtualSystemManagementService class.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public AutomaticShutdownActionValues AutomaticShutdownAction {
-            get {
-                if ((curObj["AutomaticShutdownAction"] == null)) {
-                    return ((AutomaticShutdownActionValues)(System.Convert.ToInt32(3)));
-                }
-                return ((AutomaticShutdownActionValues)(System.Convert.ToInt32(curObj["AutomaticShutdownAction"])));
-            }
-            set {
-                if ((AutomaticShutdownActionValues.NULL_ENUM_VALUE == value)) {
-                    curObj["AutomaticShutdownAction"] = null;
-                }
-                else {
-                    curObj["AutomaticShutdownAction"] = value;
-                }
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticStartupActionNull {
-            get {
-                if ((curObj["AutomaticStartupAction"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The action to be taken when the host is started. The default action is 1 (\"Restar" +
-            "t if Previously Running\").\nThis is a read-only property, but it can be changed u" +
-            "sing the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService c" +
-            "lass.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public AutomaticStartupActionValues AutomaticStartupAction {
-            get {
-                if ((curObj["AutomaticStartupAction"] == null)) {
-                    return ((AutomaticStartupActionValues)(System.Convert.ToInt32(3)));
-                }
-                return ((AutomaticStartupActionValues)(System.Convert.ToInt32(curObj["AutomaticStartupAction"])));
-            }
-            set {
-                if ((AutomaticStartupActionValues.NULL_ENUM_VALUE == value)) {
-                    curObj["AutomaticStartupAction"] = null;
-                }
-                else {
-                    curObj["AutomaticStartupAction"] = value;
-                }
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticStartupActionDelayNull {
-            get {
-                if ((curObj["AutomaticStartupActionDelay"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The time interval to wait before performing the startup action. By default, there" +
-            " is no delay.\nThis is a read-only property, but it can be changed using the Modi" +
-            "fyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.TimeSpan AutomaticStartupActionDelay {
-            get {
-                if ((curObj["AutomaticStartupActionDelay"] != null)) {
-                    return ToTimeSpan(((string)(curObj["AutomaticStartupActionDelay"])));
-                }
-                else {
-                    return new System.TimeSpan(0, 0, 0, 0, 0);
-                }
-            }
-            set {
-                curObj["AutomaticStartupActionDelay"] = ToDmtfTimeInterval(((System.TimeSpan)(value)));
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsCreationTimeNull {
-            get {
-                if ((curObj["CreationTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime CreationTime {
-            get {
-                if ((curObj["CreationTime"] != null)) {
-                    return ToDateTime(((string)(curObj["CreationTime"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsDebugChannelIdNull {
-            get {
-                if ((curObj["DebugChannelId"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The channel identifier used to debug the virtual system using the VUD unified deb" +
-            "ugger.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint DebugChannelId {
-            get {
-                if ((curObj["DebugChannelId"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["DebugChannelId"]));
-            }
-            set {
-                curObj["DebugChannelId"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsDebugPortNull {
-            get {
-                if ((curObj["DebugPort"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The tcpip port used to debug the virtual system using synthetic debugging.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint DebugPort {
-            get {
-                if ((curObj["DebugPort"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["DebugPort"]));
-            }
-            set {
-                curObj["DebugPort"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsDebugPortEnabledNull {
-            get {
-                if ((curObj["DebugPortEnabled"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Whether the virtual system is using synthetic debugging.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public DebugPortEnabledValues DebugPortEnabled {
-            get {
-                if ((curObj["DebugPortEnabled"] == null)) {
-                    return ((DebugPortEnabledValues)(System.Convert.ToInt32(3)));
-                }
-                return ((DebugPortEnabledValues)(System.Convert.ToInt32(curObj["DebugPortEnabled"])));
-            }
-            set {
-                if ((DebugPortEnabledValues.NULL_ENUM_VALUE == value)) {
-                    curObj["DebugPortEnabled"] = null;
-                }
-                else {
-                    curObj["DebugPortEnabled"] = value;
-                }
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The fully-qualified path to the root directory of the virtual machine's data store. This store is managed by the virtual system management service and may contain private data from multiple virtual systems. This property may only be specified at the time the virtual machine is defined.
-This is a read-only property, but it can be changed before the virtual machine is created using the DefineVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        public string ExternalDataRoot {
-            get {
-                return ((string)(curObj["ExternalDataRoot"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherVirtualSystemType {
-            get {
-                return ((string)(curObj["OtherVirtualSystemType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The authorization scope to use in determining the access control policy for this " +
-            "virtual system.\nThis is a read-only property, but it can be changed using the Mo" +
-            "difyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        public string ScopeOfResidence {
-            get {
-                return ((string)(curObj["ScopeOfResidence"]));
-            }
-            set {
-                curObj["ScopeOfResidence"] = value;
-                if (((isEmbedded == false) 
-                            && (AutoCommitProp == true))) {
-                    PrivateLateBoundObject.Put();
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsSettingTypeNull {
-            get {
-                if ((curObj["SettingType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public SettingTypeValues SettingType {
-            get {
-                if ((curObj["SettingType"] == null)) {
-                    return ((SettingTypeValues)(System.Convert.ToInt32(0)));
-                }
-                return ((SettingTypeValues)(System.Convert.ToInt32(curObj["SettingType"])));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The fully-qualified path to the root directory of the data store used to store snapshots for this virtual system. This store is managed by the virtual system management service and may contain private data from multiple virtual systems. This property may only be changed if the virtual system has no snapshots.
-This is a read-only property, but it can be changed using the ModifyVirtualSystem method of the Msvm_VirtualSystemManagementService class.")]
-        public string SnapshotDataRoot {
-            get {
-                return ((string)(curObj["SnapshotDataRoot"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The version of the virtual system in a format of \"major.minor\", for example \"2.0\"" +
-            ".\nWindows Server 2008:  The Version property is not supported.")]
-        public string Version {
-            get {
-                return ((string)(curObj["Version"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVirtualSystemTypeNull {
-            get {
-                if ((curObj["VirtualSystemType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort VirtualSystemType {
-            get {
-                if ((curObj["VirtualSystemType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["VirtualSystemType"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private void ResetAdditionalRecoveryInformation() {
-            curObj["AdditionalRecoveryInformation"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeAllowFullSCSICommandSet() {
-            if ((this.IsAllowFullSCSICommandSetNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetAllowFullSCSICommandSet() {
-            curObj["AllowFullSCSICommandSet"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeAutoActivate() {
-            if ((this.IsAutoActivateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticRecoveryAction() {
-            if ((this.IsAutomaticRecoveryActionNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetAutomaticRecoveryAction() {
-            curObj["AutomaticRecoveryAction"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeAutomaticShutdownAction() {
-            if ((this.IsAutomaticShutdownActionNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetAutomaticShutdownAction() {
-            curObj["AutomaticShutdownAction"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeAutomaticStartupAction() {
-            if ((this.IsAutomaticStartupActionNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetAutomaticStartupAction() {
-            curObj["AutomaticStartupAction"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        private bool ShouldSerializeAutomaticStartupActionDelay() {
-            if ((this.IsAutomaticStartupActionDelayNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetAutomaticStartupActionDelay() {
-            curObj["AutomaticStartupActionDelay"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeCreationTime() {
-            if ((this.IsCreationTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeDebugChannelId() {
-            if ((this.IsDebugChannelIdNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetDebugChannelId() {
-            curObj["DebugChannelId"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeDebugPort() {
-            if ((this.IsDebugPortNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetDebugPort() {
-            curObj["DebugPort"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeDebugPortEnabled() {
-            if ((this.IsDebugPortEnabledNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private void ResetDebugPortEnabled() {
-            curObj["DebugPortEnabled"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private void ResetScopeOfResidence() {
-            curObj["ScopeOfResidence"] = null;
-            if (((isEmbedded == false) 
-                        && (AutoCommitProp == true))) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        private bool ShouldSerializeSettingType() {
-            if ((this.IsSettingTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeVirtualSystemType() {
-            if ((this.IsVirtualSystemTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_VirtualSystemGlobalSettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VirtualSystemGlobalSettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VirtualSystemGlobalSettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VirtualSystemGlobalSettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VirtualSystemGlobalSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VirtualSystemGlobalSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VirtualSystemGlobalSettingData";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VirtualSystemGlobalSettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VirtualSystemGlobalSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VirtualSystemGlobalSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VirtualSystemGlobalSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemGlobalSettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VirtualSystemGlobalSettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VirtualSystemGlobalSettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VirtualSystemGlobalSettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public enum AutomaticRecoveryActionValues {
-            
-            None = 0,
-            
-            Restart = 1,
-            
-            Revert_to_Snapshot = 2,
-            
-            NULL_ENUM_VALUE = 3,
-        }
-        
-        public enum AutomaticShutdownActionValues {
-            
-            Turn_Off = 0,
-            
-            Save_State = 1,
-            
-            ShutDown = 2,
-            
-            NULL_ENUM_VALUE = 3,
-        }
-        
-        public enum AutomaticStartupActionValues {
-            
-            None = 0,
-            
-            Restart_if_Previously_Running = 1,
-            
-            Always_Startup = 2,
-            
-            NULL_ENUM_VALUE = 3,
-        }
-        
-        public enum DebugPortEnabledValues {
-            
-            Off = 0,
-            
-            On = 1,
-            
-            OnAutoAssigned = 2,
-            
-            NULL_ENUM_VALUE = 3,
-        }
-        
-        public enum SettingTypeValues {
-            
-            Input = 1,
-            
-            Recorded = 2,
-            
-            Current = 3,
-            
-            Capability = 4,
-            
-            Snapshot = 5,
-            
-            Global = 32768,
-            
-            NULL_ENUM_VALUE = 0,
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VirtualSystemGlobalSettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VirtualSystemGlobalSettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VirtualSystemGlobalSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VirtualSystemGlobalSettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VirtualSystemGlobalSettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VirtualSystemGlobalSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VirtualSystemGlobalSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[40/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/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 6afa788..5a9d586 100755
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -39,15 +39,13 @@ namespace HypervResource
             // Trigger assembly load into curren appdomain
         }
 
+        private static ILog logger = LogManager.GetLogger(typeof(WmiCallsV2));
+
         /// <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";
         }
 
@@ -64,13 +62,1142 @@ namespace HypervResource
             kvpItem.LateBoundObject["Name"] = WmiCallsV2.CloudStackUserDataKey;
             kvpItem.LateBoundObject["Data"] = userData;
             kvpItem.LateBoundObject["Source"] = 0;
-            logger.Debug("VM " + vm.Name + " gets userdata " + userData);
+            logger.Debug("VM " + vm.Name + " gets userdata " + userData);
+
+            // Update the resource settings for the VM.
+            System.Management.ManagementBaseObject kvpMgmtObj = kvpItem.LateBoundObject;
+            System.Management.ManagementPath jobPath;
+            String kvpStr = kvpMgmtObj.GetText(System.Management.TextFormat.CimDtd20);
+            uint ret_val = vmMgmtSvc.AddKvpItems(new String[] { kvpStr }, vm.Path, out jobPath);
+
+            // If the Job is done asynchronously
+            if (ret_val == ReturnCode.Started)
+            {
+                JobCompleted(jobPath);
+            }
+            else if (ret_val != ReturnCode.Completed)
+            {
+                var errMsg = string.Format(
+                    "Failed to update VM {0} (GUID {1}) due to {2} (ModifyVirtualSystem call), existing VM not deleted",
+                    vm.ElementName,
+                    vm.Name,
+                    ReturnCode.ToString(ret_val));
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            return vm;
+        }
+		
+        /// <summary>
+        /// Returns ComputerSystem lacking any NICs and VOLUMEs
+        /// </summary>
+        public ComputerSystem CreateVM(string name, long memory_mb, int vcpus)
+        {
+            // Obtain controller for Hyper-V virtualisation subsystem
+            VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
+
+            // Create VM with correct name and default resources
+            ComputerSystem vm = CreateDefaultVm(vmMgmtSvc, name);
+
+            // Update the resource settings for the VM.
+
+            // Resource settings are referenced through the Msvm_VirtualSystemSettingData object.
+            VirtualSystemSettingData vmSettings = GetVmSettings(vm);
+
+            // For memory settings, there is no Dynamic Memory, so reservation, limit and quantity are identical.
+            MemorySettingData memSettings = GetMemSettings(vmSettings);
+            memSettings.LateBoundObject["VirtualQuantity"] = memory_mb;
+            memSettings.LateBoundObject["Reservation"] = memory_mb;
+            memSettings.LateBoundObject["Limit"] = memory_mb;
+
+            // Update the processor settings for the VM, static assignment of 100% for CPU limit
+            ProcessorSettingData procSettings = GetProcSettings(vmSettings);
+            procSettings.LateBoundObject["VirtualQuantity"] = vcpus;
+            procSettings.LateBoundObject["Reservation"] = vcpus;
+            procSettings.LateBoundObject["Limit"] = 100000;
+
+            ModifyVmResources(vmMgmtSvc, vm, new String[] {
+                memSettings.LateBoundObject.GetText(TextFormat.CimDtd20),
+                procSettings.LateBoundObject.GetText(TextFormat.CimDtd20)
+                });
+            logger.InfoFormat("VM with display name {0} has GUID {1}", vm.ElementName, vm.Name);
+            logger.DebugFormat("Resources for vm {0}: {1} MB memory, {2} vcpus", name, memory_mb, vcpus);
+
+            return vm;
+        }
+
+        /// <summary>
+        /// Create a (synthetic) nic, and attach it to the vm
+        /// </summary>
+        /// <param name="vm"></param>
+        /// <param name="mac"></param>
+        /// <param name="vlan"></param>
+        /// <returns></returns>
+        public SyntheticEthernetPortSettingData CreateNICforVm(ComputerSystem vm, string mac)
+        {
+            logger.DebugFormat("Creating nic for VM {0} (GUID {1})", vm.ElementName, vm.Name);
+
+            // Obtain controller for Hyper-V networking subsystem
+            var vmNetMgmtSvc = GetVirtualSwitchManagementService();
+
+            // Create NIC resource by cloning the default NIC 
+            var synthNICsSettings = SyntheticEthernetPortSettingData.GetInstances(vmNetMgmtSvc.Scope, "InstanceID LIKE \"%Default\"");
+
+            // Assert
+            if (synthNICsSettings.Count != 1)
+            {
+                var errMsg = string.Format("Internal error, coudl not find default SyntheticEthernetPort instance");
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+            var defaultSynthNICSettings = synthNICsSettings.OfType<SyntheticEthernetPortSettingData>().First();
+
+            var newSynthNICSettings = new SyntheticEthernetPortSettingData((ManagementBaseObject)defaultSynthNICSettings.LateBoundObject.Clone());
+
+            //  Assign configuration to new NIC
+            string normalisedMAC = string.Join("", (mac.Split(new char[] { ':' })));
+            newSynthNICSettings.LateBoundObject["ElementName"] = vm.ElementName;
+            newSynthNICSettings.LateBoundObject["Address"] = normalisedMAC;
+            newSynthNICSettings.LateBoundObject["StaticMacAddress"] = "TRUE";
+            newSynthNICSettings.LateBoundObject["VirtualSystemIdentifiers"] = new string[] { "{" + Guid.NewGuid().ToString() + "}" };
+            newSynthNICSettings.CommitObject();
+
+            // Insert NIC into vm
+            string[] newResources = new string[] { newSynthNICSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20)};
+            ManagementPath[] newResourcePaths = AddVirtualResource(newResources, vm );
+
+            // assert
+            if (newResourcePaths.Length != 1)
+            {
+                var errMsg = string.Format(
+                    "Failed to properly insert a single NIC on VM {0} (GUID {1}): number of resource created {2}",
+                    vm.ElementName,
+                    vm.Name,
+                    newResourcePaths.Length);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            return new SyntheticEthernetPortSettingData(newResourcePaths[0]);
+        }
+
+        public const string IDE_HARDDISK_CONTROLLER = "Microsoft:Hyper-V:Emulated IDE Controller";
+        public const string IDE_HARDDISK_DRIVE = "Microsoft:Hyper-V:Synthetic Disk Drive";
+        public const string IDE_ISO_DRIVE = "Microsoft:Hyper-V:Synthetic DVD Drive";
+
+        // TODO: names harvested from Msvm_ResourcePool, not clear how to create new instances
+        public const string IDE_ISO_DISK = "Microsoft:Hyper-V:Virtual CD/DVD Disk"; // For IDE_ISO_DRIVE
+        public const string IDE_HARDDISK_DISK = "Microsoft:Hyper-V:Virtual Hard Disk"; // For IDE_HARDDISK_DRIVE
+
+        /// <summary>
+        /// Create new VM.  By default we start it. 
+        /// </summary>
+        public ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso)
+        {
+            var vmInfo = jsonObj.vm;
+            string vmName = vmInfo.name;
+            var nicInfo = vmInfo.nics;
+            int vcpus = vmInfo.cpus;
+            int memSize = vmInfo.maxRam / 1048576;
+            string errMsg = vmName;
+            var diskDrives = vmInfo.disks;
+            var bootArgs = vmInfo.bootArgs;
+
+            // assert
+            errMsg = vmName + ": missing disk information, array empty or missing, agent expects *at least* one disk for a VM";
+            if (diskDrives == null)
+            {
+                logger.Error(errMsg);
+                throw new ArgumentException(errMsg);
+            }
+            // assert
+            errMsg = vmName + ": missing NIC information, array empty or missing, agent expects at least an empty array.";
+            if (nicInfo == null )
+            {
+                logger.Error(errMsg);
+                throw new ArgumentException(errMsg);
+            }
+
+
+            // For existing VMs, return when we spot one of this name not stopped.  In the meantime, remove any existing VMs of same name.
+            ComputerSystem vmWmiObj = null;
+            while ((vmWmiObj = GetComputerSystem(vmName)) != null)
+            {
+                logger.WarnFormat("Create request for existing vm, name {0}", vmName);
+                if (vmWmiObj.EnabledState == EnabledState.Disabled)
+                {
+                    logger.InfoFormat("Deleting existing VM with name {0}, before we go on to create a VM with the same name", vmName);
+                    DestroyVm(vmName);
+                }
+                else
+                {
+                    // TODO: revise exception type
+                    errMsg = string.Format("Create VM failing, because there exists a VM with name {0}, state {1}", 
+                        vmName,
+                        EnabledState.ToString(vmWmiObj.EnabledState));
+                    var ex = new WmiException(errMsg);
+                    logger.Error(errMsg, ex);
+                    throw ex;
+                }
+            }
+
+            // Create vm carcase
+            logger.DebugFormat("Going ahead with create VM {0}, {1} vcpus, {2}MB RAM", vmName, vcpus, memSize);
+            var newVm = CreateVM(vmName, memSize, vcpus);
+
+            foreach (var diskDrive in diskDrives)
+            {
+                string vhdFile = null;
+                string diskName = null;
+                VolumeObjectTO volInfo = VolumeObjectTO.ParseJson(diskDrive.data);
+                if (volInfo != null)
+                {
+                    // assert
+                    errMsg = vmName + ": volume missing primaryDataStore for disk " + diskDrive.ToString();
+                    if (volInfo.primaryDataStore == null)
+                    {
+                        logger.Error(errMsg);
+                        throw new ArgumentException(errMsg);
+                    }
+                    diskName = volInfo.name;
+
+                    // assert
+                    errMsg = vmName + ": can't deal with DataStore type for disk " + diskDrive.ToString();
+                    if (volInfo.primaryDataStore == null)
+                    {
+                        logger.Error(errMsg);
+                        throw new ArgumentException(errMsg);
+                    }
+                    errMsg = vmName + ": Malformed PrimaryDataStore for disk " + diskDrive.ToString();
+                    if (String.IsNullOrEmpty(volInfo.primaryDataStore.path))
+                    {
+                        logger.Error(errMsg);
+                        throw new ArgumentException(errMsg);
+                    }
+                    errMsg = vmName + ": Missing folder PrimaryDataStore for disk " + diskDrive.ToString() + ", missing path: " +  volInfo.primaryDataStore.path;
+                    if (!Directory.Exists(volInfo.primaryDataStore.path))
+                    {
+                        logger.Error(errMsg);
+                        throw new ArgumentException(errMsg);
+                    }
+
+                    vhdFile = volInfo.FullFileName;
+                    if (!System.IO.File.Exists(vhdFile))
+                    {
+                        errMsg = vmName + ": non-existent volume, missing " + vhdFile + " for drive " + diskDrive.ToString();
+                        logger.Error(errMsg);
+                        throw new ArgumentException(errMsg);
+                    }
+                    logger.Debug("Going to create " + vmName + " with attached voluem " + diskName + " at " + vhdFile);
+                }
+
+                string driveType = diskDrive.type;
+
+                string ideCtrllr = "0";
+                string driveResourceType = null;
+                switch (driveType) {
+                    case "ROOT":
+                        ideCtrllr = "0";
+                        driveResourceType = IDE_HARDDISK_DRIVE;
+                        break;
+                    case "ISO":
+                        ideCtrllr = "1";
+                        driveResourceType = IDE_ISO_DRIVE;
+                        break;
+                    default: 
+                        // TODO: double check exception type
+                        errMsg = string.Format("Unknown disk type {0} for disk {1}, vm named {2}", 
+                                string.IsNullOrEmpty(driveType) ? "NULL" : driveType,
+                                string.IsNullOrEmpty(diskName) ? "NULL" : diskName, vmName);
+                        var ex = new WmiException(errMsg);
+                        logger.Error(errMsg, ex);
+                        throw ex;
+                }
+                logger.DebugFormat("Create disk type {1} (Named: {0}), on vm {2} {3}", diskName, driveResourceType, vmName, 
+                                        string.IsNullOrEmpty(vhdFile) ? " no disk to insert" : ", inserting disk" +vhdFile );
+                AddDiskDriveToVm(newVm, vhdFile, ideCtrllr, driveResourceType);
+            }
+
+            // Add the Nics to the VM in the deviceId order.
+            for (int i = 0; i <= 2; i++)
+            {
+                foreach (var nic in nicInfo)
+                {
+
+                    int nicid = nic.deviceId;
+                    string mac = nic.mac;
+                    string vlan = null;
+                    string isolationUri = nic.isolationUri;
+                    if (isolationUri != null && isolationUri.StartsWith("vlan://") && !isolationUri.Equals("vlan://untagged"))
+                    {
+                        vlan = isolationUri.Substring("vlan://".Length);
+                        int tmp;
+                        if (!int.TryParse(vlan, out tmp))
+                        {
+                            // TODO: double check exception type
+                            errMsg = string.Format("Invalid VLAN value {0} for on vm {1} for nic uuid {2}", isolationUri, vmName, nic.uuid);
+                            var ex = new WmiException(errMsg);
+                            logger.Error(errMsg, ex);
+                            throw ex;
+                        }
+                    }
+                    
+                    if (nicid == i)
+                    {
+                        // Create network adapter
+                        var newAdapter = CreateNICforVm(newVm, mac);
+
+                        // connection to vswitch
+                        var portSettings = AttachNicToPort(newVm, newAdapter);
+
+                        // set vlan
+                        if (vlan != null)
+                        {
+                            SetPortVlan(vlan, portSettings);
+                        }
+
+                        logger.DebugFormat("Created adapter {0} on port {1}, {2}", 
+                            newAdapter.Path, portSettings.Path, (vlan == null ? "No VLAN" : "VLAN " + vlan));
+                    }
+                }
+            }
+
+            // 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 = GetComputerSystem(vmName);
+            if (bootArgs != null && !String.IsNullOrEmpty((string)bootArgs))
+            {
+               
+                String bootargs = bootArgs;
+                AddUserData(vm, bootargs);
+
+
+                // Get existing KVP
+                //var vmSettings = GetVmSettings(vm);
+                //var kvpInfo = GetKvpSettings(vmSettings);
+                //logger.DebugFormat("Boot Args presisted on the VM are ", kvpInfo);
+                //AddUserData(vm, bootargs);
+
+                // Verify key added to subsystem
+                //kvpInfo = 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;
+
+            }
+            // call patch systemvm iso only for systemvms
+            if (vmName.StartsWith("r-"))
+            {
+                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-"))
+            {
+                System.Threading.Thread.Sleep(90000);
+                SetState(newVm, RequiredState.Reboot);
+               // wait for the second boot and then return with suces
+                System.Threading.Thread.Sleep(50000);
+            }
+            logger.InfoFormat("Started VM {0}", vmName);
+            return newVm;
+       }
+
+        private EthernetPortAllocationSettingData AttachNicToPort(ComputerSystem newVm, SyntheticEthernetPortSettingData newAdapter)
+        {
+            // Get the virtual switch
+            VirtualEthernetSwitch vSwitch = GetExternalVirtSwitch();
+
+            // Create port for adapter
+            var defaultEthernetPortSettings = EthernetPortAllocationSettingData.GetInstances(vSwitch.Scope, "InstanceID LIKE \"%Default\"");
+
+            // assert
+            if (defaultEthernetPortSettings.Count != 1)
+            {
+                var errMsg = string.Format("Internal error, coudl not find default EthernetPortAllocationSettingData instance");
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            var defaultEthernetPortSettingsObj = defaultEthernetPortSettings.OfType<EthernetPortAllocationSettingData>().First();
+            var newEthernetPortSettings = new EthernetPortAllocationSettingData((ManagementBaseObject)defaultEthernetPortSettingsObj.LateBoundObject.Clone());
+            newEthernetPortSettings.LateBoundObject["Parent"] = newAdapter.Path.Path;
+            newEthernetPortSettings.LateBoundObject["HostResource"] = new string[] { vSwitch.Path.Path };
+
+            // Insert NIC into vm
+            string[] newResources = new string[] { newEthernetPortSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20) };
+            ManagementPath[] newResourcePaths = AddVirtualResource(newResources, newVm);
+
+            // assert
+            if (newResourcePaths.Length != 1)
+            {
+                var errMsg = string.Format(
+                    "Failed to properly insert a single NIC on VM {0} (GUID {1}): number of resource created {2}",
+                    newVm.ElementName,
+                    newVm.Name,
+                    newResourcePaths.Length);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            return new EthernetPortAllocationSettingData(newResourcePaths[0]);
+        }
+
+        /// this method is to add a dvd drive and attach the systemvm iso.
+        /// 
+        public void patchSystemVmIso(String vmName, String systemVmIso)
+        {
+            ComputerSystem vmObject = GetComputerSystem(vmName);
+            AddDiskDriveToVm(vmObject, "", "1", IDE_ISO_DRIVE);
+            AttachIso(vmName, systemVmIso);
+        }
+
+
+        /// </summary>
+        /// <param name="vm"></param>
+        /// <param name="cntrllerAddr"></param>
+        /// <param name="driveResourceType">IDE_HARDDISK_DRIVE or IDE_ISO_DRIVE</param>
+        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,
+                        vm.Name,
+                        vhdfile);
+
+            // Determine disk type for drive and assert drive type valid
+            string diskResourceSubType = null;
+            switch(driveResourceType) {
+                case IDE_HARDDISK_DRIVE:
+                    diskResourceSubType = IDE_HARDDISK_DISK;
+                    break;
+                case IDE_ISO_DRIVE: 
+                    diskResourceSubType = IDE_ISO_DISK;
+                    break;
+                default:
+                    var errMsg = string.Format(
+                        "Unrecognised disk drive type {0} for VM {1} (GUID {2})",
+                        string.IsNullOrEmpty(driveResourceType) ? "NULL": driveResourceType, 
+                        vm.ElementName,
+                        vm.Name);
+                    var ex = new WmiException(errMsg);
+                    logger.Error(errMsg, ex);
+                    throw ex;
+            }
+
+            ManagementPath newDrivePath = AttachNewDriveToVm(vm, cntrllerAddr, driveResourceType);
+
+            // If there's not disk to insert, we are done.
+            if (String.IsNullOrEmpty(vhdfile))
+            {
+                logger.DebugFormat("No disk to be added to drive, disk drive {0} is complete", newDrivePath.Path);
+            }
+            else
+            {
+                InsertDiskImage(vm, vhdfile, diskResourceSubType, newDrivePath);
+            }
+            return newDrivePath;
+        }
+
+
+        public void DetachDisk(string displayName, string diskFileName)
+        {
+            logger.DebugFormat("Got request to detach virtual disk {0} from vm {1}", diskFileName, displayName);
+
+            ComputerSystem vm = GetComputerSystem(displayName);
+            if (vm == null)
+            {
+                logger.DebugFormat("VM {0} not found", displayName);
+                return;
+            }
+            else
+            {
+                RemoveStorageImageFromVm(vm, diskFileName);
+            }
+        }
+
+        /// <summary>
+        /// Removes a disk image from a drive, but does not remove the drive itself.
+        /// </summary>
+        /// <param name="vm"></param>
+        /// <param name="diskFileName"></param>
+        private void RemoveStorageImageFromVm(ComputerSystem vm, string diskFileName)
+        {
+            // Obtain StorageAllocationSettingData for disk
+            StorageAllocationSettingData.StorageAllocationSettingDataCollection storageSettingsObjs = StorageAllocationSettingData.GetInstances();
+
+            StorageAllocationSettingData imageToRemove = null;
+            foreach (StorageAllocationSettingData item in storageSettingsObjs)
+            {
+                if (item.HostResource == null || item.HostResource.Length != 1)
+                {
+                    continue;
+                }
+
+                string hostResource = item.HostResource[0];
+                if (!hostResource.Equals(diskFileName))
+                {
+                    continue;
+                }
+                imageToRemove = item;
+            }
+
+            // assert
+            if (imageToRemove  == null)
+            {
+                var errMsg = string.Format(
+                    "Failed to remove disk image {0} from VM {1} (GUID {2}): the disk image is not attached.",
+                    diskFileName,
+                    vm.ElementName,
+                    vm.Name);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            RemoveStorageResource(imageToRemove.Path, vm);
+
+            logger.InfoFormat("REmoved disk image {0} from VM {1} (GUID {2}): the disk image is not attached.",
+                    diskFileName,
+                    vm.ElementName,
+                    vm.Name);
+        }
+
+        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);
+            var ctrller = GetIDEControllerSettings(vmSettings, cntrllerAddr);
+
+            // A description of the drive is created by modifying a clone of the default ResourceAllocationSettingData for that drive type
+            string defaultDriveQuery = String.Format("ResourceSubType LIKE \"{0}\" AND InstanceID LIKE \"%Default\"", driveType);
+            var newDiskDriveSettings = CloneResourceAllocationSetting(defaultDriveQuery);
+
+            // Set IDE controller and address on the controller for the new drive
+            newDiskDriveSettings.LateBoundObject["Parent"] = ctrller.Path.ToString();
+            newDiskDriveSettings.LateBoundObject["AddressOnParent"] = "0";
+            newDiskDriveSettings.CommitObject();
+
+            // Add this new disk drive to the VM
+            logger.DebugFormat("Creating disk drive type {0}, parent IDE controller is {1} and address on controller is {2}",
+                newDiskDriveSettings.ResourceSubType,
+                newDiskDriveSettings.Parent,
+                newDiskDriveSettings.AddressOnParent);
+            string[] newDriveResource = new string[] { newDiskDriveSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20) };
+            ManagementPath[] newDrivePaths = AddVirtualResource(newDriveResource, vm);
+
+            // assert
+            if (newDrivePaths.Length != 1)
+            {
+                var errMsg = string.Format(
+                    "Failed to add disk drive type {3} to VM {0} (GUID {1}): number of resource created {2}",
+                    vm.ElementName,
+                    vm.Name,
+                    newDrivePaths.Length,
+                    driveType);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+            logger.DebugFormat("New disk drive type {0} WMI path is {1}s",
+                newDiskDriveSettings.ResourceSubType,
+                newDrivePaths[0].Path);
+            return newDrivePaths[0];
+        }
+
+
+        private void InsertDiskImage(ComputerSystem vm, string diskImagePath, 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);
+            var newDiskSettings = CloneStorageAllocationSetting(defaultDiskQuery);
+
+            // Set file containing the disk image
+            newDiskSettings.LateBoundObject["Parent"] = drivePath.Path;
+
+            // V2 API uses HostResource to specify image, see http://msdn.microsoft.com/en-us/library/hh859775(v=vs.85).aspx
+            newDiskSettings.LateBoundObject["HostResource"] = new string[] { diskImagePath };
+            newDiskSettings.CommitObject();
+
+            // Add the new Msvm_StorageAllocationSettingData object as a virtual hard disk to the vm.
+            string[] newDiskResource = new string[] { newDiskSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20) };
+            ManagementPath[] newDiskPaths = AddStorageResource(newDiskResource, vm);
+            // assert
+            if (newDiskPaths.Length != 1)
+            {
+                var errMsg = string.Format(
+                    "Failed to add disk image type {3} to VM {0} (GUID {1}): number of resource created {2}",
+                    vm.ElementName,
+                    vm.Name,
+                    newDiskPaths.Length,
+                    diskResourceSubType);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+            logger.InfoFormat("Created disk {2} for VM {0} (GUID {1}), image {3} ",
+                    vm.ElementName,
+                    vm.Name,
+                    newDiskPaths[0].Path,
+                    diskImagePath);
+        }
+
+        /// <summary>
+        /// Create Msvm_StorageAllocationSettingData corresponding to the ISO image, and 
+        /// associate this with the VM's DVD drive.
+        /// </summary>
+        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);
+            var driveWmiObj = GetDvdDriveSettings(vmSettings);
+
+            InsertDiskImage(vm, isoPath, IDE_ISO_DISK, driveWmiObj.Path);
+        }
+
+
+
+        private static ResourceAllocationSettingData CloneResourceAllocationSetting(string wmiQuery)
+        {
+            var defaultDiskDriveSettingsObjs = ResourceAllocationSettingData.GetInstances(wmiQuery);
+
+            // assert
+            if (defaultDiskDriveSettingsObjs.Count != 1)
+            {
+                var errMsg = string.Format("Failed to find Msvm_ResourceAllocationSettingData for the query {0}", wmiQuery);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            ResourceAllocationSettingData defaultDiskDriveSettings = defaultDiskDriveSettingsObjs.OfType<ResourceAllocationSettingData>().First();
+            return new ResourceAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
+        }
+
+        public void AttachIso(string displayName, string iso)
+        {
+            logger.DebugFormat("Got request to attach iso {0} to vm {1}", iso, displayName);
+
+            ComputerSystem vm = GetComputerSystem(displayName);
+            if (vm == null)
+            {
+                logger.DebugFormat("VM {0} not found", displayName);
+                return;
+            }
+            else
+            {
+                AttachIsoToVm(vm, iso);
+            }
+        }
+
+        public void DestroyVm(dynamic jsonObj)
+        {
+            string vmToDestroy = jsonObj.vmName;
+            DestroyVm(vmToDestroy);
+        }
+        
+        /// <summary>
+        /// Remove all VMs and all SwitchPorts with the displayName.  VHD gets deleted elsewhere.
+        /// </summary>
+        /// <param name="displayName"></param>
+        public void DestroyVm(string displayName)
+        {
+            logger.DebugFormat("Got request to destroy vm {0}", displayName);
+
+            var vm = GetComputerSystem(displayName);
+            if ( vm  == null )
+            {
+                logger.DebugFormat("VM {0} already destroyed (or never existed)", displayName);
+                return;
+            }
+
+            // Stop VM
+            logger.DebugFormat("Stop VM {0} (GUID {1})", vm.ElementName, vm.Name);
+            SetState(vm, RequiredState.Disabled);
+
+            // Delete SwitchPort
+            logger.DebugFormat("Remove associated switch ports for VM {0} (GUID {1})", vm.ElementName, vm.Name);
+            DeleteSwitchPort(vm.ElementName);
+
+            // Delete VM
+            var virtSysMgmtSvc = GetVirtualisationSystemManagementService();
+            ManagementPath jobPath;
+
+            do
+            {
+                logger.DebugFormat("Delete VM {0} (GUID {1})", vm.ElementName, vm.Name);
+                var ret_val = virtSysMgmtSvc.DestroySystem(vm.Path, out jobPath);
+
+                if (ret_val == ReturnCode.Started)
+                {
+                    JobCompleted(jobPath);
+                }
+                else if (ret_val != ReturnCode.Completed)
+                {
+                    var errMsg = string.Format(
+                        "Failed Delete VM {0} (GUID {1}) due to {2}",
+                        vm.ElementName,
+                        vm.Name,
+                        ReturnCode.ToString(ret_val));
+                    var ex = new WmiException(errMsg);
+                    logger.Error(errMsg, ex);
+                    throw ex;
+                }
+                vm = GetComputerSystem(displayName);
+            }
+            while (vm != null);
+        }
+        
+        /// <summary>
+        /// Create new storage media resources, e.g. hard disk images and ISO disk images
+        /// see http://msdn.microsoft.com/en-us/library/hh859775(v=vs.85).aspx
+        /// </summary>
+        /// <param name="wmiQuery"></param>
+        /// <returns></returns>
+        private static StorageAllocationSettingData CloneStorageAllocationSetting(string wmiQuery)
+        {
+            var defaultDiskImageSettingsObjs = StorageAllocationSettingData.GetInstances(wmiQuery);
+
+            // assert
+            if (defaultDiskImageSettingsObjs.Count != 1)
+            {
+                var errMsg = string.Format("Failed to find Msvm_StorageAllocationSettingData for the query {0}", wmiQuery);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            StorageAllocationSettingData defaultDiskDriveSettings = defaultDiskImageSettingsObjs.OfType<StorageAllocationSettingData>().First();
+            return new StorageAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
+        }
+
+        /// < summary>
+        /// Removes a storage resource from a computer system.
+        /// </summary>
+        /// <param name="storageSettings">Path that uniquely identifies the resource.</param>
+        /// <param name="vm">VM to which the disk image will be attached.</param>
+        // Add new 
+        private void RemoveNetworkResource(ManagementPath resourcePath)
+        {
+            var virtSwitchMgmtSvc = GetVirtualSwitchManagementService();
+            ManagementPath jobPath;
+            var ret_val = virtSwitchMgmtSvc.RemoveResourceSettings(
+                new ManagementPath[] { resourcePath },
+                out jobPath);
+
+            // If the Job is done asynchronously
+            if (ret_val == ReturnCode.Started)
+            {
+                JobCompleted(jobPath);
+            }
+            else if (ret_val != ReturnCode.Completed)
+            {
+                var errMsg = string.Format(
+                    "Failed to remove network resources {0} from switch due to {1}",
+                    resourcePath.Path,
+                    ReturnCode.ToString(ret_val));
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+        }
+
+        /// < summary>
+        /// Removes a storage resource from a computer system.
+        /// </summary>
+        /// <param name="storageSettings">Path that uniquely identifies the resource.</param>
+        /// <param name="vm">VM to which the disk image will be attached.</param>
+        private void RemoveStorageResource(ManagementPath resourcePath, ComputerSystem vm)
+        {
+            var virtSysMgmtSvc = GetVirtualisationSystemManagementService();
+
+            ManagementPath jobPath;
+            var ret_val = virtSysMgmtSvc.RemoveResourceSettings(
+                new ManagementPath[] { resourcePath },
+                out jobPath);
+
+            // If the Job is done asynchronously
+            if (ret_val == ReturnCode.Started)
+            {
+                JobCompleted(jobPath);
+            }
+            else if (ret_val != ReturnCode.Completed)
+            {
+                var errMsg = string.Format(
+                    "Failed to remove resource {0} from VM {1} (GUID {2}) due to {3}",
+                    resourcePath.Path,
+                    vm.ElementName,
+                    vm.Name,
+                    ReturnCode.ToString(ret_val));
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+        }
+
+        public void SetState(ComputerSystem vm, ushort requiredState)
+        {
+            logger.InfoFormat(
+                "Changing state of {0} (GUID {1}) to {2}", 
+                vm.ElementName, 
+                vm.Name,  
+                RequiredState.ToString(requiredState));
+
+            ManagementPath jobPath;
+            // DateTime is unused
+            var ret_val = vm.RequestStateChange(requiredState, new DateTime(), out jobPath);
+
+            // If the Job is done asynchronously
+            if (ret_val == ReturnCode.Started)
+            {
+                JobCompleted(jobPath);
+            }
+            else if (ret_val == 32775)
+            {   // TODO: check
+                logger.InfoFormat("RequestStateChange returned 32775, which means vm in wrong state for requested state change.  Treating as if requested state was reached");
+            }
+            else if (ret_val != ReturnCode.Completed)
+            {
+                var errMsg = string.Format(
+                    "Failed to change state of VM {0} (GUID {1}) to {2} due to {3}",
+                    vm.ElementName,
+                    vm.Name,
+                    RequiredState.ToString(requiredState),
+                    ReturnCode.ToString(ret_val));
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            logger.InfoFormat(
+                "Successfully changed vm state of {0} (GUID {1} to requested state {2}", 
+                vm.ElementName, 
+                vm.Name,  
+                requiredState);
+        }
+
+
+        //TODO:  Write method to delete SwitchPort based on Name
+        /// <summary>
+        /// Delete switch port by removing settings from the switch
+        /// </summary>
+        /// <param name="elementName"></param>
+        /// <returns></returns>
+        public void DeleteSwitchPort(string elementName)
+        {
+            // Get NIC path
+            var condition = string.Format("ElementName=\"{0}\"", elementName);
+            var virtSwitchMgmtSvc = GetVirtualSwitchManagementService();
+
+            var switchPortCollection = EthernetSwitchPort.GetInstances(virtSwitchMgmtSvc.Scope, condition);
+            if (switchPortCollection.Count == 0)
+            {
+                return;
+            }
+
+            foreach (EthernetSwitchPort port in switchPortCollection)
+            {
+                var settings = GetSyntheticEthernetPortSettings(port);
+                RemoveNetworkResource(settings.Path);
+            }
+        }
+
+        public SyntheticEthernetPortSettingData GetSyntheticEthernetPortSettings(EthernetSwitchPort port)
+        {
+            // An ASSOCIATOR object provides the cross reference from the EthernetSwitchPort and the 
+            // SyntheticEthernetPortSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.
+            // Instead, we use the System.Management to code the equivalant of 
+            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vm.path, resultclassName);
+            //
+            var wmiObjQuery = new RelatedObjectQuery(port.Path.Path, SyntheticEthernetPortSettingData.CreatedClassName);
+
+            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
+            // the virtualisation objects.
+            var wmiObjectSearch = new ManagementObjectSearcher(port.Scope, wmiObjQuery);
+            var wmiObjCollection = new SyntheticEthernetPortSettingData.SyntheticEthernetPortSettingDataCollection(wmiObjectSearch.Get());
+
+            // When snapshots are taken into account, there can be multiple settings objects
+            // take the first one that isn't a snapshot
+            foreach (SyntheticEthernetPortSettingData wmiObj in wmiObjCollection)
+            {
+                return wmiObj;
+            }
+
+            var errMsg = string.Format("No SyntheticEthernetPortSettingData for port {0}, path {1}", port.ElementName, port.Path.Path);
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+
+        /// <summary>
+        /// Adds storage images to coputer system (disk image, iso image).
+        /// </summary>
+        /// <param name="storageSettings">Msvm_StorageAllocationSettings with HostResource configured with image
+        /// file and Parent set to a controller associated with the ComputerSystem</param>
+        /// <param name="vm">VM to which the disk image will be attached.</param>
+        // Add new 
+        private ManagementPath[] AddStorageResource(string[] storageSettings, ComputerSystem vm)
+        {
+            return AddVirtualResource(storageSettings, vm);
+        }
+
+        private ManagementPath[] AddVirtualResource(string[] resourceSettings, ComputerSystem vm )
+        {
+            var virtSysMgmtSvc = GetVirtualisationSystemManagementService();
+
+            ManagementPath jobPath;
+            ManagementPath[] resourcePaths;
+            var ret_val = virtSysMgmtSvc.AddResourceSettings(
+                vm.Path,
+                resourceSettings,
+                out jobPath,
+                out resourcePaths);
+
+            // If the Job is done asynchronously
+            if (ret_val == ReturnCode.Started)
+            {
+                JobCompleted(jobPath);
+            }
+            else if (ret_val != ReturnCode.Completed)
+            {
+                var errMsg = string.Format(
+                    "Failed to add resources to VM {0} (GUID {1}) due to {2}",
+                    vm.ElementName,
+                    vm.Name,
+                    ReturnCode.ToString(ret_val));
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            return resourcePaths;
+        }
+
+        private ManagementPath[] AddFeatureSettings(string[] featureSettings, ManagementPath affectedConfiguration)
+        {
+            var virtSysMgmtSvc = GetVirtualisationSystemManagementService();
+
+            ManagementPath jobPath;
+            ManagementPath[] resultSettings;
+            var ret_val = virtSysMgmtSvc.AddFeatureSettings(
+                affectedConfiguration,
+                featureSettings,
+                out jobPath,
+                out resultSettings);
+
+            // If the Job is done asynchronously
+            if (ret_val == ReturnCode.Started)
+            {
+                JobCompleted(jobPath);
+            }
+            else if (ret_val != ReturnCode.Completed)
+            {
+                var errMsg = string.Format(
+                    "Failed to add features settings {0} to resource {1} due to {2}",
+                    featureSettings,
+                    affectedConfiguration,
+                    ReturnCode.ToString(ret_val));
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            return resultSettings;
+        }
+
+        private ManagementPath SetPortVlan(string vlan, EthernetPortAllocationSettingData portPath)
+        {
+            logger.DebugFormat("Setting VLAN to {0}", vlan);
+
+            var vmVirtMgmtSvc = GetVirtualisationSystemManagementService();
+            EthernetSwitchPortVlanSettingData.GetInstances();
+
+            // Create NIC resource by cloning the default NIC 
+            var vlanSettings = EthernetSwitchPortVlanSettingData.GetInstances(vmVirtMgmtSvc.Scope, "InstanceID LIKE \"%Default\"");
+
+            // Assert
+            if (vlanSettings.Count != 1)
+            {
+                var errMsg = string.Format("Internal error, could not find default EthernetSwitchPortVlanSettingData instance");
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+            var defaultVlanSettings = vlanSettings.OfType<EthernetSwitchPortVlanSettingData>().First();
+
+            var newVlanSettings = new EthernetSwitchPortVlanSettingData((ManagementBaseObject)defaultVlanSettings.LateBoundObject.Clone());
+
+            //  Assign configuration to new NIC
+            newVlanSettings.LateBoundObject["AccessVlanId"] = vlan;
+            newVlanSettings.LateBoundObject["OperationMode"] = 1; // Access=1, trunk=2, private=3 ;
+            newVlanSettings.CommitObject();
+
+            // Insert NIC into vm
+            string[] newResources = new string[] { newVlanSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20) };
+            ManagementPath[] newResourcePaths = AddFeatureSettings(newResources, portPath.Path);
+
+            // assert
+            if (newResourcePaths.Length != 1)
+            {
+                var errMsg = string.Format(
+                    "Failed to properly set VLAN to {0} for NIC on port {1}",
+                    vlan,
+                    portPath.Path);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            return newResourcePaths[0];
+        }
+
+
+        /// <summary>
+        /// External VSwitch has an external NIC, and we assume there is only one external NIC and one external vswitch.
+        /// </summary>
+        /// <param name="vmSettings"></param>
+        /// <returns></returns>
+        /// <throw>Throws if there is no vswitch</throw>
+        /// <remarks>
+        /// With V1 API, external ethernet port was attached to the land endpoint, which was attached to the switch.
+        /// e.g. Msvm_ExternalEthernetPort -> SwitchLANEndpoint -> SwitchPort -> VirtualSwitch
+        /// 
+        /// With V2 API, there are two kinds of lan endpoint:  one on the computer system and one on the switch
+        /// e.g. Msvm_ExternalEthernetPort -> LANEndpoint -> LANEdnpoint -> EthernetSwitchPort -> VirtualEthernetSwitch
+        /// </remarks>
+        public static VirtualEthernetSwitch GetExternalVirtSwitch()
+        {
+            // Work back from the first *bound* external NIC we find.
+            var externNICs = ExternalEthernetPort.GetInstances("IsBound = TRUE");
+
+            // Assert
+            if (externNICs.Count == 0 )
+            {
+                var errMsg = "No ExternalEthernetPort available to Hyper-V";
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            ExternalEthernetPort externNIC = externNICs.OfType<ExternalEthernetPort>().First();
+            // A sequence of ASSOCIATOR objects need to be traversed to get from external NIC the vswitch.
+            // We use ManagementObjectSearcher objects to execute this sequence of questions
+            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
+            // the virtualisation objects.
+            var endpointQuery = new RelatedObjectQuery(externNIC.Path.Path, LANEndpoint.CreatedClassName);
+            var endpointSearch = new ManagementObjectSearcher(externNIC.Scope, endpointQuery);
+            var endpointCollection = new LANEndpoint.LANEndpointCollection(endpointSearch.Get());
+
+            // assert
+            if (endpointCollection.Count < 1 )
+            {
+                var errMsg = string.Format("No adapter-based LANEndpoint for external NIC {0} on Hyper-V server", externNIC.Name);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            LANEndpoint adapterEndPoint = endpointCollection.OfType<LANEndpoint>().First();
+            var switchEndpointQuery = new RelatedObjectQuery(adapterEndPoint.Path.Path, LANEndpoint.CreatedClassName);
+            var switchEndpointSearch = new ManagementObjectSearcher(externNIC.Scope, switchEndpointQuery);
+            var switchEndpointCollection = new LANEndpoint.LANEndpointCollection(switchEndpointSearch.Get());
+        
+            // assert
+            if (endpointCollection.Count < 1)
+            {
+                var errMsg = string.Format("No Switch-based LANEndpoint for external NIC {0} on Hyper-V server", externNIC.Name);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+        
+            LANEndpoint switchEndPoint = switchEndpointCollection.OfType<LANEndpoint>().First();
+            var switchPortQuery = new RelatedObjectQuery(switchEndPoint.Path.Path, EthernetSwitchPort.CreatedClassName);
+            var switchPortSearch = new ManagementObjectSearcher(switchEndPoint.Scope, switchPortQuery);
+            var switchPortCollection = new EthernetSwitchPort.EthernetSwitchPortCollection(switchPortSearch.Get());
+        
+            // assert
+            if (switchPortCollection.Count < 1 )
+            {
+                var errMsg = string.Format("No SwitchPort for external NIC {0} on Hyper-V server", externNIC.Name);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+        
+            EthernetSwitchPort switchPort = switchPortCollection.OfType<EthernetSwitchPort>().First();
+            var vSwitchQuery = new RelatedObjectQuery(switchPort.Path.Path, VirtualEthernetSwitch.CreatedClassName);
+            var vSwitchSearch = new ManagementObjectSearcher(externNIC.Scope, vSwitchQuery);
+            var vSwitchCollection = new VirtualEthernetSwitch.VirtualEthernetSwitchCollection(vSwitchSearch.Get());
+        
+            // assert
+            if (vSwitchCollection.Count < 1)
+            {
+                var errMsg = string.Format("No virtual switch for external NIC {0} on Hyper-V server", externNIC.Name);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+            VirtualEthernetSwitch vSwitch = vSwitchCollection.OfType<VirtualEthernetSwitch>().First();
+            return vSwitch;
+        }
+
+        private static void ModifyVmResources(VirtualSystemManagementService vmMgmtSvc, ComputerSystem vm, string[] resourceSettings)
+        {
+            // Resource settings are changed through the management service
+            System.Management.ManagementPath jobPath;
+            System.Management.ManagementPath[] results;
+
+            var ret_val = vmMgmtSvc.ModifyResourceSettings(
+                resourceSettings,
+                out jobPath,
+                out results);
+
+            // If the Job is done asynchronously
+            if (ret_val == ReturnCode.Started)
+            {
+                JobCompleted(jobPath);
+            }
+            else if (ret_val != ReturnCode.Completed)
+            {
+                var errMsg = string.Format(
+                    "Failed to update VM {0} (GUID {1}) due to {2} (ModifyVirtualSystem call), existing VM not deleted",
+                    vm.ElementName,
+                    vm.Name,
+                    ReturnCode.ToString(ret_val));
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+        }
+
+        public void DeleteHostKvpItem(ComputerSystem vm, string key)
+        {
+            // Obtain controller for Hyper-V virtualisation subsystem
+            VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
+
+            // Create object to hold the data.
+            KvpExchangeDataItem kvpItem = KvpExchangeDataItem.CreateInstance();
+            kvpItem.LateBoundObject["Name"] = WmiCallsV2.CloudStackUserDataKey;
+            kvpItem.LateBoundObject["Data"] = "dummy";
+            kvpItem.LateBoundObject["Source"] = 0;
+            logger.Debug("VM " + vm.Name + " will have KVP key " + key + " removed.");
+
+            String kvpStr = kvpItem.LateBoundObject.GetText(TextFormat.CimDtd20);
 
             // Update the resource settings for the VM.
-            System.Management.ManagementBaseObject kvpMgmtObj = kvpItem.LateBoundObject;
-            System.Management.ManagementPath jobPath;
-            String kvpStr = kvpMgmtObj.GetText(System.Management.TextFormat.CimDtd20);
-            uint ret_val = vmMgmtSvc.AddKvpItems(new String[] { kvpStr }, vm.Path, out jobPath);
+            ManagementPath jobPath;
+
+            uint ret_val = vmMgmtSvc.RemoveKvpItems(new String[] { kvpStr }, vm.Path, out jobPath);
 
             // If the Job is done asynchronously
             if (ret_val == ReturnCode.Started)
@@ -88,31 +1215,106 @@ namespace HypervResource
                 logger.Error(errMsg, ex);
                 throw ex;
             }
+        }
+
+        private static ComputerSystem CreateDefaultVm(VirtualSystemManagementService vmMgmtSvc, string name)
+        {
+            // Tweak default settings by basing new VM on default global setting object 
+            // with designed display name.
+
+            VirtualSystemSettingData vs_gs_data = VirtualSystemSettingData.CreateInstance();
+            vs_gs_data.LateBoundObject["ElementName"] = name;
+
+            System.Management.ManagementPath jobPath;
+            System.Management.ManagementPath defined_sys;
+            var ret_val = vmMgmtSvc.DefineSystem(
+                null,
+                new string[0],
+                vs_gs_data.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20),
+                out jobPath,
+                out defined_sys);
+
+            // If the Job is done asynchronously
+            if (ret_val == ReturnCode.Started)
+            {
+                JobCompleted(jobPath);
+            }
+            else if (ret_val != ReturnCode.Completed)
+            {
+                var errMsg = string.Format(
+                    "Failed to create VM {0} due to {1} (DefineVirtualSystem call)",
+                    name, ReturnCode.ToString(ret_val));
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            logger.DebugFormat(CultureInfo.InvariantCulture, "Created VM {0}", name);
+
+            // Is the defined_system real?
+            var vm = new ComputerSystem(defined_sys);
+
+            // Assertion
+            if (vm.ElementName.CompareTo(name) != 0)
+            {
+                var errMsg = string.Format(
+                    "New VM created with wrong name (is {0}, should be {1}, GUID {2})",
+                    vm.ElementName,
+                    name,
+                    vm.Name);
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
 
             return vm;
         }
 
+        public VirtualEthernetSwitchManagementService GetVirtualSwitchManagementService()
+        {
+            // VirtualSwitchManagementService is a singleton, most anonymous way of lookup is by asking for the set
+            // of local instances, which should be size 1.
+            var virtSwtichSvcCollection = VirtualEthernetSwitchManagementService.GetInstances();
+            foreach (VirtualEthernetSwitchManagementService item in virtSwtichSvcCollection)
+            {
+                return item;
+            }
+
+            var errMsg = string.Format("No Hyper-V subsystem on server");
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+
         /// <summary>
-        /// Returns ComputerSystem lacking any NICs and VOLUMEs
+        /// Always produces a VHDX.
         /// </summary>
-        public void DeleteHostKvpItem(ComputerSystem vm, string key)
+        /// <param name="MaxInternalSize"></param>
+        /// <param name="Path"></param>
+        public void CreateDynamicVirtualHardDisk(ulong MaxInternalSize, string Path)
         {
-            // Obtain controller for Hyper-V virtualisation subsystem
-            VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
+            // Produce description of the virtual disk in the format of a Msvm_VirtualHardDiskSettings object
 
-            // Create object to hold the data.
-            KvpExchangeDataItem kvpItem = KvpExchangeDataItem.CreateInstance();
-            kvpItem.LateBoundObject["Name"] = WmiCallsV2.CloudStackUserDataKey;
-            kvpItem.LateBoundObject["Data"] = "dummy";
-            kvpItem.LateBoundObject["Source"] = 0;
-            logger.Debug("VM " + vm.Name + " will have KVP key " + key + " removed.");
+            // Example at http://www.getcodesamples.com/src/FC025DDC/76689747, but
+            // Is there a template we can use to fill in the settings?
+            var newVirtHDSettings = VirtualHardDiskSettingData.CreateInstance();
+            newVirtHDSettings.LateBoundObject["Type"] = 3; // Dynamic
+            newVirtHDSettings.LateBoundObject["Format"] = 3; // VHDX
+            newVirtHDSettings.LateBoundObject["Path"] = Path;
+            newVirtHDSettings.LateBoundObject["MaxInternalSize"] = MaxInternalSize;
+            newVirtHDSettings.LateBoundObject["BlockSize"] = 0; // Use defaults
+            newVirtHDSettings.LateBoundObject["LogicalSectorSize"] = 0; // Use defaults
+            newVirtHDSettings.LateBoundObject["PhysicalSectorSize"] = 0; // Use defaults
 
-            String kvpStr = kvpItem.LateBoundObject.GetText(TextFormat.CimDtd20);
+            // Optional: newVirtHDSettings.CommitObject();
 
-            // Update the resource settings for the VM.
-            ManagementPath jobPath;
+            // Add the new vhd object as a virtual hard disk to the vm.
+            string newVirtHDSettingsString = newVirtHDSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20);
 
-            uint ret_val = vmMgmtSvc.RemoveKvpItems(new String[] { kvpStr }, vm.Path, out jobPath);
+            // Resource settings are changed through the management service
+            System.Management.ManagementPath jobPath;
+            var imgMgr = GetImageManagementService();
+            var ret_val = imgMgr.CreateVirtualHardDisk(newVirtHDSettingsString, out jobPath);
 
             // If the Job is done asynchronously
             if (ret_val == ReturnCode.Started)
@@ -122,9 +1324,9 @@ namespace HypervResource
             else if (ret_val != ReturnCode.Completed)
             {
                 var errMsg = string.Format(
-                    "Failed to update VM {0} (GUID {1}) due to {2} (ModifyVirtualSystem call), existing VM not deleted",
-                    vm.ElementName,
-                    vm.Name,
+                    "Failed to CreateVirtualHardDisk size {0}, path {1} due to {2}",
+                    MaxInternalSize,
+                    Path,
                     ReturnCode.ToString(ret_val));
                 var ex = new WmiException(errMsg);
                 logger.Error(errMsg, ex);
@@ -132,6 +1334,24 @@ namespace HypervResource
             }
         }
 
+        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.
+
+            var coll = ImageManagementService.GetInstances();
+            foreach (ImageManagementService item in coll)
+            {
+                return item;
+            }
+
+            var errMsg = string.Format("No Hyper-V subsystem on server");
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+
+
         public VirtualSystemManagementService GetVirtualisationSystemManagementService()
         {
             // VirtualSystemManagementService is a singleton, most anonymous way of lookup is by asking for the set
@@ -182,6 +1402,61 @@ namespace HypervResource
             logger.DebugFormat("WMI job succeeded: {0}, Elapsed={1}", jobObj.Description, jobObj.ElapsedTime);
         }
 
+        public void GetProcessorResources(out uint cores, out uint mhz)
+        {
+            //  Processor processors
+            cores = 0;
+            mhz = 0;
+            Processor.ProcessorCollection procCol = Processor.GetInstances();
+            foreach (Processor procInfo in procCol)
+            {
+                cores += procInfo.NumberOfCores;
+                mhz = procInfo.MaxClockSpeed;
+           }
+        }
+        
+        public void GetProcessorUsageInfo(out double cpuUtilization)
+        {
+            PerfFormattedData_Counters_ProcessorInformation.PerfFormattedData_Counters_ProcessorInformationCollection coll = 
+                            PerfFormattedData_Counters_ProcessorInformation.GetInstances("Name=\"_Total\"");
+            cpuUtilization = 100;
+            // Use the first one
+            foreach (PerfFormattedData_Counters_ProcessorInformation procInfo in coll)
+            {
+                // Idle during a given internal 
+                // See http://library.wmifun.net/cimv2/win32_perfformatteddata_counters_processorinformation.html
+                cpuUtilization = 100.0 - (double)procInfo.PercentIdleTime;            
+            }
+        }
+
+
+        public void GetMemoryResources(out ulong physicalRamKBs, out ulong freeMemoryKBs)
+        {
+            OperatingSystem0 os = new OperatingSystem0();
+            physicalRamKBs = os.TotalVisibleMemorySize;
+            freeMemoryKBs = os.FreePhysicalMemory;
+        }
+
+        public string GetDefaultVirtualDiskFolder()
+        {
+            VirtualSystemManagementServiceSettingData.VirtualSystemManagementServiceSettingDataCollection coll = VirtualSystemManagementServiceSettingData.GetInstances();
+            string defaultVirtualHardDiskPath = null;
+            foreach (VirtualSystemManagementServiceSettingData settings in coll)
+            {
+                defaultVirtualHardDiskPath = settings.DefaultVirtualHardDiskPath;
+            }
+
+            // assert
+            if (!System.IO.Directory.Exists(defaultVirtualHardDiskPath) ){
+                var errMsg = string.Format(
+                    "Hyper-V DefaultVirtualHardDiskPath is invalid!");
+                logger.Error(errMsg);
+                return null;
+            }
+            
+            return defaultVirtualHardDiskPath;
+        }
+
         public ComputerSystem GetComputerSystem(string displayName)
         {
             var wmiQuery = String.Format("ElementName=\"{0}\"", displayName);
@@ -212,6 +1487,217 @@ namespace HypervResource
             return result;
         }
 
+        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.
+            // Instead, we use the System.Management to code the equivalant of 
+            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
+            //
+            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, ProcessorSettingData.CreatedClassName);
+
+            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
+            // the virtualisation objects.
+            var wmiObjectSearch = new ManagementObjectSearcher(vmSettings.Scope, wmiObjQuery);
+            var wmiObjCollection = new ProcessorSettingData.ProcessorSettingDataCollection(wmiObjectSearch.Get());
+
+            foreach (ProcessorSettingData wmiObj in wmiObjCollection)
+            {
+                return wmiObj;
+            }
+
+            var errMsg = string.Format("No ProcessorSettingData in VirtualSystemSettingData {0}", vmSettings.Path.Path);
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+
+        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.
+            // Instead, we use the System.Management to code the equivalant of 
+            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
+            //
+            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, MemorySettingData.CreatedClassName);
+
+            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
+            // the virtualisation objects.
+            var wmiObjectSearch = new ManagementObjectSearcher(vmSettings.Scope, wmiObjQuery);
+            var wmiObjCollection = new MemorySettingData.MemorySettingDataCollection(wmiObjectSearch.Get());
+
+            foreach (MemorySettingData wmiObj in wmiObjCollection)
+            {
+                return wmiObj;
+            }
+
+            var errMsg = string.Format("No MemorySettingData in VirtualSystemSettingData {0}", vmSettings.Path.Path);
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+
+
+        public ResourceAllocationSettingData GetDvdDriveSettings(VirtualSystemSettingData vmSettings)
+        {
+            var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
+
+            foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection)
+            {
+                // DVD drive is '16', see http://msdn.microsoft.com/en-us/library/hh850200(v=vs.85).aspx 
+                if (wmiObj.ResourceType == 16)
+                {
+                    return wmiObj;
+                }
+            }
+
+            var errMsg = string.Format(
+                                "Cannot find the Dvd drive in VirtualSystemSettingData {0}",
+                                vmSettings.Path.Path);
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+
+        public ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr)
+        {
+            var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
+
+            foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection)
+            {
+                if (wmiObj.ResourceSubType == IDE_HARDDISK_CONTROLLER && wmiObj.Address == cntrllerAddr)
+                {
+                    return wmiObj;
+                }
+            }
+
+            var errMsg = string.Format(
+                                "Cannot find the Microsoft Emulated IDE Controlle at address {0} in VirtualSystemSettingData {1}", 
+                                cntrllerAddr, 
+                                vmSettings.Path.Path);
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+
+        /// <summary>
+        /// VM resources, typically hardware a described by a generic MSVM_ResourceAllocationSettingData object.  The hardware type being 
+        /// described is identified in two ways:  in general terms using an enum in the ResourceType field, and in terms of the implementation 
+        /// using text in the ResourceSubType field.
+        /// See http://msdn.microsoft.com/en-us/library/cc136877%28v=vs.85%29.aspx
+        /// </summary>
+        /// <param name="vmSettings"></param>
+        /// <returns></returns>
+        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.
+            // Instead, we use the System.Management to code the equivalant of 
+            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
+            //
+            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, ResourceAllocationSettingData.CreatedClassName);
+
+            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
+            // the virtualisation objects.
+            var wmiObjectSearch = new ManagementObjectSearcher(vmSettings.Scope, wmiObjQuery);
+            var wmiObjCollection = new ResourceAllocationSettingData.ResourceAllocationSettingDataCollection(wmiObjectSearch.Get());
+
+            if (wmiObjCollection != null)
+            {
+                return wmiObjCollection;
+            }
+
+            var errMsg = string.Format("No ResourceAllocationSettingData in VirtualSystemSettingData {0}", vmSettings.Path.Path);
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+
+        public EthernetPortAllocationSettingData[] GetEthernetConnections(ComputerSystem vm)
+        {
+            // ComputerSystem -> VirtualSystemSettingData -> EthernetPortAllocationSettingData
+            VirtualSystemSettingData vmSettings = GetVmSettings(vm);
+
+            // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the 
+            // EthernetPortAllocationSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.
+            // Instead, we use the System.Management to code the equivalant of 
+            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
+            //
+            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, EthernetPortAllocationSettingData.CreatedClassName);
+
+            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
+            // the virtualisation objects.
+            var wmiObjectSearch = new ManagementObjectSearcher(vmSettings.Scope, wmiObjQuery);
+            var wmiObjCollection = new EthernetPortAllocationSettingData.EthernetPortAllocationSettingDataCollection(wmiObjectSearch.Get());
+
+            var result = new List<EthernetPortAllocationSettingData>(wmiObjCollection.Count);
+            foreach (EthernetPortAllocationSettingData item in wmiObjCollection)
+            {
+                result.Add(item);
+            }
+            return result.ToArray();
+        }
+
+
+        public EthernetSwitchPortVlanSettingData GetVlanSettings(EthernetPortAllocationSettingData ethernetConnection)
+        {
+            // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the 
+            // EthernetPortAllocationSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.
+            // Instead, we use the System.Management to code the equivalant of 
+            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
+            //
+            var wmiObjQuery = new RelatedObjectQuery(ethernetConnection.Path.Path, EthernetSwitchPortVlanSettingData.CreatedClassName);
+
+            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
+            // the virtualisation objects.
+            var wmiObjectSearch = new ManagementObjectSearcher(ethernetConnection.Scope, wmiObjQuery);
+            var wmiObjCollection = new EthernetSwitchPortVlanSettingData.EthernetSwitchPortVlanSettingDataCollection(wmiObjectSearch.Get());
+
+            if (wmiObjCollection.Count == 0)
+            {
+                return null;
+            }
+
+            // Assert
+            if (wmiObjCollection.Count > 1)
+            {
+                var errMsg = string.Format("Internal error, morn one VLAN settings for a single ethernetConnection");
+                var ex = new WmiException(errMsg);
+                logger.Error(errMsg, ex);
+                throw ex;
+            }
+
+            return wmiObjCollection.OfType<EthernetSwitchPortVlanSettingData>().First();
+        }
+        
+
+        public SyntheticEthernetPortSettingData[] GetEthernetPortSettings(ComputerSystem vm)
+        {
+            // An ASSOCIATOR object provides the cross reference from the ComputerSettings and the 
+            // SyntheticEthernetPortSettingData, via the VirtualSystemSettingData.
+            // However, generated wrappers do not expose a ASSOCIATOR OF query as a method.
+            // Instead, we use the System.Management to code the equivalant of 
+            //
+            // string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vm.path, resultclassName);
+            //
+            VirtualSystemSettingData vmSettings = GetVmSettings(vm);
+
+            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, SyntheticEthernetPortSettingData.CreatedClassName);
+
+            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
+            // the virtualisation objects.
+            var wmiObjectSearch = new ManagementObjectSearcher(vm.Scope, wmiObjQuery);
+            var wmiObjCollection = new SyntheticEthernetPortSettingData.SyntheticEthernetPortSettingDataCollection(wmiObjectSearch.Get());
+
+            List<SyntheticEthernetPortSettingData> results = new List<SyntheticEthernetPortSettingData>(wmiObjCollection.Count);
+            foreach (SyntheticEthernetPortSettingData item in wmiObjCollection)
+            {
+                results.Add(item);
+            }
+
+            return results.ToArray();
+        }
+
         public string GetDefaultDataRoot()
         {
             string defaultRootPath = null;
@@ -224,9 +1710,8 @@ namespace HypervResource
 
             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.
@@ -281,6 +1766,41 @@ namespace HypervResource
             logger.Error(errMsg, ex);
             throw ex;
         }
+
+        public void GetSummaryInfo(Dictionary<string, VmStatsEntry> vmProcessorInfo, List<System.Management.ManagementPath> vmsToInspect)
+        {
+            // Process info available from WMI, 
+            // See http://msdn.microsoft.com/en-us/library/hh850062(v=vs.85).aspx
+            uint[] requestedInfo = new uint[] {  // TODO: correct?
+                    0, // Name
+                    1, // ElementName
+                    4, // Number of processes
+                    101 // ProcessorLoad
+                };
+
+            System.Management.ManagementBaseObject[] sysSummary;
+            var vmsvc = GetVirtualisationSystemManagementService();
+            System.Management.ManagementPath[] vmPaths = vmsToInspect.ToArray();
+            vmsvc.GetSummaryInformation(requestedInfo, vmPaths, out sysSummary);
+
+            foreach (var summary in sysSummary)
+            {
+
+                var summaryInfo = new SummaryInformation(summary);
+
+                logger.Debug("VM " + summaryInfo.Name + "(elementName " + summaryInfo.ElementName + ") has " +
+                                summaryInfo.NumberOfProcessors + " CPUs, and load of " + summaryInfo.ProcessorLoad);
+                var vmInfo = new VmStatsEntry
+                {
+                    cpuUtilization = summaryInfo.ProcessorLoad,
+                    numCPUs = summaryInfo.NumberOfProcessors,
+                    networkReadKBs = 1,
+                    networkWriteKBs = 1,
+                    entityType = "vm"
+                };
+                vmProcessorInfo.Add(summaryInfo.ElementName, vmInfo);
+            }
+        }
     }
 
     public class WmiException : Exception


[34/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_IDEController.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_IDEController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_IDEController.cs
deleted file mode 100644
index 1264906..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_IDEController.cs
+++ /dev/null
@@ -1,1610 +0,0 @@
-namespace ServerResource.Tests.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_IDEController
-    public class IDEController : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_IDEController";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public IDEController() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public IDEController(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(IDEController.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public IDEController(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(IDEController.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public IDEController(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public IDEController(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public IDEController(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public IDEController(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public IDEController(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public IDEController(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] AdditionalAvailability {
-            get {
-                return ((ushort[])(curObj["AdditionalAvailability"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAvailabilityNull {
-            get {
-                if ((curObj["Availability"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort Availability {
-            get {
-                if ((curObj["Availability"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["Availability"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string DeviceID {
-            get {
-                return ((string)(curObj["DeviceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsErrorClearedNull {
-            get {
-                if ((curObj["ErrorCleared"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool ErrorCleared {
-            get {
-                if ((curObj["ErrorCleared"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["ErrorCleared"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ErrorDescription {
-            get {
-                return ((string)(curObj["ErrorDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] IdentifyingDescriptions {
-            get {
-                return ((string[])(curObj["IdentifyingDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLastErrorCodeNull {
-            get {
-                if ((curObj["LastErrorCode"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint LastErrorCode {
-            get {
-                if ((curObj["LastErrorCode"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["LastErrorCode"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLocationIndicatorNull {
-            get {
-                if ((curObj["LocationIndicator"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort LocationIndicator {
-            get {
-                if ((curObj["LocationIndicator"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["LocationIndicator"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxNumberControlledNull {
-            get {
-                if ((curObj["MaxNumberControlled"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint MaxNumberControlled {
-            get {
-                if ((curObj["MaxNumberControlled"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["MaxNumberControlled"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxQuiesceTimeNull {
-            get {
-                if ((curObj["MaxQuiesceTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong MaxQuiesceTime {
-            get {
-                if ((curObj["MaxQuiesceTime"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["MaxQuiesceTime"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] OtherIdentifyingInfo {
-            get {
-                return ((string[])(curObj["OtherIdentifyingInfo"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] PowerManagementCapabilities {
-            get {
-                return ((ushort[])(curObj["PowerManagementCapabilities"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPowerManagementSupportedNull {
-            get {
-                if ((curObj["PowerManagementSupported"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool PowerManagementSupported {
-            get {
-                if ((curObj["PowerManagementSupported"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["PowerManagementSupported"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsPowerOnHoursNull {
-            get {
-                if ((curObj["PowerOnHours"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong PowerOnHours {
-            get {
-                if ((curObj["PowerOnHours"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["PowerOnHours"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ProtocolDescription {
-            get {
-                return ((string)(curObj["ProtocolDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolSupportedNull {
-            get {
-                if ((curObj["ProtocolSupported"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolSupported {
-            get {
-                if ((curObj["ProtocolSupported"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolSupported"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsStatusInfoNull {
-            get {
-                if ((curObj["StatusInfo"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort StatusInfo {
-            get {
-                if ((curObj["StatusInfo"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["StatusInfo"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastResetNull {
-            get {
-                if ((curObj["TimeOfLastReset"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastReset {
-            get {
-                if ((curObj["TimeOfLastReset"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastReset"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTotalPowerOnHoursNull {
-            get {
-                if ((curObj["TotalPowerOnHours"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong TotalPowerOnHours {
-            get {
-                if ((curObj["TotalPowerOnHours"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["TotalPowerOnHours"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAvailability() {
-            if ((this.IsAvailabilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeErrorCleared() {
-            if ((this.IsErrorClearedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLastErrorCode() {
-            if ((this.IsLastErrorCodeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLocationIndicator() {
-            if ((this.IsLocationIndicatorNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxNumberControlled() {
-            if ((this.IsMaxNumberControlledNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxQuiesceTime() {
-            if ((this.IsMaxQuiesceTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePowerManagementSupported() {
-            if ((this.IsPowerManagementSupportedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializePowerOnHours() {
-            if ((this.IsPowerOnHoursNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProtocolSupported() {
-            if ((this.IsProtocolSupportedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeStatusInfo() {
-            if ((this.IsStatusInfoNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastReset() {
-            if ((this.IsTimeOfLastResetNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTotalPowerOnHours() {
-            if ((this.IsTotalPowerOnHoursNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_IDEController";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static IDEControllerCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static IDEControllerCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static IDEControllerCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static IDEControllerCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static IDEControllerCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_IDEController";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new IDEControllerCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static IDEControllerCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static IDEControllerCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static IDEControllerCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_IDEController", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new IDEControllerCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static IDEController CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new IDEController(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint EnableDevice(bool Enabled) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice");
-                inParams["Enabled"] = ((bool)(Enabled));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint OnlineDevice(bool Online) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice");
-                inParams["Online"] = ((bool)(Online));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint QuiesceDevice(bool Quiesce) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice");
-                inParams["Quiesce"] = ((bool)(Quiesce));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint Reset() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint RestoreProperties() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SaveProperties() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SetPowerState(ushort PowerState, System.DateTime Time) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState");
-                inParams["PowerState"] = ((ushort)(PowerState));
-                inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class IDEControllerCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public IDEControllerCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new IDEController(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new IDEControllerEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class IDEControllerEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public IDEControllerEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new IDEController(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[03/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs
new file mode 100755
index 0000000..38760cf
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs
@@ -0,0 +1,1034 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_VirtualHardDiskSettingData
+    public class VirtualHardDiskSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Msvm_VirtualHardDiskSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public VirtualHardDiskSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public VirtualHardDiskSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(VirtualHardDiskSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public VirtualHardDiskSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualHardDiskSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public VirtualHardDiskSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public VirtualHardDiskSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public VirtualHardDiskSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public VirtualHardDiskSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public VirtualHardDiskSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public VirtualHardDiskSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsBlockSizeNull {
+            get {
+                if ((curObj["BlockSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The block size used by the virtual hard disk")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint BlockSize {
+            get {
+                if ((curObj["BlockSize"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["BlockSize"]));
+            }
+            set {
+                curObj["BlockSize"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+            set {
+                curObj["Caption"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+            set {
+                curObj["Description"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+            set {
+                curObj["ElementName"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFormatNull {
+            get {
+                if ((curObj["Format"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The format for the virtual hard disk.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public FormatValues Format {
+            get {
+                if ((curObj["Format"] == null)) {
+                    return ((FormatValues)(System.Convert.ToInt32(0)));
+                }
+                return ((FormatValues)(System.Convert.ToInt32(curObj["Format"])));
+            }
+            set {
+                if ((FormatValues.NULL_ENUM_VALUE == value)) {
+                    curObj["Format"] = null;
+                }
+                else {
+                    curObj["Format"] = value;
+                }
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+            set {
+                curObj["InstanceID"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLogicalSectorSizeNull {
+            get {
+                if ((curObj["LogicalSectorSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The logical sector size used by the virtual hard disk")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint LogicalSectorSize {
+            get {
+                if ((curObj["LogicalSectorSize"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["LogicalSectorSize"]));
+            }
+            set {
+                curObj["LogicalSectorSize"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxInternalSizeNull {
+            get {
+                if ((curObj["MaxInternalSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum size of the virtual hard disk as viewable by the virtual machine, in " +
+            "bytes. The specified size will be rounded up to the next largest multiple of the" +
+            " sector size.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxInternalSize {
+            get {
+                if ((curObj["MaxInternalSize"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxInternalSize"]));
+            }
+            set {
+                curObj["MaxInternalSize"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The parent of the virtual hard disk. If the virtual hard disk does not have a par" +
+            "ent, then this field is empty.")]
+        public string ParentPath {
+            get {
+                return ((string)(curObj["ParentPath"]));
+            }
+            set {
+                curObj["ParentPath"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The path of the virtual hard disk.")]
+        public string Path0 {
+            get {
+                return ((string)(curObj["Path"]));
+            }
+            set {
+                curObj["Path"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPhysicalSectorSizeNull {
+            get {
+                if ((curObj["PhysicalSectorSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The physical sector size used by the virtual hard disk")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint PhysicalSectorSize {
+            get {
+                if ((curObj["PhysicalSectorSize"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["PhysicalSectorSize"]));
+            }
+            set {
+                curObj["PhysicalSectorSize"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTypeNull {
+            get {
+                if ((curObj["Type"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The type of virtual hard disk.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public TypeValues Type {
+            get {
+                if ((curObj["Type"] == null)) {
+                    return ((TypeValues)(System.Convert.ToInt32(0)));
+                }
+                return ((TypeValues)(System.Convert.ToInt32(curObj["Type"])));
+            }
+            set {
+                if ((TypeValues.NULL_ENUM_VALUE == value)) {
+                    curObj["Type"] = null;
+                }
+                else {
+                    curObj["Type"] = value;
+                }
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeBlockSize() {
+            if ((this.IsBlockSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetBlockSize() {
+            curObj["BlockSize"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetCaption() {
+            curObj["Caption"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetDescription() {
+            curObj["Description"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetElementName() {
+            curObj["ElementName"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeFormat() {
+            if ((this.IsFormatNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetFormat() {
+            curObj["Format"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeLogicalSectorSize() {
+            if ((this.IsLogicalSectorSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetLogicalSectorSize() {
+            curObj["LogicalSectorSize"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeMaxInternalSize() {
+            if ((this.IsMaxInternalSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetMaxInternalSize() {
+            curObj["MaxInternalSize"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetParentPath() {
+            curObj["ParentPath"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private void ResetPath0() {
+            curObj["Path"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializePhysicalSectorSize() {
+            if ((this.IsPhysicalSectorSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetPhysicalSectorSize() {
+            curObj["PhysicalSectorSize"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeType() {
+            if ((this.IsTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetType() {
+            curObj["Type"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualHardDiskSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static VirtualHardDiskSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static VirtualHardDiskSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static VirtualHardDiskSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static VirtualHardDiskSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_VirtualHardDiskSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new VirtualHardDiskSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualHardDiskSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new VirtualHardDiskSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static VirtualHardDiskSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new VirtualHardDiskSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public enum FormatValues {
+            
+            VHD = 2,
+            
+            VHDX = 3,
+            
+            NULL_ENUM_VALUE = 0,
+        }
+        
+        public enum TypeValues {
+            
+            Fixed = 2,
+            
+            Dynamic = 3,
+            
+            Differencing = 4,
+            
+            NULL_ENUM_VALUE = 0,
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class VirtualHardDiskSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public VirtualHardDiskSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new VirtualHardDiskSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new VirtualHardDiskSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class VirtualHardDiskSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public VirtualHardDiskSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new VirtualHardDiskSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs
index b5da7f6..72a7b90 100755
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs
@@ -1006,13 +1006,13 @@
                 inParams["FeatureSettings"] = ((string[])(FeatureSettings));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFeatureSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 ResultingFeatureSettings = null;
-                if ((outParams.Properties["ResultingFeatureSettings"] != null)) {
+                if ((outParams.Properties["ResultingFeatureSettings"] != null && outParams.Properties["ResultingFeatureSettings"].Value != null))
+                {
                     int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length;
                     System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
                     for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
@@ -1052,11 +1052,9 @@
                 inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddKvpItems", inParams, null);
                 Job = null;
-//                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-//                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1074,13 +1072,13 @@
                 inParams["ResourceSettings"] = ((string[])(ResourceSettings));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddResourceSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 ResultingResourceSettings = null;
-                if ((outParams.Properties["ResultingResourceSettings"] != null)) {
+                if ((outParams.Properties["ResultingResourceSettings"] != null && outParams.Properties["ResultingResourceSettings"].Value != null))
+                {
                     int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length;
                     System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
                     for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
@@ -1097,23 +1095,23 @@
             }
         }
         
-        public uint DefineSystem(System.Management.ManagementPath ReferenceConfiguration, string[] ResourceSettings, string SystemSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) {
+        public uint DefineSystem(string ReferenceConfigurationPath, string[] ResourceSettings, string SystemSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) {
             if ((isEmbedded == false)) {
                 System.Management.ManagementBaseObject inParams = null;
                 inParams = PrivateLateBoundObject.GetMethodParameters("DefineSystem");
-                inParams["ReferenceConfiguration"] = ((System.Management.ManagementPath)(ReferenceConfiguration)).Path;
-                inParams["ResourceSettings"] = ((string[])(ResourceSettings));
-                inParams["SystemSettings"] = ((string)(SystemSettings));
+                inParams["ReferenceConfiguration"] = ReferenceConfigurationPath;
+                inParams["ResourceSettings"] = ResourceSettings;
+                inParams["SystemSettings"] = SystemSettings;
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DefineSystem", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null)
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 ResultingSystem = null;
-                if ((outParams.Properties["ResultingSystem"] != null)) {
-                    ResultingSystem = new System.Management.ManagementPath(outParams.Properties["ResultingSystem"].ToString());
+                if ((outParams.Properties["ResultingSystem"] != null && outParams.Properties["ResultingSystem"].Value != null))
+                {
+                    ResultingSystem = new System.Management.ManagementPath((string)outParams.Properties["ResultingSystem"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1131,10 +1129,9 @@
                 inParams["AffectedSystem"] = ((System.Management.ManagementPath)(AffectedSystem)).Path;
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DestroySystem", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1153,11 +1150,11 @@
                 inParams["ExportSettingData"] = ((string)(ExportSettingData));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ExportSystemDefinition", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
+
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
             else {
@@ -1290,7 +1287,8 @@
                 inParams["SnapshotFolder"] = ((string)(SnapshotFolder));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportSnapshotDefinitions", inParams, null);
                 ImportedSnapshots = null;
-                if ((outParams.Properties["ImportedSnapshots"] != null)) {
+                if ((outParams.Properties["ImportedSnapshots"] != null && outParams.Properties["ImportedSnapshots"].Value != null))
+                {
                     int len = ((System.Array)(outParams.Properties["ImportedSnapshots"].Value)).Length;
                     System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
                     for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
@@ -1299,10 +1297,9 @@
                     ImportedSnapshots = arrToRet;
                 }
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1322,15 +1319,16 @@
                 inParams["SystemDefinitionFile"] = ((string)(SystemDefinitionFile));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportSystemDefinition", inParams, null);
                 ImportedSystem = null;
-                if ((outParams.Properties["ImportedSystem"] != null)) {
+                if ((outParams.Properties["ImportedSystem"] != null && outParams.Properties["ImportedSystem"].Value != null))
+                {
                     ImportedSystem = new System.Management.ManagementPath(outParams.Properties["ImportedSystem"].ToString());
                 }
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
+
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
             else {
@@ -1347,10 +1345,9 @@
                 inParams["SettingData"] = ((string)(SettingData));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyDiskMergeSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1367,13 +1364,13 @@
                 inParams["FeatureSettings"] = ((string[])(FeatureSettings));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyFeatureSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 ResultingFeatureSettings = null;
-                if ((outParams.Properties["ResultingFeatureSettings"] != null)) {
+                if ((outParams.Properties["ResultingFeatureSettings"] != null && outParams.Properties["ResultingFeatureSettings"].Value != null))
+                {
                     int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length;
                     System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
                     for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
@@ -1398,10 +1395,9 @@
                 inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyKvpItems", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1418,13 +1414,13 @@
                 inParams["ResourceSettings"] = ((string[])(ResourceSettings));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyResourceSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null)
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 ResultingResourceSettings = null;
-                if ((outParams.Properties["ResultingResourceSettings"] != null)) {
+                if ((outParams.Properties["ResultingResourceSettings"] != null && outParams.Properties["ResultingResourceSettings"].Value != null))
+                {
                     int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length;
                     System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
                     for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
@@ -1448,10 +1444,9 @@
                 inParams["SettingData"] = ((string)(SettingData));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyServiceSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1468,10 +1463,9 @@
                 inParams["SystemSettings"] = ((string)(SystemSettings));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifySystemSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1488,10 +1482,9 @@
                 inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path;
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RealizePlannedSystem", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 ResultingSystem = null;
                 if ((outParams.Properties["ResultingSystem"] != null)) {
@@ -1523,10 +1516,9 @@
                 }
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFeatureSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1557,11 +1549,9 @@
                 inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveKvpItems", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1588,11 +1578,9 @@
                 }
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveResourceSettings", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1610,11 +1598,9 @@
                 inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1632,11 +1618,9 @@
                 inParams["NetworkConfiguration"] = ((string[])(NetworkConfiguration));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetGuestNetworkAdapterConfiguration", inParams, null);
                 Job = null;
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
-                //                if (outParams.Properties["Job"] != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1675,10 +1659,9 @@
                 inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path;
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ValidatePlannedSystem", inParams, null);
                 Job = null;
-                //                if (outParams.Properties["Job"] != null)
-                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                if ((outParams.Properties["Job"] != null))
                 {
-                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }


[21/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitchManagementService.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitchManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitchManagementService.cs
deleted file mode 100644
index 9a4b5d2..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitchManagementService.cs
+++ /dev/null
@@ -1,1379 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_VirtualSwitchManagementService
-    public class VirtualSwitchManagementService : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_VirtualSwitchManagementService";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VirtualSwitchManagementService() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VirtualSwitchManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public VirtualSwitchManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public VirtualSwitchManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VirtualSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VirtualSwitchManagementService(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VirtualSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VirtualSwitchManagementService(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VirtualSwitchManagementService(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerContact {
-            get {
-                return ((string)(curObj["PrimaryOwnerContact"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerName {
-            get {
-                return ((string)(curObj["PrimaryOwnerName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsStartedNull {
-            get {
-                if ((curObj["Started"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool Started {
-            get {
-                if ((curObj["Started"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["Started"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string StartMode {
-            get {
-                return ((string)(curObj["StartMode"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeStarted() {
-            if ((this.IsStartedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_VirtualSwitchManagementService";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VirtualSwitchManagementServiceCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VirtualSwitchManagementServiceCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VirtualSwitchManagementServiceCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VirtualSwitchManagementServiceCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VirtualSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VirtualSwitchManagementService";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VirtualSwitchManagementServiceCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VirtualSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VirtualSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VirtualSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSwitchManagementService", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VirtualSwitchManagementServiceCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VirtualSwitchManagementService CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VirtualSwitchManagementService(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint BindExternalEthernetPort(System.Management.ManagementPath ExternalEthernetPort) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("BindExternalEthernetPort");
-                inParams["ExternalEthernetPort"] = ((System.Management.ManagementPath)(ExternalEthernetPort)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("BindExternalEthernetPort", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ConnectSwitchPort(System.Management.ManagementPath LANEndpoint, System.Management.ManagementPath SwitchPort, out System.Management.ManagementPath ActiveConnection) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ConnectSwitchPort");
-                inParams["LANEndpoint"] = ((System.Management.ManagementPath)(LANEndpoint)).Path;
-                inParams["SwitchPort"] = ((System.Management.ManagementPath)(SwitchPort)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ConnectSwitchPort", inParams, null);
-                ActiveConnection = null;
-                if ((outParams.Properties["ActiveConnection"] != null)) {
-                    ActiveConnection = new System.Management.ManagementPath((string)outParams.Properties["ActiveConnection"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                ActiveConnection = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateInternalEthernetPort(string FriendlyName, string MACAddress, string Name, out System.Management.ManagementPath CreatedInternalEthernetPort) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateInternalEthernetPort");
-                inParams["FriendlyName"] = ((string)(FriendlyName));
-                inParams["MACAddress"] = ((string)(MACAddress));
-                inParams["Name"] = ((string)(Name));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateInternalEthernetPort", inParams, null);
-                CreatedInternalEthernetPort = null;
-                if ((outParams.Properties["CreatedInternalEthernetPort"] != null)) {
-                    CreatedInternalEthernetPort = new System.Management.ManagementPath((string)outParams.Properties["CreatedInternalEthernetPort"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                CreatedInternalEthernetPort = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateInternalEthernetPortDynamicMac(string FriendlyName, string Name, out System.Management.ManagementPath CreatedInternalEthernetPort) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateInternalEthernetPortDynamicMac");
-                inParams["FriendlyName"] = ((string)(FriendlyName));
-                inParams["Name"] = ((string)(Name));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateInternalEthernetPortDynamicMac", inParams, null);
-                CreatedInternalEthernetPort = null;
-                if ((outParams.Properties["CreatedInternalEthernetPort"] != null)) {
-                    CreatedInternalEthernetPort = new System.Management.ManagementPath((string)outParams.Properties["CreatedInternalEthernetPort"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                CreatedInternalEthernetPort = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateSwitch(string FriendlyName, string Name, uint NumLearnableAddresses, string ScopeOfResidence, out System.Management.ManagementPath CreatedVirtualSwitch) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateSwitch");
-                inParams["FriendlyName"] = ((string)(FriendlyName));
-                inParams["Name"] = ((string)(Name));
-                inParams["NumLearnableAddresses"] = ((uint)(NumLearnableAddresses));
-                inParams["ScopeOfResidence"] = ((string)(ScopeOfResidence));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateSwitch", inParams, null);
-                CreatedVirtualSwitch = null;
-                if ((outParams.Properties["CreatedVirtualSwitch"] != null)) {
-                    CreatedVirtualSwitch = new System.Management.ManagementPath((string)outParams.Properties["CreatedVirtualSwitch"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                CreatedVirtualSwitch = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateSwitchPort(string FriendlyName, string Name, string ScopeOfResidence, System.Management.ManagementPath VirtualSwitch, out System.Management.ManagementPath CreatedSwitchPort) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateSwitchPort");
-                inParams["FriendlyName"] = ((string)(FriendlyName));
-                inParams["Name"] = ((string)(Name));
-                inParams["ScopeOfResidence"] = ((string)(ScopeOfResidence));
-                inParams["VirtualSwitch"] = ((System.Management.ManagementPath)(VirtualSwitch)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateSwitchPort", inParams, null);
-                CreatedSwitchPort = null;
-                if ((outParams.Properties["CreatedSwitchPort"] != null)) {
-                    CreatedSwitchPort = new System.Management.ManagementPath((string)outParams.Properties["CreatedSwitchPort"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                CreatedSwitchPort = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint DeleteInternalEthernetPort(System.Management.ManagementPath InternalEthernetPort) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("DeleteInternalEthernetPort");
-                inParams["InternalEthernetPort"] = ((System.Management.ManagementPath)(InternalEthernetPort)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DeleteInternalEthernetPort", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint DeleteSwitch(System.Management.ManagementPath VirtualSwitch) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("DeleteSwitch");
-                inParams["VirtualSwitch"] = ((System.Management.ManagementPath)(VirtualSwitch)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DeleteSwitch", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint DeleteSwitchPort(System.Management.ManagementPath SwitchPort) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("DeleteSwitchPort");
-                inParams["SwitchPort"] = ((System.Management.ManagementPath)(SwitchPort)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DeleteSwitchPort", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint DisconnectSwitchPort(System.Management.ManagementPath SwitchPort) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("DisconnectSwitchPort");
-                inParams["SwitchPort"] = ((System.Management.ManagementPath)(SwitchPort)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DisconnectSwitchPort", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint SetupSwitch(System.Management.ManagementPath ExternalEthernetPort, System.Management.ManagementPath ExternalSwitchPort, string InternalEthernetPortFriendlyName, string InternalEthernetPortName, System.Management.ManagementPath InternalSwitchPort, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("SetupSwitch");
-                inParams["ExternalEthernetPort"] = ((System.Management.ManagementPath)(ExternalEthernetPort)).Path;
-                inParams["ExternalSwitchPort"] = ((System.Management.ManagementPath)(ExternalSwitchPort)).Path;
-                inParams["InternalEthernetPortFriendlyName"] = ((string)(InternalEthernetPortFriendlyName));
-                inParams["InternalEthernetPortName"] = ((string)(InternalEthernetPortName));
-                inParams["InternalSwitchPort"] = ((System.Management.ManagementPath)(InternalSwitchPort)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetupSwitch", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint StartService() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint StopService() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint TeardownSwitch(System.Management.ManagementPath ExternalEthernetPort, System.Management.ManagementPath InternalEthernetPort, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("TeardownSwitch");
-                inParams["ExternalEthernetPort"] = ((System.Management.ManagementPath)(ExternalEthernetPort)).Path;
-                inParams["InternalEthernetPort"] = ((System.Management.ManagementPath)(InternalEthernetPort)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("TeardownSwitch", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint UnbindExternalEthernetPort(System.Management.ManagementPath ExternalEthernetPort) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("UnbindExternalEthernetPort");
-                inParams["ExternalEthernetPort"] = ((System.Management.ManagementPath)(ExternalEthernetPort)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("UnbindExternalEthernetPort", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VirtualSwitchManagementServiceCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VirtualSwitchManagementServiceCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VirtualSwitchManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VirtualSwitchManagementServiceEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VirtualSwitchManagementServiceEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VirtualSwitchManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VirtualSwitchManagementService(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[32/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_MemorySettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_MemorySettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_MemorySettingData.cs
deleted file mode 100644
index 3e5d903..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_MemorySettingData.cs
+++ /dev/null
@@ -1,1083 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // An Early Bound class generated for the WMI class.Msvm_MemorySettingData
-    public class MemorySettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_MemorySettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public MemorySettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public MemorySettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(MemorySettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public MemorySettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(MemorySettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public MemorySettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public MemorySettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public MemorySettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public MemorySettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public MemorySettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public MemorySettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Address {
-            get {
-                return ((string)(curObj["Address"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string AllocationUnits {
-            get {
-                return ((string)(curObj["AllocationUnits"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticAllocationNull {
-            get {
-                if ((curObj["AutomaticAllocation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutomaticAllocation {
-            get {
-                if ((curObj["AutomaticAllocation"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutomaticAllocation"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAutomaticDeallocationNull {
-            get {
-                if ((curObj["AutomaticDeallocation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool AutomaticDeallocation {
-            get {
-                if ((curObj["AutomaticDeallocation"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["AutomaticDeallocation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] Connection {
-            get {
-                return ((string[])(curObj["Connection"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsConsumerVisibilityNull {
-            get {
-                if ((curObj["ConsumerVisibility"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ConsumerVisibility {
-            get {
-                if ((curObj["ConsumerVisibility"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ConsumerVisibility"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Address or other identifying information to uniquely name the logical device. Thi" +
-            "s property is always set to \"Microsoft:GUID\".")]
-        public string DeviceID {
-            get {
-                return ((string)(curObj["DeviceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The format of the corresponding DeviceID property, or the supported device IDs wh" +
-            "en used to represent a capability. This property is not used.")]
-        public string DeviceIDFormat {
-            get {
-                return ((string)(curObj["DeviceIDFormat"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsDynamicMemoryEnabledNull {
-            get {
-                if ((curObj["DynamicMemoryEnabled"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Reserved for future use.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool DynamicMemoryEnabled {
-            get {
-                if ((curObj["DynamicMemoryEnabled"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["DynamicMemoryEnabled"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] HostResource {
-            get {
-                return ((string[])(curObj["HostResource"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsIsVirtualizedNull {
-            get {
-                if ((curObj["IsVirtualized"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Indicates whether this device is virtualized or passed through, possibly using partitioning. When set to False, the underlying or host resource is utilized. At least one item shall be present in the DeviceID property. When set to True, the resource is virtualized and may not map directly to an underlying/host resource. Some implementations may support specific assignment for virtualized resources, in which case the host resource(s) are exposed using the DeviceID property. This property is always set to True.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool IsVirtualized {
-            get {
-                if ((curObj["IsVirtualized"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["IsVirtualized"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLimitNull {
-            get {
-                if ((curObj["Limit"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Limit {
-            get {
-                if ((curObj["Limit"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Limit"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMappingBehaviorNull {
-            get {
-                if ((curObj["MappingBehavior"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort MappingBehavior {
-            get {
-                if ((curObj["MappingBehavior"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["MappingBehavior"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherResourceType {
-            get {
-                return ((string)(curObj["OtherResourceType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Parent {
-            get {
-                return ((string)(curObj["Parent"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PoolID {
-            get {
-                return ((string)(curObj["PoolID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsReservationNull {
-            get {
-                if ((curObj["Reservation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong Reservation {
-            get {
-                if ((curObj["Reservation"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["Reservation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ResourceSubType {
-            get {
-                return ((string)(curObj["ResourceSubType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsResourceTypeNull {
-            get {
-                if ((curObj["ResourceType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ResourceType {
-            get {
-                if ((curObj["ResourceType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ResourceType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTargetMemoryBufferNull {
-            get {
-                if ((curObj["TargetMemoryBuffer"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint TargetMemoryBuffer {
-            get {
-                if ((curObj["TargetMemoryBuffer"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["TargetMemoryBuffer"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsVirtualQuantityNull {
-            get {
-                if ((curObj["VirtualQuantity"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong VirtualQuantity {
-            get {
-                if ((curObj["VirtualQuantity"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["VirtualQuantity"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsWeightNull {
-            get {
-                if ((curObj["Weight"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint Weight {
-            get {
-                if ((curObj["Weight"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["Weight"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticAllocation() {
-            if ((this.IsAutomaticAllocationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAutomaticDeallocation() {
-            if ((this.IsAutomaticDeallocationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeConsumerVisibility() {
-            if ((this.IsConsumerVisibilityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeDynamicMemoryEnabled() {
-            if ((this.IsDynamicMemoryEnabledNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeIsVirtualized() {
-            if ((this.IsIsVirtualizedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLimit() {
-            if ((this.IsLimitNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMappingBehavior() {
-            if ((this.IsMappingBehaviorNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeReservation() {
-            if ((this.IsReservationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeResourceType() {
-            if ((this.IsResourceTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTargetMemoryBuffer() {
-            if ((this.IsTargetMemoryBufferNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeVirtualQuantity() {
-            if ((this.IsVirtualQuantityNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeWeight() {
-            if ((this.IsWeightNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization:Msvm_MemorySettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static MemorySettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static MemorySettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static MemorySettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static MemorySettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_MemorySettingData";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new MemorySettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static MemorySettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_MemorySettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new MemorySettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static MemorySettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new MemorySettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class MemorySettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public MemorySettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new MemorySettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new MemorySettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class MemorySettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public MemorySettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new MemorySettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[04/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs
new file mode 100755
index 0000000..63b21e3
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs
@@ -0,0 +1,1498 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
+    // An Early Bound class generated for the WMI class.Msvm_VirtualEthernetSwitchManagementService
+    public class VirtualEthernetSwitchManagementService : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Msvm_VirtualEthernetSwitchManagementService";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public VirtualEthernetSwitchManagementService() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public VirtualEthernetSwitchManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(null, new System.Management.ManagementPath(VirtualEthernetSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualEthernetSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public VirtualEthernetSwitchManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public VirtualEthernetSwitchManagementService(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public VirtualEthernetSwitchManagementService(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public VirtualEthernetSwitchManagementService(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] AvailableRequestedStates {
+            get {
+                return ((ushort[])(curObj["AvailableRequestedStates"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCommunicationStatusNull {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort CommunicationStatus {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["CommunicationStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string CreationClassName {
+            get {
+                return ((string)(curObj["CreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDetailedStatusNull {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DetailedStatus {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DetailedStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledDefaultNull {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledDefault {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledDefault"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledState {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHealthStateNull {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HealthState {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HealthState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInstallDateNull {
+            get {
+                if ((curObj["InstallDate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime InstallDate {
+            get {
+                if ((curObj["InstallDate"] != null)) {
+                    return ToDateTime(((string)(curObj["InstallDate"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOperatingStatusNull {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort OperatingStatus {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["OperatingStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] OperationalStatus {
+            get {
+                return ((ushort[])(curObj["OperationalStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherEnabledState {
+            get {
+                return ((string)(curObj["OtherEnabledState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PrimaryOwnerContact {
+            get {
+                return ((string)(curObj["PrimaryOwnerContact"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PrimaryOwnerName {
+            get {
+                return ((string)(curObj["PrimaryOwnerName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPrimaryStatusNull {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PrimaryStatus {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PrimaryStatus"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRequestedStateNull {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort RequestedState {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["RequestedState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsStartedNull {
+            get {
+                if ((curObj["Started"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool Started {
+            get {
+                if ((curObj["Started"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["Started"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string StartMode {
+            get {
+                return ((string)(curObj["StartMode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Status {
+            get {
+                return ((string)(curObj["Status"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] StatusDescriptions {
+            get {
+                return ((string[])(curObj["StatusDescriptions"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemCreationClassName {
+            get {
+                return ((string)(curObj["SystemCreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemName {
+            get {
+                return ((string)(curObj["SystemName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimeOfLastStateChangeNull {
+            get {
+                if ((curObj["TimeOfLastStateChange"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime TimeOfLastStateChange {
+            get {
+                if ((curObj["TimeOfLastStateChange"] != null)) {
+                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTransitioningToStateNull {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort TransitioningToState {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["TransitioningToState"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCommunicationStatus() {
+            if ((this.IsCommunicationStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDetailedStatus() {
+            if ((this.IsDetailedStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledDefault() {
+            if ((this.IsEnabledDefaultNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledState() {
+            if ((this.IsEnabledStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHealthState() {
+            if ((this.IsHealthStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        // Converts a given datetime in DMTF format to System.DateTime object.
+        static System.DateTime ToDateTime(string dmtfDate) {
+            System.DateTime initializer = System.DateTime.MinValue;
+            int year = initializer.Year;
+            int month = initializer.Month;
+            int day = initializer.Day;
+            int hour = initializer.Hour;
+            int minute = initializer.Minute;
+            int second = initializer.Second;
+            long ticks = 0;
+            string dmtf = dmtfDate;
+            System.DateTime datetime = System.DateTime.MinValue;
+            string tempString = string.Empty;
+            if ((dmtf == null)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length == 0)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length != 25)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            try {
+                tempString = dmtf.Substring(0, 4);
+                if (("****" != tempString)) {
+                    year = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(4, 2);
+                if (("**" != tempString)) {
+                    month = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(6, 2);
+                if (("**" != tempString)) {
+                    day = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(8, 2);
+                if (("**" != tempString)) {
+                    hour = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(10, 2);
+                if (("**" != tempString)) {
+                    minute = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(12, 2);
+                if (("**" != tempString)) {
+                    second = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(15, 6);
+                if (("******" != tempString)) {
+                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
+                }
+                if (((((((((year < 0) 
+                            || (month < 0)) 
+                            || (day < 0)) 
+                            || (hour < 0)) 
+                            || (minute < 0)) 
+                            || (minute < 0)) 
+                            || (second < 0)) 
+                            || (ticks < 0))) {
+                    throw new System.ArgumentOutOfRangeException();
+                }
+            }
+            catch (System.Exception e) {
+                throw new System.ArgumentOutOfRangeException(null, e.Message);
+            }
+            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
+            datetime = datetime.AddTicks(ticks);
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
+            int UTCOffset = 0;
+            int OffsetToBeAdjusted = 0;
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            tempString = dmtf.Substring(22, 3);
+            if ((tempString != "******")) {
+                tempString = dmtf.Substring(21, 4);
+                try {
+                    UTCOffset = int.Parse(tempString);
+                }
+                catch (System.Exception e) {
+                    throw new System.ArgumentOutOfRangeException(null, e.Message);
+                }
+                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
+                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
+            }
+            return datetime;
+        }
+        
+        // Converts a given System.DateTime object to DMTF datetime format.
+        static string ToDmtfDateTime(System.DateTime date) {
+            string utcString = string.Empty;
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            if ((System.Math.Abs(OffsetMins) > 999)) {
+                date = date.ToUniversalTime();
+                utcString = "+000";
+            }
+            else {
+                if ((tickOffset.Ticks >= 0)) {
+                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
+                }
+                else {
+                    string strTemp = ((long)(OffsetMins)).ToString();
+                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
+                }
+            }
+            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ".");
+            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
+            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
+                        * 1000) 
+                        / System.TimeSpan.TicksPerMillisecond)));
+            string strMicrosec = ((long)(microsec)).ToString();
+            if ((strMicrosec.Length > 6)) {
+                strMicrosec = strMicrosec.Substring(0, 6);
+            }
+            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
+            return dmtfDateTime;
+        }
+        
+        private bool ShouldSerializeInstallDate() {
+            if ((this.IsInstallDateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOperatingStatus() {
+            if ((this.IsOperatingStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePrimaryStatus() {
+            if ((this.IsPrimaryStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRequestedState() {
+            if ((this.IsRequestedStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeStarted() {
+            if ((this.IsStartedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimeOfLastStateChange() {
+            if ((this.IsTimeOfLastStateChangeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTransitioningToState() {
+            if ((this.IsTransitioningToStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualEthernetSwitchManagementService";
+            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static VirtualEthernetSwitchManagementServiceCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_VirtualEthernetSwitchManagementService";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new VirtualEthernetSwitchManagementServiceCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualEthernetSwitchManagementService", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new VirtualEthernetSwitchManagementServiceCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static VirtualEthernetSwitchManagementService CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new VirtualEthernetSwitchManagementService(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public uint AddFeatureSettings(System.Management.ManagementPath AffectedConfiguration, string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("AddFeatureSettings");
+                inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path;
+                inParams["FeatureSettings"] = ((string[])(FeatureSettings));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFeatureSettings", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                ResultingFeatureSettings = null;
+                if ((outParams.Properties["ResultingFeatureSettings"] != null)) {
+                    int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length;
+                    System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
+                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
+                        arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString());
+                    }
+                    ResultingFeatureSettings = arrToRet;
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                ResultingFeatureSettings = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint AddResourceSettings(System.Management.ManagementPath AffectedConfiguration, string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("AddResourceSettings");
+                inParams["AffectedConfiguration"] = ((System.Management.ManagementPath)(AffectedConfiguration)).Path;
+                inParams["ResourceSettings"] = ((string[])(ResourceSettings));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddResourceSettings", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                ResultingResourceSettings = null;
+                if ((outParams.Properties["ResultingResourceSettings"] != null)) {
+                    int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length;
+                    System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
+                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
+                        arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString());
+                    }
+                    ResultingResourceSettings = arrToRet;
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                ResultingResourceSettings = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint DefineSystem(System.Management.ManagementPath ReferenceConfiguration, string[] ResourceSettings, string SystemSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("DefineSystem");
+                inParams["ReferenceConfiguration"] = ((System.Management.ManagementPath)(ReferenceConfiguration)).Path;
+                inParams["ResourceSettings"] = ((string[])(ResourceSettings));
+                inParams["SystemSettings"] = ((string)(SystemSettings));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DefineSystem", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                ResultingSystem = null;
+                if ((outParams.Properties["ResultingSystem"] != null)) {
+                    ResultingSystem = new System.Management.ManagementPath(outParams.Properties["ResultingSystem"].ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                ResultingSystem = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint DestroySystem(System.Management.ManagementPath AffectedSystem, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("DestroySystem");
+                inParams["AffectedSystem"] = ((System.Management.ManagementPath)(AffectedSystem)).Path;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DestroySystem", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint ModifyFeatureSettings(string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ModifyFeatureSettings");
+                inParams["FeatureSettings"] = ((string[])(FeatureSettings));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyFeatureSettings", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                ResultingFeatureSettings = null;
+                if ((outParams.Properties["ResultingFeatureSettings"] != null)) {
+                    int len = ((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).Length;
+                    System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
+                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
+                        arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingFeatureSettings"].Value)).GetValue(iCounter).ToString());
+                    }
+                    ResultingFeatureSettings = arrToRet;
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                ResultingFeatureSettings = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint ModifyResourceSettings(string[] ResourceSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingResourceSettings) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ModifyResourceSettings");
+                inParams["ResourceSettings"] = ((string[])(ResourceSettings));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyResourceSettings", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                ResultingResourceSettings = null;
+                if ((outParams.Properties["ResultingResourceSettings"] != null)) {
+                    int len = ((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).Length;
+                    System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
+                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
+                        arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ResultingResourceSettings"].Value)).GetValue(iCounter).ToString());
+                    }
+                    ResultingResourceSettings = arrToRet;
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                ResultingResourceSettings = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint ModifySystemSettings(string SystemSettings, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ModifySystemSettings");
+                inParams["SystemSettings"] = ((string)(SystemSettings));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifySystemSettings", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint RemoveFeatureSettings(System.Management.ManagementPath[] FeatureSettings, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RemoveFeatureSettings");
+                if ((FeatureSettings != null)) {
+                    int len = ((System.Array)(FeatureSettings)).Length;
+                    string[] arrProp = new string[len];
+                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
+                        arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(FeatureSettings)).GetValue(iCounter))).Path;
+                    }
+                    inParams["FeatureSettings"] = arrProp;
+                }
+                else {
+                    inParams["FeatureSettings"] = null;
+                }
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFeatureSettings", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint RemoveResourceSettings(System.Management.ManagementPath[] ResourceSettings, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RemoveResourceSettings");
+                if ((ResourceSettings != null)) {
+                    int len = ((System.Array)(ResourceSettings)).Length;
+                    string[] arrProp = new string[len];
+                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
+                        arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(ResourceSettings)).GetValue(iCounter))).Path;
+                    }
+                    inParams["ResourceSettings"] = arrProp;
+                }
+                else {
+                    inParams["ResourceSettings"] = null;
+                }
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveResourceSettings", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null)
+                {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
+                inParams["RequestedState"] = ((ushort)(RequestedState));
+                inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint StartService() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint StopService() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class VirtualEthernetSwitchManagementServiceCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public VirtualEthernetSwitchManagementServiceCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new VirtualEthernetSwitchManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new VirtualEthernetSwitchManagementServiceEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class VirtualEthernetSwitchManagementServiceEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public VirtualEthernetSwitchManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new VirtualEthernetSwitchManagementService(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[50/56] [abbrv] Fix checkstyle errors in Nicira NVP plugin

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
index 114c939..3ab5f2b 100644
--- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
+++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java
@@ -83,54 +83,54 @@ import com.cloud.resource.ServerResource;
 
 public class NiciraNvpResource implements ServerResource {
     private static final Logger s_logger = Logger.getLogger(NiciraNvpResource.class);
-    
+
     private String _name;
     private String _guid;
     private String _zoneId;
     private int _numRetries;
-    
+
     private NiciraNvpApi _niciraNvpApi;
-    
+
     protected NiciraNvpApi createNiciraNvpApi() {
-    	return new NiciraNvpApi();
+        return new NiciraNvpApi();
     }
-    
+
     @Override
     public boolean configure(String name, Map<String, Object> params)
             throws ConfigurationException {
-    	
+
         _name = (String) params.get("name");
         if (_name == null) {
             throw new ConfigurationException("Unable to find name");
         }
-        
+
         _guid = (String)params.get("guid");
         if (_guid == null) {
             throw new ConfigurationException("Unable to find the guid");
         }
-        
+
         _zoneId = (String) params.get("zoneId");
         if (_zoneId == null) {
             throw new ConfigurationException("Unable to find zone");
         }
-        
+
         _numRetries = 2;
 
         String ip = (String) params.get("ip");
         if (ip == null) {
             throw new ConfigurationException("Unable to find IP");
         }
-        
+
         String adminuser = (String) params.get("adminuser");
         if (adminuser == null) {
             throw new ConfigurationException("Unable to find admin username");
         }
-        
+
         String adminpass = (String) params.get("adminpass");
         if (adminpass == null) {
             throw new ConfigurationException("Unable to find admin password");
-        }               
-        
+        }
+
         _niciraNvpApi = createNiciraNvpApi();
         _niciraNvpApi.setControllerAddress(ip);
         _niciraNvpApi.setAdminCredentials(adminuser,adminpass);
@@ -172,21 +172,21 @@ public class NiciraNvpResource implements ServerResource {
         return new StartupCommand[] { sc };
     }
 
-	@Override
-	public PingCommand getCurrentStatus(long id) {
+    @Override
+    public PingCommand getCurrentStatus(long id) {
         try {
             ControlClusterStatus ccs = _niciraNvpApi.getControlClusterStatus();
             if (!"stable".equals(ccs.getClusterStatus())) {
-            	s_logger.error("ControlCluster state is not stable: "
-            			+ ccs.getClusterStatus());
-            	return null;
+                s_logger.error("ControlCluster state is not stable: "
+                        + ccs.getClusterStatus());
+                return null;
             }
         } catch (NiciraNvpApiException e) {
-        	s_logger.error("getControlClusterStatus failed", e);
-        	return null;
+            s_logger.error("getControlClusterStatus failed", e);
+            return null;
         }
         return new PingCommand(Host.Type.L2Networking, id);
-	}
+    }
 
     @Override
     public Answer executeRequest(Command cmd) {
@@ -213,25 +213,25 @@ public class NiciraNvpResource implements ServerResource {
             return executeRequest((DeleteLogicalSwitchPortCommand) cmd, numRetries);
         }
         else if (cmd instanceof UpdateLogicalSwitchPortCommand) {
-        	return executeRequest((UpdateLogicalSwitchPortCommand) cmd, numRetries);
+            return executeRequest((UpdateLogicalSwitchPortCommand) cmd, numRetries);
         }
         else if (cmd instanceof FindLogicalSwitchPortCommand) {
-        	return executeRequest((FindLogicalSwitchPortCommand) cmd, numRetries);
+            return executeRequest((FindLogicalSwitchPortCommand) cmd, numRetries);
         }
         else if (cmd instanceof CreateLogicalRouterCommand) {
-        	return executeRequest((CreateLogicalRouterCommand) cmd, numRetries);
+            return executeRequest((CreateLogicalRouterCommand) cmd, numRetries);
         }
         else if (cmd instanceof DeleteLogicalRouterCommand) {
-        	return executeRequest((DeleteLogicalRouterCommand) cmd, numRetries);
+            return executeRequest((DeleteLogicalRouterCommand) cmd, numRetries);
         }
         else if (cmd instanceof ConfigureStaticNatRulesOnLogicalRouterCommand) {
-        	return executeRequest((ConfigureStaticNatRulesOnLogicalRouterCommand) cmd, numRetries);
+            return executeRequest((ConfigureStaticNatRulesOnLogicalRouterCommand) cmd, numRetries);
         }
         else if (cmd instanceof ConfigurePortForwardingRulesOnLogicalRouterCommand) {
-        	return executeRequest((ConfigurePortForwardingRulesOnLogicalRouterCommand) cmd, numRetries);
-        }       
+            return executeRequest((ConfigurePortForwardingRulesOnLogicalRouterCommand) cmd, numRetries);
+        }
         else if (cmd instanceof ConfigurePublicIpsOnLogicalRouterCommand) {
-        	return executeRequest((ConfigurePublicIpsOnLogicalRouterCommand) cmd, numRetries);
+            return executeRequest((ConfigurePublicIpsOnLogicalRouterCommand) cmd, numRetries);
         }
         s_logger.debug("Received unsupported command " + cmd.toString());
         return Answer.createUnsupportedCommandAnswer(cmd);
@@ -249,7 +249,7 @@ public class NiciraNvpResource implements ServerResource {
     @Override
     public void setAgentControl(IAgentControl agentControl) {
     }
-    
+
     private Answer executeRequest(CreateLogicalSwitchCommand cmd, int numRetries) {
         LogicalSwitch logicalSwitch = new LogicalSwitch();
         logicalSwitch.setDisplay_name(truncate("lswitch-" + cmd.getName(), 40));
@@ -264,39 +264,39 @@ public class NiciraNvpResource implements ServerResource {
         List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
         tags.add(new NiciraNvpTag("cs_account",cmd.getOwnerName()));
         logicalSwitch.setTags(tags);
-        
+
         try {
             logicalSwitch = _niciraNvpApi.createLogicalSwitch(logicalSwitch);
             return new CreateLogicalSwitchAnswer(cmd, true, "Logicalswitch " + logicalSwitch.getUuid() + " created", logicalSwitch.getUuid());
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new CreateLogicalSwitchAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new CreateLogicalSwitchAnswer(cmd, e);
+            }
         }
-        
+
     }
-    
+
     private Answer executeRequest(DeleteLogicalSwitchCommand cmd, int numRetries) {
         try {
             _niciraNvpApi.deleteLogicalSwitch(cmd.getLogicalSwitchUuid());
             return new DeleteLogicalSwitchAnswer(cmd, true, "Logicalswitch " + cmd.getLogicalSwitchUuid() + " deleted");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new DeleteLogicalSwitchAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new DeleteLogicalSwitchAnswer(cmd, e);
+            }
         }
     }
-    
+
     private Answer executeRequest(CreateLogicalSwitchPortCommand cmd, int numRetries) {
         String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String attachmentUuid = cmd.getAttachmentUuid();
-        
+
         try {
             // Tags set to scope cs_account and account name
             List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
@@ -305,35 +305,35 @@ public class NiciraNvpResource implements ServerResource {
             LogicalSwitchPort logicalSwitchPort = new LogicalSwitchPort(attachmentUuid, tags, true);
             LogicalSwitchPort newPort = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, logicalSwitchPort);
             try {
-            	_niciraNvpApi.modifyLogicalSwitchPortAttachment(cmd.getLogicalSwitchUuid(), newPort.getUuid(), new VifAttachment(attachmentUuid));
+                _niciraNvpApi.modifyLogicalSwitchPortAttachment(cmd.getLogicalSwitchUuid(), newPort.getUuid(), new VifAttachment(attachmentUuid));
             } catch (NiciraNvpApiException ex) {
-            	s_logger.warn("modifyLogicalSwitchPort failed after switchport was created, removing switchport");
-            	_niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), newPort.getUuid());
-            	throw (ex); // Rethrow the original exception
+                s_logger.warn("modifyLogicalSwitchPort failed after switchport was created, removing switchport");
+                _niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), newPort.getUuid());
+                throw (ex); // Rethrow the original exception
             }
             return new CreateLogicalSwitchPortAnswer(cmd, true, "Logical switch port " + newPort.getUuid() + " created", newPort.getUuid());
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new CreateLogicalSwitchPortAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new CreateLogicalSwitchPortAnswer(cmd, e);
+            }
         }
-        
+
     }
-    
+
     private Answer executeRequest(DeleteLogicalSwitchPortCommand cmd, int numRetries) {
         try {
             _niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), cmd.getLogicalSwitchPortUuid());
             return new DeleteLogicalSwitchPortAnswer(cmd, true, "Logical switch port " + cmd.getLogicalSwitchPortUuid() + " deleted");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new DeleteLogicalSwitchPortAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new DeleteLogicalSwitchPortAnswer(cmd, e);
+            }
         }
     }
 
@@ -341,7 +341,7 @@ public class NiciraNvpResource implements ServerResource {
         String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String logicalSwitchPortUuid = cmd.getLogicalSwitchPortUuid();
         String attachmentUuid = cmd.getAttachmentUuid();
-        
+
         try {
             // Tags set to scope cs_account and account name
             List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
@@ -350,474 +350,474 @@ public class NiciraNvpResource implements ServerResource {
             _niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, new VifAttachment(attachmentUuid));
             return new UpdateLogicalSwitchPortAnswer(cmd, true, "Attachment for  " + logicalSwitchPortUuid + " updated", logicalSwitchPortUuid);
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new UpdateLogicalSwitchPortAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new UpdateLogicalSwitchPortAnswer(cmd, e);
+            }
         }
-    	
+
     }
-    
+
     private Answer executeRequest(FindLogicalSwitchPortCommand cmd, int numRetries) {
-    	String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
+        String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
         String logicalSwitchPortUuid = cmd.getLogicalSwitchPortUuid();
-        
+
         try {
-        	NiciraNvpList<LogicalSwitchPort> ports = _niciraNvpApi.findLogicalSwitchPortsByUuid(logicalSwitchUuid, logicalSwitchPortUuid);
-        	if (ports.getResultCount() == 0) {
-        		return new FindLogicalSwitchPortAnswer(cmd, false, "Logical switchport " + logicalSwitchPortUuid + " not found", null);
-        	}
-        	else {
-        		return new FindLogicalSwitchPortAnswer(cmd, true, "Logical switchport " + logicalSwitchPortUuid + " found", logicalSwitchPortUuid);
-        	}
+            NiciraNvpList<LogicalSwitchPort> ports = _niciraNvpApi.findLogicalSwitchPortsByUuid(logicalSwitchUuid, logicalSwitchPortUuid);
+            if (ports.getResultCount() == 0) {
+                return new FindLogicalSwitchPortAnswer(cmd, false, "Logical switchport " + logicalSwitchPortUuid + " not found", null);
+            }
+            else {
+                return new FindLogicalSwitchPortAnswer(cmd, true, "Logical switchport " + logicalSwitchPortUuid + " found", logicalSwitchPortUuid);
+            }
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new FindLogicalSwitchPortAnswer(cmd, e);
-        	}
-        }    	
-    }
-    
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new FindLogicalSwitchPortAnswer(cmd, e);
+            }
+        }
+    }
+
     private Answer executeRequest(CreateLogicalRouterCommand cmd, int numRetries) {
-    	String routerName = cmd.getName();
-    	String gatewayServiceUuid = cmd.getGatewayServiceUuid();
-    	String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
-    	
+        String routerName = cmd.getName();
+        String gatewayServiceUuid = cmd.getGatewayServiceUuid();
+        String logicalSwitchUuid = cmd.getLogicalSwitchUuid();
+
         List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
         tags.add(new NiciraNvpTag("cs_account",cmd.getOwnerName()));
-        
+
         String publicNetworkNextHopIp = cmd.getPublicNextHop();
         String publicNetworkIpAddress = cmd.getPublicIpCidr();
         String internalNetworkAddress = cmd.getInternalIpCidr();
-        
-        s_logger.debug("Creating a logical router with external ip " 
-        		+ publicNetworkIpAddress + " and internal ip " + internalNetworkAddress
-        		+ "on gateway service " + gatewayServiceUuid);
-        
+
+        s_logger.debug("Creating a logical router with external ip "
+                + publicNetworkIpAddress + " and internal ip " + internalNetworkAddress
+                + "on gateway service " + gatewayServiceUuid);
+
         try {
-        	// Create the Router
-        	LogicalRouterConfig lrc = new LogicalRouterConfig();
-        	lrc.setDisplayName(truncate(routerName, 40));
-        	lrc.setTags(tags);
-        	lrc.setRoutingConfig(new SingleDefaultRouteImplictRoutingConfig(
-        			new RouterNextHop(publicNetworkNextHopIp)));
-        	lrc = _niciraNvpApi.createLogicalRouter(lrc);
-        	
-        	// store the switchport for rollback
-        	LogicalSwitchPort lsp = null;
-        	
-        	try {
-	        	// Create the outside port for the router
-	        	LogicalRouterPort lrpo = new LogicalRouterPort();
-	        	lrpo.setAdminStatusEnabled(true);
-	        	lrpo.setDisplayName(truncate(routerName + "-outside-port", 40));
-	        	lrpo.setTags(tags);
-	        	List<String> outsideIpAddresses = new ArrayList<String>();
-	        	outsideIpAddresses.add(publicNetworkIpAddress);
-	        	lrpo.setIpAddresses(outsideIpAddresses);
-	        	lrpo = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpo);
-	        	
-	        	// Attach the outside port to the gateway service on the correct VLAN
-	        	L3GatewayAttachment attachment = new L3GatewayAttachment(gatewayServiceUuid);
-	        	if (cmd.getVlanId() != 0) {
-	        		attachment.setVlanId(cmd.getVlanId());
-	        	}
-	        	_niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
-	        	
-	        	// Create the inside port for the router
-	        	LogicalRouterPort lrpi = new LogicalRouterPort();
-	        	lrpi.setAdminStatusEnabled(true);
-	        	lrpi.setDisplayName(truncate(routerName + "-inside-port", 40));
-	        	lrpi.setTags(tags);
-	        	List<String> insideIpAddresses = new ArrayList<String>();
-	        	insideIpAddresses.add(internalNetworkAddress);
-	        	lrpi.setIpAddresses(insideIpAddresses);
-	        	lrpi = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpi);
-	        	
-	        	// Create the inside port on the lswitch
-	            lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", 40), tags, true);
-	            lsp = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);
-	       	
-	        	// Attach the inside router port to the lswitch port with a PatchAttachment
-	            _niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpi.getUuid(), 
-	            		new PatchAttachment(lsp.getUuid()));
-	        	
-	        	// Attach the inside lswitch port to the router with a PatchAttachment
-	            _niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(), 
-	            		new PatchAttachment(lrpi.getUuid()));
-	            
-	            // Setup the source nat rule
-	            SourceNatRule snr = new SourceNatRule();
-	            snr.setToSourceIpAddressMin(publicNetworkIpAddress.split("/")[0]);
-	            snr.setToSourceIpAddressMax(publicNetworkIpAddress.split("/")[0]);
-	            Match match = new Match();
-	            match.setSourceIpAddresses(internalNetworkAddress);
-	            snr.setMatch(match);
-	            snr.setOrder(200); 
-	            _niciraNvpApi.createLogicalRouterNatRule(lrc.getUuid(), snr);
-        	} catch (NiciraNvpApiException e) {
-        		// We need to destroy the router if we already created it
-        		// this will also take care of any router ports and rules
-        		try {
-        			_niciraNvpApi.deleteLogicalRouter(lrc.getUuid());
-        			if (lsp != null) {
-        				_niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
-        			}
-        		} catch (NiciraNvpApiException ex) {}
-        		
-        		throw e;
-        	}
-            
-            return new CreateLogicalRouterAnswer(cmd, true, "Logical Router created (uuid " + lrc.getUuid() + ")", lrc.getUuid());    	
+            // Create the Router
+            LogicalRouterConfig lrc = new LogicalRouterConfig();
+            lrc.setDisplayName(truncate(routerName, 40));
+            lrc.setTags(tags);
+            lrc.setRoutingConfig(new SingleDefaultRouteImplictRoutingConfig(
+                    new RouterNextHop(publicNetworkNextHopIp)));
+            lrc = _niciraNvpApi.createLogicalRouter(lrc);
+
+            // store the switchport for rollback
+            LogicalSwitchPort lsp = null;
+
+            try {
+                // Create the outside port for the router
+                LogicalRouterPort lrpo = new LogicalRouterPort();
+                lrpo.setAdminStatusEnabled(true);
+                lrpo.setDisplayName(truncate(routerName + "-outside-port", 40));
+                lrpo.setTags(tags);
+                List<String> outsideIpAddresses = new ArrayList<String>();
+                outsideIpAddresses.add(publicNetworkIpAddress);
+                lrpo.setIpAddresses(outsideIpAddresses);
+                lrpo = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpo);
+
+                // Attach the outside port to the gateway service on the correct VLAN
+                L3GatewayAttachment attachment = new L3GatewayAttachment(gatewayServiceUuid);
+                if (cmd.getVlanId() != 0) {
+                    attachment.setVlanId(cmd.getVlanId());
+                }
+                _niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpo.getUuid(), attachment);
+
+                // Create the inside port for the router
+                LogicalRouterPort lrpi = new LogicalRouterPort();
+                lrpi.setAdminStatusEnabled(true);
+                lrpi.setDisplayName(truncate(routerName + "-inside-port", 40));
+                lrpi.setTags(tags);
+                List<String> insideIpAddresses = new ArrayList<String>();
+                insideIpAddresses.add(internalNetworkAddress);
+                lrpi.setIpAddresses(insideIpAddresses);
+                lrpi = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpi);
+
+                // Create the inside port on the lswitch
+                lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", 40), tags, true);
+                lsp = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp);
+
+                // Attach the inside router port to the lswitch port with a PatchAttachment
+                _niciraNvpApi.modifyLogicalRouterPortAttachment(lrc.getUuid(), lrpi.getUuid(),
+                        new PatchAttachment(lsp.getUuid()));
+
+                // Attach the inside lswitch port to the router with a PatchAttachment
+                _niciraNvpApi.modifyLogicalSwitchPortAttachment(logicalSwitchUuid, lsp.getUuid(),
+                        new PatchAttachment(lrpi.getUuid()));
+
+                // Setup the source nat rule
+                SourceNatRule snr = new SourceNatRule();
+                snr.setToSourceIpAddressMin(publicNetworkIpAddress.split("/")[0]);
+                snr.setToSourceIpAddressMax(publicNetworkIpAddress.split("/")[0]);
+                Match match = new Match();
+                match.setSourceIpAddresses(internalNetworkAddress);
+                snr.setMatch(match);
+                snr.setOrder(200);
+                _niciraNvpApi.createLogicalRouterNatRule(lrc.getUuid(), snr);
+            } catch (NiciraNvpApiException e) {
+                // We need to destroy the router if we already created it
+                // this will also take care of any router ports and rules
+                try {
+                    _niciraNvpApi.deleteLogicalRouter(lrc.getUuid());
+                    if (lsp != null) {
+                        _niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid());
+                    }
+                } catch (NiciraNvpApiException ex) {}
+
+                throw e;
+            }
+
+            return new CreateLogicalRouterAnswer(cmd, true, "Logical Router created (uuid " + lrc.getUuid() + ")", lrc.getUuid());
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new CreateLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new CreateLogicalRouterAnswer(cmd, e);
+            }
         }
     }
-    
+
     private Answer executeRequest(DeleteLogicalRouterCommand cmd, int numRetries) {
-    	try {
-    		_niciraNvpApi.deleteLogicalRouter(cmd.getLogicalRouterUuid());
-    		return new DeleteLogicalRouterAnswer(cmd, true, "Logical Router deleted (uuid " + cmd.getLogicalRouterUuid() + ")");
+        try {
+            _niciraNvpApi.deleteLogicalRouter(cmd.getLogicalRouterUuid());
+            return new DeleteLogicalRouterAnswer(cmd, true, "Logical Router deleted (uuid " + cmd.getLogicalRouterUuid() + ")");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new DeleteLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new DeleteLogicalRouterAnswer(cmd, e);
+            }
         }
     }
-    
+
     private Answer executeRequest(ConfigurePublicIpsOnLogicalRouterCommand cmd, int numRetries) {
-    	try {
-    		NiciraNvpList<LogicalRouterPort> ports = _niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(cmd.getLogicalRouterUuid(), cmd.getL3GatewayServiceUuid());
-    		if (ports.getResultCount() != 1) {
-    			return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, false, "No logical router ports found, unable to set ip addresses");
-    		}
-    		LogicalRouterPort lrp = ports.getResults().get(0);
-    		lrp.setIpAddresses(cmd.getPublicCidrs());
-    		_niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
-    		
-    		return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() + 
-    				" ip addresses on logical router uuid " + cmd.getLogicalRouterUuid());
+        try {
+            NiciraNvpList<LogicalRouterPort> ports = _niciraNvpApi.findLogicalRouterPortByGatewayServiceUuid(cmd.getLogicalRouterUuid(), cmd.getL3GatewayServiceUuid());
+            if (ports.getResultCount() != 1) {
+                return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, false, "No logical router ports found, unable to set ip addresses");
+            }
+            LogicalRouterPort lrp = ports.getResults().get(0);
+            lrp.setIpAddresses(cmd.getPublicCidrs());
+            _niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp);
+
+            return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() +
+                    " ip addresses on logical router uuid " + cmd.getLogicalRouterUuid());
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, e);
+            }
         }
-    	
+
     }
-    
+
     private Answer executeRequest(ConfigureStaticNatRulesOnLogicalRouterCommand cmd, int numRetries) {
-    	try {
-    		NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
-    		// Rules of the game (also known as assumptions-that-will-make-stuff-break-later-on)
-    		// A SourceNat rule with a match other than a /32 cidr is assumed to be the "main" SourceNat rule
-    		// Any other SourceNat rule should have a corresponding DestinationNat rule
-    		
-    		for (StaticNatRuleTO rule : cmd.getRules()) {
-    			
-    			NatRule[] rulepair = generateStaticNatRulePair(rule.getDstIp(), rule.getSrcIp());
-    							
-				NatRule incoming = null;
-				NatRule outgoing = null;
-
-				for (NatRule storedRule : existingRules.getResults()) {					
-    				if (storedRule.equalsIgnoreUuid(rulepair[1])) {
-						// The outgoing rule exists
-    					outgoing = storedRule;
-    					s_logger.debug("Found matching outgoing rule " + outgoing.getUuid());
-    					if (incoming != null) {
-    						break;
-    					}
-        			}    					
-    				else if (storedRule.equalsIgnoreUuid(rulepair[0])) {
-    					// The incoming rule exists
-    					incoming = storedRule;
-    					s_logger.debug("Found matching incoming rule " + incoming.getUuid());
-    					if (outgoing != null) {
-    						break;
-    					}
-    				}
-    			}
-				if (incoming != null && outgoing != null) {
-					if (rule.revoked()) {
-						s_logger.debug("Deleting incoming rule " + incoming.getUuid());
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
-						
-						s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
-					}
-				}
-				else {
-					if (rule.revoked()) {
-						s_logger.warn("Tried deleting a rule that does not exist, " + 
-								rule.getSrcIp() + " -> " + rule.getDstIp());
-						break;
-					}
-					
-					rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
-					s_logger.debug("Created " + natRuleToString(rulepair[0]));
-					
-					try {
-						rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
-						s_logger.debug("Created " + natRuleToString(rulepair[1]));
-					} catch (NiciraNvpApiException ex) {
-						s_logger.debug("Failed to create SourceNatRule, rolling back DestinationNatRule");
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
-						throw ex; // Rethrow original exception
-					}
-					
-				}
-    		}
-    		return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, true, cmd.getRules().size() +" StaticNat rules applied");
+        try {
+            NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
+            // Rules of the game (also known as assumptions-that-will-make-stuff-break-later-on)
+            // A SourceNat rule with a match other than a /32 cidr is assumed to be the "main" SourceNat rule
+            // Any other SourceNat rule should have a corresponding DestinationNat rule
+
+            for (StaticNatRuleTO rule : cmd.getRules()) {
+
+                NatRule[] rulepair = generateStaticNatRulePair(rule.getDstIp(), rule.getSrcIp());
+
+                NatRule incoming = null;
+                NatRule outgoing = null;
+
+                for (NatRule storedRule : existingRules.getResults()) {
+                    if (storedRule.equalsIgnoreUuid(rulepair[1])) {
+                        // The outgoing rule exists
+                        outgoing = storedRule;
+                        s_logger.debug("Found matching outgoing rule " + outgoing.getUuid());
+                        if (incoming != null) {
+                            break;
+                        }
+                    }
+                    else if (storedRule.equalsIgnoreUuid(rulepair[0])) {
+                        // The incoming rule exists
+                        incoming = storedRule;
+                        s_logger.debug("Found matching incoming rule " + incoming.getUuid());
+                        if (outgoing != null) {
+                            break;
+                        }
+                    }
+                }
+                if (incoming != null && outgoing != null) {
+                    if (rule.revoked()) {
+                        s_logger.debug("Deleting incoming rule " + incoming.getUuid());
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
+
+                        s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
+                    }
+                }
+                else {
+                    if (rule.revoked()) {
+                        s_logger.warn("Tried deleting a rule that does not exist, " +
+                                rule.getSrcIp() + " -> " + rule.getDstIp());
+                        break;
+                    }
+
+                    rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
+                    s_logger.debug("Created " + natRuleToString(rulepair[0]));
+
+                    try {
+                        rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
+                        s_logger.debug("Created " + natRuleToString(rulepair[1]));
+                    } catch (NiciraNvpApiException ex) {
+                        s_logger.debug("Failed to create SourceNatRule, rolling back DestinationNatRule");
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
+                        throw ex; // Rethrow original exception
+                    }
+
+                }
+            }
+            return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, true, cmd.getRules().size() +" StaticNat rules applied");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, e);
+            }
         }
     }
 
     private Answer executeRequest(ConfigurePortForwardingRulesOnLogicalRouterCommand cmd, int numRetries) {
-    	try {
-    		NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
-    		// Rules of the game (also known as assumptions-that-will-make-stuff-break-later-on)
-    		// A SourceNat rule with a match other than a /32 cidr is assumed to be the "main" SourceNat rule
-    		// Any other SourceNat rule should have a corresponding DestinationNat rule
-    		
-    		for (PortForwardingRuleTO rule : cmd.getRules()) {
-    			if (rule.isAlreadyAdded() && !rule.revoked()) {
-    				// Don't need to do anything
-    				continue;
-    			}
-    			
-    			if (rule.getDstPortRange()[0] != rule.getDstPortRange()[1] || 
-    			        rule.getSrcPortRange()[0] != rule.getSrcPortRange()[1]    ) {
-    				return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, false, "Nicira NVP doesn't support port ranges for port forwarding");
-    			}
-    			
-    			NatRule[] rulepair = generatePortForwardingRulePair(rule.getDstIp(), rule.getDstPortRange(), rule.getSrcIp(), rule.getSrcPortRange(), rule.getProtocol());
-				
-				NatRule incoming = null;
-				NatRule outgoing = null;
-
-				for (NatRule storedRule : existingRules.getResults()) {
-    				if (storedRule.equalsIgnoreUuid(rulepair[1])) {
-						// The outgoing rule exists
-    					outgoing = storedRule;
-    					s_logger.debug("Found matching outgoing rule " + outgoing.getUuid());
-    					if (incoming != null) {
-    						break;
-    					}
-        			}    					
-    				else if (storedRule.equalsIgnoreUuid(rulepair[0])) {
-    					// The incoming rule exists
-    					incoming = storedRule;
-    					s_logger.debug("Found matching incoming rule " + incoming.getUuid());
-    					if (outgoing != null) {
-    						break;
-    					}
-    				}
-				}
-				if (incoming != null && outgoing != null) {
-					if (rule.revoked()) {
-						s_logger.debug("Deleting incoming rule " + incoming.getUuid());
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
-						
-						s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
-					}
-				}
-				else {
-					if (rule.revoked()) {
-						s_logger.warn("Tried deleting a rule that does not exist, " + 
-								rule.getSrcIp() + " -> " + rule.getDstIp());
-						break;
-					}
-					
-					rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
-					s_logger.debug("Created " + natRuleToString(rulepair[0]));
-					
-					try {
-						rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
-						s_logger.debug("Created " + natRuleToString(rulepair[1]));
-					} catch (NiciraNvpApiException ex) {
-						s_logger.warn("NiciraNvpApiException during create call, rolling back previous create");
-						_niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
-						throw ex; // Rethrow the original exception
-					}
-					
-				}
-    		}
-    		return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, true, cmd.getRules().size() +" PortForwarding rules applied");
+        try {
+            NiciraNvpList<NatRule> existingRules = _niciraNvpApi.findNatRulesByLogicalRouterUuid(cmd.getLogicalRouterUuid());
+            // Rules of the game (also known as assumptions-that-will-make-stuff-break-later-on)
+            // A SourceNat rule with a match other than a /32 cidr is assumed to be the "main" SourceNat rule
+            // Any other SourceNat rule should have a corresponding DestinationNat rule
+
+            for (PortForwardingRuleTO rule : cmd.getRules()) {
+                if (rule.isAlreadyAdded() && !rule.revoked()) {
+                    // Don't need to do anything
+                    continue;
+                }
+
+                if (rule.getDstPortRange()[0] != rule.getDstPortRange()[1] ||
+                        rule.getSrcPortRange()[0] != rule.getSrcPortRange()[1]    ) {
+                    return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, false, "Nicira NVP doesn't support port ranges for port forwarding");
+                }
+
+                NatRule[] rulepair = generatePortForwardingRulePair(rule.getDstIp(), rule.getDstPortRange(), rule.getSrcIp(), rule.getSrcPortRange(), rule.getProtocol());
+
+                NatRule incoming = null;
+                NatRule outgoing = null;
+
+                for (NatRule storedRule : existingRules.getResults()) {
+                    if (storedRule.equalsIgnoreUuid(rulepair[1])) {
+                        // The outgoing rule exists
+                        outgoing = storedRule;
+                        s_logger.debug("Found matching outgoing rule " + outgoing.getUuid());
+                        if (incoming != null) {
+                            break;
+                        }
+                    }
+                    else if (storedRule.equalsIgnoreUuid(rulepair[0])) {
+                        // The incoming rule exists
+                        incoming = storedRule;
+                        s_logger.debug("Found matching incoming rule " + incoming.getUuid());
+                        if (outgoing != null) {
+                            break;
+                        }
+                    }
+                }
+                if (incoming != null && outgoing != null) {
+                    if (rule.revoked()) {
+                        s_logger.debug("Deleting incoming rule " + incoming.getUuid());
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid());
+
+                        s_logger.debug("Deleting outgoing rule " + outgoing.getUuid());
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid());
+                    }
+                }
+                else {
+                    if (rule.revoked()) {
+                        s_logger.warn("Tried deleting a rule that does not exist, " +
+                                rule.getSrcIp() + " -> " + rule.getDstIp());
+                        break;
+                    }
+
+                    rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]);
+                    s_logger.debug("Created " + natRuleToString(rulepair[0]));
+
+                    try {
+                        rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]);
+                        s_logger.debug("Created " + natRuleToString(rulepair[1]));
+                    } catch (NiciraNvpApiException ex) {
+                        s_logger.warn("NiciraNvpApiException during create call, rolling back previous create");
+                        _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid());
+                        throw ex; // Rethrow the original exception
+                    }
+
+                }
+            }
+            return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, true, cmd.getRules().size() +" PortForwarding rules applied");
         } catch (NiciraNvpApiException e) {
-        	if (numRetries > 0) {
-        		return retry(cmd, --numRetries);
-        	} 
-        	else {
-        		return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, e);
-        	}
+            if (numRetries > 0) {
+                return retry(cmd, --numRetries);
+            }
+            else {
+                return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, e);
+            }
         }
-    	
+
     }
-    
+
     private Answer executeRequest(ReadyCommand cmd) {
         return new ReadyAnswer(cmd);
     }
-    
+
     private Answer executeRequest(MaintainCommand cmd) {
         return new MaintainAnswer(cmd);
-    }    
+    }
 
     private Answer retry(Command cmd, int numRetries) {
         s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries);
         return executeRequest(cmd, numRetries);
     }
-    
+
     private String natRuleToString(NatRule rule) {
-    	
-		StringBuilder natRuleStr = new StringBuilder();
-		natRuleStr.append("Rule ");
-		natRuleStr.append(rule.getUuid());
-		natRuleStr.append(" (");
-		natRuleStr.append(rule.getType());
-		natRuleStr.append(") :");
-		Match m = rule.getMatch();
-		natRuleStr.append("match (");
-		natRuleStr.append(m.getProtocol());
-		natRuleStr.append(" ");
-		natRuleStr.append(m.getSourceIpAddresses());
-		natRuleStr.append(" [");
-		natRuleStr.append(m.getSourcePort());
-		natRuleStr.append(" ] -> ");
-		natRuleStr.append(m.getDestinationIpAddresses());
-		natRuleStr.append(" [");
-		natRuleStr.append(m.getDestinationPort());
-		natRuleStr.append(" ]) -->");
-		if ("SourceNatRule".equals(rule.getType())) {
-			natRuleStr.append(((SourceNatRule)rule).getToSourceIpAddressMin());
-			natRuleStr.append("-");
-			natRuleStr.append(((SourceNatRule)rule).getToSourceIpAddressMax());
-			natRuleStr.append(" [");
-			natRuleStr.append(((SourceNatRule)rule).getToSourcePort());
-			natRuleStr.append(" ])");
-		}
-		else {
-			natRuleStr.append(((DestinationNatRule)rule).getToDestinationIpAddress());
-			natRuleStr.append(" [");
-			natRuleStr.append(((DestinationNatRule)rule).getToDestinationPort());
-			natRuleStr.append(" ])");
-		}
-		return natRuleStr.toString();
-    }
-    
+
+        StringBuilder natRuleStr = new StringBuilder();
+        natRuleStr.append("Rule ");
+        natRuleStr.append(rule.getUuid());
+        natRuleStr.append(" (");
+        natRuleStr.append(rule.getType());
+        natRuleStr.append(") :");
+        Match m = rule.getMatch();
+        natRuleStr.append("match (");
+        natRuleStr.append(m.getProtocol());
+        natRuleStr.append(" ");
+        natRuleStr.append(m.getSourceIpAddresses());
+        natRuleStr.append(" [");
+        natRuleStr.append(m.getSourcePort());
+        natRuleStr.append(" ] -> ");
+        natRuleStr.append(m.getDestinationIpAddresses());
+        natRuleStr.append(" [");
+        natRuleStr.append(m.getDestinationPort());
+        natRuleStr.append(" ]) -->");
+        if ("SourceNatRule".equals(rule.getType())) {
+            natRuleStr.append(((SourceNatRule)rule).getToSourceIpAddressMin());
+            natRuleStr.append("-");
+            natRuleStr.append(((SourceNatRule)rule).getToSourceIpAddressMax());
+            natRuleStr.append(" [");
+            natRuleStr.append(((SourceNatRule)rule).getToSourcePort());
+            natRuleStr.append(" ])");
+        }
+        else {
+            natRuleStr.append(((DestinationNatRule)rule).getToDestinationIpAddress());
+            natRuleStr.append(" [");
+            natRuleStr.append(((DestinationNatRule)rule).getToDestinationPort());
+            natRuleStr.append(" ])");
+        }
+        return natRuleStr.toString();
+    }
+
     private String truncate(String string, int length) {
-    	if (string.length() <= length) {
-    		return string;
-    	}
-    	else {
-    		return string.substring(0, length);
-    	}
-    }
-    
+        if (string.length() <= length) {
+            return string;
+        }
+        else {
+            return string.substring(0, length);
+        }
+    }
+
     protected NatRule[] generateStaticNatRulePair(String insideIp, String outsideIp) {
-    	NatRule[] rulepair = new NatRule[2];
-    	rulepair[0] = new DestinationNatRule();
-    	rulepair[0].setType("DestinationNatRule");
-    	rulepair[0].setOrder(100);
-    	rulepair[1] = new SourceNatRule();
-    	rulepair[1].setType("SourceNatRule");
-    	rulepair[1].setOrder(100);
-    	
-		Match m = new Match();
-		m.setDestinationIpAddresses(outsideIp);
-		rulepair[0].setMatch(m);
-		((DestinationNatRule)rulepair[0]).setToDestinationIpAddress(insideIp);
-
-		// create matching snat rule
-		m = new Match();
-		m.setSourceIpAddresses(insideIp);
-		rulepair[1].setMatch(m);
-		((SourceNatRule)rulepair[1]).setToSourceIpAddressMin(outsideIp);
-		((SourceNatRule)rulepair[1]).setToSourceIpAddressMax(outsideIp);
-    	
-    	return rulepair;
-    	
-    }
-    
+        NatRule[] rulepair = new NatRule[2];
+        rulepair[0] = new DestinationNatRule();
+        rulepair[0].setType("DestinationNatRule");
+        rulepair[0].setOrder(100);
+        rulepair[1] = new SourceNatRule();
+        rulepair[1].setType("SourceNatRule");
+        rulepair[1].setOrder(100);
+
+        Match m = new Match();
+        m.setDestinationIpAddresses(outsideIp);
+        rulepair[0].setMatch(m);
+        ((DestinationNatRule)rulepair[0]).setToDestinationIpAddress(insideIp);
+
+        // create matching snat rule
+        m = new Match();
+        m.setSourceIpAddresses(insideIp);
+        rulepair[1].setMatch(m);
+        ((SourceNatRule)rulepair[1]).setToSourceIpAddressMin(outsideIp);
+        ((SourceNatRule)rulepair[1]).setToSourceIpAddressMax(outsideIp);
+
+        return rulepair;
+
+    }
+
     protected NatRule[] generatePortForwardingRulePair(String insideIp, int[] insidePorts, String outsideIp, int[] outsidePorts, String protocol) {
-       	// Start with a basic static nat rule, then add port and protocol details
-    	NatRule[] rulepair = generateStaticNatRulePair(insideIp, outsideIp);
-    	
-    	((DestinationNatRule)rulepair[0]).setToDestinationPort(insidePorts[0]);
-    	rulepair[0].getMatch().setDestinationPort(outsidePorts[0]);
-    	rulepair[0].setOrder(50);
-    	rulepair[0].getMatch().setEthertype("IPv4");
-		if ("tcp".equals(protocol)) {
-			rulepair[0].getMatch().setProtocol(6);
-		}
-		else if ("udp".equals(protocol)) {
-			rulepair[0].getMatch().setProtocol(17);
-		}
-
-    	((SourceNatRule)rulepair[1]).setToSourcePort(outsidePorts[0]);
-    	rulepair[1].getMatch().setSourcePort(insidePorts[0]);
-    	rulepair[1].setOrder(50);
-    	rulepair[1].getMatch().setEthertype("IPv4");
-		if ("tcp".equals(protocol)) {
-			rulepair[1].getMatch().setProtocol(6);
-		}
-		else if ("udp".equals(protocol)) {
-			rulepair[1].getMatch().setProtocol(17);
-		}
-
-		return rulepair;
-   	
-    }
-
-	@Override
-	public void setName(String name) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	@Override
-	public void setConfigParams(Map<String, Object> params) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	@Override
-	public Map<String, Object> getConfigParams() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public int getRunLevel() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public void setRunLevel(int level) {
-		// TODO Auto-generated method stub
-		
-	}
-    
+        // Start with a basic static nat rule, then add port and protocol details
+        NatRule[] rulepair = generateStaticNatRulePair(insideIp, outsideIp);
+
+        ((DestinationNatRule)rulepair[0]).setToDestinationPort(insidePorts[0]);
+        rulepair[0].getMatch().setDestinationPort(outsidePorts[0]);
+        rulepair[0].setOrder(50);
+        rulepair[0].getMatch().setEthertype("IPv4");
+        if ("tcp".equals(protocol)) {
+            rulepair[0].getMatch().setProtocol(6);
+        }
+        else if ("udp".equals(protocol)) {
+            rulepair[0].getMatch().setProtocol(17);
+        }
+
+        ((SourceNatRule)rulepair[1]).setToSourcePort(outsidePorts[0]);
+        rulepair[1].getMatch().setSourcePort(insidePorts[0]);
+        rulepair[1].setOrder(50);
+        rulepair[1].getMatch().setEthertype("IPv4");
+        if ("tcp".equals(protocol)) {
+            rulepair[1].getMatch().setProtocol(6);
+        }
+        else if ("udp".equals(protocol)) {
+            rulepair[1].getMatch().setProtocol(17);
+        }
+
+        return rulepair;
+
+    }
+
+    @Override
+    public void setName(String name) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setConfigParams(Map<String, Object> params) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public Map<String, Object> getConfigParams() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public int getRunLevel() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setRunLevel(int level) {
+        // TODO Auto-generated method stub
+
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
index 6b5c103..9202241 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/element/NiciraNvpElementTest.java
@@ -16,6 +16,16 @@
 // under the License.
 package com.cloud.network.element;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -31,7 +41,6 @@ import org.mockito.ArgumentMatcher;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 
 import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.Command;
 import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer;
 import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand;
 import com.cloud.deploy.DeployDestination;
@@ -41,11 +50,11 @@ import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
+import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.Network.GuestType;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
-import com.cloud.network.IpAddress;
 import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.TrafficType;
@@ -55,18 +64,12 @@ import com.cloud.network.PublicIpAddress;
 import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.NiciraNvpDao;
 import com.cloud.network.dao.NiciraNvpRouterMappingDao;
-import com.cloud.network.nicira.NatRule;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.resource.ResourceManager;
 import com.cloud.user.Account;
 import com.cloud.utils.net.Ip;
 import com.cloud.vm.ReservationContext;
 
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
-
 public class NiciraNvpElementTest {
 
     NiciraNvpElement _element = new NiciraNvpElement();
@@ -136,7 +139,7 @@ public class NiciraNvpElementTest {
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
-        DeployDestination dest = mock(DeployDestination.class);
+        mock(DeployDestination.class);
 
         Domain dom = mock(Domain.class);
         when(dom.getName()).thenReturn("domain");


[24/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpoint.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpoint.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpoint.cs
deleted file mode 100644
index d5c0bb0..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpoint.cs
+++ /dev/null
@@ -1,1390 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_VLANEndpoint
-    public class VLANEndpoint : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_VLANEndpoint";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VLANEndpoint() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VLANEndpoint(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VLANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public VLANEndpoint(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VLANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public VLANEndpoint(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VLANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VLANEndpoint(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VLANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VLANEndpoint(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VLANEndpoint(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsBroadcastResetSupportedNull {
-            get {
-                if ((curObj["BroadcastResetSupported"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool BroadcastResetSupported {
-            get {
-                if ((curObj["BroadcastResetSupported"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["BroadcastResetSupported"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsDesiredEndpointModeNull {
-            get {
-                if ((curObj["DesiredEndpointMode"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort DesiredEndpointMode {
-            get {
-                if ((curObj["DesiredEndpointMode"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["DesiredEndpointMode"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsDesiredVLANTrunkEncapsulationNull {
-            get {
-                if ((curObj["DesiredVLANTrunkEncapsulation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort DesiredVLANTrunkEncapsulation {
-            get {
-                if ((curObj["DesiredVLANTrunkEncapsulation"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["DesiredVLANTrunkEncapsulation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsGVRPStatusNull {
-            get {
-                if ((curObj["GVRPStatus"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort GVRPStatus {
-            get {
-                if ((curObj["GVRPStatus"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["GVRPStatus"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string NameFormat {
-            get {
-                return ((string)(curObj["NameFormat"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsOperationalEndpointModeNull {
-            get {
-                if ((curObj["OperationalEndpointMode"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort OperationalEndpointMode {
-            get {
-                if ((curObj["OperationalEndpointMode"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["OperationalEndpointMode"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsOperationalVLANTrunkEncapsulationNull {
-            get {
-                if ((curObj["OperationalVLANTrunkEncapsulation"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort OperationalVLANTrunkEncapsulation {
-            get {
-                if ((curObj["OperationalVLANTrunkEncapsulation"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["OperationalVLANTrunkEncapsulation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEndpointMode {
-            get {
-                return ((string)(curObj["OtherEndpointMode"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherTrunkEncapsulation {
-            get {
-                return ((string)(curObj["OtherTrunkEncapsulation"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherTypeDescription {
-            get {
-                return ((string)(curObj["OtherTypeDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolIFTypeNull {
-            get {
-                if ((curObj["ProtocolIFType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolIFType {
-            get {
-                if ((curObj["ProtocolIFType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolIFType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolTypeNull {
-            get {
-                if ((curObj["ProtocolType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolType {
-            get {
-                if ((curObj["ProtocolType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The endpoint mode supported by this port.")]
-        public ushort[] SupportedEndpointModes {
-            get {
-                return ((ushort[])(curObj["SupportedEndpointModes"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeBroadcastResetSupported() {
-            if ((this.IsBroadcastResetSupportedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeDesiredEndpointMode() {
-            if ((this.IsDesiredEndpointModeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeDesiredVLANTrunkEncapsulation() {
-            if ((this.IsDesiredVLANTrunkEncapsulationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeGVRPStatus() {
-            if ((this.IsGVRPStatusNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeOperationalEndpointMode() {
-            if ((this.IsOperationalEndpointModeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeOperationalVLANTrunkEncapsulation() {
-            if ((this.IsOperationalVLANTrunkEncapsulationNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProtocolIFType() {
-            if ((this.IsProtocolIFTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProtocolType() {
-            if ((this.IsProtocolTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_VLANEndpoint";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VLANEndpointCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VLANEndpointCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VLANEndpointCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VLANEndpointCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VLANEndpoint";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VLANEndpointCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VLANEndpoint", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VLANEndpointCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VLANEndpoint CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VLANEndpoint(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint BroadcastReset() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("BroadcastReset", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VLANEndpointCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VLANEndpointCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VLANEndpoint(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VLANEndpointEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VLANEndpointEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VLANEndpointEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VLANEndpoint(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[48/56] [abbrv] Fix checkstyle errors in Nicira NVP plugin

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/256763cf/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
index 8b5af3c..78465e4 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java
@@ -16,8 +16,18 @@
 // under the License.
 package com.cloud.network.resource;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -74,768 +84,769 @@ import com.cloud.network.nicira.NiciraNvpList;
 import com.cloud.network.nicira.SourceNatRule;
 
 public class NiciraNvpResourceTest {
-	NiciraNvpApi _nvpApi = mock(NiciraNvpApi.class);
-	NiciraNvpResource _resource;
-	Map<String,Object> _parameters;
-	
-	@Before
-	public void setUp() throws ConfigurationException {
-		_resource = new NiciraNvpResource() {
-			protected NiciraNvpApi createNiciraNvpApi() {
-				return _nvpApi;
-			}
-		};
-
-		_parameters = new HashMap<String,Object>();
-		_parameters.put("name","nvptestdevice");
-		_parameters.put("ip","127.0.0.1");
-		_parameters.put("adminuser","adminuser");
-		_parameters.put("guid", "aaaaa-bbbbb-ccccc");
-		_parameters.put("zoneId", "blublub");
-		_parameters.put("adminpass","adminpass");
-	}
-	
-	@Test (expected=ConfigurationException.class)
-	public void resourceConfigureFailure() throws ConfigurationException {
-		_resource.configure("NiciraNvpResource", Collections.<String,Object>emptyMap());
-	}
-	
-	@Test 
-	public void resourceConfigure() throws ConfigurationException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		verify(_nvpApi).setAdminCredentials("adminuser", "adminpass");
-		verify(_nvpApi).setControllerAddress("127.0.0.1");
-		
-		assertTrue("nvptestdevice".equals(_resource.getName()));
-		
-		/* Pretty lame test, but here to assure this plugin fails 
-		 * if the type name ever changes from L2Networking
-		 */ 
-		assertTrue(_resource.getType() == Host.Type.L2Networking);
-	}
-	
-	@Test
-	public void testInitialization() throws ConfigurationException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		StartupCommand[] sc = _resource.initialize();
-		assertTrue(sc.length ==1);
-		assertTrue("aaaaa-bbbbb-ccccc".equals(sc[0].getGuid()));
-		assertTrue("nvptestdevice".equals(sc[0].getName()));
-		assertTrue("blublub".equals(sc[0].getDataCenter()));
-	}
-	
-	@Test
-	public void testPingCommandStatusOk() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		ControlClusterStatus ccs = mock(ControlClusterStatus.class);
-		when(ccs.getClusterStatus()).thenReturn("stable");
-		when(_nvpApi.getControlClusterStatus()).thenReturn(ccs);
-		
-		PingCommand ping = _resource.getCurrentStatus(42);
-		assertTrue(ping != null);
-		assertTrue(ping.getHostId() == 42);
-		assertTrue(ping.getHostType() == Host.Type.L2Networking);		
-	}
-
-	@Test
-	public void testPingCommandStatusFail() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		ControlClusterStatus ccs = mock(ControlClusterStatus.class);
-		when(ccs.getClusterStatus()).thenReturn("unstable");
-		when(_nvpApi.getControlClusterStatus()).thenReturn(ccs);
-		
-		PingCommand ping = _resource.getCurrentStatus(42);
-		assertTrue(ping == null);
-	}
-
-	@Test
-	public void testPingCommandStatusApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		ControlClusterStatus ccs = mock(ControlClusterStatus.class);
-		when(ccs.getClusterStatus()).thenReturn("unstable");
-		when(_nvpApi.getControlClusterStatus()).thenThrow(new NiciraNvpApiException());
-		
-		PingCommand ping = _resource.getCurrentStatus(42);
-		assertTrue(ping == null);
-	}
-	
-	@Test
-	public void testRetries() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitch ls = mock(LogicalSwitch.class);
-		when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
-		when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException()).thenThrow(new NiciraNvpApiException()).thenReturn(ls);
-		
-		CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
-		CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
-		assertTrue(clsa.getResult());
-	}
-	
-	@Test
-	public void testCreateLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitch ls = mock(LogicalSwitch.class);
-		when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
-		when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenReturn(ls);
-		
-		CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
-		CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
-		assertTrue(clsa.getResult());
-		assertTrue("cccc".equals(clsa.getLogicalSwitchUuid()));
-	}
-
-	@Test
-	public void testCreateLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitch ls = mock(LogicalSwitch.class);
-		when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
-		when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException());
-		
-		CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
-		CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
-		assertFalse(clsa.getResult());
-	}
-
-	@Test
-	public void testDeleteLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
-		DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc);
-		assertTrue(dlsa.getResult());
-	}
-
-	@Test
-	public void testDeleteLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitch((String)any());
-		
-		DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
-		DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc);
-		assertFalse(dlsa.getResult());
-	}
-
-	@Test
-	public void testCreateLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lsp.getUuid()).thenReturn("eeee");
-		when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
-		
-		CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
-		CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
-		assertTrue(clspa.getResult());
-		assertTrue("eeee".equals(clspa.getLogicalSwitchPortUuid()));
-		
-	}
-
-	@Test
-	public void testCreateLogicalSwitchPortApiExceptionInCreate() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lsp.getUuid()).thenReturn("eeee");
-		when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenThrow(new NiciraNvpApiException());
-		
-		CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
-		CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
-		assertFalse(clspa.getResult());		
-	}
-
-	@Test
-	public void testCreateLogicalSwitchPortApiExceptionInModify() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lsp.getUuid()).thenReturn("eeee");
-		when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any());
-		
-		
-		CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
-		CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
-		assertFalse(clspa.getResult());		
-		verify(_nvpApi, atLeastOnce()).deleteLogicalSwitchPort((String) any(),  (String) any());
-	}
-
-	@Test
-	public void testDeleteLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitchPort((String) any(), (String) any());
-		DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer) _resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa","bbbb"));
-		assertFalse(dlspa.getResult());
-	}
-	
-	@Test
-	public void testUpdateLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String) any(), (String) any(), (Attachment) any());
-		UpdateLogicalSwitchPortAnswer dlspa = (UpdateLogicalSwitchPortAnswer) _resource.executeRequest(
-				new UpdateLogicalSwitchPortCommand("aaaa","bbbb","cccc","owner","nicname"));
-		assertFalse(dlspa.getResult());
-	}
-	
-	@Test
-	public void testFindLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<LogicalSwitchPort> lspl = (NiciraNvpList<LogicalSwitchPort>)mock(NiciraNvpList.class);
-		when(lspl.getResultCount()).thenReturn(1); 
-		when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
-		
-		FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
-		assertTrue(flspa.getResult());
-	}
-
-	@Test
-	public void testFindLogicalSwitchPortNotFound() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<LogicalSwitchPort> lspl = (NiciraNvpList<LogicalSwitchPort>)mock(NiciraNvpList.class);
-		when(lspl.getResultCount()).thenReturn(0); 
-		when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
-		
-		FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
-		assertFalse(flspa.getResult());
-	}
-
-	@Test
-	public void testFindLogicalSwitchPortApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenThrow(new NiciraNvpApiException());
-		
-		FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
-		assertFalse(flspa.getResult());
-	}
-	
-	@Test
-	public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
-		LogicalRouterPort lrp = mock(LogicalRouterPort.class);
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lrc.getUuid()).thenReturn("ccccc");
-		when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
-		when(lsp.getUuid()).thenReturn("fffff");
-		when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
-		when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
-		when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
-		CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
-		CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
-		
-		assertTrue(clra.getResult());
-		assertTrue("ccccc".equals(clra.getLogicalRouterUuid()));
-		verify(_nvpApi, atLeast(1)).createLogicalRouterNatRule((String) any(), (NatRule) any());
-	}
-
-	@Test
-	public void testCreateLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenThrow(new NiciraNvpApiException());
-		CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
-		CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
-		
-		assertFalse(clra.getResult());
-	}
-
-	@Test
-	public void testCreateLogicalRouterApiExceptionRollbackRouter() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
-		when(lrc.getUuid()).thenReturn("ccccc");
-		when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
-		when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenThrow(new NiciraNvpApiException());
-		CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
-		CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
-		
-		assertFalse(clra.getResult());
-		verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
-	}
-
-	@Test
-	public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
-		LogicalRouterPort lrp = mock(LogicalRouterPort.class);
-		LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
-		when(lrc.getUuid()).thenReturn("ccccc");
-		when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
-		when(lsp.getUuid()).thenReturn("fffff");
-		when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
-		when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
-		when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
-		when(_nvpApi.createLogicalRouterNatRule((String) any(), (NatRule)any())).thenThrow(new NiciraNvpApiException());
-		CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
-		CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
-		
-		assertFalse(clra.getResult());
-		verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
-		verify(_nvpApi, atLeast(1)).deleteLogicalSwitchPort(eq("bbbbb"), eq("fffff"));
-	}
-	
-	@Test
-	public void testDeleteLogicalRouterApiException() throws ConfigurationException,NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalRouter(eq("aaaaa"));
-		DeleteLogicalRouterAnswer dlspa = (DeleteLogicalRouterAnswer) _resource.executeRequest(new DeleteLogicalRouterCommand("aaaaa"));
-		assertFalse(dlspa.getResult());		
-	}
-	
-	@Test
-	public void testConfigurePublicIpsOnLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		
-		ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class);
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<LogicalRouterPort> list = mock(NiciraNvpList.class);
-		
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
-		doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalRouterPort((String) any(), (LogicalRouterPort) any());
-		when(_nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa","bbbbb")).thenReturn(list);
-		
-		ConfigurePublicIpsOnLogicalRouterAnswer answer = 
-				(ConfigurePublicIpsOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		assertFalse(answer.getResult());
-		
-	}
-	
-	@Test
-	public void testConfigureStaticNatRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
-		StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
-		List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-		
-		ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
-			@Override
-			public boolean matches(Object argument) {
-				NatRule rule = (NatRule) argument;
-				if (rule.getType().equals("DestinationNatRule") &&
-						((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
-					return true;
-				}
-				if (rule.getType().equals("SourceNatRule") &&
-						((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigureStaticNatRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
-		StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
-		List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(2);
-		when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
-			@Override
-			public boolean matches(Object argument) {
-				NatRule rule = (NatRule) argument;
-				if (rule.getType().equals("DestinationNatRule") &&
-				        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
-					return true;
-				}
-				if (rule.getType().equals("SourceNatRule") &&
-				        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigureStaticNatRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
-		StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, true, false);
-		List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		final UUID rule0Uuid = UUID.randomUUID();
-		final UUID rule1Uuid = UUID.randomUUID();
-		rulepair[0].setUuid(rule0Uuid);
-		rulepair[1].setUuid(rule1Uuid);
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(2);
-		when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
-			@Override
-			public boolean matches(Object argument) {
-				UUID uuid = (UUID) argument;
-				if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigureStaticNatRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
-		StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
-		List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(0);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertFalse(a.getResult());
-		verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
-			@Override
-			public boolean matches(Object argument) {
-				NatRule rule = (NatRule) argument;
-				if (rule.getType().equals("DestinationNatRule") &&
-						((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
-					return true;
-				}
-				if (rule.getType().equals("SourceNatRule") &&
-						((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, true);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(2);
-		when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
-			@Override
-			public boolean matches(Object argument) {
-				NatRule rule = (NatRule) argument;
-				if (rule.getType().equals("DestinationNatRule") &&
-						((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
-					return true;
-				}
-				if (rule.getType().equals("SourceNatRule") &&
-						((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", true, true);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+    NiciraNvpApi _nvpApi = mock(NiciraNvpApi.class);
+    NiciraNvpResource _resource;
+    Map<String,Object> _parameters;
+
+    @Before
+    public void setUp() throws ConfigurationException {
+        _resource = new NiciraNvpResource() {
+            @Override
+            protected NiciraNvpApi createNiciraNvpApi() {
+                return _nvpApi;
+            }
+        };
+
+        _parameters = new HashMap<String,Object>();
+        _parameters.put("name","nvptestdevice");
+        _parameters.put("ip","127.0.0.1");
+        _parameters.put("adminuser","adminuser");
+        _parameters.put("guid", "aaaaa-bbbbb-ccccc");
+        _parameters.put("zoneId", "blublub");
+        _parameters.put("adminpass","adminpass");
+    }
+
+    @Test (expected=ConfigurationException.class)
+    public void resourceConfigureFailure() throws ConfigurationException {
+        _resource.configure("NiciraNvpResource", Collections.<String,Object>emptyMap());
+    }
+
+    @Test
+    public void resourceConfigure() throws ConfigurationException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        verify(_nvpApi).setAdminCredentials("adminuser", "adminpass");
+        verify(_nvpApi).setControllerAddress("127.0.0.1");
+
+        assertTrue("nvptestdevice".equals(_resource.getName()));
+
+        /* Pretty lame test, but here to assure this plugin fails
+         * if the type name ever changes from L2Networking
+         */
+        assertTrue(_resource.getType() == Host.Type.L2Networking);
+    }
+
+    @Test
+    public void testInitialization() throws ConfigurationException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        StartupCommand[] sc = _resource.initialize();
+        assertTrue(sc.length ==1);
+        assertTrue("aaaaa-bbbbb-ccccc".equals(sc[0].getGuid()));
+        assertTrue("nvptestdevice".equals(sc[0].getName()));
+        assertTrue("blublub".equals(sc[0].getDataCenter()));
+    }
+
+    @Test
+    public void testPingCommandStatusOk() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+        when(ccs.getClusterStatus()).thenReturn("stable");
+        when(_nvpApi.getControlClusterStatus()).thenReturn(ccs);
+
+        PingCommand ping = _resource.getCurrentStatus(42);
+        assertTrue(ping != null);
+        assertTrue(ping.getHostId() == 42);
+        assertTrue(ping.getHostType() == Host.Type.L2Networking);
+    }
+
+    @Test
+    public void testPingCommandStatusFail() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+        when(ccs.getClusterStatus()).thenReturn("unstable");
+        when(_nvpApi.getControlClusterStatus()).thenReturn(ccs);
+
+        PingCommand ping = _resource.getCurrentStatus(42);
+        assertTrue(ping == null);
+    }
+
+    @Test
+    public void testPingCommandStatusApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        ControlClusterStatus ccs = mock(ControlClusterStatus.class);
+        when(ccs.getClusterStatus()).thenReturn("unstable");
+        when(_nvpApi.getControlClusterStatus()).thenThrow(new NiciraNvpApiException());
+
+        PingCommand ping = _resource.getCurrentStatus(42);
+        assertTrue(ping == null);
+    }
+
+    @Test
+    public void testRetries() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitch ls = mock(LogicalSwitch.class);
+        when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
+        when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException()).thenThrow(new NiciraNvpApiException()).thenReturn(ls);
+
+        CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
+        CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
+        assertTrue(clsa.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitch ls = mock(LogicalSwitch.class);
+        when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
+        when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenReturn(ls);
+
+        CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
+        CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
+        assertTrue(clsa.getResult());
+        assertTrue("cccc".equals(clsa.getLogicalSwitchUuid()));
+    }
+
+    @Test
+    public void testCreateLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitch ls = mock(LogicalSwitch.class);
+        when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
+        when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException());
+
+        CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
+        CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
+        assertFalse(clsa.getResult());
+    }
+
+    @Test
+    public void testDeleteLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
+        DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc);
+        assertTrue(dlsa.getResult());
+    }
+
+    @Test
+    public void testDeleteLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitch((String)any());
+
+        DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc");
+        DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc);
+        assertFalse(dlsa.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lsp.getUuid()).thenReturn("eeee");
+        when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
+
+        CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+        CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
+        assertTrue(clspa.getResult());
+        assertTrue("eeee".equals(clspa.getLogicalSwitchPortUuid()));
+
+    }
+
+    @Test
+    public void testCreateLogicalSwitchPortApiExceptionInCreate() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lsp.getUuid()).thenReturn("eeee");
+        when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenThrow(new NiciraNvpApiException());
+
+        CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+        CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
+        assertFalse(clspa.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalSwitchPortApiExceptionInModify() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lsp.getUuid()).thenReturn("eeee");
+        when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp);
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any());
+
+
+        CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname");
+        CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc);
+        assertFalse(clspa.getResult());
+        verify(_nvpApi, atLeastOnce()).deleteLogicalSwitchPort((String) any(),  (String) any());
+    }
+
+    @Test
+    public void testDeleteLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitchPort((String) any(), (String) any());
+        DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer) _resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa","bbbb"));
+        assertFalse(dlspa.getResult());
+    }
+
+    @Test
+    public void testUpdateLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String) any(), (String) any(), (Attachment) any());
+        UpdateLogicalSwitchPortAnswer dlspa = (UpdateLogicalSwitchPortAnswer) _resource.executeRequest(
+                new UpdateLogicalSwitchPortCommand("aaaa","bbbb","cccc","owner","nicname"));
+        assertFalse(dlspa.getResult());
+    }
+
+    @Test
+    public void testFindLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<LogicalSwitchPort> lspl = mock(NiciraNvpList.class);
+        when(lspl.getResultCount()).thenReturn(1);
+        when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
+
+        FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+        assertTrue(flspa.getResult());
+    }
+
+    @Test
+    public void testFindLogicalSwitchPortNotFound() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<LogicalSwitchPort> lspl = mock(NiciraNvpList.class);
+        when(lspl.getResultCount()).thenReturn(0);
+        when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl);
+
+        FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+        assertFalse(flspa.getResult());
+    }
+
+    @Test
+    public void testFindLogicalSwitchPortApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenThrow(new NiciraNvpApiException());
+
+        FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb"));
+        assertFalse(flspa.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
+        LogicalRouterPort lrp = mock(LogicalRouterPort.class);
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lrc.getUuid()).thenReturn("ccccc");
+        when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
+        when(lsp.getUuid()).thenReturn("fffff");
+        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+        when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
+        when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
+        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+        CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
+
+        assertTrue(clra.getResult());
+        assertTrue("ccccc".equals(clra.getLogicalRouterUuid()));
+        verify(_nvpApi, atLeast(1)).createLogicalRouterNatRule((String) any(), (NatRule) any());
+    }
+
+    @Test
+    public void testCreateLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenThrow(new NiciraNvpApiException());
+        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+        CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
+
+        assertFalse(clra.getResult());
+    }
+
+    @Test
+    public void testCreateLogicalRouterApiExceptionRollbackRouter() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
+        when(lrc.getUuid()).thenReturn("ccccc");
+        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+        when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenThrow(new NiciraNvpApiException());
+        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+        CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
+
+        assertFalse(clra.getResult());
+        verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
+    }
+
+    @Test
+    public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        LogicalRouterConfig lrc = mock(LogicalRouterConfig.class);
+        LogicalRouterPort lrp = mock(LogicalRouterPort.class);
+        LogicalSwitchPort lsp = mock(LogicalSwitchPort.class);
+        when(lrc.getUuid()).thenReturn("ccccc");
+        when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee");
+        when(lsp.getUuid()).thenReturn("fffff");
+        when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc);
+        when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp);
+        when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp);
+        when(_nvpApi.createLogicalRouterNatRule((String) any(), (NatRule)any())).thenThrow(new NiciraNvpApiException());
+        CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner");
+        CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc);
+
+        assertFalse(clra.getResult());
+        verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc"));
+        verify(_nvpApi, atLeast(1)).deleteLogicalSwitchPort(eq("bbbbb"), eq("fffff"));
+    }
+
+    @Test
+    public void testDeleteLogicalRouterApiException() throws ConfigurationException,NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalRouter(eq("aaaaa"));
+        DeleteLogicalRouterAnswer dlspa = (DeleteLogicalRouterAnswer) _resource.executeRequest(new DeleteLogicalRouterCommand("aaaaa"));
+        assertFalse(dlspa.getResult());
+    }
+
+    @Test
+    public void testConfigurePublicIpsOnLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+
+        ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class);
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<LogicalRouterPort> list = mock(NiciraNvpList.class);
+
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+        when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb");
+        doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalRouterPort((String) any(), (LogicalRouterPort) any());
+        when(_nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa","bbbbb")).thenReturn(list);
+
+        ConfigurePublicIpsOnLogicalRouterAnswer answer =
+                (ConfigurePublicIpsOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+        assertFalse(answer.getResult());
+
+    }
+
+    @Test
+    public void testConfigureStaticNatRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+        StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+        List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
+            @Override
+            public boolean matches(Object argument) {
+                NatRule rule = (NatRule) argument;
+                if (rule.getType().equals("DestinationNatRule") &&
+                        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
+                    return true;
+                }
+                if (rule.getType().equals("SourceNatRule") &&
+                        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigureStaticNatRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+        StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+        List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(2);
+        when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
+            @Override
+            public boolean matches(Object argument) {
+                NatRule rule = (NatRule) argument;
+                if (rule.getType().equals("DestinationNatRule") &&
+                        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
+                    return true;
+                }
+                if (rule.getType().equals("SourceNatRule") &&
+                        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigureStaticNatRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+        StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, true, false);
+        List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
         final UUID rule0Uuid = UUID.randomUUID();
         final UUID rule1Uuid = UUID.randomUUID();
         rulepair[0].setUuid(rule0Uuid);
         rulepair[1].setUuid(rule1Uuid);
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(2);
-		when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertTrue(a.getResult());
-		verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
-			@Override
-			public boolean matches(Object argument) {
-				UUID uuid = (UUID) argument;
-				if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
-					return true;
-				}
-				return false;
-			} }));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
-
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(storedRules.getResultCount()).thenReturn(0);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		assertFalse(a.getResult());
-		verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
-	}
-
-	@Test
-	public void testConfigurePortForwardingRulesOnLogicalRouterPortRange() throws ConfigurationException, NiciraNvpApiException {
-		_resource.configure("NiciraNvpResource", _parameters);
-		/* StaticNat
-		 * Outside IP: 11.11.11.11
-		 * Inside IP:  10.10.10.10
-		 */
-		
-		// Mock the command
-		ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
-		PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 85, "10.10.10.10", 80, 85, "tcp", false, false);
-		List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
-		rules.add(rule);
-		when(cmd.getRules()).thenReturn(rules);
-		when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
-		
-		// Mock the api find call
-		@SuppressWarnings("unchecked")
-		NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
-		when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
-		
-		// Mock the api create calls
-		NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 80, 85 }, "11.11.11.11", new int[] { 80, 85}, "tcp");
-		rulepair[0].setUuid(UUID.randomUUID());
-		rulepair[1].setUuid(UUID.randomUUID());
-		when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
-		
-		ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
-		
-		// The expected result is false, Nicira does not support port ranges in DNAT
-		assertFalse(a.getResult());
-
-	}
-
-	@Test
-	public void testGenerateStaticNatRulePair() {
-		NatRule[] rules = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
-		assertTrue("DestinationNatRule".equals(rules[0].getType()));
-		assertTrue("SourceNatRule".equals(rules[1].getType()));
-		
-		DestinationNatRule dnr = (DestinationNatRule) rules[0];
-		assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
-		assertTrue(dnr.getToDestinationPort() == null);
-		assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));	
-		
-		SourceNatRule snr = (SourceNatRule) rules[1];
-		assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
-		assertTrue(snr.getToSourcePort() == null);
-		assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
-	}
-
-	@Test
-	public void testGeneratePortForwardingRulePair() {
-		NatRule[] rules = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080,  8080 }, "11.11.11.11", new int[] { 80, 80 }, "tcp" );
-		assertTrue("DestinationNatRule".equals(rules[0].getType()));
-		assertTrue("SourceNatRule".equals(rules[1].getType()));
-		
-		DestinationNatRule dnr = (DestinationNatRule) rules[0];
-		assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
-		assertTrue(dnr.getToDestinationPort() == 8080);
-		assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));	
-		assertTrue(dnr.getMatch().getDestinationPort() == 80 );
-		assertTrue(dnr.getMatch().getEthertype().equals("IPv4") && dnr.getMatch().getProtocol() == 6);
-		
-		SourceNatRule snr = (SourceNatRule) rules[1];
-		assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
-		assertTrue(snr.getToSourcePort() == 80);
-		assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
-		assertTrue(snr.getMatch().getSourcePort() == 8080);
-		assertTrue(snr.getMatch().getEthertype().equals("IPv4") && rules[1].getMatch().getProtocol() == 6);
-	}
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(2);
+        when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
+            @Override
+            public boolean matches(Object argument) {
+                UUID uuid = (UUID) argument;
+                if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigureStaticNatRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class);
+        StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false);
+        List<StaticNatRuleTO> rules = new ArrayList<StaticNatRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(0);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertFalse(a.getResult());
+        verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
+            @Override
+            public boolean matches(Object argument) {
+                NatRule rule = (NatRule) argument;
+                if (rule.getType().equals("DestinationNatRule") &&
+                        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
+                    return true;
+                }
+                if (rule.getType().equals("SourceNatRule") &&
+                        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, true);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(2);
+        when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<NatRule>() {
+            @Override
+            public boolean matches(Object argument) {
+                NatRule rule = (NatRule) argument;
+                if (rule.getType().equals("DestinationNatRule") &&
+                        ((DestinationNatRule)rule).getToDestinationIpAddress().equals("10.10.10.10")) {
+                    return true;
+                }
+                if (rule.getType().equals("SourceNatRule") &&
+                        ((SourceNatRule)rule).getToSourceIpAddressMin().equals("11.11.11.11")) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", true, true);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+        final UUID rule0Uuid = UUID.randomUUID();
+        final UUID rule1Uuid = UUID.randomUUID();
+        rulepair[0].setUuid(rule0Uuid);
+        rulepair[1].setUuid(rule1Uuid);
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(2);
+        when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair));
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertTrue(a.getResult());
+        verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher<UUID>() {
+            @Override
+            public boolean matches(Object argument) {
+                UUID uuid = (UUID) argument;
+                if (rule0Uuid.equals(uuid) || rule1Uuid.equals(uuid)) {
+                    return true;
+                }
+                return false;
+            } }));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException());
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(storedRules.getResultCount()).thenReturn(0);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        assertFalse(a.getResult());
+        verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq(rulepair[0].getUuid()));
+    }
+
+    @Test
+    public void testConfigurePortForwardingRulesOnLogicalRouterPortRange() throws ConfigurationException, NiciraNvpApiException {
+        _resource.configure("NiciraNvpResource", _parameters);
+        /* StaticNat
+         * Outside IP: 11.11.11.11
+         * Inside IP:  10.10.10.10
+         */
+
+        // Mock the command
+        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class);
+        PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 85, "10.10.10.10", 80, 85, "tcp", false, false);
+        List<PortForwardingRuleTO> rules = new ArrayList<PortForwardingRuleTO>();
+        rules.add(rule);
+        when(cmd.getRules()).thenReturn(rules);
+        when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa");
+
+        // Mock the api find call
+        @SuppressWarnings("unchecked")
+        NiciraNvpList<NatRule> storedRules = mock(NiciraNvpList.class);
+        when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules);
+
+        // Mock the api create calls
+        NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 80, 85 }, "11.11.11.11", new int[] { 80, 85}, "tcp");
+        rulepair[0].setUuid(UUID.randomUUID());
+        rulepair[1].setUuid(UUID.randomUUID());
+        when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]);
+
+        ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd);
+
+        // The expected result is false, Nicira does not support port ranges in DNAT
+        assertFalse(a.getResult());
+
+    }
+
+    @Test
+    public void testGenerateStaticNatRulePair() {
+        NatRule[] rules = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11");
+        assertTrue("DestinationNatRule".equals(rules[0].getType()));
+        assertTrue("SourceNatRule".equals(rules[1].getType()));
+
+        DestinationNatRule dnr = (DestinationNatRule) rules[0];
+        assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
+        assertTrue(dnr.getToDestinationPort() == null);
+        assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));
+
+        SourceNatRule snr = (SourceNatRule) rules[1];
+        assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
+        assertTrue(snr.getToSourcePort() == null);
+        assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
+    }
+
+    @Test
+    public void testGeneratePortForwardingRulePair() {
+        NatRule[] rules = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080,  8080 }, "11.11.11.11", new int[] { 80, 80 }, "tcp" );
+        assertTrue("DestinationNatRule".equals(rules[0].getType()));
+        assertTrue("SourceNatRule".equals(rules[1].getType()));
+
+        DestinationNatRule dnr = (DestinationNatRule) rules[0];
+        assertTrue(dnr.getToDestinationIpAddress().equals("10.10.10.10"));
+        assertTrue(dnr.getToDestinationPort() == 8080);
+        assertTrue(dnr.getMatch().getDestinationIpAddresses().equals("11.11.11.11"));
+        assertTrue(dnr.getMatch().getDestinationPort() == 80 );
+        assertTrue(dnr.getMatch().getEthertype().equals("IPv4") && dnr.getMatch().getProtocol() == 6);
+
+        SourceNatRule snr = (SourceNatRule) rules[1];
+        assertTrue(snr.getToSourceIpAddressMin().equals("11.11.11.11") && snr.getToSourceIpAddressMax().equals("11.11.11.11"));
+        assertTrue(snr.getToSourcePort() == 80);
+        assertTrue(snr.getMatch().getSourceIpAddresses().equals("10.10.10.10"));
+        assertTrue(snr.getMatch().getSourcePort() == 8080);
+        assertTrue(snr.getMatch().getEthertype().equals("IPv4") && rules[1].getMatch().getProtocol() == 6);
+    }
 }
 


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

Posted by bf...@apache.org.
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


[19/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementService.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementService.cs
deleted file mode 100644
index 81016a2..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementService.cs
+++ /dev/null
@@ -1,1731 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_VirtualSystemManagementService
-    public class VirtualSystemManagementService : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_VirtualSystemManagementService";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VirtualSystemManagementService() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VirtualSystemManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public VirtualSystemManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VirtualSystemManagementService(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VirtualSystemManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VirtualSystemManagementService(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VirtualSystemManagementService(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerContact {
-            get {
-                return ((string)(curObj["PrimaryOwnerContact"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string PrimaryOwnerName {
-            get {
-                return ((string)(curObj["PrimaryOwnerName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsStartedNull {
-            get {
-                if ((curObj["Started"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool Started {
-            get {
-                if ((curObj["Started"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["Started"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string StartMode {
-            get {
-                return ((string)(curObj["StartMode"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeStarted() {
-            if ((this.IsStartedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_VirtualSystemManagementService";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VirtualSystemManagementServiceCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VirtualSystemManagementServiceCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VirtualSystemManagementServiceCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VirtualSystemManagementService";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VirtualSystemManagementServiceCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementService", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VirtualSystemManagementServiceCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VirtualSystemManagementService CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VirtualSystemManagementService(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint AddKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("AddKvpItems");
-                inParams["DataItems"] = ((string[])(DataItems));
-                inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddKvpItems", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint AddVirtualSystemResources(string[] ResourceSettingData, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] NewResources) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("AddVirtualSystemResources");
-                inParams["ResourceSettingData"] = ((string[])(ResourceSettingData));
-                inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddVirtualSystemResources", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                NewResources = null;
-                if ((outParams.Properties["NewResources"] != null) && outParams.Properties["NewResources"].Value != null)
-                {
-                    int len = ((System.Array)(outParams.Properties["NewResources"].Value)).Length;
-                    System.Management.ManagementPath[] arrToRet = new System.Management.ManagementPath[len];
-                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
-                        arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["NewResources"].Value)).GetValue(iCounter).ToString());
-                    }
-                    NewResources = arrToRet;
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                NewResources = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ApplyVirtualSystemSnapshot(System.Management.ManagementPath ComputerSystem, System.Management.ManagementPath SnapshotSettingData) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ApplyVirtualSystemSnapshot");
-                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
-                inParams["SnapshotSettingData"] = ((System.Management.ManagementPath)(SnapshotSettingData)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ApplyVirtualSystemSnapshot", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ApplyVirtualSystemSnapshotEx(System.Management.ManagementPath ComputerSystem, System.Management.ManagementPath SnapshotSettingData, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ApplyVirtualSystemSnapshotEx");
-                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
-                inParams["SnapshotSettingData"] = ((System.Management.ManagementPath)(SnapshotSettingData)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ApplyVirtualSystemSnapshotEx", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CheckSystemCompatibilityInfo(byte[] CompatibilityInfo, out string[] Reasons) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CheckSystemCompatibilityInfo");
-                inParams["CompatibilityInfo"] = ((byte[])(CompatibilityInfo));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CheckSystemCompatibilityInfo", inParams, null);
-                Reasons = ((string[])(outParams.Properties["Reasons"].Value));
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Reasons = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CloneVirtualSystem(System.Management.ManagementPath SourceInstance, System.Management.ManagementPath SourceSystem, out System.Management.ManagementPath ClonedSystem, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CloneVirtualSystem");
-                inParams["SourceInstance"] = ((System.Management.ManagementPath)(SourceInstance)).Path;
-                inParams["SourceSystem"] = ((System.Management.ManagementPath)(SourceSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CloneVirtualSystem", inParams, null);
-                ClonedSystem = null;
-                if ((outParams.Properties["ClonedSystem"] != null)) {
-                    ClonedSystem = new System.Management.ManagementPath(outParams.Properties["ClonedSystem"].Value.ToString());
-                }
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                ClonedSystem = null;
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint CreateVirtualSystemSnapshot(System.Management.ManagementPath SourceSystem, out System.Management.ManagementPath Job, out System.Management.ManagementPath SnapshotSettingData) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("CreateVirtualSystemSnapshot");
-                inParams["SourceSystem"] = ((System.Management.ManagementPath)(SourceSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("CreateVirtualSystemSnapshot", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                SnapshotSettingData = null;
-                if ((outParams.Properties["SnapshotSettingData"] != null)) {
-                    SnapshotSettingData = new System.Management.ManagementPath((string)outParams.Properties["SnapshotSettingData"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                SnapshotSettingData = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint DefineVirtualSystem(string[] ResourceSettingData, string SourceSettingPath, string SystemSettingData, out System.Management.ManagementPath DefinedSystem, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("DefineVirtualSystem");
-                inParams["ResourceSettingData"] = ((string[])(ResourceSettingData));
-                inParams["SourceSetting"] = SourceSettingPath;
-                inParams["SystemSettingData"] = ((string)(SystemSettingData));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DefineVirtualSystem", inParams, null);
-                DefinedSystem = null;
-                if ((outParams.Properties["DefinedSystem"] != null)) {
-                    DefinedSystem = new System.Management.ManagementPath((string)outParams.Properties["DefinedSystem"].Value);
-                }
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                DefinedSystem = null;
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint DestroyVirtualSystem(System.Management.ManagementPath ComputerSystem, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("DestroyVirtualSystem");
-                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("DestroyVirtualSystem", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null))
-                {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ExportVirtualSystem(System.Management.ManagementPath ComputerSystem, bool CopyVmState, string ExportDirectory, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ExportVirtualSystem");
-                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
-                inParams["CopyVmState"] = ((bool)(CopyVmState));
-                inParams["ExportDirectory"] = ((string)(ExportDirectory));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ExportVirtualSystem", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ExportVirtualSystemEx(System.Management.ManagementPath ComputerSystem, string ExportDirectory, string ExportSettingData, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ExportVirtualSystemEx");
-                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
-                inParams["ExportDirectory"] = ((string)(ExportDirectory));
-                inParams["ExportSettingData"] = ((string)(ExportSettingData));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ExportVirtualSystemEx", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint FormatError(string[] Errors, out string ErrorMessage) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("FormatError");
-                inParams["Errors"] = ((string[])(Errors));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("FormatError", inParams, null);
-                ErrorMessage = System.Convert.ToString(outParams.Properties["ErrorMessage"].Value);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                ErrorMessage = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint GetSummaryInformation(uint[] RequestedInformation, System.Management.ManagementPath[] SettingData, out System.Management.ManagementBaseObject[] SummaryInformation) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("GetSummaryInformation");
-                inParams["RequestedInformation"] = ((uint[])(RequestedInformation));
-                if ((SettingData != null)) {
-                    int len = ((System.Array)(SettingData)).Length;
-                    string[] arrProp = new string[len];
-                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
-                        arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(SettingData)).GetValue(iCounter))).Path;
-                    }
-                    inParams["SettingData"] = arrProp;
-                }
-                else {
-                    inParams["SettingData"] = null;
-                }
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetSummaryInformation", inParams, null);
-                SummaryInformation = ((System.Management.ManagementBaseObject[])(outParams.Properties["SummaryInformation"].Value));
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                SummaryInformation = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint GetSystemCompatibilityInfo(System.Management.ManagementPath ComputerSystem, out byte[] CompatibilityInfo) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("GetSystemCompatibilityInfo");
-                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetSystemCompatibilityInfo", inParams, null);
-                CompatibilityInfo = ((byte[])(outParams.Properties["CompatibilityInfo"].Value));
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                CompatibilityInfo = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint GetVirtualSystemImportSettingData(string ImportDirectory, out System.Management.ManagementBaseObject ImportSettingData, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualSystemImportSettingData");
-                inParams["ImportDirectory"] = ((string)(ImportDirectory));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualSystemImportSettingData", inParams, null);
-                ImportSettingData = ((System.Management.ManagementBaseObject)(outParams.Properties["ImportSettingData"].Value));
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                ImportSettingData = null;
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint GetVirtualSystemThumbnailImage(ushort HeightPixels, System.Management.ManagementPath TargetSystem, ushort WidthPixels, out byte[] ImageData) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("GetVirtualSystemThumbnailImage");
-                inParams["HeightPixels"] = ((ushort)(HeightPixels));
-                inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
-                inParams["WidthPixels"] = ((ushort)(WidthPixels));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetVirtualSystemThumbnailImage", inParams, null);
-                ImageData = ((byte[])(outParams.Properties["ImageData"].Value));
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                ImageData = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ImportVirtualSystem(bool GenerateNewID, string ImportDirectory, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ImportVirtualSystem");
-                inParams["GenerateNewID"] = ((bool)(GenerateNewID));
-                inParams["ImportDirectory"] = ((string)(ImportDirectory));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportVirtualSystem", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ImportVirtualSystemEx(string ImportDirectory, string ImportSettingData, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ImportVirtualSystemEx");
-                inParams["ImportDirectory"] = ((string)(ImportDirectory));
-                inParams["ImportSettingData"] = ((string)(ImportSettingData));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportVirtualSystemEx", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint InstantiateVirtualSystem(System.Management.ManagementPath VirtualSystemSettingData, out System.Management.ManagementPath ComputerSystem, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("InstantiateVirtualSystem");
-                inParams["VirtualSystemSettingData"] = ((System.Management.ManagementPath)(VirtualSystemSettingData)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("InstantiateVirtualSystem", inParams, null);
-                ComputerSystem = null;
-                if ((outParams.Properties["ComputerSystem"] != null)) {
-                    ComputerSystem = new System.Management.ManagementPath((string)outParams.Properties["ComputerSystem"].Value);
-                }
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                ComputerSystem = null;
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ModifyKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ModifyKvpItems");
-                inParams["DataItems"] = ((string[])(DataItems));
-                inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyKvpItems", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ModifyServiceSettings(string SettingData, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ModifyServiceSettings");
-                inParams["SettingData"] = ((string)(SettingData));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyServiceSettings", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ModifyVirtualSystem(System.Management.ManagementPath ComputerSystem, string SystemSettingData, out System.Management.ManagementPath Job, out System.Management.ManagementPath ModifiedSettingData) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ModifyVirtualSystem");
-                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
-                inParams["SystemSettingData"] = ((string)(SystemSettingData));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyVirtualSystem", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                ModifiedSettingData = null;
-                if ((outParams.Properties["ModifiedSettingData"] != null)) {
-                    ModifiedSettingData = new System.Management.ManagementPath((string)outParams.Properties["ModifiedSettingData"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                ModifiedSettingData = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint ModifyVirtualSystemResources(System.Management.ManagementPath ComputerSystem, string[] ResourceSettingData, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("ModifyVirtualSystemResources");
-                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
-                inParams["ResourceSettingData"] = ((string[])(ResourceSettingData));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ModifyVirtualSystemResources", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint PlanVirtualSystem(string[] ResourceSettingData, System.Management.ManagementPath SourceSetting, string SystemSettingData, out System.Management.ManagementPath Job, out System.Management.ManagementPath PlannedSystemSettingData) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("PlanVirtualSystem");
-                inParams["ResourceSettingData"] = ((string[])(ResourceSettingData));
-                inParams["SourceSetting"] = ((System.Management.ManagementPath)(SourceSetting)).Path;
-                inParams["SystemSettingData"] = ((string)(SystemSettingData));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("PlanVirtualSystem", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                PlannedSystemSettingData = null;
-                if ((outParams.Properties["PlannedSystemSettingData"] != null)) {
-                    PlannedSystemSettingData = new System.Management.ManagementPath((string)outParams.Properties["PlannedSystemSettingData"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                PlannedSystemSettingData = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint RemoveKvpItems(string[] DataItems, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RemoveKvpItems");
-                inParams["DataItems"] = ((string[])(DataItems));
-                inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveKvpItems", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint RemoveVirtualSystemResources(System.Management.ManagementPath[] ResourceSettingData, System.Management.ManagementPath TargetSystem, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RemoveVirtualSystemResources");
-                if ((ResourceSettingData != null)) {
-                    int len = ((System.Array)(ResourceSettingData)).Length;
-                    string[] arrProp = new string[len];
-                    for (int iCounter = 0; (iCounter < len); iCounter = (iCounter + 1)) {
-                        arrProp[iCounter] = ((System.Management.ManagementPath)(((System.Array)(ResourceSettingData)).GetValue(iCounter))).Path;
-                    }
-                    inParams["ResourceSettingData"] = arrProp;
-                }
-                else {
-                    inParams["ResourceSettingData"] = null;
-                }
-                inParams["TargetSystem"] = ((System.Management.ManagementPath)(TargetSystem)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveVirtualSystemResources", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint RemoveVirtualSystemSnapshot(System.Management.ManagementPath SnapshotSettingData, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RemoveVirtualSystemSnapshot");
-                inParams["SnapshotSettingData"] = ((System.Management.ManagementPath)(SnapshotSettingData)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveVirtualSystemSnapshot", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint RemoveVirtualSystemSnapshotTree(System.Management.ManagementPath SnapshotSettingData, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RemoveVirtualSystemSnapshotTree");
-                inParams["SnapshotSettingData"] = ((System.Management.ManagementPath)(SnapshotSettingData)).Path;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveVirtualSystemSnapshotTree", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath((string)outParams.Properties["Job"].Value);
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint StartService() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StartService", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        public uint StopService() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("StopService", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VirtualSystemManagementServiceCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VirtualSystemManagementServiceCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VirtualSystemManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VirtualSystemManagementServiceEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VirtualSystemManagementServiceEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VirtualSystemManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VirtualSystemManagementService(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[29/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SummaryInformation.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SummaryInformation.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SummaryInformation.cs
deleted file mode 100644
index 8c0df73..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SummaryInformation.cs
+++ /dev/null
@@ -1,1184 +0,0 @@
-namespace CloudStack.Plugin.AgentShell.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // 
-    // 
-    // 
-    // 
-    // If the embedded property is strongly typed then, to strongly type the property to the type of
-    // the embedded object, you have to do the following things.
-    // 	1. Generate Managed class for the WMI class of the embedded property. This can be done with MgmtClassGen.exe tool or from Server Explorer.
-    // 	2. Include the namespace of the generated class.
-    // 	3. Change the property get/set functions so as return the instance of the Managed class.
-    // Below is a sample code.
-    // 
-    // VB Code
-    // 
-    // 
-    // 
-    // Property name
-    // Managed class name of Embedded Property
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // C# Code
-    // 
-    // 
-    // 
-    // Managed class name of Embedded property
-    // Property name
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // 
-    // An Early Bound class generated for the WMI class.Msvm_SummaryInformation
-    public class SummaryInformation : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        private static string CreatedClassName = "Msvm_SummaryInformation";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public SummaryInformation() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public SummaryInformation(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public SummaryInformation(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public SummaryInformation(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public SummaryInformation(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public SummaryInformation(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public SummaryInformation(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The identifier of the physical graphics processing unit (GPU) allocated to this v" +
-            "irtual machine (VM). This property only applies to VMs that use RemoteFX.")]
-        public string AllocatedGPU {
-            get {
-                return ((string)(curObj["AllocatedGPU"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("An array of Msvm_ConcreteJob instances representing any asynchronous operations r" +
-            "elated to the virtual system which are currently executing. This property is not" +
-            " valid for instances of Msvm_SummaryInformation representing a virtual system sn" +
-            "apshot.")]
-        public System.Management.ManagementBaseObject[] AsynchronousTasks {
-            get {
-                return ((System.Management.ManagementBaseObject[])(curObj["AsynchronousTasks"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsAvailableMemoryBufferNull {
-            get {
-                if ((curObj["AvailableMemoryBuffer"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The available memory buffer percentage in the virtual system.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public int AvailableMemoryBuffer {
-            get {
-                if ((curObj["AvailableMemoryBuffer"] == null)) {
-                    return System.Convert.ToInt32(0);
-                }
-                return ((int)(curObj["AvailableMemoryBuffer"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsCreationTimeNull {
-            get {
-                if ((curObj["CreationTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The time at which the virtual system or snapshot was created.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime CreationTime {
-            get {
-                if ((curObj["CreationTime"] != null)) {
-                    return ToDateTime(((string)(curObj["CreationTime"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The friendly name for the virtual system or snapshot.")]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current state of the virtual system or snapshot.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The name of the guest operating system, if available. If this information is not " +
-            "available, the value of this property is NULL. This property is not valid for in" +
-            "stances of Msvm_SummaryInformation representing a virtual system snapshot.")]
-        public string GuestOperatingSystem {
-            get {
-                return ((string)(curObj["GuestOperatingSystem"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current health state for the virtual system. This property is not valid for i" +
-            "nstances of Msvm_SummaryInformation representing a virtual system snapshot.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHeartbeatNull {
-            get {
-                if ((curObj["Heartbeat"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"The current heartbeat status for the virtual system. This property may be one of the following values: ""OK""; ""Error""; ""No Contact""; or ""Lost Communication"". For more information, see the documentation for the StatusDescriptions property of the Msvm_HeartbeatComponent class. This property is not valid for instances of Msvm_SummaryInformation representing a virtual system snapshot.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort Heartbeat {
-            get {
-                if ((curObj["Heartbeat"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["Heartbeat"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMemoryAvailableNull {
-            get {
-                if ((curObj["MemoryAvailable"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The memory available percentage in the virtual system.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public int MemoryAvailable {
-            get {
-                if ((curObj["MemoryAvailable"] == null)) {
-                    return System.Convert.ToInt32(0);
-                }
-                return ((int)(curObj["MemoryAvailable"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMemoryUsageNull {
-            get {
-                if ((curObj["MemoryUsage"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current memory usage of the virtual system. This property is not valid for in" +
-            "stances of Msvm_SummaryInformation representing a virtual system snapshot.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong MemoryUsage {
-            get {
-                if ((curObj["MemoryUsage"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["MemoryUsage"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The unique name for the virtual system or snapshot.")]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The notes associated with the virtual system or snapshot.")]
-        public string Notes {
-            get {
-                return ((string)(curObj["Notes"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsNumberOfProcessorsNull {
-            get {
-                if ((curObj["NumberOfProcessors"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The total number of virtual processors allocated to the virtual system or snapsho" +
-            "t.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort NumberOfProcessors {
-            get {
-                if ((curObj["NumberOfProcessors"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["NumberOfProcessors"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current status of the element.")]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProcessorLoadNull {
-            get {
-                if ((curObj["ProcessorLoad"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The current processor usage of the virtual system. This property is not valid for" +
-            " instances of Msvm_SummaryInformation representing a virtual system snapshot.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProcessorLoad {
-            get {
-                if ((curObj["ProcessorLoad"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProcessorLoad"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("An array of the previous 100 samples of the processor usage for the virtual syste" +
-            "m. This property is not valid for instances of Msvm_SummaryInformation represent" +
-            "ing a virtual system snapshot.")]
-        public ushort[] ProcessorLoadHistory {
-            get {
-                return ((ushort[])(curObj["ProcessorLoadHistory"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("An array of Msvm_VirtualSystemSettingData instances representing the snapshots fo" +
-            "r the virtual system. This property is not valid for instances of Msvm_SummaryIn" +
-            "formation representing a virtual system snapshot.")]
-        public System.Management.ManagementBaseObject[] Snapshots {
-            get {
-                return ((System.Management.ManagementBaseObject[])(curObj["Snapshots"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Strings that describe the various OperationalStatus array values.")]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("An array containing a small, thumbnail-sized image of the desktop for the virtual" +
-            " system or snapshot in RGB565 format.")]
-        public byte[] ThumbnailImage {
-            get {
-                return ((byte[])(curObj["ThumbnailImage"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsUpTimeNull {
-            get {
-                if ((curObj["UpTime"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The amount of time since the virtual system was last booted. This property is not" +
-            " valid for instances of Msvm_SummaryInformation representing a virtual system sn" +
-            "apshot.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ulong UpTime {
-            get {
-                if ((curObj["UpTime"] == null)) {
-                    return System.Convert.ToUInt64(0);
-                }
-                return ((ulong)(curObj["UpTime"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeAvailableMemoryBuffer() {
-            if ((this.IsAvailableMemoryBufferNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeCreationTime() {
-            if ((this.IsCreationTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHeartbeat() {
-            if ((this.IsHeartbeatNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMemoryAvailable() {
-            if ((this.IsMemoryAvailableNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMemoryUsage() {
-            if ((this.IsMemoryUsageNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeNumberOfProcessors() {
-            if ((this.IsNumberOfProcessorsNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProcessorLoad() {
-            if ((this.IsProcessorLoadNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeUpTime() {
-            if ((this.IsUpTimeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath() {
-            string strPath = "ROOT\\virtualization:Msvm_SummaryInformation";
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static SummaryInformationCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static SummaryInformationCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static SummaryInformationCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static SummaryInformationCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_SummaryInformation";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new SummaryInformationCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static SummaryInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SummaryInformation", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new SummaryInformationCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static SummaryInformation CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new SummaryInformation(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class SummaryInformationCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public SummaryInformationCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new SummaryInformation(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new SummaryInformationEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class SummaryInformationEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public SummaryInformationEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new SummaryInformation(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}


[15/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs
new file mode 100755
index 0000000..7a14ed9
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs
@@ -0,0 +1,2102 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
+    // An Early Bound class generated for the WMI class.Msvm_EthernetSwitchPort
+    public class EthernetSwitchPort : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_EthernetSwitchPort";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public EthernetSwitchPort() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public EthernetSwitchPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(null, new System.Management.ManagementPath(EthernetSwitchPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetSwitchPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public EthernetSwitchPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public EthernetSwitchPort(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public EthernetSwitchPort(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public EthernetSwitchPort(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsActiveMaximumTransmissionUnitNull {
+            get {
+                if ((curObj["ActiveMaximumTransmissionUnit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong ActiveMaximumTransmissionUnit {
+            get {
+                if ((curObj["ActiveMaximumTransmissionUnit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["ActiveMaximumTransmissionUnit"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] AdditionalAvailability {
+            get {
+                return ((ushort[])(curObj["AdditionalAvailability"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutoSenseNull {
+            get {
+                if ((curObj["AutoSense"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutoSense {
+            get {
+                if ((curObj["AutoSense"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutoSense"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAvailabilityNull {
+            get {
+                if ((curObj["Availability"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort Availability {
+            get {
+                if ((curObj["Availability"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["Availability"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] AvailableRequestedStates {
+            get {
+                return ((ushort[])(curObj["AvailableRequestedStates"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] Capabilities {
+            get {
+                return ((ushort[])(curObj["Capabilities"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] CapabilityDescriptions {
+            get {
+                return ((string[])(curObj["CapabilityDescriptions"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCommunicationStatusNull {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort CommunicationStatus {
+            get {
+                if ((curObj["CommunicationStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["CommunicationStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string CreationClassName {
+            get {
+                return ((string)(curObj["CreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDetailedStatusNull {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DetailedStatus {
+            get {
+                if ((curObj["DetailedStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DetailedStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string DeviceID {
+            get {
+                return ((string)(curObj["DeviceID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] EnabledCapabilities {
+            get {
+                return ((ushort[])(curObj["EnabledCapabilities"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledDefaultNull {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledDefault {
+            get {
+                if ((curObj["EnabledDefault"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledDefault"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort EnabledState {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["EnabledState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsErrorClearedNull {
+            get {
+                if ((curObj["ErrorCleared"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool ErrorCleared {
+            get {
+                if ((curObj["ErrorCleared"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["ErrorCleared"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ErrorDescription {
+            get {
+                return ((string)(curObj["ErrorDescription"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFullDuplexNull {
+            get {
+                if ((curObj["FullDuplex"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool FullDuplex {
+            get {
+                if ((curObj["FullDuplex"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["FullDuplex"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHealthStateNull {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort HealthState {
+            get {
+                if ((curObj["HealthState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["HealthState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] IdentifyingDescriptions {
+            get {
+                return ((string[])(curObj["IdentifyingDescriptions"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInstallDateNull {
+            get {
+                if ((curObj["InstallDate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime InstallDate {
+            get {
+                if ((curObj["InstallDate"] != null)) {
+                    return ToDateTime(((string)(curObj["InstallDate"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsIOVOffloadUsageNull {
+            get {
+                if ((curObj["IOVOffloadUsage"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The current I/O virtualization (IOV) offload usage on this port. The usage is the" +
+            "amount of IOV resources in use on the port.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint IOVOffloadUsage {
+            get {
+                if ((curObj["IOVOffloadUsage"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["IOVOffloadUsage"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLastErrorCodeNull {
+            get {
+                if ((curObj["LastErrorCode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint LastErrorCode {
+            get {
+                if ((curObj["LastErrorCode"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["LastErrorCode"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLinkTechnologyNull {
+            get {
+                if ((curObj["LinkTechnology"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort LinkTechnology {
+            get {
+                if ((curObj["LinkTechnology"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["LinkTechnology"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxDataSizeNull {
+            get {
+                if ((curObj["MaxDataSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint MaxDataSize {
+            get {
+                if ((curObj["MaxDataSize"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["MaxDataSize"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxQuiesceTimeNull {
+            get {
+                if ((curObj["MaxQuiesceTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxQuiesceTime {
+            get {
+                if ((curObj["MaxQuiesceTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxQuiesceTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxSpeedNull {
+            get {
+                if ((curObj["MaxSpeed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxSpeed {
+            get {
+                if ((curObj["MaxSpeed"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxSpeed"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] NetworkAddresses {
+            get {
+                return ((string[])(curObj["NetworkAddresses"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOperatingStatusNull {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort OperatingStatus {
+            get {
+                if ((curObj["OperatingStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["OperatingStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] OperationalStatus {
+            get {
+                return ((ushort[])(curObj["OperationalStatus"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] OtherEnabledCapabilities {
+            get {
+                return ((string[])(curObj["OtherEnabledCapabilities"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherEnabledState {
+            get {
+                return ((string)(curObj["OtherEnabledState"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] OtherIdentifyingInfo {
+            get {
+                return ((string[])(curObj["OtherIdentifyingInfo"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherLinkTechnology {
+            get {
+                return ((string)(curObj["OtherLinkTechnology"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherNetworkPortType {
+            get {
+                return ((string)(curObj["OtherNetworkPortType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherPortType {
+            get {
+                return ((string)(curObj["OtherPortType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PermanentAddress {
+            get {
+                return ((string)(curObj["PermanentAddress"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPortNumberNull {
+            get {
+                if ((curObj["PortNumber"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PortNumber {
+            get {
+                if ((curObj["PortNumber"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PortNumber"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPortTypeNull {
+            get {
+                if ((curObj["PortType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PortType {
+            get {
+                if ((curObj["PortType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PortType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ushort[] PowerManagementCapabilities {
+            get {
+                return ((ushort[])(curObj["PowerManagementCapabilities"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPowerManagementSupportedNull {
+            get {
+                if ((curObj["PowerManagementSupported"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool PowerManagementSupported {
+            get {
+                if ((curObj["PowerManagementSupported"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["PowerManagementSupported"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPowerOnHoursNull {
+            get {
+                if ((curObj["PowerOnHours"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PowerOnHours {
+            get {
+                if ((curObj["PowerOnHours"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PowerOnHours"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPrimaryStatusNull {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort PrimaryStatus {
+            get {
+                if ((curObj["PrimaryStatus"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["PrimaryStatus"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRequestedSpeedNull {
+            get {
+                if ((curObj["RequestedSpeed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong RequestedSpeed {
+            get {
+                if ((curObj["RequestedSpeed"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["RequestedSpeed"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRequestedStateNull {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort RequestedState {
+            get {
+                if ((curObj["RequestedState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["RequestedState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSpeedNull {
+            get {
+                if ((curObj["Speed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Speed {
+            get {
+                if ((curObj["Speed"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Speed"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Status {
+            get {
+                return ((string)(curObj["Status"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] StatusDescriptions {
+            get {
+                return ((string[])(curObj["StatusDescriptions"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsStatusInfoNull {
+            get {
+                if ((curObj["StatusInfo"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort StatusInfo {
+            get {
+                if ((curObj["StatusInfo"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["StatusInfo"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSupportedMaximumTransmissionUnitNull {
+            get {
+                if ((curObj["SupportedMaximumTransmissionUnit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong SupportedMaximumTransmissionUnit {
+            get {
+                if ((curObj["SupportedMaximumTransmissionUnit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["SupportedMaximumTransmissionUnit"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemCreationClassName {
+            get {
+                return ((string)(curObj["SystemCreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SystemName {
+            get {
+                return ((string)(curObj["SystemName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimeOfLastStateChangeNull {
+            get {
+                if ((curObj["TimeOfLastStateChange"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime TimeOfLastStateChange {
+            get {
+                if ((curObj["TimeOfLastStateChange"] != null)) {
+                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTotalPowerOnHoursNull {
+            get {
+                if ((curObj["TotalPowerOnHours"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong TotalPowerOnHours {
+            get {
+                if ((curObj["TotalPowerOnHours"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["TotalPowerOnHours"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTransitioningToStateNull {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort TransitioningToState {
+            get {
+                if ((curObj["TransitioningToState"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["TransitioningToState"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsUsageRestrictionNull {
+            get {
+                if ((curObj["UsageRestriction"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort UsageRestriction {
+            get {
+                if ((curObj["UsageRestriction"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["UsageRestriction"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVMQOffloadUsageNull {
+            get {
+                if ((curObj["VMQOffloadUsage"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The current VMQ offloading usage on this port. The usage is the amount of VMQ res" +
+            "ources in use on the port.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint VMQOffloadUsage {
+            get {
+                if ((curObj["VMQOffloadUsage"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["VMQOffloadUsage"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeActiveMaximumTransmissionUnit() {
+            if ((this.IsActiveMaximumTransmissionUnitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutoSense() {
+            if ((this.IsAutoSenseNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAvailability() {
+            if ((this.IsAvailabilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCommunicationStatus() {
+            if ((this.IsCommunicationStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDetailedStatus() {
+            if ((this.IsDetailedStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledDefault() {
+            if ((this.IsEnabledDefaultNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEnabledState() {
+            if ((this.IsEnabledStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeErrorCleared() {
+            if ((this.IsErrorClearedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeFullDuplex() {
+            if ((this.IsFullDuplexNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHealthState() {
+            if ((this.IsHealthStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        // Converts a given datetime in DMTF format to System.DateTime object.
+        static System.DateTime ToDateTime(string dmtfDate) {
+            System.DateTime initializer = System.DateTime.MinValue;
+            int year = initializer.Year;
+            int month = initializer.Month;
+            int day = initializer.Day;
+            int hour = initializer.Hour;
+            int minute = initializer.Minute;
+            int second = initializer.Second;
+            long ticks = 0;
+            string dmtf = dmtfDate;
+            System.DateTime datetime = System.DateTime.MinValue;
+            string tempString = string.Empty;
+            if ((dmtf == null)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length == 0)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            if ((dmtf.Length != 25)) {
+                throw new System.ArgumentOutOfRangeException();
+            }
+            try {
+                tempString = dmtf.Substring(0, 4);
+                if (("****" != tempString)) {
+                    year = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(4, 2);
+                if (("**" != tempString)) {
+                    month = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(6, 2);
+                if (("**" != tempString)) {
+                    day = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(8, 2);
+                if (("**" != tempString)) {
+                    hour = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(10, 2);
+                if (("**" != tempString)) {
+                    minute = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(12, 2);
+                if (("**" != tempString)) {
+                    second = int.Parse(tempString);
+                }
+                tempString = dmtf.Substring(15, 6);
+                if (("******" != tempString)) {
+                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
+                }
+                if (((((((((year < 0) 
+                            || (month < 0)) 
+                            || (day < 0)) 
+                            || (hour < 0)) 
+                            || (minute < 0)) 
+                            || (minute < 0)) 
+                            || (second < 0)) 
+                            || (ticks < 0))) {
+                    throw new System.ArgumentOutOfRangeException();
+                }
+            }
+            catch (System.Exception e) {
+                throw new System.ArgumentOutOfRangeException(null, e.Message);
+            }
+            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
+            datetime = datetime.AddTicks(ticks);
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
+            int UTCOffset = 0;
+            int OffsetToBeAdjusted = 0;
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            tempString = dmtf.Substring(22, 3);
+            if ((tempString != "******")) {
+                tempString = dmtf.Substring(21, 4);
+                try {
+                    UTCOffset = int.Parse(tempString);
+                }
+                catch (System.Exception e) {
+                    throw new System.ArgumentOutOfRangeException(null, e.Message);
+                }
+                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
+                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
+            }
+            return datetime;
+        }
+        
+        // Converts a given System.DateTime object to DMTF datetime format.
+        static string ToDmtfDateTime(System.DateTime date) {
+            string utcString = string.Empty;
+            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
+            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
+            if ((System.Math.Abs(OffsetMins) > 999)) {
+                date = date.ToUniversalTime();
+                utcString = "+000";
+            }
+            else {
+                if ((tickOffset.Ticks >= 0)) {
+                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
+                }
+                else {
+                    string strTemp = ((long)(OffsetMins)).ToString();
+                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
+                }
+            }
+            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, ".");
+            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
+            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
+                        * 1000) 
+                        / System.TimeSpan.TicksPerMillisecond)));
+            string strMicrosec = ((long)(microsec)).ToString();
+            if ((strMicrosec.Length > 6)) {
+                strMicrosec = strMicrosec.Substring(0, 6);
+            }
+            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
+            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
+            return dmtfDateTime;
+        }
+        
+        private bool ShouldSerializeInstallDate() {
+            if ((this.IsInstallDateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeIOVOffloadUsage() {
+            if ((this.IsIOVOffloadUsageNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLastErrorCode() {
+            if ((this.IsLastErrorCodeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLinkTechnology() {
+            if ((this.IsLinkTechnologyNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxDataSize() {
+            if ((this.IsMaxDataSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxQuiesceTime() {
+            if ((this.IsMaxQuiesceTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxSpeed() {
+            if ((this.IsMaxSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOperatingStatus() {
+            if ((this.IsOperatingStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePortNumber() {
+            if ((this.IsPortNumberNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePortType() {
+            if ((this.IsPortTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePowerManagementSupported() {
+            if ((this.IsPowerManagementSupportedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePowerOnHours() {
+            if ((this.IsPowerOnHoursNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePrimaryStatus() {
+            if ((this.IsPrimaryStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRequestedSpeed() {
+            if ((this.IsRequestedSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRequestedState() {
+            if ((this.IsRequestedStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSpeed() {
+            if ((this.IsSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeStatusInfo() {
+            if ((this.IsStatusInfoNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSupportedMaximumTransmissionUnit() {
+            if ((this.IsSupportedMaximumTransmissionUnitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimeOfLastStateChange() {
+            if ((this.IsTimeOfLastStateChangeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTotalPowerOnHours() {
+            if ((this.IsTotalPowerOnHoursNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTransitioningToState() {
+            if ((this.IsTransitioningToStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeUsageRestriction() {
+            if ((this.IsUsageRestrictionNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVMQOffloadUsage() {
+            if ((this.IsVMQOffloadUsageNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetSwitchPort";
+            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
+            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static EthernetSwitchPortCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static EthernetSwitchPortCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static EthernetSwitchPortCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static EthernetSwitchPortCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_EthernetSwitchPort";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new EthernetSwitchPortCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_EthernetSwitchPort", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new EthernetSwitchPortCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static EthernetSwitchPort CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new EthernetSwitchPort(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public uint EnableDevice(bool Enabled) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("EnableDevice");
+                inParams["Enabled"] = ((bool)(Enabled));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("EnableDevice", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint OnlineDevice(bool Online) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("OnlineDevice");
+                inParams["Online"] = ((bool)(Online));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("OnlineDevice", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint QuiesceDevice(bool Quiesce) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("QuiesceDevice");
+                inParams["Quiesce"] = ((bool)(Quiesce));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("QuiesceDevice", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
+                inParams["RequestedState"] = ((ushort)(RequestedState));
+                inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
+                Job = null;
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint Reset() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reset", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint RestoreProperties() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RestoreProperties", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint SaveProperties() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SaveProperties", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint SetPowerState(ushort PowerState, System.DateTime Time) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("SetPowerState");
+                inParams["PowerState"] = ((ushort)(PowerState));
+                inParams["Time"] = ToDmtfDateTime(((System.DateTime)(Time)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetPowerState", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class EthernetSwitchPortCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public EthernetSwitchPortCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new EthernetSwitchPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new EthernetSwitchPortEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class EthernetSwitchPortEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public EthernetSwitchPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new EthernetSwitchPort(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[06/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs
new file mode 100755
index 0000000..b208067
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs
@@ -0,0 +1,1066 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_SyntheticEthernetPortSettingData
+    public class SyntheticEthernetPortSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_SyntheticEthernetPortSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public SyntheticEthernetPortSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public SyntheticEthernetPortSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(SyntheticEthernetPortSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(SyntheticEthernetPortSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public SyntheticEthernetPortSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public SyntheticEthernetPortSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public SyntheticEthernetPortSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public SyntheticEthernetPortSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Address {
+            get {
+                return ((string)(curObj["Address"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AddressOnParent {
+            get {
+                return ((string)(curObj["AddressOnParent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string AllocationUnits {
+            get {
+                return ((string)(curObj["AllocationUnits"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticAllocationNull {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticAllocation {
+            get {
+                if ((curObj["AutomaticAllocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticAllocation"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticDeallocationNull {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AutomaticDeallocation {
+            get {
+                if ((curObj["AutomaticDeallocation"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AutomaticDeallocation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] Connection {
+            get {
+                return ((string[])(curObj["Connection"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConsumerVisibilityNull {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ConsumerVisibility {
+            get {
+                if ((curObj["ConsumerVisibility"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ConsumerVisibility"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDesiredVLANEndpointModeNull {
+            get {
+                if ((curObj["DesiredVLANEndpointMode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DesiredVLANEndpointMode {
+            get {
+                if ((curObj["DesiredVLANEndpointMode"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DesiredVLANEndpointMode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] HostResource {
+            get {
+                return ((string[])(curObj["HostResource"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLimitNull {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Limit {
+            get {
+                if ((curObj["Limit"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Limit"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMappingBehaviorNull {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort MappingBehavior {
+            get {
+                if ((curObj["MappingBehavior"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["MappingBehavior"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherEndpointMode {
+            get {
+                return ((string)(curObj["OtherEndpointMode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OtherResourceType {
+            get {
+                return ((string)(curObj["OtherResourceType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Parent {
+            get {
+                return ((string)(curObj["Parent"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string PoolID {
+            get {
+                return ((string)(curObj["PoolID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsReservationNull {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Reservation {
+            get {
+                if ((curObj["Reservation"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Reservation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ResourceSubType {
+            get {
+                return ((string)(curObj["ResourceSubType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsResourceTypeNull {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ResourceType {
+            get {
+                if ((curObj["ResourceType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ResourceType"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsStaticMacAddressNull {
+            get {
+                if ((curObj["StaticMacAddress"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates a static MAC address.\nThis is a read-only property, but it can be chang" +
+            "ed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManage" +
+            "mentService class.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool StaticMacAddress {
+            get {
+                if ((curObj["StaticMacAddress"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["StaticMacAddress"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVirtualQuantityNull {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong VirtualQuantity {
+            get {
+                if ((curObj["VirtualQuantity"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["VirtualQuantity"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string VirtualQuantityUnits {
+            get {
+                return ((string)(curObj["VirtualQuantityUnits"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. The indexes and values per index are defined on a per resource basis (that is, for each enumerated ResourceType value). This property is set to ""GUID"".
+This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the sd class.")]
+        public string[] VirtualSystemIdentifiers {
+            get {
+                return ((string[])(curObj["VirtualSystemIdentifiers"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsWeightNull {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint Weight {
+            get {
+                if ((curObj["Weight"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["Weight"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticAllocation() {
+            if ((this.IsAutomaticAllocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticDeallocation() {
+            if ((this.IsAutomaticDeallocationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConsumerVisibility() {
+            if ((this.IsConsumerVisibilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDesiredVLANEndpointMode() {
+            if ((this.IsDesiredVLANEndpointModeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLimit() {
+            if ((this.IsLimitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMappingBehavior() {
+            if ((this.IsMappingBehaviorNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeReservation() {
+            if ((this.IsReservationNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeResourceType() {
+            if ((this.IsResourceTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeStaticMacAddress() {
+            if ((this.IsStaticMacAddressNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVirtualQuantity() {
+            if ((this.IsVirtualQuantityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeWeight() {
+            if ((this.IsWeightNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_SyntheticEthernetPortSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static SyntheticEthernetPortSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static SyntheticEthernetPortSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static SyntheticEthernetPortSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static SyntheticEthernetPortSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_SyntheticEthernetPortSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new SyntheticEthernetPortSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static SyntheticEthernetPortSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_SyntheticEthernetPortSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new SyntheticEthernetPortSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static SyntheticEthernetPortSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new SyntheticEthernetPortSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class SyntheticEthernetPortSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public SyntheticEthernetPortSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new SyntheticEthernetPortSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new SyntheticEthernetPortSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class SyntheticEthernetPortSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public SyntheticEthernetPortSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new SyntheticEthernetPortSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[41/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/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
index b3695c7..82b6885 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCallsV2.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/IWmiCallsV2.cs
@@ -1,22 +1,50 @@
-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();
-    }
-}
+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
+    {
+        System.Management.ManagementPath AddDiskDriveToVm(ComputerSystem vm, string vhdfile, string cntrllerAddr, string driveResourceType);
+        ComputerSystem AddUserData(ComputerSystem vm, string userData);
+        void AttachIso(string displayName, string iso);
+        void CreateDynamicVirtualHardDisk(ulong MaxInternalSize, string Path);
+        SyntheticEthernetPortSettingData CreateNICforVm(ComputerSystem vm, string mac);
+        ComputerSystem CreateVM(string name, long memory_mb, int vcpus);
+        void DeleteHostKvpItem(ComputerSystem vm, string key);
+        void DeleteSwitchPort(string elementName);
+        ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso);
+        void DestroyVm(dynamic jsonObj);
+        void DestroyVm(string displayName);
+        void DetachDisk(string displayName, string diskFileName);
+        ComputerSystem GetComputerSystem(string displayName);
+        string GetDefaultDataRoot();
+        string GetDefaultVirtualDiskFolder();
+        ResourceAllocationSettingData GetDvdDriveSettings(VirtualSystemSettingData vmSettings);
+        EthernetPortAllocationSettingData[] GetEthernetConnections(ComputerSystem vm);
+        SyntheticEthernetPortSettingData[] GetEthernetPortSettings(ComputerSystem vm);
+        ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr);
+        ImageManagementService GetImageManagementService();
+        KvpExchangeComponentSettingData GetKvpSettings(VirtualSystemSettingData vmSettings);
+        void GetMemoryResources(out ulong physicalRamKBs, out ulong freeMemoryKBs);
+        MemorySettingData GetMemSettings(VirtualSystemSettingData vmSettings);
+        void GetProcessorResources(out uint cores, out uint mhz);
+        void GetProcessorUsageInfo(out double cpuUtilization);
+        ProcessorSettingData GetProcSettings(VirtualSystemSettingData vmSettings);
+        ResourceAllocationSettingData.ResourceAllocationSettingDataCollection GetResourceAllocationSettings(VirtualSystemSettingData vmSettings);
+        void GetSummaryInfo(System.Collections.Generic.Dictionary<string, VmStatsEntry> vmProcessorInfo, System.Collections.Generic.List<System.Management.ManagementPath> vmsToInspect);
+        SyntheticEthernetPortSettingData GetSyntheticEthernetPortSettings(EthernetSwitchPort port);
+        VirtualSystemManagementService GetVirtualisationSystemManagementService();
+        VirtualEthernetSwitchManagementService GetVirtualSwitchManagementService();
+        EthernetSwitchPortVlanSettingData GetVlanSettings(EthernetPortAllocationSettingData ethernetConnection);
+        System.Collections.Generic.List<string> GetVmElementNames();
+        VirtualSystemSettingData GetVmSettings(ComputerSystem vm);
+        void patchSystemVmIso(string vmName, string systemVmIso);
+        void SetState(ComputerSystem vm, ushort requiredState);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/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
deleted file mode 100644
index 985ceba..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ /dev/null
@@ -1,1419 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION;
-using log4net;
-using System.Globalization;
-using System.Management;
-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 : IWmiCalls
-    {
-        private IWmiCallsV2 wmiCallsV2;
-        public WmiCalls()
-        {
-            wmiCallsV2 = new WmiCallsV2();
-        }
-        public static void Initialize()
-        {
-            // Trigger assembly load into curren appdomain
-        }
-
-        private static ILog logger = LogManager.GetLogger(typeof(WmiCalls));
-
-        /// <summary>
-        /// Returns ComputerSystem lacking any NICs and VOLUMEs
-        /// </summary>
-        public ComputerSystem CreateVM(string name, long memory_mb, int vcpus)
-        {
-            // Obtain controller for Hyper-V virtualisation subsystem
-            VirtualSystemManagementService vmMgmtSvc = GetVirtualisationSystemManagementService();
-
-            // Create VM with correct name and default resources
-            ComputerSystem vm = CreateDefaultVm(vmMgmtSvc, name);
-
-            // Update the resource settings for the VM.
-
-            // Resource settings are referenced through the Msvm_VirtualSystemSettingData object.
-            VirtualSystemSettingData vmSettings = GetVmSettings(vm);
-
-            // For memory settings, there is no Dynamic Memory, so reservation, limit and quantity are identical.
-            MemorySettingData memSettings = GetMemSettings(vmSettings);
-            memSettings.LateBoundObject["VirtualQuantity"] = memory_mb;
-            memSettings.LateBoundObject["Reservation"] = memory_mb;
-            memSettings.LateBoundObject["Limit"] = memory_mb;
-
-            // Update the processor settings for the VM, static assignment of 100% for CPU limit
-            ProcessorSettingData procSettings = GetProcSettings(vmSettings);
-            procSettings.LateBoundObject["VirtualQuantity"] = vcpus;
-            procSettings.LateBoundObject["Reservation"] = vcpus;
-            procSettings.LateBoundObject["Limit"] = 100000;
-
-            ModifyVmResources(vmMgmtSvc, vm, new String[] {
-                memSettings.LateBoundObject.GetText(TextFormat.CimDtd20),
-                procSettings.LateBoundObject.GetText(TextFormat.CimDtd20)
-                });
-            logger.InfoFormat("VM with display name {0} has GUID {1}", vm.ElementName, vm.Name);
-            logger.DebugFormat("Resources for vm {0}: {1} MB memory, {2} vcpus", name, memory_mb, vcpus);
-
-            return vm;
-        }
-
-        /// <summary>
-        /// Create a (synthetic) nic, and attach it to the vm
-        /// </summary>
-        /// <param name="vm"></param>
-        /// <param name="mac"></param>
-        /// <param name="vlan"></param>
-        /// <returns></returns>
-        public SyntheticEthernetPortSettingData CreateNICforVm(ComputerSystem vm, string mac, string vlan)
-        {
-            logger.DebugFormat("Creating nic for VM {0} (GUID {1})", vm.ElementName, vm.Name);
-
-            // Obtain controller for Hyper-V networking subsystem
-            VirtualSwitchManagementService vmNetMgmtSvc = GetVirtualSwitchManagementService();
-
-            // Create NIC resource by cloning the default NIC 
-            var synthNICsSettings = SyntheticEthernetPortSettingData.GetInstances(vmNetMgmtSvc.Scope, "InstanceID LIKE \"%Default\"");
-
-            // Assert
-            if (synthNICsSettings.Count != 1)
-            {
-                var errMsg = string.Format("Internal error, coudl not find default SyntheticEthernetPort instance");
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-            var defaultSynthNICSettings = synthNICsSettings.OfType<SyntheticEthernetPortSettingData>().First();
-
-            var newSynthNICSettings = new SyntheticEthernetPortSettingData((ManagementBaseObject)defaultSynthNICSettings.LateBoundObject.Clone());
-
-            // Get the virtual switch
-            VirtualSwitch vSwitch = GetExternalVirtSwitch();
-
-            // Crate switch port for new VM
-            ManagementPath newSwitchPath = CreateSwitchPortForVm(vm, vmNetMgmtSvc, vSwitch);
-
-            // Add required VLAND support
-            if (vlan != null)
-            {
-                SetPortVlan(vlan, vmNetMgmtSvc, newSwitchPath);
-            }
-
-            logger.DebugFormat("Created switch port {0} on switch {1}", newSwitchPath.Path, vSwitch.Path.Path);
-
-            //  Assign configuration to new NIC
-            string normalisedMAC = string.Join("", (mac.Split(new char[] { ':' })));
-            newSynthNICSettings.LateBoundObject["Connection"] = new string[] { newSwitchPath.Path };
-            newSynthNICSettings.LateBoundObject["ElementName"] = vm.ElementName;
-            newSynthNICSettings.LateBoundObject["Address"] = normalisedMAC;
-            newSynthNICSettings.LateBoundObject["StaticMacAddress"] = "TRUE";
-            newSynthNICSettings.LateBoundObject["VirtualSystemIdentifiers"] = new string[] { "{" + Guid.NewGuid().ToString() + "}" };
-            newSynthNICSettings.CommitObject();
-
-            // Insert NIC into vm
-            string[] newResources = new string[] { newSynthNICSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20)};
-            ManagementPath[] newResourcePaths = AddVirtualResource(newResources, vm );
-
-            // assert
-            if (newResourcePaths.Length != 1)
-            {
-                var errMsg = string.Format(
-                    "Failed to properly insert a single NIC on VM {0} (GUID {1}): number of resource created {2}",
-                    vm.ElementName,
-                    vm.Name,
-                    newResourcePaths.Length);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            return new SyntheticEthernetPortSettingData(newResourcePaths[0]);
-        }
-
-        public const string IDE_HARDDISK_DRIVE = "Microsoft Synthetic Disk Drive";
-        public const string IDE_ISO_DRIVE  = "Microsoft Synthetic DVD Drive";
-
-        public const string IDE_ISO_DISK = "Microsoft Virtual CD/DVD Disk"; // For IDE_ISO_DRIVE
-        public const string IDE_HARDDISK_DISK = "Microsoft Virtual Hard Disk"; // For IDE_HARDDISK_DRIVE
-
-        /// <summary>
-        /// Create new VM.  By default we start it. 
-        /// </summary>
-
-        public ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso)
-        {
-            var vmInfo = jsonObj.vm;
-            string vmName = vmInfo.name;
-            var nicInfo = vmInfo.nics;
-            int vcpus = vmInfo.cpus;
-            int memSize = vmInfo.maxRam / 1048576;
-            string errMsg = vmName;
-            var diskDrives = vmInfo.disks;
-            var bootArgs = vmInfo.bootArgs;
-
-            // assert
-            errMsg = vmName + ": missing disk information, array empty or missing, agent expects *at least* one disk for a VM";
-            if (diskDrives == null)
-            {
-                logger.Error(errMsg);
-                throw new ArgumentException(errMsg);
-            }
-            // assert
-            errMsg = vmName + ": missing NIC information, array empty or missing, agent expects at least an empty array.";
-            if (nicInfo == null )
-            {
-                logger.Error(errMsg);
-                throw new ArgumentException(errMsg);
-            }
-
-
-            // For existing VMs, return when we spot one of this name not stopped.  In the meantime, remove any existing VMs of same name.
-            ComputerSystem vmWmiObj = null;
-            while ((vmWmiObj = GetComputerSystem(vmName)) != null)
-            {
-                logger.WarnFormat("Create request for existing vm, name {0}", vmName);
-                if (vmWmiObj.EnabledState == EnabledState.Disabled)
-                {
-                    logger.InfoFormat("Deleting existing VM with name {0}, before we go on to create a VM with the same name", vmName);
-                    DestroyVm(vmName);
-                }
-                else
-                {
-                    // TODO: revise exception type
-                    errMsg = string.Format("Create VM failing, because there exists a VM with name {0}, state {1}", 
-                        vmName,
-                        EnabledState.ToString(vmWmiObj.EnabledState));
-                    var ex = new WmiException(errMsg);
-                    logger.Error(errMsg, ex);
-                    throw ex;
-                }
-            }
-
-            // Create vm carcase
-            logger.DebugFormat("Going ahead with create VM {0}, {1} vcpus, {2}MB RAM", vmName, vcpus, memSize);
-            var newVm = CreateVM(vmName, memSize, vcpus);
-
-            foreach (var diskDrive in diskDrives)
-            {
-                string vhdFile = null;
-                string diskName = null;
-                VolumeObjectTO volInfo = VolumeObjectTO.ParseJson(diskDrive.data);
-                if (volInfo != null)
-                {
-                    // assert
-                    errMsg = vmName + ": volume missing primaryDataStore for disk " + diskDrive.ToString();
-                    if (volInfo.primaryDataStore == null)
-                    {
-                        logger.Error(errMsg);
-                        throw new ArgumentException(errMsg);
-                    }
-                    diskName = volInfo.name;
-
-                    // assert
-                    errMsg = vmName + ": can't deal with DataStore type for disk " + diskDrive.ToString();
-                    if (volInfo.primaryDataStore == null)
-                    {
-                        logger.Error(errMsg);
-                        throw new ArgumentException(errMsg);
-                    }
-                    errMsg = vmName + ": Malformed PrimaryDataStore for disk " + diskDrive.ToString();
-                    if (String.IsNullOrEmpty(volInfo.primaryDataStore.path))
-                    {
-                        logger.Error(errMsg);
-                        throw new ArgumentException(errMsg);
-                    }
-                    errMsg = vmName + ": Missing folder PrimaryDataStore for disk " + diskDrive.ToString() + ", missing path: " +  volInfo.primaryDataStore.path;
-                    if (!Directory.Exists(volInfo.primaryDataStore.path))
-                    {
-                        logger.Error(errMsg);
-                        throw new ArgumentException(errMsg);
-                    }
-
-                    vhdFile = volInfo.FullFileName;
-                    if (!System.IO.File.Exists(vhdFile))
-                    {
-                        errMsg = vmName + ": non-existent volume, missing " + vhdFile + " for drive " + diskDrive.ToString();
-                        logger.Error(errMsg);
-                        throw new ArgumentException(errMsg);
-                    }
-                    logger.Debug("Going to create " + vmName + " with attached voluem " + diskName + " at " + vhdFile);
-                }
-
-                string driveType = diskDrive.type;
-
-                string ideCtrllr = "0";
-                string driveResourceType = null;
-                switch (driveType) {
-                    case "ROOT":
-                        ideCtrllr = "0";
-                        driveResourceType = IDE_HARDDISK_DRIVE;
-                        break;
-                    case "ISO":
-                        ideCtrllr = "1";
-                        driveResourceType = IDE_ISO_DRIVE;
-                        break;
-                    default: 
-                        // TODO: double check exception type
-                        errMsg = string.Format("Unknown disk type {0} for disk {1}, vm named {2}", 
-                                string.IsNullOrEmpty(driveType) ? "NULL" : driveType,
-                                string.IsNullOrEmpty(diskName) ? "NULL" : diskName, vmName);
-                        var ex = new WmiException(errMsg);
-                        logger.Error(errMsg, ex);
-                        throw ex;
-                }
-                logger.DebugFormat("Create disk type {1} (Named: {0}), on vm {2} {3}", diskName, driveResourceType, vmName, 
-                                        string.IsNullOrEmpty(vhdFile) ? " no disk to insert" : ", inserting disk" +vhdFile );
-                AddDiskDriveToVm(newVm, vhdFile, ideCtrllr, driveResourceType);
-            }
-
-            // Add the Nics to the VM in the deviceId order.
-            String publicIpAddress ="";
-            for (int i = 0; i <= 2; i++)
-            {
-                foreach (var nic in nicInfo)
-                {
-
-                    int nicid = nic.deviceId;
-                    string mac = nic.mac;
-                    string vlan = null;
-                    string isolationUri = nic.isolationUri;
-                    if (isolationUri != null && isolationUri.StartsWith("vlan://") && !isolationUri.Equals("vlan://untagged"))
-                    {
-                        vlan = isolationUri.Substring("vlan://".Length);
-                        int tmp;
-                        if (!int.TryParse(vlan, out tmp))
-                        {
-                            // TODO: double check exception type
-                            errMsg = string.Format("Invalid VLAN value {0} for on vm {1} for nic uuid {2}", isolationUri, vmName, nic.uuid);
-                            var ex = new WmiException(errMsg);
-                            logger.Error(errMsg, ex);
-                            throw ex;
-                        }
-                    }
-                    if (i == 2)
-                    {
-                        publicIpAddress = nic.ip;
-                    }
-                    if (nicid == i)
-                    {
-                        CreateNICforVm(newVm, mac, vlan);
-                        break;
-                    }
-                }
-            }
-
-            // 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);
-            if (bootArgs != null)
-            {
-                String bootargs = bootArgs;
-                wmiCallsV2.AddUserData(vm, bootargs);
-            }
-
-            // call patch systemvm iso only for systemvms
-            if (vmName.StartsWith("r-") || vmName.StartsWith("s-") || vmName.StartsWith("v-"))
-            {
-                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-") || vmName.StartsWith("s-") || vmName.StartsWith("v-"))
-            {
-                System.Threading.Thread.Sleep(90000);
-                SetState(newVm, RequiredState.Reboot);
-                // 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 void patchSystemVmIso(String vmName, String systemVmIso)
-        {
-            ComputerSystem vmObject = GetComputerSystem(vmName);
-            AddDiskDriveToVm(vmObject, "", "1", IDE_ISO_DRIVE);
-
-            AttachIso(vmName, systemVmIso);
-        }
-
-        /// <summary>
-        /// Create a disk and attach it to the vm
-        /// </summary>
-        /// <param name="vm"></param>
-        /// <param name="cntrllerAddr"></param>
-        /// <param name="driveResourceType">IDE_HARDDISK_DRIVE or IDE_ISO_DRIVE</param>
-        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,
-                        vm.Name,
-                        vhdfile);
-
-            // Determine disk type for drive and assert drive type valid
-            string diskResourceSubType = null;
-            switch(driveResourceType) {
-                case IDE_HARDDISK_DRIVE:
-                    diskResourceSubType = IDE_HARDDISK_DISK;
-                    break;
-                case IDE_ISO_DRIVE: 
-                    diskResourceSubType = IDE_ISO_DISK;
-                    break;
-                default:
-                    var errMsg = string.Format(
-                        "Unrecognised disk drive type {0} for VM {1} (GUID {2})",
-                        string.IsNullOrEmpty(driveResourceType) ? "NULL": driveResourceType, 
-                        vm.ElementName,
-                        vm.Name);
-                    var ex = new WmiException(errMsg);
-                    logger.Error(errMsg, ex);
-                    throw ex;
-            }
-
-            ManagementPath newDrivePath = AttachNewDriveToVm(vm, cntrllerAddr, driveResourceType);
-
-            // If there's not disk to insert, we are done.
-            if (String.IsNullOrEmpty(vhdfile))
-            {
-                logger.DebugFormat("No disk to be added to drive, disk drive {0} is complete", newDrivePath.Path);
-            }
-            else
-            {
-                InsertDiskImage(vm, vhdfile, diskResourceSubType, newDrivePath);
-            }
-            return newDrivePath;
-    }
-
-        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);
-            var ctrller = GetIDEControllerSettings(vmSettings, cntrllerAddr);
-
-            // A description of the drive is created by modifying a clone of the default ResourceAllocationSettingData for that drive type
-            string defaultDriveQuery = String.Format("ResourceSubType LIKE \"{0}\" AND InstanceID LIKE \"%Default\"", driveType);
-            var newDiskDriveSettings = CloneResourceAllocationSetting(defaultDriveQuery);
-
-            // Set IDE controller and address on the controller for the new drive
-            newDiskDriveSettings.LateBoundObject["Parent"] = ctrller.Path.ToString();
-            newDiskDriveSettings.LateBoundObject["Address"] = "0";
-            newDiskDriveSettings.CommitObject();
-
-            // Add this new disk drive to the VM
-            logger.DebugFormat("Creating disk drive type {0}, parent IDE controller is {1} and address on controller is {2}",
-                newDiskDriveSettings.ResourceSubType,
-                newDiskDriveSettings.Parent,
-                newDiskDriveSettings.Address);
-            string[] newDriveResource = new string[] { newDiskDriveSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20) };
-            ManagementPath[] newDrivePaths = AddVirtualResource(newDriveResource, vm);
-
-            // assert
-            if (newDrivePaths.Length != 1)
-            {
-                var errMsg = string.Format(
-                    "Failed to add disk drive type {3} to VM {0} (GUID {1}): number of resource created {2}",
-                    vm.ElementName,
-                    vm.Name,
-                    newDrivePaths.Length,
-                    driveType);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-            logger.DebugFormat("New disk drive type {0} WMI path is {1}s",
-                newDiskDriveSettings.ResourceSubType,
-                newDrivePaths[0].Path);
-            return newDrivePaths[0];
-        }
-
-        /// <summary>
-        /// Attach iso to the vm
-        /// </summary>
-        /// <param name="vm"></param>
-        /// <param name="isoPath"></param>
-        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);
-            var ctrller = GetDvdDriveSettings(vmSettings);
-
-            // A description of the drive is created by modifying a clone of the default ResourceAllocationSettingData for that drive type
-            string defaultDiskQuery = String.Format("ResourceSubType LIKE \"{0}\" AND InstanceID LIKE \"%Default\"", IDE_ISO_DISK);
-            var newDiskSettings = CloneResourceAllocationSetting(defaultDiskQuery);
-
-            // Set IDE controller and address on the controller for the new drive
-            newDiskSettings.LateBoundObject["Parent"] = ctrller.Path.ToString();
-            newDiskSettings.LateBoundObject["Connection"] = new string[] { isoPath };
-            newDiskSettings.CommitObject();
-
-            // Add the new vhd object as a virtual hard disk to the vm.
-            string[] newDiskResource = new string[] { newDiskSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20) };
-            ManagementPath[] newDiskPaths = AddVirtualResource(newDiskResource, vm);
-            // assert
-            if (newDiskPaths.Length != 1)
-            {
-                var errMsg = string.Format(
-                    "Failed to add disk image to VM {0} (GUID {1}): number of resource created {2}",
-                    vm.ElementName,
-                    vm.Name,
-                    newDiskPaths.Length);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-            logger.InfoFormat("Created disk {2} for VM {0} (GUID {1}), image {3} ",
-                    vm.ElementName,
-                    vm.Name,
-                    newDiskPaths[0].Path,
-                    isoPath);
-        }
-
-        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);
-            var newDiskSettings = CloneResourceAllocationSetting(defaultDiskQuery);
-
-            // Set disk drive and VHD file on disk for new disk
-            newDiskSettings.LateBoundObject["Parent"] = drivePath.Path;
-            newDiskSettings.LateBoundObject["Connection"] = new string[] { vhdfile };
-            newDiskSettings.CommitObject();
-
-            // Add the new vhd object as a virtual hard disk to the vm.
-            string[] newDiskResource = new string[] { newDiskSettings.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20) };
-            ManagementPath[] newDiskPaths = AddVirtualResource(newDiskResource, vm);
-            // assert
-            if (newDiskPaths.Length != 1)
-            {
-                var errMsg = string.Format(
-                    "Failed to add disk image type {3} to VM {0} (GUID {1}): number of resource created {2}",
-                    vm.ElementName,
-                    vm.Name,
-                    newDiskPaths.Length,
-                    diskResourceSubType);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-            logger.InfoFormat("Created disk {2} for VM {0} (GUID {1}), image {3} ",
-                    vm.ElementName,
-                    vm.Name,
-                    newDiskPaths[0].Path,
-                    vhdfile);
-        }
-
-        private ResourceAllocationSettingData CloneResourceAllocationSetting(string wmiQuery)
-        {
-            var defaultDiskDriveSettingsObjs = ResourceAllocationSettingData.GetInstances(wmiQuery);
-
-            // assert
-            if (defaultDiskDriveSettingsObjs.Count != 1)
-            {
-                var errMsg = string.Format("Failed to find Msvm_ResourceAllocationSettingData for the query {0}", wmiQuery);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            ResourceAllocationSettingData defaultDiskDriveSettings = defaultDiskDriveSettingsObjs.OfType<ResourceAllocationSettingData>().First();
-            return new ResourceAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
-        }
-
-        public void AttachIso(string displayName, string iso)
-        {
-            logger.DebugFormat("Got request to attach iso {0} to vm {1}", iso, displayName);
-
-            ComputerSystem vm = GetComputerSystem(displayName);
-            if (vm == null)
-            {
-                logger.DebugFormat("VM {0} not found", displayName);
-                return;
-            }
-            else
-            {
-                AttachIsoToVm(vm, iso);
-            }
-        }
-
-        public void DestroyVm(dynamic jsonObj)
-        {
-            string vmToDestroy = jsonObj.vmName;
-            DestroyVm(vmToDestroy);
-        }
-        
-        /// <summary>
-        /// Remove all VMs and all SwitchPorts with the displayName.  VHD gets deleted elsewhere.
-        /// </summary>
-        /// <param name="displayName"></param>
-        public void DestroyVm(string displayName)
-        {
-            logger.DebugFormat("Got request to destroy vm {0}", displayName);
-
-            var vm = GetComputerSystem(displayName);
-            if ( vm  == null )
-            {
-                logger.DebugFormat("VM {0} already destroyed (or never existed)", displayName);
-                return;
-            }
-
-            // Stop VM
-            logger.DebugFormat("Stop VM {0} (GUID {1})", vm.ElementName, vm.Name);
-            SetState(vm, RequiredState.Disabled);
-
-            // Delete SwitchPort
-            DeleteSwitchPort(vm.ElementName);
-
-            // Delete VM
-            var virtSysMgmtSvc = GetVirtualisationSystemManagementService();
-            ManagementPath jobPath;
-
-            do
-            {
-                logger.DebugFormat("Delete VM {0} (GUID {1})", vm.ElementName, vm.Name);
-                var ret_val = virtSysMgmtSvc.DestroyVirtualSystem(vm.Path, out jobPath);
-
-                if (ret_val == ReturnCode.Started)
-                {
-                    JobCompleted(jobPath);
-                }
-                else if (ret_val != ReturnCode.Completed)
-                {
-                    var errMsg = string.Format(
-                        "Failed Delete VM {0} (GUID {1}) due to {2}",
-                        vm.ElementName,
-                        vm.Name,
-                        ReturnCode.ToString(ret_val));
-                    var ex = new WmiException(errMsg);
-                    logger.Error(errMsg, ex);
-                    throw ex;
-                }
-                vm = GetComputerSystem(displayName);
-            }
-            while (vm != null);
-        }
-
-        public void SetState(ComputerSystem vm, ushort requiredState)
-        {
-            logger.InfoFormat(
-                "Changing state of {0} (GUID {1}) to {2}", 
-                vm.ElementName, 
-                vm.Name,  
-                RequiredState.ToString(requiredState));
-
-            ManagementPath jobPath;
-            // TimeSpan is a value type; default ctor is equivalent to 0.
-            var ret_val = vm.RequestStateChange(requiredState, new TimeSpan(), out jobPath);
-
-            // If the Job is done asynchronously
-            if (ret_val == ReturnCode.Started)
-            {
-                JobCompleted(jobPath);
-            }
-            else if (ret_val == 32775)
-            {
-                logger.InfoFormat("RequestStateChange returned 32775, which means vm in wrong state for requested state change.  Treating as if requested state was reached");
-            }
-            else if (ret_val != ReturnCode.Completed)
-            {
-                var errMsg = string.Format(
-                    "Failed to change state of VM {0} (GUID {1}) to {2} due to {3}",
-                    vm.ElementName,
-                    vm.Name,
-                    RequiredState.ToString(requiredState),
-                    ReturnCode.ToString(ret_val));
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            logger.InfoFormat(
-                "Successfully changed vm state of {0} (GUID {1} to requested state {2}", 
-                vm.ElementName, 
-                vm.Name,  
-                requiredState);
-        }
-
-
-        //TODO:  Write method to delete SwitchPort based on Name
-        public bool DeleteSwitchPort(string elementName)
-        {
-            var virtSwitchMgmtSvc = GetVirtualSwitchManagementService();
-            // Get NIC path
-            var condition = string.Format("ElementName=\"{0}\"", elementName);
-            var switchPortCollection = SwitchPort.GetInstances(virtSwitchMgmtSvc.Scope, condition);
-            if (switchPortCollection.Count == 0)
-            {
-                return true;
-            }
-
-            foreach (SwitchPort port in switchPortCollection)
-            {
-                // Destroy
-                var ret_val = virtSwitchMgmtSvc.DeleteSwitchPort(port.Path);
-
-                if (ret_val != ReturnCode.Completed)
-                {
-                    return false;
-                }
-            }
-
-            return true;
-        }
-
-        // Add new 
-        private ManagementPath[] AddVirtualResource(string[] resourceSettings, ComputerSystem vm )
-        {
-            var virtSysMgmtSvc = GetVirtualisationSystemManagementService();
-
-            ManagementPath jobPath;
-            ManagementPath[] resourcePaths;
-            var ret_val = virtSysMgmtSvc.AddVirtualSystemResources(
-                resourceSettings, 
-                vm.Path,
-                out jobPath,
-                out resourcePaths);
-
-            // If the Job is done asynchronously
-            if (ret_val == ReturnCode.Started)
-            {
-                JobCompleted(jobPath);
-            }
-            else if (ret_val != ReturnCode.Completed)
-            {
-                var errMsg = string.Format(
-                    "Failed to add resources to VM {0} (GUID {1}) due to {2}",
-                    vm.ElementName,
-                    vm.Name,
-                    ReturnCode.ToString(ret_val));
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            return resourcePaths;
-        }
-
-        private ManagementPath CreateSwitchPortForVm(ComputerSystem vm, VirtualSwitchManagementService vmNetMgmtSvc, VirtualSwitch vSwitch)
-        {
-            ManagementPath newSwitchPath = null;
-            var ret_val = vmNetMgmtSvc.CreateSwitchPort(
-                vm.ElementName,
-                Guid.NewGuid().ToString(),
-                "",
-                vSwitch.Path,
-                out newSwitchPath);
-            // Job is always done synchronously
-            if (ret_val != ReturnCode.Completed)
-            {
-                var errMsg = string.Format(
-                    "Failed to create switch for NIC on VM {0} (GUID {1}), error code {2}",
-                    vm.ElementName,
-                    vm.Name,
-                    ret_val);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-            return newSwitchPath;
-        }
-
-        // add vlan support by setting AccessVLAN on VLANEndpointSettingData for port
-        private void SetPortVlan(string vlan, VirtualSwitchManagementService vmNetMgmtSvc, ManagementPath newSwitchPath)
-        {
-            logger.DebugFormat("Setting VLAN to {0}", vlan);
-
-            VLANEndpointSettingData vlanEndpointSettings = GetVlanEndpointSettings(vmNetMgmtSvc, newSwitchPath);
-            vlanEndpointSettings.LateBoundObject["AccessVLAN"] = vlan;
-            vlanEndpointSettings.CommitObject();
-        }
-
-        public VLANEndpointSettingData GetVlanEndpointSettings(VirtualSwitchManagementService vmNetMgmtSvc, ManagementPath newSwitchPath)
-        {
-            // Get Msvm_VLANEndpoint through associated with new Port
-            var vlanEndpointQuery = new RelatedObjectQuery(newSwitchPath.Path, VLANEndpoint.CreatedClassName);
-            var vlanEndpointSearch = new ManagementObjectSearcher(vmNetMgmtSvc.Scope, vlanEndpointQuery);
-            var vlanEndpointCollection = new VLANEndpoint.VLANEndpointCollection(vlanEndpointSearch.Get());
-
-            // assert
-            if (vlanEndpointCollection.Count != 1)
-            {
-                var errMsg = string.Format("No VLANs for vSwitch on Hyper-V server for switch {0}", newSwitchPath.Path);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            VLANEndpoint vlanEndpoint = vlanEndpointCollection.OfType<VLANEndpoint>().First();
-
-            // Get Msvm_VLANEndpointSettingData assocaited with Msvm_VLANEndpoint
-            var vlanEndpointSettingsQuery = new RelatedObjectQuery(vlanEndpoint.Path.Path, VLANEndpointSettingData.CreatedClassName);
-            var vlanEndpointSettingsSearch = new ManagementObjectSearcher(vmNetMgmtSvc.Scope, vlanEndpointSettingsQuery);
-            var vlanEndpointSettingsCollection = new VLANEndpointSettingData.VLANEndpointSettingDataCollection(vlanEndpointSettingsSearch.Get());
-
-            // assert
-            if (vlanEndpointSettingsCollection.Count != 1)
-            {
-                var errMsg = string.Format("Internal error, VLAN for vSwitch not setup propertly Hyper-V");
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            VLANEndpointSettingData vlanEndpointSettings = vlanEndpointSettingsCollection.OfType<VLANEndpointSettingData>().First();
-            return vlanEndpointSettings;
-        }
-
-        /// <summary>
-        /// External VSwitch has an external NIC, and we assume there is only one external NIC
-        /// </summary>
-        /// <param name="vmSettings"></param>
-        /// <returns></returns>
-        /// <throw>Throws if there is no vswitch</throw>
-        public VirtualSwitch GetExternalVirtSwitch()
-        {
-            // Work back from the first *bound* external NIC we find.
-            var externNICs = ExternalEthernetPort.GetInstances("IsBound = TRUE");
-
-            if (externNICs.Count == 0 )
-            {
-                var errMsg = "No ExternalEthernetPort available to Hyper-V";
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            ExternalEthernetPort externNIC = externNICs.OfType<ExternalEthernetPort>().First();
-
-            // A sequence of ASSOCIATOR objects need to be traversed to get from external NIC the vswitch.
-            // We use ManagementObjectSearcher objects to execute this sequence of questions
-            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
-            // the virtualisation objects.
-            var endpointQuery = new RelatedObjectQuery(externNIC.Path.Path, SwitchLANEndpoint.CreatedClassName);
-            var endpointSearch = new ManagementObjectSearcher(externNIC.Scope, endpointQuery);
-            var endpointCollection = new SwitchLANEndpoint.SwitchLANEndpointCollection(endpointSearch.Get());
-
-            // assert
-            if (endpointCollection.Count < 1 )
-            {
-                var errMsg = string.Format("No SwitchLANEndpoint for external NIC {0} on Hyper-V server", externNIC.Name);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            SwitchLANEndpoint endPoint = endpointCollection.OfType<SwitchLANEndpoint>().First();
-            var switchPortQuery = new RelatedObjectQuery(endPoint.Path.Path, SwitchPort.CreatedClassName);
-            var switchPortSearch = new ManagementObjectSearcher(externNIC.Scope, switchPortQuery);
-            var switchPortCollection = new SwitchPort.SwitchPortCollection(switchPortSearch.Get());
-
-            // assert
-            if (switchPortCollection.Count < 1 )
-            {
-                var errMsg = string.Format("No SwitchPort for external NIC {0} on Hyper-V server", externNIC.Name);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            SwitchPort switchPort = switchPortCollection.OfType<SwitchPort>().First();
-            var vSwitchQuery = new RelatedObjectQuery(switchPort.Path.Path, VirtualSwitch.CreatedClassName);
-            var vSwitchSearch = new ManagementObjectSearcher(externNIC.Scope, vSwitchQuery);
-            var vSwitchCollection = new VirtualSwitch.VirtualSwitchCollection(vSwitchSearch.Get());
-
-            // assert
-            if (vSwitchCollection.Count < 1)
-            {
-                var errMsg = string.Format("No virtual switch for external NIC {0} on Hyper-V server", externNIC.Name);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            VirtualSwitch vSwitch = vSwitchCollection.OfType<VirtualSwitch>().First();
-
-            return vSwitch;
-        }
-
-
-        private void ModifyVmResources(VirtualSystemManagementService vmMgmtSvc, ComputerSystem vm, string[] resourceSettings)
-        {
-            // Resource settings are changed through the management service
-            System.Management.ManagementPath jobPath;
-
-            var ret_val = vmMgmtSvc.ModifyVirtualSystemResources(vm.Path,
-                resourceSettings,
-                out jobPath);
-            // If the Job is done asynchronously
-            if (ret_val == ReturnCode.Started)
-            {
-                JobCompleted(jobPath);
-            }
-            else if (ret_val != ReturnCode.Completed)
-            {
-                var errMsg = string.Format(
-                    "Failed to update VM {0} (GUID {1}) due to {2} (ModifyVirtualSystem call), existing VM not deleted",
-                    vm.ElementName,
-                    vm.Name,
-                    ReturnCode.ToString(ret_val));
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-        }
-
-        private ComputerSystem CreateDefaultVm(VirtualSystemManagementService vmMgmtSvc, string name)
-        {
-            // Tweak default settings by basing new VM on default global setting object 
-            // with designed display name.
-
-            VirtualSystemGlobalSettingData vs_gs_data = VirtualSystemGlobalSettingData.CreateInstance();
-            vs_gs_data.LateBoundObject["ElementName"] = name;
-
-            System.Management.ManagementPath jobPath;
-            System.Management.ManagementPath defined_sys;
-            var ret_val = vmMgmtSvc.DefineVirtualSystem(
-                new string[0],
-                null,
-                vs_gs_data.LateBoundObject.GetText(System.Management.TextFormat.CimDtd20),
-                out defined_sys,
-                out jobPath);
-
-            // If the Job is done asynchronously
-            if (ret_val == ReturnCode.Started)
-            {
-                JobCompleted(jobPath);
-            }
-            else if (ret_val != ReturnCode.Completed)
-            {
-                var errMsg = string.Format(
-                    "Failed to create VM {0} due to {1} (DefineVirtualSystem call)",
-                    name, ReturnCode.ToString(ret_val));
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            logger.DebugFormat(CultureInfo.InvariantCulture, "Created VM {0}", name);
-
-            // Is the defined_system real?
-            var vm = new ComputerSystem(defined_sys);
-
-            // Assertion
-            if (vm.ElementName.CompareTo(name) != 0)
-            {
-                var errMsg = string.Format(
-                    "New VM created with wrong name (is {0}, should be {1}, GUID {2})",
-                    vm.ElementName,
-                    name,
-                    vm.Name);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            return vm;
-        }
-
-        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.
-            var virtSwtichSvcCollection = VirtualSwitchManagementService.GetInstances();
-            foreach (VirtualSwitchManagementService item in virtSwtichSvcCollection)
-            {
-                return item;
-            }
-
-            var errMsg = string.Format("No Hyper-V subsystem on server");
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-
-        public  void CreateDynamicVirtualHardDisk(ulong MaxInternalSize, string Path)
-        {
-            // Resource settings are changed through the management service
-            System.Management.ManagementPath jobPath;
-            var imgMgr = GetImageManagementService();
-            var ret_val = imgMgr.CreateDynamicVirtualHardDisk(MaxInternalSize, Path, out jobPath);
-            // If the Job is done asynchronously
-            if (ret_val == ReturnCode.Started)
-            {
-                JobCompleted(jobPath);
-            }
-            else if (ret_val != ReturnCode.Completed)
-            {
-                var errMsg = string.Format(
-                    "Failed to CreateDynamicVirtualHardDisk size {0}, path {1} to {2}",
-                    MaxInternalSize,
-                    Path,
-                    ReturnCode.ToString(ret_val));
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-        }
-
-        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.
-
-            var coll = ImageManagementService.GetInstances();
-            foreach (ImageManagementService item in coll)
-            {
-                return item;
-            }
-
-            var errMsg = string.Format("No Hyper-V subsystem on server");
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-
-
-        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.
-           
-            var virtSysMgmtSvcCollection = VirtualSystemManagementService.GetInstances();
-            foreach (VirtualSystemManagementService item in virtSysMgmtSvcCollection)
-            {
-                return item;
-            }
-
-            var errMsg = string.Format("No Hyper-V subsystem on server");
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-
-        /// <summary>
-        /// Similar to http://msdn.microsoft.com/en-us/library/hh850031%28v=vs.85%29.aspx
-        /// </summary>
-        /// <param name="jobPath"></param>
-        /// <returns></returns>
-        private  void JobCompleted(ManagementPath jobPath)
-        {
-            ConcreteJob jobObj = null;
-            for(;;)
-            {
-                jobObj = new ConcreteJob(jobPath);
-                if (jobObj.JobState != JobState.Starting && jobObj.JobState != JobState.Running)
-                {
-                    break;
-                }
-                logger.InfoFormat("In progress... {0}% completed.", jobObj.PercentComplete);
-                System.Threading.Thread.Sleep(1000);
-            }
-
-            if (jobObj.JobState != JobState.Completed)
-            {
-                var errMsg = string.Format(
-                    "Hyper-V Job failed, Error Code:{0}, Description: {1}", 
-                    jobObj.ErrorCode, 
-                    jobObj.ErrorDescription);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            logger.DebugFormat("WMI job succeeded: {0}, Elapsed={1}", jobObj.Description, jobObj.ElapsedTime);
-        }
-
-        public  void GetProcessorResources(out uint cores, out uint mhz)
-        {
-            //  Processor processors
-            cores = 0;
-            mhz = 0;
-            Processor.ProcessorCollection procCol = Processor.GetInstances();
-            foreach (Processor procInfo in procCol)
-            {
-                cores += procInfo.NumberOfCores;
-                mhz = procInfo.MaxClockSpeed;
-           }
-        }
-        
-        public  void GetProcessorUsageInfo(out double cpuUtilization)
-        {
-            PerfFormattedData_Counters_ProcessorInformation.PerfFormattedData_Counters_ProcessorInformationCollection coll = 
-                            PerfFormattedData_Counters_ProcessorInformation.GetInstances("Name=\"_Total\"");
-            cpuUtilization = 100;
-            // Use the first one
-            foreach (PerfFormattedData_Counters_ProcessorInformation procInfo in coll)
-            {
-                // Idle during a given internal 
-                // See http://library.wmifun.net/cimv2/win32_perfformatteddata_counters_processorinformation.html
-                cpuUtilization = 100.0 - (double)procInfo.PercentIdleTime;            
-            }
-        }
-
-
-        public  void GetMemoryResources(out ulong physicalRamKBs, out ulong freeMemoryKBs)
-        {
-            OperatingSystem0 os = new OperatingSystem0();
-            physicalRamKBs = os.TotalVisibleMemorySize;
-            freeMemoryKBs = os.FreePhysicalMemory;
-        }
-
-        public  string GetDefaultVirtualDiskFolder()
-        {
-            VirtualSystemManagementServiceSettingData.VirtualSystemManagementServiceSettingDataCollection coll = VirtualSystemManagementServiceSettingData.GetInstances();
-            string defaultVirtualHardDiskPath = null;
-            foreach (VirtualSystemManagementServiceSettingData settings in coll)
-            {
-                return settings.DefaultVirtualHardDiskPath;
-            }
-
-            // assert
-            if (!System.IO.Directory.Exists(defaultVirtualHardDiskPath) ){
-                var errMsg = string.Format(
-                    "Hyper-V DefaultVirtualHardDiskPath is invalid!");
-                logger.Error(errMsg);
-                return null;
-            }
-            
-            return defaultVirtualHardDiskPath;
-        }
-
-        public  ComputerSystem GetComputerSystem(string displayName)
-        {
-            var wmiQuery = String.Format("ElementName=\"{0}\"", displayName);
-            ComputerSystem.ComputerSystemCollection vmCollection = ComputerSystem.GetInstances(wmiQuery);
-
-            // Return the first one
-            foreach (ComputerSystem vm in vmCollection)
-            {
-                return vm;
-            }
-            return null;
-        }
-
-        public  List<string> GetVmElementNames()
-        {
-            List<string> result = new List<string>();
-            ComputerSystem.ComputerSystemCollection vmCollection = ComputerSystem.GetInstances();
-
-            // Return the first one
-            foreach (ComputerSystem vm in vmCollection)
-            {
-                if (vm.Caption.StartsWith("Hosting Computer System") )
-                {
-                    continue;
-                }
-                result.Add(vm.ElementName);
-            }
-            return result;
-        }
-
-        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.
-            // Instead, we use the System.Management to code the equivalant of 
-            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
-            //
-            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, ProcessorSettingData.CreatedClassName);
-
-            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
-            // the virtualisation objects.
-            var wmiObjectSearch = new ManagementObjectSearcher(vmSettings.Scope, wmiObjQuery);
-            var wmiObjCollection = new ProcessorSettingData.ProcessorSettingDataCollection(wmiObjectSearch.Get());
-
-            foreach (ProcessorSettingData wmiObj in wmiObjCollection)
-            {
-                return wmiObj;
-            }
-
-            var errMsg = string.Format("No ProcessorSettingData in VirtualSystemSettingData {0}", vmSettings.Path.Path);
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-
-        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.
-            // Instead, we use the System.Management to code the equivalant of 
-            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
-            //
-            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, MemorySettingData.CreatedClassName);
-
-            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
-            // the virtualisation objects.
-            var wmiObjectSearch = new ManagementObjectSearcher(vmSettings.Scope, wmiObjQuery);
-            var wmiObjCollection = new MemorySettingData.MemorySettingDataCollection(wmiObjectSearch.Get());
-
-            foreach (MemorySettingData wmiObj in wmiObjCollection)
-            {
-                return wmiObj;
-            }
-
-            var errMsg = string.Format("No MemorySettingData in VirtualSystemSettingData {0}", vmSettings.Path.Path);
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-
-        public  ResourceAllocationSettingData GetDvdDriveSettings(VirtualSystemSettingData vmSettings)
-        {
-            var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
-
-            foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection)
-            {
-                if (wmiObj.ResourceType == 16)
-                {
-                    return wmiObj;
-                }
-            }
-
-            var errMsg = string.Format(
-                                "Cannot find the Dvd drive in VirtualSystemSettingData {0}",
-                                vmSettings.Path.Path);
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-
-        public  ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr)
-        {
-            var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
-
-            foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection)
-            {
-                if (wmiObj.ResourceSubType == "Microsoft Emulated IDE Controller" && wmiObj.Address == cntrllerAddr)
-                {
-                    return wmiObj;
-                }
-            }
-
-            var errMsg = string.Format(
-                                "Cannot find the Microsoft Emulated IDE Controlle at address {0} in VirtualSystemSettingData {1}", 
-                                cntrllerAddr, 
-                                vmSettings.Path.Path);
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-
-        /// <summary>
-        /// VM resources, typically hardware a described by a generic MSVM_ResourceAllocationSettingData object.  The hardware type being 
-        /// described is identified in two ways:  in general terms using an enum in the ResourceType field, and in terms of the implementation 
-        /// using text in the ResourceSubType field.
-        /// See http://msdn.microsoft.com/en-us/library/cc136877%28v=vs.85%29.aspx
-        /// </summary>
-        /// <param name="vmSettings"></param>
-        /// <returns></returns>
-        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.
-            // Instead, we use the System.Management to code the equivalant of 
-            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
-            //
-            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, ResourceAllocationSettingData.CreatedClassName);
-
-            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
-            // the virtualisation objects.
-            var wmiObjectSearch = new ManagementObjectSearcher(vmSettings.Scope, wmiObjQuery);
-            var wmiObjCollection = new ResourceAllocationSettingData.ResourceAllocationSettingDataCollection(wmiObjectSearch.Get());
-
-            if (wmiObjCollection != null)
-            {
-                return wmiObjCollection;
-            }
-
-            var errMsg = string.Format("No ResourceAllocationSettingData in VirtualSystemSettingData {0}", vmSettings.Path.Path);
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-
-        public  SwitchPort[] GetSwitchPorts(ComputerSystem vm)
-        {
-            var virtSwitchMgmtSvc = GetVirtualSwitchManagementService();
-            // Get NIC path
-            var condition = string.Format("ElementName=\"{0}\"", vm.ElementName);
-            var switchPortCollection = SwitchPort.GetInstances(virtSwitchMgmtSvc.Scope, condition);
-
-            List<SwitchPort> result = new List<SwitchPort>(switchPortCollection.Count);
-            foreach (SwitchPort item in switchPortCollection)
-            {
-                result.Add(item);
-            }
-            return result.ToArray();
-        }
-
-
-        /// <summary>
-        /// Deprecated
-        /// </summary>
-        /// <param name="nic"></param>
-        /// <returns></returns>
-        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.
-            // Instead, we use the System.Management to code the equivalant of 
-            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", wmiObject.path, resultclassName);
-            //
-            var wmiObjQuery = new RelatedObjectQuery(nic.Path.Path, VmLANEndpoint.CreatedClassName);
-
-            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
-            // the virtualisation objects.
-            var wmiObjectSearch = new ManagementObjectSearcher(nic.Scope, wmiObjQuery);
-            var wmiObjCollection = new VmLANEndpoint.VmLANEndpointCollection(wmiObjectSearch.Get());
-
-            // assert
-            if (wmiObjCollection.Count < 1)
-            {
-                var errMsg = string.Format("No VmLANEndpoint for external NIC {0} on Hyper-V server", nic.Name);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            VmLANEndpoint vmEndPoint = wmiObjCollection.OfType<VmLANEndpoint>().First();
-            var switchPortQuery = new RelatedObjectQuery(vmEndPoint.Path.Path, SwitchPort.CreatedClassName);
-            var switchPortSearch = new ManagementObjectSearcher(nic.Scope, switchPortQuery);
-            var switchPortCollection = new SwitchPort.SwitchPortCollection(switchPortSearch.Get());
-
-            // assert
-            if (switchPortCollection.Count < 1)
-            {
-                var errMsg = string.Format("No SwitchPort for external NIC {0} on Hyper-V server", nic.Name);
-                var ex = new WmiException(errMsg);
-                logger.Error(errMsg, ex);
-                throw ex;
-            }
-
-            SwitchPort switchPort = wmiObjCollection.OfType<SwitchPort>().First();
-
-            return switchPort;
-        }
-
-        public  SyntheticEthernetPortSettingData[] GetEthernetPorts(ComputerSystem vm)
-        {
-            // An ASSOCIATOR object provides the cross reference from the ComputerSettings and the 
-            // SyntheticEthernetPortSettingData, via the VirtualSystemSettingData.
-            // However, generated wrappers do not expose a ASSOCIATOR OF query as a method.
-            // Instead, we use the System.Management to code the equivalant of 
-            //
-            // string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vm.path, resultclassName);
-            //
-            VirtualSystemSettingData vmSettings = GetVmSettings(vm);
-
-            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, SyntheticEthernetPortSettingData.CreatedClassName);
-
-            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
-            // the virtualisation objects.
-            var wmiObjectSearch = new ManagementObjectSearcher(vm.Scope, wmiObjQuery);
-            var wmiObjCollection = new SyntheticEthernetPortSettingData.SyntheticEthernetPortSettingDataCollection(wmiObjectSearch.Get());
-
-            List<SyntheticEthernetPortSettingData> results = new List<SyntheticEthernetPortSettingData>(wmiObjCollection.Count);
-            foreach (SyntheticEthernetPortSettingData item in wmiObjCollection)
-            {
-                results.Add(item);
-            }
-
-            return results.ToArray();
-        }
-
-        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.
-            // Instead, we use the System.Management to code the equivalant of 
-            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vm.path, resultclassName);
-            //
-            var wmiObjQuery = new RelatedObjectQuery(vm.Path.Path, VirtualSystemSettingData.CreatedClassName);
-
-            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
-            // the virtualisation objects.
-            var wmiObjectSearch = new ManagementObjectSearcher(vm.Scope, wmiObjQuery);
-            var wmiObjCollection = new VirtualSystemSettingData.VirtualSystemSettingDataCollection(wmiObjectSearch.Get());
-
-            // When snapshots are taken into account, there can be multiple settings objects
-            // take the first one that isn't a snapshot
-            foreach (VirtualSystemSettingData wmiObj in wmiObjCollection)
-            {
-                if (wmiObj.SettingType == 3)
-                {
-                    return wmiObj;
-                }
-            }
-
-            var errMsg = string.Format("No VirtualSystemSettingData for VM {0}, path {1}", vm.ElementName, vm.Path.Path);
-            var ex = new WmiException(errMsg);
-            logger.Error(errMsg, ex);
-            throw ex;
-        }
-    }
-}


[46/56] [abbrv] 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 comm

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs
new file mode 100644
index 0000000..1226561
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs
@@ -0,0 +1,321 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+using System;
+using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION;
+using System.Management;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System.IO;
+using log4net;
+using HypervResource;
+using CloudStack.Plugin.AgentShell;
+using System.Collections.Generic;
+using NSubstitute;
+using System.Web.Http;
+using Xunit;
+
+namespace ServerResource.Tests
+{
+    public class HypervResourceController1Test
+    {
+
+        protected static string testCifsUrl = AgentSettings.Default.testCifsUrl;
+        protected static string testCifsPath = AgentSettings.Default.testCifsPath;
+        protected static String testPrimaryDataStoreHost = HypervResourceController.config.StorageIpAddress;
+        protected static String testS3TemplateName = AgentSettings.Default.testS3TemplateName;
+        protected static String testCifsTemplateName = AgentSettings.Default.testS3TemplateName;
+        protected static String testSystemVMTemplateName = AgentSettings.Default.testSystemVMTemplateName;
+        protected static String testSystemVMTemplateNameNoExt = AgentSettings.Default.testSystemVMTemplateNameNoExt;
+        protected static String testLocalStoreUUID = "5fe2bad3-d785-394e-9949-89786b8a63d2";
+        protected static String testLocalStorePath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "storagepool");
+        protected static String testSecondaryStoreLocalPath = Path.Combine(AgentSettings.Default.hyperv_plugin_root, "var", "test", "secondary");
+
+        // TODO: differentiate between NFS and HTTP template URLs.
+        protected static String testSampleTemplateUUID = "TestCopiedLocalTemplate.vhdx";
+        protected static String testSampleTemplateURL = testSampleTemplateUUID;
+
+        // test volumes are both a minimal size vhdx.  Changing the extension to .vhd makes on corrupt.
+        protected static String testSampleVolumeWorkingUUID = "TestVolumeLegit.vhdx";
+        protected static String testSampleVolumeCorruptUUID = "TestVolumeCorrupt.vhd";
+        protected static String testSampleVolumeTempUUID = "TestVolumeTemp.vhdx";
+        protected static String testSampleVolumeTempUUIDNoExt = "TestVolumeTemp";
+        protected static String testSampleVolumeWorkingURIJSON;
+        protected static String testSampleVolumeCorruptURIJSON;
+        protected static String testSampleVolumeTempURIJSON;
+
+        protected static String testSampleTemplateURLJSON;
+        protected static String testLocalStorePathJSON;
+
+        protected static IWmiCalls wmiCalls;
+
+
+        private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceController1Test));
+
+        /// <summary>
+        /// Test WmiCalls to which incoming HTTP POST requests are dispatched.
+        /// 
+        /// TODO: revise beyond first approximation
+        /// First approximation is a quick port of the existing Java tests for Hyper-V server resource.
+        /// A second approximation would use the AgentShell settings files directly.
+        /// A third approximation would look to invoke ServerResource methods via an HTTP request
+        /// </summary>
+
+        public HypervResourceController1Test()
+        {
+            wmiCalls = Substitute.For<IWmiCalls>();
+            //AgentService.ConfigServerResource();
+            HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address;
+            HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask;
+            HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress;
+            HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress;
+            HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask;
+
+
+            // Used to create existing StoragePool in preparation for the ModifyStoragePool
+            testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString();
+
+            // Make sure secondary store is available.
+            string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath);
+            s_logger.Info("Test secondary storage in " + fullPath);
+            DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath);
+            if (!testSecondarStoreDir.Exists)
+            {
+                try
+                {
+                    testSecondarStoreDir.Create();
+                }
+                catch (System.IO.IOException ex)
+                {
+                    throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message);
+                }
+            }
+
+            // Convert to secondary storage string to canonical path
+            testSecondaryStoreLocalPath = testSecondarStoreDir.FullName;
+            AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath;
+
+            // Make sure local primary storage is available
+            DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath);
+            //Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName);
+
+            // Convert to local primary storage string to canonical path
+            testLocalStorePath = testPoolDir.FullName;
+            AgentSettings.Default.local_storage_path = testLocalStorePath;
+
+            // Clean up old test files in local storage folder
+            FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID));
+            // Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName);           
+            
+            testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID);
+            s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage.");           
+
+
+            // Capture other JSON encoded paths
+            testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName);
+            testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath);
+
+            // TODO: may need to initialise the server resource in future.
+            //    s_hypervresource.initialize();
+
+            // Verify sample template is in place storage pool
+            s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON
+                      + " sample template at " + testSampleTemplateURLJSON);
+        }
+
+        private String CreateTestDiskImageFromExistingImage(FileInfo srcFile,
+        String dstPath,
+        String dstFileName)
+        {
+            var newFullname = Path.Combine(dstPath, dstFileName);
+            var newFileInfo = new FileInfo(newFullname);
+            if (!newFileInfo.Exists)
+            {
+                newFileInfo = srcFile.CopyTo(newFullname);
+            }
+            newFileInfo.Refresh();
+            Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName);
+
+            return JsonConvert.SerializeObject(newFileInfo.FullName);
+        }
+        
+        [Fact]
+        public void TestCreateCommand()
+        {
+            DirectoryInfo localStorePath = new DirectoryInfo(testLocalStorePath);
+            if (!localStorePath.Exists)
+            {
+                try
+                {
+                    localStorePath.Create();
+                }
+                catch (System.IO.IOException ex)
+                {
+                    throw new NotImplementedException("Need to be able to create the folder " + localStorePath.FullName + " failed due to " + ex.Message);
+                }
+            }
+
+            FileInfo sampleTemplateFile = new FileInfo(Path.Combine(testLocalStorePath, testSampleTemplateUUID));
+            if (!sampleTemplateFile.Exists)
+            {
+                //Create a file to write to.
+                using (StreamWriter sw = sampleTemplateFile.CreateText())
+                {
+                    sw.WriteLine("This is fake template file for test");
+                }
+            }
+            var counter = 0;
+            wmiCalls.When(x => x.CreateDynamicVirtualHardDisk(Arg.Any<ulong>(), Arg.Any<String>())).Do(x => counter++);
+            // TODO: Need sample to update the test.
+            // Arrange
+            String createCmd = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + testLocalStoreUUID + "\",\"host\":\"" + HypervResourceController.config.StorageIpAddress + "\"" +
+                            ",\"path\":" + testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"},\"diskCharacteristics\":{\"size\":0," +
+                            "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\",\"useLocalStorage\":true,\"recreatable\":true,\"diskOfferingId\":11," +
+                            "\"volumeId\":10,\"hyperType\":\"Hyperv\"},\"templateUrl\":" + testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}";
+            dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd);
+            HypervResourceController rsrcServer = new HypervResourceController();
+            HypervResourceController.wmiCalls = wmiCalls;
+
+            Assert.True(Directory.Exists(testLocalStorePath), testLocalStorePath + " does not exist ");
+            string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON));
+            Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath);
+            int fileCount = Directory.GetFiles(testLocalStorePath).Length;
+            s_logger.Debug(" test local store has " + fileCount + "files");
+
+            // Act
+            // Test requires there to be a template at the tempalteUrl, which is its location in the local file system.
+            dynamic jsonResult = rsrcServer.CreateCommand(jsonCreateCmd);
+            s_logger.Debug("CreateDynamicVirtualHardDisk method is called " + counter + " times");
+
+            //Assert.Equal(counter, 1);
+
+            JObject ansAsProperty2 = jsonResult[0];
+            dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
+            Assert.NotNull(ans);
+            Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result);
+            Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1);
+            FileInfo newFile = new FileInfo((string)ans.volume.path);
+            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
+            newFile.Delete();
+            sampleTemplateFile.Delete();
+        }
+
+        /// <summary>
+        /// Possible additional tests:  place an ISO in the drive
+        /// </summary>        
+
+        [Fact]
+        public void TestStartCommand()
+        {
+            ComputerSystem system = new ComputerSystem();
+            wmiCalls.DeployVirtualMachine(Arg.Any<Object>(), Arg.Any<string>()).Returns(system);
+
+            // Arrange
+            HypervResourceController rsrcServer = new HypervResourceController();
+            HypervResourceController.wmiCalls = wmiCalls;
+            String sample = getSampleStartCommand();
+
+
+            dynamic jsonStartCmd = JsonConvert.DeserializeObject(sample);
+
+            // Act
+            dynamic startAns = rsrcServer.StartCommand(jsonStartCmd);
+
+            // Assert
+            Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]);
+            Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details);
+
+            Assert.Null((string)startAns[0][CloudStackTypes.StartAnswer].details);            
+        }
+
+        [Fact]
+        public void TestStopCommand()
+        {
+            //string vmName = "Test VM";
+            var counter = 0;
+            wmiCalls.When(x => x.DestroyVm(Arg.Any<Object>())).Do(x => counter++);
+
+            // Arrange
+            HypervResourceController rsrcServer = new HypervResourceController();
+            HypervResourceController.wmiCalls = wmiCalls;
+
+            String sampleStop = "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\",\"contextMap\":{},\"wait\":0}";
+            dynamic jsonStopCmd = JsonConvert.DeserializeObject(sampleStop);
+
+            // Act
+            dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd);
+
+            // Assert VM is gone!
+            Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]);
+            Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details);
+
+            Assert.Null((string)stopAns[0][CloudStackTypes.StopAnswer].details);
+            Assert.Equal<int>(counter, 1);
+        }
+
+        public static String getSamplePrimaryDataStoreInfo()
+        {
+            String samplePrimaryDataStoreInfo =
+            "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":" +
+                "{\"uuid\":\"" + testLocalStoreUUID + "\"," +
+                "\"id\":201," +
+                "\"host\":\"" + testPrimaryDataStoreHost + "\"," +
+                "\"type\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
+                "\"poolType\":\"Filesystem\"," +  // Not used in PrimaryDataStoreTO
+                "\"path\":" + testLocalStorePathJSON + "," +
+                "\"port\":0}" +
+            "}";
+            return samplePrimaryDataStoreInfo;
+        }
+
+        public static String getSampleVolumeObjectTO()
+        {
+            String sampleVolumeObjectTO =
+                    "{\"org.apache.cloudstack.storage.to.VolumeObjectTO\":" +
+                        "{\"uuid\":\"19ae8e67-cb2c-4ab4-901e-e0b864272b59\"," +
+                        "\"volumeType\":\"ROOT\"," +
+                        "\"format\":\"VHDX\"," +
+                        "\"dataStore\":" + getSamplePrimaryDataStoreInfo() + "," +
+                        "\"name\":\"" + testSampleVolumeTempUUIDNoExt + "\"," +
+                        "\"size\":52428800," +
+                        "\"volumeId\":10," +
+                //                            "\"vmName\":\"i-3-5-VM\"," +  // TODO: do we have to fill in the vmName?
+                        "\"accountId\":3,\"id\":10}" +
+                    "}";  // end of destTO 
+            return sampleVolumeObjectTO;
+        }
+
+        public static String getSampleStartCommand()
+        {
+            String sample = "{\"vm\":{\"id\":17,\"name\":\"i-2-17-VM\",\"type\":\"User\",\"cpus\":1,\"speed\":500," +
+                                "\"minRam\":536870912,\"maxRam\":536870912,\"arch\":\"x86_64\"," +
+                                "\"os\":\"CentOS 6.0 (64-bit)\",\"bootArgs\":\"\",\"rebootOnCrash\":false," +
+                                "\"enableHA\":false,\"limitCpuUse\":false,\"vncPassword\":\"31f82f29aff646eb\"," +
+                                "\"params\":{},\"uuid\":\"8b030b6a-0243-440a-8cc5-45d08815ca11\"" +
+                            ",\"disks\":[" +
+                               "{\"data\":" + getSampleVolumeObjectTO() + ",\"diskSeq\":0,\"type\":\"ROOT\"}," +
+                               "{\"diskSeq\":1,\"type\":\"ISO\"}" +
+                            "]," +
+                            "\"nics\":[" +
+                                    "{\"deviceId\":0,\"networkRateMbps\":100,\"defaultNic\":true,\"uuid\":\"99cb4813-23af-428c-a87a-2d1899be4f4b\"," +
+                                    "\"ip\":\"10.1.1.67\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\"," +
+                                    "\"mac\":\"02:00:51:2c:00:0e\",\"dns1\":\"4.4.4.4\",\"broadcastType\":\"Vlan\",\"type\":\"Guest\"," +
+                                    "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" +
+                            "]},\"contextMap\":{},\"wait\":0}";
+            return sample;
+        }        
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
index 8a86727..c66c616 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
@@ -15,7 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 using System;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
 using CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION;
 using System.Management;
 using Newtonsoft.Json.Linq;
@@ -26,10 +25,10 @@ using HypervResource;
 using CloudStack.Plugin.AgentShell;
 using System.Collections.Generic;
 using System.Xml;
+using Xunit;
 
 namespace ServerResource.Tests
 {
-    [TestClass]
     public class HypervResourceControllerTest
     {
         protected static string testCifsUrl = AgentSettings.Default.testCifsUrl;
@@ -59,6 +58,9 @@ namespace ServerResource.Tests
         protected static String testSampleTemplateURLJSON;
         protected static String testLocalStorePathJSON;
 
+        protected static WmiCalls wmiCalls = new WmiCalls();
+        protected static WmiCallsV2 wmiCallsV2 = new WmiCallsV2();
+
         private static ILog s_logger = LogManager.GetLogger(typeof(HypervResourceControllerTest));
 
         /// <summary>
@@ -69,8 +71,7 @@ namespace ServerResource.Tests
         /// A second approximation would use the AgentShell settings files directly.
         /// A third approximation would look to invoke ServerResource methods via an HTTP request
         /// </summary>
-        [TestInitializeAttribute]
-        public void setUp()
+        public HypervResourceControllerTest()
         {
             AgentService.ConfigServerResource();
             HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address;
@@ -95,7 +96,7 @@ namespace ServerResource.Tests
                 }
                 catch (System.IO.IOException ex)
                 {
-                    Assert.Fail("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message);
+                    throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message);
                 }
             }
 
@@ -105,7 +106,7 @@ namespace ServerResource.Tests
 
             // Make sure local primary storage is available
             DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath);
-            Assert.IsTrue(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName);
+            Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName);
 
             // Convert to local primary storage string to canonical path
             testLocalStorePath = testPoolDir.FullName;
@@ -113,7 +114,7 @@ namespace ServerResource.Tests
 
             // Clean up old test files in local storage folder
             FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID));
-            Assert.IsTrue(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName);
+            Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName);
 
 
             // Delete all temporary files in local folder save the testVolWorks
@@ -125,7 +126,7 @@ namespace ServerResource.Tests
                 }
                 file.Delete();
                 file.Refresh();
-                Assert.IsFalse(file.Exists, "removed file from previous test called " + file.FullName);
+                Assert.False(file.Exists, "removed file from previous test called " + file.FullName);
             }
 
             // Recreate starting point files for test, and record JSON encoded paths for each ...
@@ -165,12 +166,12 @@ namespace ServerResource.Tests
                 newFileInfo = srcFile.CopyTo(newFullname);
             }
             newFileInfo.Refresh();
-            Assert.IsTrue(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName);
+            Assert.True(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName);
 
             return JsonConvert.SerializeObject(newFileInfo.FullName);
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestPrimaryStorageDownloadCommandHTTP()
         {
             string downloadURI = "https://s3-eu-west-1.amazonaws.com/cshv3eu/SmallDisk.vhdx";
@@ -190,7 +191,7 @@ namespace ServerResource.Tests
             // Assert
             JObject ansAsProperty = jsonResult[0];
             dynamic ans = ansAsProperty.GetValue(CloudStackTypes.PrimaryStorageDownloadAnswer);
-            Assert.IsTrue((bool)ans.result, "PrimaryStorageDownloadCommand did not succeed " + ans.details);
+            Assert.True((bool)ans.result, "PrimaryStorageDownloadCommand did not succeed " + ans.details);
 
             // Test that URL of downloaded template works for file creation.
             dynamic jsonCreateCmd = JsonConvert.DeserializeObject(CreateCommandSample());
@@ -199,10 +200,10 @@ namespace ServerResource.Tests
             JObject ansAsProperty2 = jsonAns2[0];
             dynamic ans2 = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
 
-            Assert.IsTrue((bool)ans2.result, (string)ans2.details);
+            Assert.True((bool)ans2.result, (string)ans2.details);
 
             FileInfo newFile = new FileInfo((string)ans2.volume.path);
-            Assert.IsTrue(newFile.Length > 0, "The new file should have a size greater than zero");
+            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
             newFile.Delete();
         }
 
@@ -227,7 +228,7 @@ namespace ServerResource.Tests
             return sample;
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestDestroyCommand()
         {
             // Arrange
@@ -252,11 +253,11 @@ namespace ServerResource.Tests
             JObject ansAsProperty2 = destoryAns[0];
             dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.Answer);
             String path = jsonDestoryCmd.volume.path;
-            Assert.IsTrue((bool)ans.result, "DestroyCommand did not succeed " + ans.details);
-            Assert.IsTrue(!File.Exists(path), "Failed to delete file " + path);
+            Assert.True((bool)ans.result, "DestroyCommand did not succeed " + ans.details);
+            Assert.True(!File.Exists(path), "Failed to delete file " + path);
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestCreateCommand()
         {
             // TODO: Need sample to update the test.
@@ -268,9 +269,9 @@ namespace ServerResource.Tests
             dynamic jsonCreateCmd = JsonConvert.DeserializeObject(createCmd);
             HypervResourceController rsrcServer = new HypervResourceController();
 
-            Assert.IsTrue(Directory.Exists(testLocalStorePath));
+            Assert.True(Directory.Exists(testLocalStorePath));
             string filePath = Path.Combine(testLocalStorePath, (string)JsonConvert.DeserializeObject(testSampleTemplateURLJSON));
-            Assert.IsTrue(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath);
+            Assert.True(File.Exists(filePath), "The template we make volumes from is missing from path " + filePath);
             int fileCount = Directory.GetFiles(testLocalStorePath).Length;
             s_logger.Debug(" test local store has " + fileCount + "files");
 
@@ -280,18 +281,18 @@ namespace ServerResource.Tests
 
             JObject ansAsProperty2 = jsonResult[0];
             dynamic ans = ansAsProperty2.GetValue(CloudStackTypes.CreateAnswer);
-            Assert.IsNotNull(ans, "Should be an answer object of type CreateAnswer");
-            Assert.IsTrue((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result);
-            Assert.AreEqual(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1);
+            Assert.NotNull(ans);
+            Assert.True((bool)ans.result, "Failed to CreateCommand due to " + (string)ans.result);
+            Assert.Equal(Directory.GetFiles(testLocalStorePath).Length, fileCount + 1);
             FileInfo newFile = new FileInfo((string)ans.volume.path);
-            Assert.IsTrue(newFile.Length > 0, "The new file should have a size greater than zero");
+            Assert.True(newFile.Length > 0, "The new file should have a size greater than zero");
             newFile.Delete();
         }
 
         /// <summary>
         /// Possible additional tests:  place an ISO in the drive
         /// </summary>
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestStartStopCommand()
         {
             string vmName = TestStartCommand();
@@ -351,7 +352,7 @@ namespace ServerResource.Tests
         }
 
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestCopyCommandFromCifs()
         {
             // Arrange
@@ -411,7 +412,7 @@ namespace ServerResource.Tests
             File.Delete(dwnldDest);
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestCopyCommand()
         {
             // Arrange
@@ -515,9 +516,9 @@ namespace ServerResource.Tests
             dynamic copyResult = rsrcServer.CopyCommand(jsonCloneCopyCmd);
 
             // Assert
-            Assert.IsNotNull(copyResult[0][CloudStackTypes.CopyCmdAnswer], "CopyCommand should return a StartAnswer in all cases");
-            Assert.IsTrue((bool)copyResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + copyResult[0][CloudStackTypes.CopyCmdAnswer].details);
-            Assert.IsTrue(File.Exists(newVolName), "CopyCommand failed to generate " + newVolName);
+            Assert.NotNull(copyResult[0][CloudStackTypes.CopyCmdAnswer]);
+            Assert.True((bool)copyResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + copyResult[0][CloudStackTypes.CopyCmdAnswer].details);
+            Assert.True(File.Exists(newVolName), "CopyCommand failed to generate " + newVolName);
         }
 
         private static void DownloadTemplateToPrimaryStorage(HypervResourceController rsrcServer, dynamic jsonDownloadCopyCmd, string dwnldDest)
@@ -525,12 +526,12 @@ namespace ServerResource.Tests
             dynamic dwnldResult = rsrcServer.CopyCommand(jsonDownloadCopyCmd);
 
             // Assert
-            Assert.IsNotNull(dwnldResult[0][CloudStackTypes.CopyCmdAnswer], "CopyCommand should return a StartAnswer in all cases");
-            Assert.IsTrue((bool)dwnldResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + dwnldResult[0][CloudStackTypes.CopyCmdAnswer].details);
-            Assert.IsTrue(File.Exists(dwnldDest), "CopyCommand failed to generate " + dwnldDest);
+            Assert.NotNull(dwnldResult[0][CloudStackTypes.CopyCmdAnswer]);
+            Assert.True((bool)dwnldResult[0][CloudStackTypes.CopyCmdAnswer].result, "CopyCommand did not succeed " + dwnldResult[0][CloudStackTypes.CopyCmdAnswer].details);
+            Assert.True(File.Exists(dwnldDest), "CopyCommand failed to generate " + dwnldDest);
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestCopyCommandBz2Img()
         {
             // Arrange
@@ -662,7 +663,7 @@ namespace ServerResource.Tests
             jsonCloneCopyCmd = null;
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestModifyStoragePoolCommand()
         {
             // Create dummy folder
@@ -696,7 +697,7 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.ModifyStoragePoolAnswer];
-            Assert.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds
+            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds
 
             // Clean up
             var cmd2 = new
@@ -711,10 +712,10 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans2 = jsonResult2[0][CloudStackTypes.Answer];
-            Assert.IsTrue((bool)ans2.result, (string)ans2.details);  // always succeeds
+            Assert.True((bool)ans2.result, (string)ans2.details);  // always succeeds
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void CreateStoragePoolCommand()
         {
             var cmd = new { localPath = "NULL" };
@@ -726,10 +727,10 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.Answer];
-            Assert.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds
+            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void MaintainCommand()
         {
             // Omit HostEnvironment object, as this is a series of settings currently not used.
@@ -742,10 +743,10 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.MaintainAnswer];
-            Assert.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds
+            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void SetupCommand()
         {
             // Omit HostEnvironment object, as this is a series of settings currently not used.
@@ -758,10 +759,10 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.SetupAnswer];
-            Assert.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds
+            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestPassingUserdataToVm()
         {
             // Sample data
@@ -769,14 +770,14 @@ namespace ServerResource.Tests
             String value = "username=root;password=1pass@word1";
 
             // Find the VM
-            List<String> vmNames = WmiCallsV2.GetVmElementNames();
+            List<String> vmNames = wmiCallsV2.GetVmElementNames();
 
             // Get associated WMI object
-            var vm = WmiCallsV2.GetComputerSystem(AgentSettings.Default.testKvpVmName);
+            var vm = wmiCallsV2.GetComputerSystem(AgentSettings.Default.testKvpVmName);
 
             // Get existing KVP
-            var vmSettings = WmiCallsV2.GetVmSettings(vm);
-            var kvpInfo = WmiCallsV2.GetKvpSettings(vmSettings);
+            var vmSettings = wmiCallsV2.GetVmSettings(vm);
+            var kvpInfo = wmiCallsV2.GetKvpSettings(vmSettings);
 
             // HostExchangesItems are embedded objects in the sense that the object value is stored and not a reference to the object.
             string[] kvpProps = kvpInfo.HostExchangeItems;
@@ -791,16 +792,16 @@ namespace ServerResource.Tests
 
                 if (existingKey == key)
                 {
-                    WmiCallsV2.DeleteHostKvpItem(vm, existingKey);
+                    wmiCallsV2.DeleteHostKvpItem(vm, existingKey);
                     break;
                 }
             }
 
             // Add new user data
-            WmiCallsV2.AddUserData(vm, value);
+            wmiCallsV2.AddUserData(vm, value);
 
             // Verify key added to subsystem
-            kvpInfo = WmiCallsV2.GetKvpSettings(vmSettings);
+            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;
@@ -816,13 +817,13 @@ namespace ServerResource.Tests
 
                 if (existingKey == key && existingValue == value)
                 {
-//                    WmiCallsV2.DeleteHostKvpItem(vm, existingKey);
+//                    wmiCallsV2.DeleteHostKvpItem(vm, existingKey);
                     userDataInPlace = true;
                     break;
                 }
             }
 
-            Assert.IsTrue(userDataInPlace, "User data key / value did no save properly");
+            Assert.True(userDataInPlace, "User data key / value did no save properly");
         }
 
         private static void ParseKVP(String wmiObjectXml, out String existingKey, out String existingValue)
@@ -844,7 +845,7 @@ namespace ServerResource.Tests
             existingValue = dataNode.InnerText;
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void GetVmStatsCommandFail()
         {
             // Use WMI to find existing VMs
@@ -865,14 +866,14 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer];
-            Assert.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds, fake VM means no answer for the named VM
+            Assert.True((bool)ans.result, (string)ans.details);  // always succeeds, fake VM means no answer for the named VM
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void GetVmStatsCommand()
         {
             // Use WMI to find existing VMs
-            List<String> vmNames = WmiCalls.GetVmElementNames();
+            List<String> vmNames = wmiCalls.GetVmElementNames();
 
             var cmd = new
             {
@@ -888,10 +889,10 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.GetVmStatsAnswer];
-            Assert.IsTrue((bool)ans.result, (string)ans.details);
+            Assert.True((bool)ans.result, (string)ans.details);
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void GetStorageStatsCommand()
         {
             // TODO:  Update sample data to unsure it is using correct info.
@@ -916,12 +917,12 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.GetStorageStatsAnswer];
-            Assert.IsTrue((bool)ans.result, (string)ans.details);
-            Assert.IsTrue((long)ans.used <= (long)ans.capacity);  // TODO: verify that capacity is indeed capacity and not used.
+            Assert.True((bool)ans.result, (string)ans.details);
+            Assert.True((long)ans.used <= (long)ans.capacity);  // TODO: verify that capacity is indeed capacity and not used.
         }
 
         // TODO: can we speed up this command?  The logic takes over a second.
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void GetHostStatsCommand()
         {
             // Arrange
@@ -945,19 +946,19 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.GetHostStatsAnswer];
-            Assert.IsTrue((bool)ans.result);
-            Assert.IsTrue(hostIdVal == (long)ans.hostStats.hostId);
-            Assert.IsTrue(0.0 < (double)ans.hostStats.totalMemoryKBs);
-            Assert.IsTrue(0.0 < (double)ans.hostStats.freeMemoryKBs);
-            Assert.IsTrue(0.0 <= (double)ans.hostStats.networkReadKBs);
-            Assert.IsTrue(0.0 <= (double)ans.hostStats.networkWriteKBs);
-            Assert.IsTrue(0.0 <= (double)ans.hostStats.cpuUtilization);
-            Assert.IsTrue(100.0 >= (double)ans.hostStats.cpuUtilization);
-            Assert.IsTrue("host".Equals((string)ans.hostStats.entityType));
-            Assert.IsTrue(String.IsNullOrEmpty((string)ans.details));
+            Assert.True((bool)ans.result);
+            Assert.True(hostIdVal == (long)ans.hostStats.hostId);
+            Assert.True(0.0 < (double)ans.hostStats.totalMemoryKBs);
+            Assert.True(0.0 < (double)ans.hostStats.freeMemoryKBs);
+            Assert.True(0.0 <= (double)ans.hostStats.networkReadKBs);
+            Assert.True(0.0 <= (double)ans.hostStats.networkWriteKBs);
+            Assert.True(0.0 <= (double)ans.hostStats.cpuUtilization);
+            Assert.True(100.0 >= (double)ans.hostStats.cpuUtilization);
+            Assert.True("host".Equals((string)ans.hostStats.entityType));
+            Assert.True(String.IsNullOrEmpty((string)ans.details));
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void GetHostStatsCommandFail()
         {
             // Arrange
@@ -970,12 +971,12 @@ namespace ServerResource.Tests
 
             // Assert
             dynamic ans = jsonResult[0][CloudStackTypes.GetHostStatsAnswer];
-            Assert.IsFalse((bool)ans.result);
-            Assert.IsNull((string)ans.hostStats);
-            Assert.IsNotNull(ans.details);
+            Assert.False((bool)ans.result);
+            Assert.Null((string)ans.hostStats);
+            Assert.NotNull(ans.details);
         }
 
-        [TestMethod]
+        [Fact(Skip="these are functional tests")]
         public void TestStartupCommand()
         {
             // Arrange
@@ -1008,16 +1009,16 @@ namespace ServerResource.Tests
 
             uint cores;
             uint mhz;
-            WmiCalls.GetProcessorResources(out cores, out mhz);
+            wmiCalls.GetProcessorResources(out cores, out mhz);
             ulong memory_mb;
             ulong freememory;
-            WmiCalls.GetMemoryResources(out memory_mb, out freememory);
+            wmiCalls.GetMemoryResources(out memory_mb, out freememory);
             memory_mb *= 1024;
             long capacityBytes;
             long availableBytes;
-            HypervResourceController.GetCapacityForLocalPath(WmiCalls.GetDefaultVirtualDiskFolder(),
+            HypervResourceController.GetCapacityForLocalPath(wmiCalls.GetDefaultVirtualDiskFolder(),
                     out capacityBytes, out availableBytes);
-            var DefaultVirtualDiskFolder = JsonConvert.SerializeObject(WmiCalls.GetDefaultVirtualDiskFolder());
+            var DefaultVirtualDiskFolder = JsonConvert.SerializeObject(wmiCalls.GetDefaultVirtualDiskFolder());
             string expected =
             #region string_literal
                     "[{\"" + CloudStackTypes.StartupRoutingCommand + "\":{" +
@@ -1073,7 +1074,7 @@ namespace ServerResource.Tests
 
             // Assert
             string actual = JsonConvert.SerializeObject(jsonResult);
-            Assert.AreEqual(expected, actual, "StartupRoutingCommand not populated properly");
+            Assert.Equal(expected, actual);
         }
 
 
@@ -1090,40 +1091,40 @@ namespace ServerResource.Tests
             dynamic startAns = rsrcServer.StartCommand(jsonStartCmd);
 
             // Assert
-            Assert.IsNotNull(startAns[0][CloudStackTypes.StartAnswer], "StartCommand should return a StartAnswer in all cases");
-            Assert.IsTrue((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details);
+            Assert.NotNull(startAns[0][CloudStackTypes.StartAnswer]);
+            Assert.True((bool)startAns[0][CloudStackTypes.StartAnswer].result, "StartCommand did not succeed " + startAns[0][CloudStackTypes.StartAnswer].details);
             string vmCmdName = jsonStartCmd.vm.name.Value;
-            var vm = WmiCalls.GetComputerSystem(vmCmdName);
-            VirtualSystemSettingData vmSettings = WmiCalls.GetVmSettings(vm);
-            MemorySettingData memSettings = WmiCalls.GetMemSettings(vmSettings);
-            ProcessorSettingData procSettings = WmiCalls.GetProcSettings(vmSettings);
+            var vm = wmiCalls.GetComputerSystem(vmCmdName);
+            VirtualSystemSettingData vmSettings = wmiCalls.GetVmSettings(vm);
+            MemorySettingData memSettings = wmiCalls.GetMemSettings(vmSettings);
+            ProcessorSettingData procSettings = wmiCalls.GetProcSettings(vmSettings);
             dynamic jsonObj = JsonConvert.DeserializeObject(sample);
             var vmInfo = jsonObj.vm;
             string vmName = vmInfo.name;
             var nicInfo = vmInfo.nics;
             int vcpus = vmInfo.cpus;
             int memSize = vmInfo.maxRam / 1048576;
-            Assert.IsTrue((long)memSettings.VirtualQuantity == memSize);
-            Assert.IsTrue((long)memSettings.Reservation == memSize);
-            Assert.IsTrue((long)memSettings.Limit == memSize);
-            Assert.IsTrue((int)procSettings.VirtualQuantity == vcpus);
-            Assert.IsTrue((int)procSettings.Reservation == vcpus);
-            Assert.IsTrue((int)procSettings.Limit == 100000);
+            Assert.True((long)memSettings.VirtualQuantity == memSize);
+            Assert.True((long)memSettings.Reservation == memSize);
+            Assert.True((long)memSettings.Limit == memSize);
+            Assert.True((int)procSettings.VirtualQuantity == vcpus);
+            Assert.True((int)procSettings.Reservation == vcpus);
+            Assert.True((int)procSettings.Limit == 100000);
 
             // examine NIC
-            SyntheticEthernetPortSettingData[] nicSettingsViaVm = WmiCalls.GetEthernetPorts(vm);
-            Assert.IsTrue(nicSettingsViaVm.Length > 0, "Should be at least one ethernet port on VM");
+            SyntheticEthernetPortSettingData[] nicSettingsViaVm = wmiCalls.GetEthernetPorts(vm);
+            Assert.True(nicSettingsViaVm.Length > 0, "Should be at least one ethernet port on VM");
             string expectedMac = (string)jsonStartCmd.vm.nics[0].mac;
             string strippedExpectedMac = expectedMac.Replace(":", string.Empty);
-            Assert.AreEqual(nicSettingsViaVm[0].Address.ToLower(), strippedExpectedMac.ToLower());
+            Assert.Equal(nicSettingsViaVm[0].Address.ToLower(), strippedExpectedMac.ToLower());
 
             // Assert switchport has correct VLAN 
-            SwitchPort[] switchPorts = WmiCalls.GetSwitchPorts(vm);
-            VirtualSwitchManagementService vmNetMgmtSvc = WmiCalls.GetVirtualSwitchManagementService();
-            VLANEndpointSettingData vlanSettings = WmiCalls.GetVlanEndpointSettings(vmNetMgmtSvc, switchPorts[0].Path);
+            SwitchPort[] switchPorts = wmiCalls.GetSwitchPorts(vm);
+            VirtualSwitchManagementService vmNetMgmtSvc = wmiCalls.GetVirtualSwitchManagementService();
+            VLANEndpointSettingData vlanSettings = wmiCalls.GetVlanEndpointSettings(vmNetMgmtSvc, switchPorts[0].Path);
             string isolationUri = (string)jsonStartCmd.vm.nics[0].isolationUri;
             string vlan = isolationUri.Replace("vlan://", string.Empty);
-            Assert.AreEqual(vlanSettings.AccessVLAN.ToString(), vlan);
+            Assert.Equal(vlanSettings.AccessVLAN.ToString(), vlan);
 
             return vmName;
         }
@@ -1139,10 +1140,10 @@ namespace ServerResource.Tests
             dynamic stopAns = rsrcServer.StopCommand(jsonStopCmd);
 
             // Assert VM is gone!
-            Assert.IsNotNull(stopAns[0][CloudStackTypes.StopAnswer], "StopCommand should return a StopAnswer in all cases");
-            Assert.IsTrue((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details);
-            var finalVm = WmiCalls.GetComputerSystem(vmName);
-            Assert.IsTrue(WmiCalls.GetComputerSystem(vmName) == null);
+            Assert.NotNull(stopAns[0][CloudStackTypes.StopAnswer]);
+            Assert.True((bool)stopAns[0][CloudStackTypes.StopAnswer].result, "StopCommand did not succeed " + stopAns[0][CloudStackTypes.StopAnswer].details);
+            var finalVm = wmiCalls.GetComputerSystem(vmName);
+            Assert.True(wmiCalls.GetComputerSystem(vmName) == null);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
index 381245e..2e7a93c 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
@@ -53,17 +53,22 @@
     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
   </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>
     <Reference Include="log4net">
       <HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
     </Reference>
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+    <Reference Include="Microsoft.CSharp" />    
     <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.ComponentModel.DataAnnotations" />
     <Reference Include="System.Configuration" />
@@ -80,13 +85,15 @@
     <Reference Include="System.Xml" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Net.Http">
-    </Reference>
-    <Reference Include="System.Net.Http.WebRequest">
+    </Reference>    
+    <Reference Include="xunit">
+      <HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
     </Reference>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="HypervResourceController1Test.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="HypervResourceControllerTest.cs" />
+    <!--<Compile Include="HypervResourceControllerTest.cs" /> -->
   </ItemGroup>
   <ItemGroup>
     <Content Include="App.config">
@@ -121,4 +128,9 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
\ No newline at end of file
+  <UsingTask AssemblyFile="..\packages\xunit.1.9.2\lib\net20\xunit.runner.msbuild.dll"
+           TaskName="Xunit.Runner.MSBuild.xunit" />
+  <Target Name="AfterBuild">
+    <Xunit.Runner.MSBuild.xunit Assembly="..\ServerResource.Tests\bin\Debug\ServerResource.Tests.dll" />
+  </Target>
+</Project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/packages.config
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/packages.config b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/packages.config
index 08ef691..4c538e4 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/packages.config
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/packages.config
@@ -1,6 +1,9 @@
 <?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="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/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs
new file mode 100644
index 0000000..72f3432
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs
@@ -0,0 +1,791 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_VirtualSystemManagementServiceSettingData
+    public class VirtualSystemManagementServiceSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_VirtualSystemManagementServiceSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public VirtualSystemManagementServiceSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemManagementServiceSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemManagementServiceSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Used by OEMs to allow BIOS-locked Windows operating systems to run in the virtual machine. This string must be exactly 32 characters in length.
+This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        public string BiosLockString {
+            get {
+                return ((string)(curObj["BiosLockString"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The WorldWideNodeName address for dynamically generated WorldWideName addresses u" +
+            "sed for Synthetic HBAs.\nThis is a read-only property, but it can be changed usin" +
+            "g the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService cl" +
+            "ass.")]
+        public string CurrentWWNNAddress {
+            get {
+                return ((string)(curObj["CurrentWWNNAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The default external data root. By default, \"root\\ProgramData\\Microsoft\\Windows\\V" +
+            "irtualization\".\nThis is a read-only property, but it can be changed using the Mo" +
+            "difyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        public string DefaultExternalDataRoot {
+            get {
+                return ((string)(curObj["DefaultExternalDataRoot"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The default virtual hard disk path. By default, \"root\\Users\\Public\\Documents\\Virt" +
+            "ual Hard Disks\".\nThis is a read-only property, but it can be changed using the M" +
+            "odifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        public string DefaultVirtualHardDiskPath {
+            get {
+                return ((string)(curObj["DefaultVirtualHardDiskPath"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHbaLunTimeoutNull {
+            get {
+                if ((curObj["HbaLunTimeout"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"This property describes the amount of time that the Synthetic FC virtual device will wait for a LUN to appear before starting a virtual machine.
+This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint HbaLunTimeout {
+            get {
+                if ((curObj["HbaLunTimeout"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["HbaLunTimeout"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum MAC address for dynamically generated MAC addresses.\nThis is a read-o" +
+            "nly property, but it can be changed using the ModifyServiceSettings method of th" +
+            "e Msvm_VirtualSystemManagementService class.")]
+        public string MaximumMacAddress {
+            get {
+                return ((string)(curObj["MaximumMacAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum WorldWidePortName address for dynamically generated WorldWideName add" +
+            "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" +
+            "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" +
+            "rvice class.")]
+        public string MaximumWWPNAddress {
+            get {
+                return ((string)(curObj["MaximumWWPNAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The minimum MAC address for dynamically generated MAC addresses.\nThis is a read-o" +
+            "nly property, but it can be changed using the ModifyServiceSettings method of th" +
+            "e Msvm_VirtualSystemManagementService class.")]
+        public string MinimumMacAddress {
+            get {
+                return ((string)(curObj["MinimumMacAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The minimum WorldWidePortName address for dynamically generated WorldWideName add" +
+            "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" +
+            "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" +
+            "rvice class.")]
+        public string MinimumWWPNAddress {
+            get {
+                return ((string)(curObj["MinimumWWPNAddress"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNumaSpanningEnabledNull {
+            get {
+                if ((curObj["NumaSpanningEnabled"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Reserved for future use.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool NumaSpanningEnabled {
+            get {
+                if ((curObj["NumaSpanningEnabled"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["NumaSpanningEnabled"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Controls memory allocation for the VMs on non-uniform memory access (NUMA) system" +
+            "s.\nThis is a read-only property, but it can be changed using the ModifyServiceSe" +
+            "ttings method of the Msvm_VirtualSystemManagementService class.")]
+        public string PrimaryOwnerContact {
+            get {
+                return ((string)(curObj["PrimaryOwnerContact"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Describes how the primary system owner can be reached (for example, phone number or e-mail address). By default, empty. This name may not exceed 256 characters in length.
+This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        public string PrimaryOwnerName {
+            get {
+                return ((string)(curObj["PrimaryOwnerName"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHbaLunTimeout() {
+            if ((this.IsHbaLunTimeoutNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumaSpanningEnabled() {
+            if ((this.IsNumaSpanningEnabledNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemManagementServiceSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_VirtualSystemManagementServiceSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new VirtualSystemManagementServiceSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementServiceSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new VirtualSystemManagementServiceSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static VirtualSystemManagementServiceSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new VirtualSystemManagementServiceSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class VirtualSystemManagementServiceSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public VirtualSystemManagementServiceSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new VirtualSystemManagementServiceSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class VirtualSystemManagementServiceSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public VirtualSystemManagementServiceSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


[45/56] [abbrv] 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 comm

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
index d3baab4..ad6245e 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
@@ -11,6 +11,8 @@
     <AssemblyName>WmiWrappers</AssemblyName>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -48,6 +50,21 @@
     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
   </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>
+    <Reference Include="log4net">
+      <HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
+    </Reference>
+    <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" />
@@ -56,9 +73,11 @@
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Data" />
     <Reference Include="System.Xml" />
+    <Reference Include="xunit">
+      <HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="ROOT.CIMV2.Win32_OperatingSystem.cs">
       <SubType>Component</SubType>
     </Compile>
@@ -149,6 +168,9 @@
     <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs">
       <SubType>Component</SubType>
     </Compile>
+    <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
     <Compile Include="ROOT.virtualization.v2.Msvm_VirtualSystemSettingData.cs">
       <SubType>Component</SubType>
     </Compile>
@@ -156,7 +178,11 @@
   <ItemGroup>
     <Content Include="Readme.txt" />
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/buildagent.sh
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/buildagent.sh b/plugins/hypervisors/hyperv/buildagent.sh
old mode 100644
new mode 100755
index f2a4921..4abde38
--- a/plugins/hypervisors/hyperv/buildagent.sh
+++ b/plugins/hypervisors/hyperv/buildagent.sh
@@ -19,4 +19,11 @@ export EnableNuGetPackageRestore=true
 wget http://nuget.org/nuget.exe
 mv nuget.exe ./DotNet/ServerResource/.nuget/NuGet.exe
 chmod a+x ./DotNet/ServerResource/.nuget/NuGet.exe
-xbuild /p:Configuration="NoUnitTests" /p:BuildWithMono="true" ./DotNet/ServerResource/ServerResource.sln
+if [ "$1" ==  "true" ] ; then
+  echo " skipping tests"
+  xbuild /p:Configuration="NoUnitTests" /p:BuildWithMono="true" ./DotNet/ServerResource/ServerResource.sln
+  
+else
+  echo " running tests "
+  xbuild /p:BuildWithMono="true" ./DotNet/ServerResource/ServerResource.sln
+fi

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/pom.xml b/plugins/hypervisors/hyperv/pom.xml
index e9f0371..042d3aa 100644
--- a/plugins/hypervisors/hyperv/pom.xml
+++ b/plugins/hypervisors/hyperv/pom.xml
@@ -27,7 +27,8 @@
     <relativePath>../../pom.xml</relativePath>
   </parent>
   <properties>
-    <skipTests>true</skipTests>
+    <skipTests>false</skipTests>
+    <skipFunctionalTests>true</skipFunctionalTests>
   </properties>
   <dependencies>
     <dependency>
@@ -134,6 +135,7 @@
           <executable>bash</executable>
           <arguments>
             <argument>./buildagent.sh</argument>
+            <argument>${skipTests}</argument>
           </arguments>
         </configuration>
       </plugin>
@@ -148,7 +150,7 @@
             <includes>
               <include>**/HypervDirectConnectResourceTest.java</include>
             </includes>
-            <skipTests>${skipTests}</skipTests>            
+            <skipTests>${skipFunctionalTests}</skipTests>            
         </configuration>
       </plugin>
       </plugins>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
index 11df222..f011ce0 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
@@ -16,18 +16,26 @@
 // under the License.
 package com.cloud.hypervisor.hyperv.discoverer;
 
+import java.io.File;
+import java.io.IOException;
 import java.net.InetAddress;
 import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
 import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 import java.util.UUID;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.utils.identity.ManagementServerNode;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
@@ -42,6 +50,7 @@ import com.cloud.agent.api.SetupCommand;
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
 import com.cloud.alert.AlertManager;
+import com.cloud.configuration.Config;
 import com.cloud.dc.ClusterDetailsDao;
 import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenterVO;
@@ -67,6 +76,13 @@ import com.cloud.resource.ResourceManager;
 import com.cloud.resource.ResourceStateAdapter;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.UnableDeleteHostException;
+import com.cloud.storage.JavaStorageLayer;
+import com.cloud.storage.StorageLayer;
+import com.cloud.utils.FileUtil;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
 
 /**
  * Methods to discover and managem a Hyper-V agent. Prepares a
@@ -76,8 +92,15 @@ import com.cloud.resource.UnableDeleteHostException;
 @Local(value = Discoverer.class)
 public class HypervServerDiscoverer extends DiscovererBase implements
         Discoverer, Listener, ResourceStateAdapter {
-    private static final Logger s_logger = Logger
-            .getLogger(HypervServerDiscoverer.class);
+    private static final Logger s_logger = Logger.getLogger(HypervServerDiscoverer.class);
+
+    private String _instance;
+    private String _mountParent;
+    private int _timeout;
+    Random _rand = new Random(System.currentTimeMillis());
+
+    Map<String, String> _storageMounts = new HashMap<String, String>();
+    StorageLayer _storage;
 
     @Inject
     private HostDao _hostDao = null;
@@ -91,6 +114,8 @@ public class HypervServerDiscoverer extends DiscovererBase implements
     private HostPodDao _podDao;
     @Inject
     private DataCenterDao _dcDao;
+    @Inject
+    DataStoreManager _dataStoreMgr;
 
     // TODO: AgentManager and AlertManager not being used to transmit info,
     // may want to reconsider.
@@ -152,8 +177,17 @@ public class HypervServerDiscoverer extends DiscovererBase implements
             s_logger.debug("Setting up host " + agentId);
         }
 
+        String secondaryStorageUri = getSecondaryStorageStoreUrl(cluster.getDataCenterId());
+        if (secondaryStorageUri == null) {
+            s_logger.debug("Secondary storage uri for dc " + cluster.getDataCenterId() + " couldn't be obtained");
+        } else {
+            prepareSecondaryStorageStore(secondaryStorageUri);
+        }
+
         HostEnvironment env = new HostEnvironment();
         SetupCommand setup = new SetupCommand(env);
+        setup.setSecondaryStorage(secondaryStorageUri);
+        setup.setSystemVmIso("systemvm/" + getSystemVMIsoFileNameOnDatastore());
         if (!host.isSetup()) {
             setup.setNeedSetup(true);
         }
@@ -298,6 +332,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements
             params.put("cluster", Long.toString(clusterId));
             params.put("guid", guidWithTail);
             params.put("ipaddress", agentIp);
+            params.put("sec.storage.url", getSecondaryStorageStoreUrl(dcId));
 
             // Hyper-V specific settings
             Map<String, String> details = new HashMap<String, String>();
@@ -348,6 +383,177 @@ public class HypervServerDiscoverer extends DiscovererBase implements
         }
         return null;
     }
+    
+
+    private void prepareSecondaryStorageStore(String storageUrl) {
+        String mountPoint = getMountPoint(storageUrl);
+
+        GlobalLock lock = GlobalLock.getInternLock("prepare.systemvm");
+        try {
+            if(lock.lock(3600)) {
+                try {
+                    File patchFolder = new File(mountPoint + "/systemvm");
+                    if(!patchFolder.exists()) {
+                        if(!patchFolder.mkdirs()) {
+                            String msg = "Unable to create systemvm folder on secondary storage. location: " + patchFolder.toString();
+                            s_logger.error(msg);
+                            throw new CloudRuntimeException(msg);
+                        }
+                    }
+
+                    File srcIso = getSystemVMPatchIsoFile();
+                    File destIso = new File(mountPoint + "/systemvm/" + getSystemVMIsoFileNameOnDatastore());
+                    if(!destIso.exists()) {
+                        s_logger.info("Copy System VM patch ISO file to secondary storage. source ISO: " +
+                                srcIso.getAbsolutePath() + ", destination: " + destIso.getAbsolutePath());
+                        try {
+                            FileUtil.copyfile(srcIso, destIso);
+                        } catch(IOException e) {
+                            s_logger.error("Unexpected exception ", e);
+
+                            String msg = "Unable to copy systemvm ISO on secondary storage. src location: " + srcIso.toString() + ", dest location: " + destIso;
+                            s_logger.error(msg);
+                            throw new CloudRuntimeException(msg);
+                        }
+                    } else {
+                        if(s_logger.isTraceEnabled()) {
+                            s_logger.trace("SystemVM ISO file " + destIso.getPath() + " already exists");
+                        }
+                    }
+                } finally {
+                    lock.unlock();
+                }
+            }
+        } finally {
+            lock.releaseRef();
+        }
+    }
+
+    private String getMountPoint(String storageUrl) {
+        String mountPoint = null;
+        synchronized(_storageMounts) {
+            mountPoint = _storageMounts.get(storageUrl);
+            if(mountPoint != null) {
+                return mountPoint;
+            }
+
+            URI uri;
+            try {
+                uri = new URI(storageUrl);
+            } catch (URISyntaxException e) {
+                s_logger.error("Invalid storage URL format ", e);
+                throw new CloudRuntimeException("Unable to create mount point due to invalid storage URL format " + storageUrl);
+            }
+
+            mountPoint = mount(File.separator + File.separator + uri.getHost() + uri.getPath(), _mountParent,
+                    uri.getScheme(), uri.getQuery());
+            if(mountPoint == null) {
+                s_logger.error("Unable to create mount point for " + storageUrl);
+                return "/mnt/sec";
+            }
+
+            _storageMounts.put(storageUrl, mountPoint);
+            return mountPoint;
+        }
+    }
+
+    protected String mount(String path, String parent, String scheme, String query) {
+        String mountPoint = setupMountPoint(parent);
+        if (mountPoint == null) {
+            s_logger.warn("Unable to create a mount point");
+            return null;
+        }
+
+        Script script = null;
+        String result = null;
+        if (scheme.equals("cifs")) {
+            Script command = new Script(true, "mount", _timeout, s_logger);
+            command.add("-t", "cifs");
+            command.add(path);
+            command.add(mountPoint);
+
+            if (query != null) {
+                query = query.replace('&', ',');
+                command.add("-o", query);
+            }
+            result = command.execute();
+        }
+
+        if (result != null) {
+            s_logger.warn("Unable to mount " + path + " due to " + result);
+            File file = new File(mountPoint);
+            if (file.exists()) {
+                file.delete();
+            }
+            return null;
+        }
+
+        // Change permissions for the mountpoint
+        script = new Script(true, "chmod", _timeout, s_logger);
+        script.add("-R", "777", mountPoint);
+        result = script.execute();
+        if (result != null) {
+            s_logger.warn("Unable to set permissions for " + mountPoint + " due to " + result);
+        }
+        return mountPoint;
+    }
+
+    private String setupMountPoint(String parent) {
+        String mountPoint = null;
+        long mshostId = ManagementServerNode.getManagementServerId();
+        for (int i = 0; i < 10; i++) {
+            String mntPt = parent + File.separator + String.valueOf(mshostId) + "." + Integer.toHexString(_rand.nextInt(Integer.MAX_VALUE));
+            File file = new File(mntPt);
+            if (!file.exists()) {
+                if (_storage.mkdir(mntPt)) {
+                    mountPoint = mntPt;
+                    break;
+                }
+            }
+            s_logger.error("Unable to create mount: " + mntPt);
+        }
+
+        return mountPoint;
+    }
+
+    private String getSystemVMIsoFileNameOnDatastore() {
+        String version = this.getClass().getPackage().getImplementationVersion();
+        String fileName = "systemvm-" + version + ".iso";
+        return fileName.replace(':', '-');
+    }
+
+    private File getSystemVMPatchIsoFile() {
+        // locate systemvm.iso
+        URL url = this.getClass().getClassLoader().getResource("vms/systemvm.iso");
+        File isoFile = null;
+        if (url != null) {
+            isoFile = new File(url.getPath());
+        }
+
+        if(isoFile == null || !isoFile.exists()) {
+            isoFile = new File("/usr/share/cloudstack-common/vms/systemvm.iso");
+        }
+
+        assert(isoFile != null);
+        if(!isoFile.exists()) {
+            s_logger.error("Unable to locate systemvm.iso in your setup at " + isoFile.toString());
+        }
+        return isoFile;
+    }
+
+    private String getSecondaryStorageStoreUrl(long zoneId) {
+        String secUrl = null;
+        DataStore secStore = _dataStoreMgr.getImageStore(zoneId);
+        if (secStore != null) {
+            secUrl = secStore.getUri();
+        }
+
+        if (secUrl == null) {
+            s_logger.warn("Secondary storage uri couldn't be retrieved");
+        }
+
+        return secUrl;
+    }
 
     /**
      * Encapsulate GUID calculation in public method to allow access to test
@@ -371,10 +577,27 @@ public class HypervServerDiscoverer extends DiscovererBase implements
     // Inherit Adapter.stop
     // Inherit Adapter.start
     @Override
-    public final boolean configure(final String name,
-            final Map<String, Object> params) throws ConfigurationException {
+    public final boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
         super.configure(name, params);
 
+        _mountParent = (String) params.get(Config.MountParent.key());
+        if (_mountParent == null) {
+            _mountParent = File.separator + "mnt";
+        }
+
+        if (_instance != null) {
+            _mountParent = _mountParent + File.separator + _instance;
+        }
+
+        String value = (String)params.get("scripts.timeout");
+        _timeout = NumbersUtil.parseInt(value, 30) * 1000;
+
+        _storage = (StorageLayer)params.get(StorageLayer.InstanceConfigKey);
+        if (_storage == null) {
+            _storage = new JavaStorageLayer();
+            _storage.configure("StorageLayer", params);
+        }
+
         // TODO: allow timeout on we HTTPRequests to be configured
         _agentMgr.registerForHostEvents(this, true, false, true);
         _resourceMgr.registerResourceStateAdapter(this.getClass()

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
index 6d6dc1f..a8a09f6 100644
--- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
@@ -27,14 +27,20 @@ import java.nio.channels.SocketChannel;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 import java.util.UUID;
 
+import javax.ejb.Local;
+import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.utils.identity.ManagementServerNode;
 import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.HttpClient;
-import org.apache.http.HttpStatus;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.DefaultHttpClient;
@@ -54,11 +60,12 @@ import com.cloud.agent.api.NetworkUsageCommand;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.PingRoutingCommand;
 import com.cloud.agent.api.PingTestCommand;
+import com.cloud.agent.api.StartCommand;
 import com.cloud.agent.api.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
+import com.cloud.agent.api.StartupRoutingCommand.VmState;
 import com.cloud.agent.api.StartupStorageCommand;
 import com.cloud.agent.api.UnsupportedAnswer;
-import com.cloud.agent.api.StartupRoutingCommand.VmState;
 import com.cloud.agent.api.check.CheckSshAnswer;
 import com.cloud.agent.api.check.CheckSshCommand;
 import com.cloud.agent.api.routing.CreateIpAliasCommand;
@@ -88,6 +95,8 @@ import com.cloud.agent.api.to.FirewallRuleTO;
 import com.cloud.agent.api.to.IpAddressTO;
 import com.cloud.agent.api.to.PortForwardingRuleTO;
 import com.cloud.agent.api.to.StaticNatRuleTO;
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.configuration.Config;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor;
@@ -98,19 +107,26 @@ import com.cloud.network.rules.FirewallRule;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.ServerResourceBase;
 import com.cloud.serializer.GsonHelper;
+import com.cloud.storage.JavaStorageLayer;
+import com.cloud.storage.StorageLayer;
+import com.cloud.utils.FileUtil;
+import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.StringUtils;
+import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
+import com.cloud.utils.script.Script;
 import com.cloud.utils.ssh.SshHelper;
+import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineName;
 import com.google.gson.Gson;
 
 /**
  * Implementation of dummy resource to be returned from discoverer.
  **/
-
-public class HypervDirectConnectResource extends ServerResourceBase implements
-        ServerResource {
+@Local(value = ServerResource.class)
+public class HypervDirectConnectResource extends ServerResourceBase implements ServerResource {
     public static final int DEFAULT_AGENT_PORT = 8250;
     private static final Logger s_logger = Logger
             .getLogger(HypervDirectConnectResource.class.getName());
@@ -387,7 +403,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
             answer = execute((VmDataCommand) cmd);
         } else if (clazz == SavePasswordCommand.class) {
             answer = execute((SavePasswordCommand) cmd);
-        } else  if (clazz == SetFirewallRulesCommand.class) {
+        } else if (clazz == SetFirewallRulesCommand.class) {
             answer = execute((SetFirewallRulesCommand)cmd);
         } else if (clazz == LoadBalancerConfigCommand.class) {
             answer = execute((LoadBalancerConfigCommand) cmd);
@@ -411,19 +427,19 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
             answer = execute((SetStaticRouteCommand) cmd);
         }
         else {
-        // Else send the cmd to hyperv agent.
-        String ansStr = postHttpRequest(s_gson.toJson(cmd), agentUri);
-        if (ansStr == null) {
-           return Answer.createUnsupportedCommandAnswer(cmd);
-        }
-        // Only Answer instances are returned by remote agents.
-        // E.g. see Response.getAnswers()
-        Answer[] result = s_gson.fromJson(ansStr, Answer[].class);
-        s_logger.debug("executeRequest received response "
-                + s_gson.toJson(result));
-        if (result.length > 0) {
-            return result[0];
-        }
+            // Else send the cmd to hyperv agent.
+            String ansStr = postHttpRequest(s_gson.toJson(cmd), agentUri);
+            if (ansStr == null) {
+               return Answer.createUnsupportedCommandAnswer(cmd);
+            }
+            // Only Answer instances are returned by remote agents.
+            // E.g. see Response.getAnswers()
+            Answer[] result = s_gson.fromJson(ansStr, Answer[].class);
+            s_logger.debug("executeRequest received response "
+                    + s_gson.toJson(result));
+            if (result.length > 0) {
+                return result[0];
+            }
         }
         return answer;
     }
@@ -1259,7 +1275,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         for(DhcpTO dhcpTo : dhcpTos) {
             args = args + dhcpTo.getRouterIp()+":"+dhcpTo.getGateway()+":"+dhcpTo.getNetmask()+":"+dhcpTo.getStartIpOfSubnet()+"-";
         }
-        //File keyFile = mgr.getSystemVMKeyFile();
 
         try {
             Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/dnsmasq.sh " + args);
@@ -1319,43 +1334,17 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
     protected void assignPublicIpAddress(final String vmName, final String privateIpAddress, final String publicIpAddress, final boolean add, final boolean firstIP,
             final boolean sourceNat, final String vlanId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception {
 
-        //String publicNeworkName = HypervisorHostHelper.getPublicNetworkNamePrefix(vlanId);
-        //Pair<Integer, VirtualDevice> publicNicInfo = vmMo.getNicDeviceIndex(publicNeworkName);
-
-        if (s_logger.isDebugEnabled()) {
-            //s_logger.debug("Find public NIC index, public network name: " + publicNeworkName + ", index: " + publicNicInfo.first());
-        }
-
         boolean addVif = false;
         boolean removeVif = false;
-        if (add ) { // && publicNicInfo.first().intValue() == -1) {
+        if (add) {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Plug new NIC to associate" + privateIpAddress + " to " + publicIpAddress);
             }
-
             addVif = true;
         } else if (!add && firstIP) {
             removeVif = true;
-
-            if (s_logger.isDebugEnabled()) {
-                //s_logger.debug("Unplug NIC " + publicNicInfo.first());
-            }
         }
 
-/*        if (addVif) {
-            plugPublicNic(vmMo, vlanId, vifMacAddress);
-            publicNicInfo = vmMo.getNicDeviceIndex(publicNeworkName);
-            if (publicNicInfo.first().intValue() >= 0) {
-                networkUsage(privateIpAddress, "addVif", "eth" + publicNicInfo.first());
-            }
-        }
-*/
-/*        if (publicNicInfo.first().intValue() < 0) {
-            String msg = "Failed to find DomR VIF to associate/disassociate IP with.";
-            s_logger.error(msg);
-            throw new InternalErrorException(msg);
-        }
-*/
         String args = null;
 
         if (add) {
@@ -1400,7 +1389,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         }
     }
 
-   protected Answer execute(GetDomRVersionCmd cmd) {
+    protected Answer execute(GetDomRVersionCmd cmd) {
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Executing resource GetDomRVersionCmd: " + s_gson.toJson(cmd));
             s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/get_template_version.sh ");
@@ -1558,25 +1547,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         return null;
     }
 
-    private File getSystemVMPatchIsoFile() {
-        // locate systemvm.iso
-        URL url = this.getClass().getClassLoader().getResource("vms/systemvm.iso");
-        File isoFile = null;
-        if (url != null) {
-            isoFile = new File(url.getPath());
-        }
-
-        if(isoFile == null || !isoFile.exists()) {
-            isoFile = new File("/usr/share/cloudstack-common/vms/systemvm.iso");
-        }
-
-        assert(isoFile != null);
-        if(!isoFile.exists()) {
-            s_logger.error("Unable to locate systemvm.iso in your setup at " + isoFile.toString());
-        }
-        return isoFile;
-    }
-
     public File getSystemVMKeyFile() {
         URL url = this.getClass().getClassLoader().getResource("scripts/vm/systemvm/id_rsa.cloud");
         File keyFile = null;
@@ -1721,6 +1691,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
     public void setRunLevel(final int level) {
         // TODO Auto-generated method stub
     }
+
     protected String connect(final String vmName, final String ipAddress, final int port) {
         long startTick = System.currentTimeMillis();
 
@@ -1735,9 +1706,10 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
                 sch = SocketChannel.open();
                 sch.configureBlocking(true);
                 sch.socket().setSoTimeout(5000);
-
+                // we need to connect to the public ip address to check the status of the VM
+/*
                 InetSocketAddress addr = new InetSocketAddress(ipAddress, port);
-                sch.connect(addr);
+                sch.connect(addr);*/
                 return null;
             } catch (IOException e) {
                 s_logger.info("Could not connect to " + ipAddress + " due to " + e.toString());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/36b8b357/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java b/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java
index fddd23a..1f90da9 100644
--- a/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java
+++ b/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java
@@ -28,7 +28,6 @@ import java.io.OutputStreamWriter;
 import java.net.URL;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
-import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -43,6 +42,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.io.Files;
 import com.google.gson.Gson;
 
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
@@ -265,7 +265,7 @@ public class HypervDirectConnectResourceTest {
         String newFileURIJSON = null;
         File testVolTemp = new File(dstPath + File.separator + dstFileName);
         try {
-            Files.copy(srcFile.toPath(), testVolTemp.toPath());
+            Files.copy(srcFile, testVolTemp);
         } catch (IOException e) {
             ; // NOP
         }
@@ -671,7 +671,7 @@ public class HypervDirectConnectResourceTest {
                         + "\","
                         + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}";
         DestroyCommand cmd = s_gson.fromJson(sample2, DestroyCommand.class);
-        Answer ans = (Answer) s_hypervresource.executeRequest(cmd);
+        Answer ans = s_hypervresource.executeRequest(cmd);
         Assert.assertTrue(ans.getDetails(), ans.getResult());
     }
 
@@ -844,25 +844,25 @@ public class HypervDirectConnectResourceTest {
                         params.get("TestCoreMhz"),
                         params.get("TestMemoryMb"),
                         params.get("TestDom0MinMemoryMb"),
-                        s_gson.toJson((String) params.get("zone")),
-                        s_gson.toJson((String) params.get("pod")),
-                        s_gson.toJson((String) params.get("cluster")),
-                        s_gson.toJson((String) params.get("ipaddress")),
-                        s_gson.toJson((String) params
+                        s_gson.toJson(params.get("zone")),
+                        s_gson.toJson(params.get("pod")),
+                        s_gson.toJson(params.get("cluster")),
+                        s_gson.toJson(params.get("ipaddress")),
+                        s_gson.toJson(params
                                 .get("private.mac.address")),
-                        s_gson.toJson((String) params.get(
+                        s_gson.toJson(params.get(
                                 "private.ip.netmask")),
-                        s_gson.toJson((String) params.get("ipaddress")),
-                        s_gson.toJson((String) params.get(
+                        s_gson.toJson(params.get("ipaddress")),
+                        s_gson.toJson(params.get(
                                 "private.ip.netmask")),
-                        s_gson.toJson((String) params
+                        s_gson.toJson(params
                                 .get("private.mac.address")),
-                        s_gson.toJson((String) params.get(
+                        s_gson.toJson(params.get(
                                 "gateway.ip.address")),
-                        s_gson.toJson((String) params.get("ipaddress")),
-                        s_gson.toJson((String) params
+                        s_gson.toJson(params.get("ipaddress")),
+                        s_gson.toJson(params
                                 .get("DefaultVirtualDiskFolder")),
-                        s_gson.toJson((String) params
+                        s_gson.toJson(params
                                 .get("DefaultVirtualDiskFolder")),
                         s_gson.toJson(totalSpace),
                         s_gson.toJson(usableCapacity)


[02/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs
index 72f3432..abc5681 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs
@@ -1,791 +1,792 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // An Early Bound class generated for the WMI class.Msvm_VirtualSystemManagementServiceSettingData
-    public class VirtualSystemManagementServiceSettingData : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_VirtualSystemManagementServiceSettingData";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VirtualSystemManagementServiceSettingData() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(string keyInstanceID) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemManagementServiceSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemManagementServiceSettingData.ConstructPath(keyInstanceID)), null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VirtualSystemManagementServiceSettingData(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization\\v2";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Used by OEMs to allow BIOS-locked Windows operating systems to run in the virtual machine. This string must be exactly 32 characters in length.
-This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        public string BiosLockString {
-            get {
-                return ((string)(curObj["BiosLockString"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The WorldWideNodeName address for dynamically generated WorldWideName addresses u" +
-            "sed for Synthetic HBAs.\nThis is a read-only property, but it can be changed usin" +
-            "g the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService cl" +
-            "ass.")]
-        public string CurrentWWNNAddress {
-            get {
-                return ((string)(curObj["CurrentWWNNAddress"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The default external data root. By default, \"root\\ProgramData\\Microsoft\\Windows\\V" +
-            "irtualization\".\nThis is a read-only property, but it can be changed using the Mo" +
-            "difyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        public string DefaultExternalDataRoot {
-            get {
-                return ((string)(curObj["DefaultExternalDataRoot"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The default virtual hard disk path. By default, \"root\\Users\\Public\\Documents\\Virt" +
-            "ual Hard Disks\".\nThis is a read-only property, but it can be changed using the M" +
-            "odifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        public string DefaultVirtualHardDiskPath {
-            get {
-                return ((string)(curObj["DefaultVirtualHardDiskPath"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHbaLunTimeoutNull {
-            get {
-                if ((curObj["HbaLunTimeout"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"This property describes the amount of time that the Synthetic FC virtual device will wait for a LUN to appear before starting a virtual machine.
-This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint HbaLunTimeout {
-            get {
-                if ((curObj["HbaLunTimeout"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["HbaLunTimeout"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string InstanceID {
-            get {
-                return ((string)(curObj["InstanceID"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The maximum MAC address for dynamically generated MAC addresses.\nThis is a read-o" +
-            "nly property, but it can be changed using the ModifyServiceSettings method of th" +
-            "e Msvm_VirtualSystemManagementService class.")]
-        public string MaximumMacAddress {
-            get {
-                return ((string)(curObj["MaximumMacAddress"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The maximum WorldWidePortName address for dynamically generated WorldWideName add" +
-            "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" +
-            "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" +
-            "rvice class.")]
-        public string MaximumWWPNAddress {
-            get {
-                return ((string)(curObj["MaximumWWPNAddress"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The minimum MAC address for dynamically generated MAC addresses.\nThis is a read-o" +
-            "nly property, but it can be changed using the ModifyServiceSettings method of th" +
-            "e Msvm_VirtualSystemManagementService class.")]
-        public string MinimumMacAddress {
-            get {
-                return ((string)(curObj["MinimumMacAddress"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("The minimum WorldWidePortName address for dynamically generated WorldWideName add" +
-            "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" +
-            "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" +
-            "rvice class.")]
-        public string MinimumWWPNAddress {
-            get {
-                return ((string)(curObj["MinimumWWPNAddress"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsNumaSpanningEnabledNull {
-            get {
-                if ((curObj["NumaSpanningEnabled"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Reserved for future use.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool NumaSpanningEnabled {
-            get {
-                if ((curObj["NumaSpanningEnabled"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["NumaSpanningEnabled"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("Controls memory allocation for the VMs on non-uniform memory access (NUMA) system" +
-            "s.\nThis is a read-only property, but it can be changed using the ModifyServiceSe" +
-            "ttings method of the Msvm_VirtualSystemManagementService class.")]
-        public string PrimaryOwnerContact {
-            get {
-                return ((string)(curObj["PrimaryOwnerContact"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description(@"Describes how the primary system owner can be reached (for example, phone number or e-mail address). By default, empty. This name may not exceed 256 characters in length.
-This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
-        public string PrimaryOwnerName {
-            get {
-                return ((string)(curObj["PrimaryOwnerName"]));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHbaLunTimeout() {
-            if ((this.IsHbaLunTimeoutNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeNumaSpanningEnabled() {
-            if ((this.IsNumaSpanningEnabledNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyInstanceID) {
-            string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemManagementServiceSettingData";
-            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VirtualSystemManagementServiceSettingData";
-            pathObj.NamespacePath = "root\\virtualization\\v2";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VirtualSystemManagementServiceSettingDataCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementServiceSettingData", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VirtualSystemManagementServiceSettingDataCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VirtualSystemManagementServiceSettingData CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VirtualSystemManagementServiceSettingData(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VirtualSystemManagementServiceSettingDataCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VirtualSystemManagementServiceSettingDataCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VirtualSystemManagementServiceSettingDataEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VirtualSystemManagementServiceSettingDataEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VirtualSystemManagementServiceSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}
+namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 
+{
+    using System;
+    using System.ComponentModel;
+    using System.Management;
+    using System.Collections;
+    using System.Globalization;
+    using System.ComponentModel.Design.Serialization;
+    using System.Reflection;
+    
+    
+    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
+    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
+    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
+    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
+    // An Early Bound class generated for the WMI class.Msvm_VirtualSystemManagementServiceSettingData
+    public class VirtualSystemManagementServiceSettingData : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        public static string CreatedClassName = "Msvm_VirtualSystemManagementServiceSettingData";
+        
+        // Private member variable to hold the ManagementScope which is used by the various methods.
+        private static System.Management.ManagementScope statMgmtScope = null;
+        
+        private ManagementSystemProperties PrivateSystemProperties;
+        
+        // Underlying lateBound WMI object.
+        private System.Management.ManagementObject PrivateLateBoundObject;
+        
+        // Member variable to store the 'automatic commit' behavior for the class.
+        private bool AutoCommitProp;
+        
+        // Private variable to hold the embedded property representing the instance.
+        private System.Management.ManagementBaseObject embeddedObj;
+        
+        // The current WMI object used
+        private System.Management.ManagementBaseObject curObj;
+        
+        // Flag to indicate if the instance is an embedded object.
+        private bool isEmbedded;
+        
+        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
+        public VirtualSystemManagementServiceSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemManagementServiceSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemManagementServiceSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                PrivateLateBoundObject = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+                curObj = PrivateLateBoundObject;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        public VirtualSystemManagementServiceSettingData(System.Management.ManagementBaseObject theObject) {
+            Initialize();
+            if ((CheckIfProperClass(theObject) == true)) {
+                embeddedObj = theObject;
+                PrivateSystemProperties = new ManagementSystemProperties(theObject);
+                curObj = embeddedObj;
+                isEmbedded = true;
+            }
+            else {
+                throw new System.ArgumentException("Class name does not match.");
+            }
+        }
+        
+        // Property returns the namespace of the WMI class.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string OriginatingNamespace {
+            get {
+                return "ROOT\\virtualization\\v2";
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ManagementClassName {
+            get {
+                string strRet = CreatedClassName;
+                if ((curObj != null)) {
+                    if ((curObj.ClassPath != null)) {
+                        strRet = ((string)(curObj["__CLASS"]));
+                        if (((strRet == null) 
+                                    || (strRet == string.Empty))) {
+                            strRet = CreatedClassName;
+                        }
+                    }
+                }
+                return strRet;
+            }
+        }
+        
+        // Property pointing to an embedded object to get System properties of the WMI object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public ManagementSystemProperties SystemProperties {
+            get {
+                return PrivateSystemProperties;
+            }
+        }
+        
+        // Property returning the underlying lateBound object.
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementBaseObject LateBoundObject {
+            get {
+                return curObj;
+            }
+        }
+        
+        // ManagementScope of the object.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public System.Management.ManagementScope Scope {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Scope;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    PrivateLateBoundObject.Scope = value;
+                }
+            }
+        }
+        
+        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool AutoCommit {
+            get {
+                return AutoCommitProp;
+            }
+            set {
+                AutoCommitProp = value;
+            }
+        }
+        
+        // The ManagementPath of the underlying WMI object.
+        [Browsable(true)]
+        public System.Management.ManagementPath Path {
+            get {
+                if ((isEmbedded == false)) {
+                    return PrivateLateBoundObject.Path;
+                }
+                else {
+                    return null;
+                }
+            }
+            set {
+                if ((isEmbedded == false)) {
+                    if ((CheckIfProperClass(null, value, null) != true)) {
+                        throw new System.ArgumentException("Class name does not match.");
+                    }
+                    PrivateLateBoundObject.Path = value;
+                }
+            }
+        }
+        
+        // Public static scope property which is used by the various methods.
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public static System.Management.ManagementScope StaticScope {
+            get {
+                return statMgmtScope;
+            }
+            set {
+                statMgmtScope = value;
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Used by OEMs to allow BIOS-locked Windows operating systems to run in the virtual machine. This string must be exactly 32 characters in length.
+This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        public string BiosLockString {
+            get {
+                return ((string)(curObj["BiosLockString"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The WorldWideNodeName address for dynamically generated WorldWideName addresses u" +
+            "sed for Synthetic HBAs.\nThis is a read-only property, but it can be changed usin" +
+            "g the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService cl" +
+            "ass.")]
+        public string CurrentWWNNAddress {
+            get {
+                return ((string)(curObj["CurrentWWNNAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The default external data root. By default, \"root\\ProgramData\\Microsoft\\Windows\\V" +
+            "irtualization\".\nThis is a read-only property, but it can be changed using the Mo" +
+            "difyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        public string DefaultExternalDataRoot {
+            get {
+                return ((string)(curObj["DefaultExternalDataRoot"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The default virtual hard disk path. By default, \"root\\Users\\Public\\Documents\\Virt" +
+            "ual Hard Disks\".\nThis is a read-only property, but it can be changed using the M" +
+            "odifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        public string DefaultVirtualHardDiskPath {
+            get {
+                return ((string)(curObj["DefaultVirtualHardDiskPath"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ElementName {
+            get {
+                return ((string)(curObj["ElementName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsHbaLunTimeoutNull {
+            get {
+                if ((curObj["HbaLunTimeout"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"This property describes the amount of time that the Synthetic FC virtual device will wait for a LUN to appear before starting a virtual machine.
+This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint HbaLunTimeout {
+            get {
+                if ((curObj["HbaLunTimeout"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["HbaLunTimeout"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum MAC address for dynamically generated MAC addresses.\nThis is a read-o" +
+            "nly property, but it can be changed using the ModifyServiceSettings method of th" +
+            "e Msvm_VirtualSystemManagementService class.")]
+        public string MaximumMacAddress {
+            get {
+                return ((string)(curObj["MaximumMacAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum WorldWidePortName address for dynamically generated WorldWideName add" +
+            "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" +
+            "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" +
+            "rvice class.")]
+        public string MaximumWWPNAddress {
+            get {
+                return ((string)(curObj["MaximumWWPNAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The minimum MAC address for dynamically generated MAC addresses.\nThis is a read-o" +
+            "nly property, but it can be changed using the ModifyServiceSettings method of th" +
+            "e Msvm_VirtualSystemManagementService class.")]
+        public string MinimumMacAddress {
+            get {
+                return ((string)(curObj["MinimumMacAddress"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The minimum WorldWidePortName address for dynamically generated WorldWideName add" +
+            "resses used for Synthetic HBAs.\nThis is a read-only property, but it can be chan" +
+            "ged using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementSe" +
+            "rvice class.")]
+        public string MinimumWWPNAddress {
+            get {
+                return ((string)(curObj["MinimumWWPNAddress"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNumaSpanningEnabledNull {
+            get {
+                if ((curObj["NumaSpanningEnabled"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Reserved for future use.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool NumaSpanningEnabled {
+            get {
+                if ((curObj["NumaSpanningEnabled"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["NumaSpanningEnabled"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Controls memory allocation for the VMs on non-uniform memory access (NUMA) system" +
+            "s.\nThis is a read-only property, but it can be changed using the ModifyServiceSe" +
+            "ttings method of the Msvm_VirtualSystemManagementService class.")]
+        public string PrimaryOwnerContact {
+            get {
+                return ((string)(curObj["PrimaryOwnerContact"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Describes how the primary system owner can be reached (for example, phone number or e-mail address). By default, empty. This name may not exceed 256 characters in length.
+This is a read-only property, but it can be changed using the ModifyServiceSettings method of the Msvm_VirtualSystemManagementService class.")]
+        public string PrimaryOwnerName {
+            get {
+                return ((string)(curObj["PrimaryOwnerName"]));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
+            if (((path != null) 
+                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
+            }
+        }
+        
+        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
+            if (((theObj != null) 
+                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
+                return true;
+            }
+            else {
+                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
+                if ((parentClasses != null)) {
+                    int count = 0;
+                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
+                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeHbaLunTimeout() {
+            if ((this.IsHbaLunTimeoutNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumaSpanningEnabled() {
+            if ((this.IsNumaSpanningEnabledNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        [Browsable(true)]
+        public void CommitObject() {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        [Browsable(true)]
+        public void CommitObject(System.Management.PutOptions putOptions) {
+            if ((isEmbedded == false)) {
+                PrivateLateBoundObject.Put(putOptions);
+            }
+        }
+        
+        private void Initialize() {
+            AutoCommitProp = true;
+            isEmbedded = false;
+        }
+        
+        private static string ConstructPath(string keyInstanceID) {
+            string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualSystemManagementServiceSettingData";
+            strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\""))));
+            return strPath;
+        }
+        
+        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            Initialize();
+            if ((path != null)) {
+                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
+                    throw new System.ArgumentException("Class name does not match.");
+                }
+            }
+            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
+            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
+            curObj = PrivateLateBoundObject;
+        }
+        
+        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_VirtualSystemManagementServiceSettingData";
+            pathObj.NamespacePath = "root\\virtualization\\v2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new VirtualSystemManagementServiceSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static VirtualSystemManagementServiceSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\virtualization\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VirtualSystemManagementServiceSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new VirtualSystemManagementServiceSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static VirtualSystemManagementServiceSettingData CreateInstance() {
+            System.Management.ManagementScope mgmtScope = null;
+            if ((statMgmtScope == null)) {
+                mgmtScope = new System.Management.ManagementScope();
+                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
+            }
+            else {
+                mgmtScope = statMgmtScope;
+            }
+            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
+            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
+            return new VirtualSystemManagementServiceSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class VirtualSystemManagementServiceSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public VirtualSystemManagementServiceSettingDataCollection(ManagementObjectCollection objCollection) {
+                privColObj = objCollection;
+            }
+            
+            public virtual int Count {
+                get {
+                    return privColObj.Count;
+                }
+            }
+            
+            public virtual bool IsSynchronized {
+                get {
+                    return privColObj.IsSynchronized;
+                }
+            }
+            
+            public virtual object SyncRoot {
+                get {
+                    return this;
+                }
+            }
+            
+            public virtual void CopyTo(System.Array array, int index) {
+                privColObj.CopyTo(array, index);
+                int nCtr;
+                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
+                    array.SetValue(new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new VirtualSystemManagementServiceSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class VirtualSystemManagementServiceSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public VirtualSystemManagementServiceSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new VirtualSystemManagementServiceSettingData(((System.Management.ManagementObject)(privObjEnum.Current)));
+                    }
+                }
+                
+                public virtual bool MoveNext() {
+                    return privObjEnum.MoveNext();
+                }
+                
+                public virtual void Reset() {
+                    privObjEnum.Reset();
+                }
+            }
+        }
+        
+        // TypeConverter to handle null values for ValueType properties
+        public class WMIValueTypeConverter : TypeConverter {
+            
+            private TypeConverter baseConverter;
+            
+            private System.Type baseType;
+            
+            public WMIValueTypeConverter(System.Type inBaseType) {
+                baseConverter = TypeDescriptor.GetConverter(inBaseType);
+                baseType = inBaseType;
+            }
+            
+            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
+                return baseConverter.CanConvertFrom(context, srcType);
+            }
+            
+            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
+                return baseConverter.CanConvertTo(context, destinationType);
+            }
+            
+            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
+                return baseConverter.ConvertFrom(context, culture, value);
+            }
+            
+            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
+                return baseConverter.CreateInstance(context, dictionary);
+            }
+            
+            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetCreateInstanceSupported(context);
+            }
+            
+            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
+                return baseConverter.GetProperties(context, value, attributeVar);
+            }
+            
+            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetPropertiesSupported(context);
+            }
+            
+            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValues(context);
+            }
+            
+            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesExclusive(context);
+            }
+            
+            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
+                return baseConverter.GetStandardValuesSupported(context);
+            }
+            
+            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
+                if ((baseType.BaseType == typeof(System.Enum))) {
+                    if ((value.GetType() == destinationType)) {
+                        return value;
+                    }
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return  "NULL_ENUM_VALUE" ;
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((baseType == typeof(bool)) 
+                            && (baseType.BaseType == typeof(System.ValueType)))) {
+                    if ((((value == null) 
+                                && (context != null)) 
+                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                        return "";
+                    }
+                    return baseConverter.ConvertTo(context, culture, value, destinationType);
+                }
+                if (((context != null) 
+                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
+                    return "";
+                }
+                return baseConverter.ConvertTo(context, culture, value, destinationType);
+            }
+        }
+        
+        // Embedded class to represent WMI system Properties.
+        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
+        public class ManagementSystemProperties {
+            
+            private System.Management.ManagementBaseObject PrivateLateBoundObject;
+            
+            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
+                PrivateLateBoundObject = ManagedObject;
+            }
+            
+            [Browsable(true)]
+            public int GENUS {
+                get {
+                    return ((int)(PrivateLateBoundObject["__GENUS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string CLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__CLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SUPERCLASS {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string DYNASTY {
+                get {
+                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string RELPATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public int PROPERTY_COUNT {
+                get {
+                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string[] DERIVATION {
+                get {
+                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string SERVER {
+                get {
+                    return ((string)(PrivateLateBoundObject["__SERVER"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string NAMESPACE {
+                get {
+                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
+                }
+            }
+            
+            [Browsable(true)]
+            public string PATH {
+                get {
+                    return ((string)(PrivateLateBoundObject["__PATH"]));
+                }
+            }
+        }
+    }
+}


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

Posted by bf...@apache.org.
New login screen colors


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

Branch: refs/heads/ui-restyle
Commit: ed6c2d27a610fc137c97f204e8ee997aea53eda2
Parents: 70330f5
Author: Brian Federle <br...@citrix.com>
Authored: Mon Nov 4 10:59:01 2013 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Mon Nov 4 10:59:01 2013 -0800

----------------------------------------------------------------------
 ui/css/cloudstack3.css | 48 ++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ed6c2d27/ui/css/cloudstack3.css
----------------------------------------------------------------------
diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css
index 3473524..ba2439a 100644
--- a/ui/css/cloudstack3.css
+++ b/ui/css/cloudstack3.css
@@ -316,23 +316,19 @@ table th div.ui-resizable-handle {
 
 /*Login screen*/
 body.login {
-  background: transparent url(../images/bg-login.png) repeat 50% -82px;
+  background: url(../images/overlay-pattern.png) repeat center, #106CA9 url(../images/bg-login.jpg) no-repeat center;
+  background-size: auto, cover;
 }
 
 .login {
   display: block;
   width: 100%;
-  height: 245px;
-  /*+placement:shift 0 100px;*/
+  height: 350px;
+  /*+placement:shift 0 80px;*/
   position: relative;
   left: 0;
-  top: 100px;
-  background: #FFFFFF;
-  /*+box-shadow:0px 3px 5px #D5D5D5;*/
-  -moz-box-shadow: 0px 3px 5px #D5D5D5;
-  -webkit-box-shadow: 0px 3px 5px #D5D5D5;
-  -o-box-shadow: 0px 3px 5px #D5D5D5;
-  box-shadow: 0px 3px 5px #D5D5D5;
+  top: 80px;
+  background: #053663;
 }
 
 .login .select-language {
@@ -341,8 +337,9 @@ body.login {
 }
 
 .login .select-language select {
-  width: 125px;
+  width: 260px;
   border: 1px solid #808080;
+  margin-top: 30px;
   /*+border-radius:4px;*/
   -moz-border-radius: 4px;
   -webkit-border-radius: 4px;
@@ -368,33 +365,34 @@ body.login {
 }
 
 .login .fields .field label {
-  font-size: 11px;
+  font-size: 12px;
   color: #4E4F53;
-  /*+placement:displace 10px 12px;*/
+  /*+placement:displace 9px 14px;*/
   position: absolute;
-  margin-left: 10px;
-  margin-top: 12px;
+  margin-left: 9px;
+  margin-top: 14px;
 }
 
 .login .fields .field label.error {
   color: #FF0000;
   float: right;
-  left: 204px;
+  left: 264px;
   top: 0;
 }
 
 .login .fields input {
-  width: 204px;
+  width: 248px;
   height: 20px;
   margin: 5px 0 0;
-  text-indent: 7px;
+  text-indent: 1px;
+  font-size: 13px;
   border: none;
-  /*+border-radius:4px;*/
-  -moz-border-radius: 4px;
-  -webkit-border-radius: 4px;
-  -khtml-border-radius: 4px;
-  border-radius: 4px;
-  border-radius: 4px 4px 4px 4px;
+  padding: 5px;
+  /*+border-radius:3px;*/
+  -moz-border-radius: 3px;
+  -webkit-border-radius: 3px;
+  -khtml-border-radius: 3px;
+  border-radius: 3px;
   /*+box-shadow:inset 0px 1px 1px #4E4E4E;*/
   -moz-box-shadow: inset 0px 1px 1px #4E4E4E;
   -webkit-box-shadow: inset 0px 1px 1px #4E4E4E;
@@ -449,7 +447,7 @@ body.login {
   width: 1000px;
   height: 100%;
   margin: auto;
-  background: #FFFFFF;
+  background: #053663;
 }
 
 /*About dialog*/


[17/56] [abbrv] Changes for switching all wmi calls to V2 namespace. V1 namespace is deprecated so it is better to be on v2 namespace.

Posted by bf...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VmLANEndpoint.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VmLANEndpoint.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VmLANEndpoint.cs
deleted file mode 100644
index 040882e..0000000
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VmLANEndpoint.cs
+++ /dev/null
@@ -1,1342 +0,0 @@
-namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION {
-    using System;
-    using System.ComponentModel;
-    using System.Management;
-    using System.Collections;
-    using System.Globalization;
-    using System.ComponentModel.Design.Serialization;
-    using System.Reflection;
-    
-    
-    // Functions ShouldSerialize<PropertyName> are functions used by VS property browser to check if a particular property has to be serialized. These functions are added for all ValueType properties ( properties of type Int32, BOOL etc.. which cannot be set to null). These functions use Is<PropertyName>Null function. These functions are also used in the TypeConverter implementation for the properties to check for NULL value of property so that an empty value can be shown in Property browser in case of Drag and Drop in Visual studio.
-    // Functions Is<PropertyName>Null() are used to check if a property is NULL.
-    // Functions Reset<PropertyName> are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL.
-    // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used.
-    // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa.
-    // Time interval functions  ToTimeSpan and ToDmtfTimeInterval are added to the class to convert DMTF Time Interval to  System.TimeSpan and vice-versa.
-    // An Early Bound class generated for the WMI class.Msvm_VmLANEndpoint
-    public class VmLANEndpoint : System.ComponentModel.Component {
-        
-        // Private property to hold the WMI namespace in which the class resides.
-        private static string CreatedWmiNamespace = "ROOT\\virtualization";
-        
-        // Private property to hold the name of WMI class which created this class.
-        public static string CreatedClassName = "Msvm_VmLANEndpoint";
-        
-        // Private member variable to hold the ManagementScope which is used by the various methods.
-        private static System.Management.ManagementScope statMgmtScope = null;
-        
-        private ManagementSystemProperties PrivateSystemProperties;
-        
-        // Underlying lateBound WMI object.
-        private System.Management.ManagementObject PrivateLateBoundObject;
-        
-        // Member variable to store the 'automatic commit' behavior for the class.
-        private bool AutoCommitProp;
-        
-        // Private variable to hold the embedded property representing the instance.
-        private System.Management.ManagementBaseObject embeddedObj;
-        
-        // The current WMI object used
-        private System.Management.ManagementBaseObject curObj;
-        
-        // Flag to indicate if the instance is an embedded object.
-        private bool isEmbedded;
-        
-        // Below are different overloads of constructors to initialize an instance of the class with a WMI object.
-        public VmLANEndpoint() {
-            this.InitializeObject(null, null, null);
-        }
-        
-        public VmLANEndpoint(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(null, new System.Management.ManagementPath(VmLANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public VmLANEndpoint(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VmLANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null);
-        }
-        
-        public VmLANEndpoint(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(null, path, getOptions);
-        }
-        
-        public VmLANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
-            this.InitializeObject(mgmtScope, path, null);
-        }
-        
-        public VmLANEndpoint(System.Management.ManagementPath path) {
-            this.InitializeObject(null, path, null);
-        }
-        
-        public VmLANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            this.InitializeObject(mgmtScope, path, getOptions);
-        }
-        
-        public VmLANEndpoint(System.Management.ManagementObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                PrivateLateBoundObject = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-                curObj = PrivateLateBoundObject;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        public VmLANEndpoint(System.Management.ManagementBaseObject theObject) {
-            Initialize();
-            if ((CheckIfProperClass(theObject) == true)) {
-                embeddedObj = theObject;
-                PrivateSystemProperties = new ManagementSystemProperties(theObject);
-                curObj = embeddedObj;
-                isEmbedded = true;
-            }
-            else {
-                throw new System.ArgumentException("Class name does not match.");
-            }
-        }
-        
-        // Property returns the namespace of the WMI class.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OriginatingNamespace {
-            get {
-                return "ROOT\\virtualization";
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ManagementClassName {
-            get {
-                string strRet = CreatedClassName;
-                if ((curObj != null)) {
-                    if ((curObj.ClassPath != null)) {
-                        strRet = ((string)(curObj["__CLASS"]));
-                        if (((strRet == null) 
-                                    || (strRet == string.Empty))) {
-                            strRet = CreatedClassName;
-                        }
-                    }
-                }
-                return strRet;
-            }
-        }
-        
-        // Property pointing to an embedded object to get System properties of the WMI object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ManagementSystemProperties SystemProperties {
-            get {
-                return PrivateSystemProperties;
-            }
-        }
-        
-        // Property returning the underlying lateBound object.
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementBaseObject LateBoundObject {
-            get {
-                return curObj;
-            }
-        }
-        
-        // ManagementScope of the object.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public System.Management.ManagementScope Scope {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Scope;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    PrivateLateBoundObject.Scope = value;
-                }
-            }
-        }
-        
-        // Property to show the commit behavior for the WMI object. If true, WMI object will be automatically saved after each property modification.(ie. Put() is called after modification of a property).
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool AutoCommit {
-            get {
-                return AutoCommitProp;
-            }
-            set {
-                AutoCommitProp = value;
-            }
-        }
-        
-        // The ManagementPath of the underlying WMI object.
-        [Browsable(true)]
-        public System.Management.ManagementPath Path {
-            get {
-                if ((isEmbedded == false)) {
-                    return PrivateLateBoundObject.Path;
-                }
-                else {
-                    return null;
-                }
-            }
-            set {
-                if ((isEmbedded == false)) {
-                    if ((CheckIfProperClass(null, value, null) != true)) {
-                        throw new System.ArgumentException("Class name does not match.");
-                    }
-                    PrivateLateBoundObject.Path = value;
-                }
-            }
-        }
-        
-        // Public static scope property which is used by the various methods.
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public static System.Management.ManagementScope StaticScope {
-            get {
-                return statMgmtScope;
-            }
-            set {
-                statMgmtScope = value;
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] AliasAddresses {
-            get {
-                return ((string[])(curObj["AliasAddresses"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsBroadcastResetSupportedNull {
-            get {
-                if ((curObj["BroadcastResetSupported"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool BroadcastResetSupported {
-            get {
-                if ((curObj["BroadcastResetSupported"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["BroadcastResetSupported"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Caption {
-            get {
-                return ((string)(curObj["Caption"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsConnectedNull {
-            get {
-                if ((curObj["Connected"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [Description("This property is set to TRUE if the LAN endpoint is connected to a switch port.")]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public bool Connected {
-            get {
-                if ((curObj["Connected"] == null)) {
-                    return System.Convert.ToBoolean(0);
-                }
-                return ((bool)(curObj["Connected"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string CreationClassName {
-            get {
-                return ((string)(curObj["CreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Description {
-            get {
-                return ((string)(curObj["Description"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string ElementName {
-            get {
-                return ((string)(curObj["ElementName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledDefaultNull {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledDefault {
-            get {
-                if ((curObj["EnabledDefault"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledDefault"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsEnabledStateNull {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort EnabledState {
-            get {
-                if ((curObj["EnabledState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["EnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] GroupAddresses {
-            get {
-                return ((string[])(curObj["GroupAddresses"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsHealthStateNull {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort HealthState {
-            get {
-                if ((curObj["HealthState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["HealthState"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsInstallDateNull {
-            get {
-                if ((curObj["InstallDate"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime InstallDate {
-            get {
-                if ((curObj["InstallDate"] != null)) {
-                    return ToDateTime(((string)(curObj["InstallDate"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string LANID {
-            get {
-                return ((string)(curObj["LANID"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsLANTypeNull {
-            get {
-                if ((curObj["LANType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort LANType {
-            get {
-                if ((curObj["LANType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["LANType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string MACAddress {
-            get {
-                return ((string)(curObj["MACAddress"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsMaxDataSizeNull {
-            get {
-                if ((curObj["MaxDataSize"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public uint MaxDataSize {
-            get {
-                if ((curObj["MaxDataSize"] == null)) {
-                    return System.Convert.ToUInt32(0);
-                }
-                return ((uint)(curObj["MaxDataSize"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Name {
-            get {
-                return ((string)(curObj["Name"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string NameFormat {
-            get {
-                return ((string)(curObj["NameFormat"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public ushort[] OperationalStatus {
-            get {
-                return ((ushort[])(curObj["OperationalStatus"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherEnabledState {
-            get {
-                return ((string)(curObj["OtherEnabledState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherLANType {
-            get {
-                return ((string)(curObj["OtherLANType"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string OtherTypeDescription {
-            get {
-                return ((string)(curObj["OtherTypeDescription"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolIFTypeNull {
-            get {
-                if ((curObj["ProtocolIFType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolIFType {
-            get {
-                if ((curObj["ProtocolIFType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolIFType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsProtocolTypeNull {
-            get {
-                if ((curObj["ProtocolType"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort ProtocolType {
-            get {
-                if ((curObj["ProtocolType"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["ProtocolType"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsRequestedStateNull {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public ushort RequestedState {
-            get {
-                if ((curObj["RequestedState"] == null)) {
-                    return System.Convert.ToUInt16(0);
-                }
-                return ((ushort)(curObj["RequestedState"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string Status {
-            get {
-                return ((string)(curObj["Status"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string[] StatusDescriptions {
-            get {
-                return ((string[])(curObj["StatusDescriptions"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemCreationClassName {
-            get {
-                return ((string)(curObj["SystemCreationClassName"]));
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public string SystemName {
-            get {
-                return ((string)(curObj["SystemName"]));
-            }
-        }
-        
-        [Browsable(false)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        public bool IsTimeOfLastStateChangeNull {
-            get {
-                if ((curObj["TimeOfLastStateChange"] == null)) {
-                    return true;
-                }
-                else {
-                    return false;
-                }
-            }
-        }
-        
-        [Browsable(true)]
-        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
-        [TypeConverter(typeof(WMIValueTypeConverter))]
-        public System.DateTime TimeOfLastStateChange {
-            get {
-                if ((curObj["TimeOfLastStateChange"] != null)) {
-                    return ToDateTime(((string)(curObj["TimeOfLastStateChange"])));
-                }
-                else {
-                    return System.DateTime.MinValue;
-                }
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) {
-            if (((path != null) 
-                        && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam));
-            }
-        }
-        
-        private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) {
-            if (((theObj != null) 
-                        && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) {
-                return true;
-            }
-            else {
-                System.Array parentClasses = ((System.Array)(theObj["__DERIVATION"]));
-                if ((parentClasses != null)) {
-                    int count = 0;
-                    for (count = 0; (count < parentClasses.Length); count = (count + 1)) {
-                        if ((string.Compare(((string)(parentClasses.GetValue(count))), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeBroadcastResetSupported() {
-            if ((this.IsBroadcastResetSupportedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeConnected() {
-            if ((this.IsConnectedNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledDefault() {
-            if ((this.IsEnabledDefaultNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeEnabledState() {
-            if ((this.IsEnabledStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeHealthState() {
-            if ((this.IsHealthStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        // Converts a given datetime in DMTF format to System.DateTime object.
-        static System.DateTime ToDateTime(string dmtfDate) {
-            System.DateTime initializer = System.DateTime.MinValue;
-            int year = initializer.Year;
-            int month = initializer.Month;
-            int day = initializer.Day;
-            int hour = initializer.Hour;
-            int minute = initializer.Minute;
-            int second = initializer.Second;
-            long ticks = 0;
-            string dmtf = dmtfDate;
-            System.DateTime datetime = System.DateTime.MinValue;
-            string tempString = string.Empty;
-            if ((dmtf == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtf.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                tempString = dmtf.Substring(0, 4);
-                if (("****" != tempString)) {
-                    year = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(4, 2);
-                if (("**" != tempString)) {
-                    month = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(6, 2);
-                if (("**" != tempString)) {
-                    day = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(8, 2);
-                if (("**" != tempString)) {
-                    hour = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(10, 2);
-                if (("**" != tempString)) {
-                    minute = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(12, 2);
-                if (("**" != tempString)) {
-                    second = int.Parse(tempString);
-                }
-                tempString = dmtf.Substring(15, 6);
-                if (("******" != tempString)) {
-                    ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-                }
-                if (((((((((year < 0) 
-                            || (month < 0)) 
-                            || (day < 0)) 
-                            || (hour < 0)) 
-                            || (minute < 0)) 
-                            || (minute < 0)) 
-                            || (second < 0)) 
-                            || (ticks < 0))) {
-                    throw new System.ArgumentOutOfRangeException();
-                }
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            datetime = new System.DateTime(year, month, day, hour, minute, second, 0);
-            datetime = datetime.AddTicks(ticks);
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(datetime);
-            int UTCOffset = 0;
-            int OffsetToBeAdjusted = 0;
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            tempString = dmtf.Substring(22, 3);
-            if ((tempString != "******")) {
-                tempString = dmtf.Substring(21, 4);
-                try {
-                    UTCOffset = int.Parse(tempString);
-                }
-                catch (System.Exception e) {
-                    throw new System.ArgumentOutOfRangeException(null, e.Message);
-                }
-                OffsetToBeAdjusted = ((int)((OffsetMins - UTCOffset)));
-                datetime = datetime.AddMinutes(((double)(OffsetToBeAdjusted)));
-            }
-            return datetime;
-        }
-        
-        // Converts a given System.DateTime object to DMTF datetime format.
-        static string ToDmtfDateTime(System.DateTime date) {
-            string utcString = string.Empty;
-            System.TimeSpan tickOffset = System.TimeZone.CurrentTimeZone.GetUtcOffset(date);
-            long OffsetMins = ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute)));
-            if ((System.Math.Abs(OffsetMins) > 999)) {
-                date = date.ToUniversalTime();
-                utcString = "+000";
-            }
-            else {
-                if ((tickOffset.Ticks >= 0)) {
-                    utcString = string.Concat("+", ((long)((tickOffset.Ticks / System.TimeSpan.TicksPerMinute))).ToString().PadLeft(3, '0'));
-                }
-                else {
-                    string strTemp = ((long)(OffsetMins)).ToString();
-                    utcString = string.Concat("-", strTemp.Substring(1, (strTemp.Length - 1)).PadLeft(3, '0'));
-                }
-            }
-            string dmtfDateTime = ((int)(date.Year)).ToString().PadLeft(4, '0');
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Month)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Day)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Hour)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Minute)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ((int)(date.Second)).ToString().PadLeft(2, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, ".");
-            System.DateTime dtTemp = new System.DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0);
-            long microsec = ((long)((((date.Ticks - dtTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicrosec = ((long)(microsec)).ToString();
-            if ((strMicrosec.Length > 6)) {
-                strMicrosec = strMicrosec.Substring(0, 6);
-            }
-            dmtfDateTime = string.Concat(dmtfDateTime, strMicrosec.PadLeft(6, '0'));
-            dmtfDateTime = string.Concat(dmtfDateTime, utcString);
-            return dmtfDateTime;
-        }
-        
-        private bool ShouldSerializeInstallDate() {
-            if ((this.IsInstallDateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeLANType() {
-            if ((this.IsLANTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeMaxDataSize() {
-            if ((this.IsMaxDataSizeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProtocolIFType() {
-            if ((this.IsProtocolIFTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeProtocolType() {
-            if ((this.IsProtocolTypeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeRequestedState() {
-            if ((this.IsRequestedStateNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        private bool ShouldSerializeTimeOfLastStateChange() {
-            if ((this.IsTimeOfLastStateChangeNull == false)) {
-                return true;
-            }
-            return false;
-        }
-        
-        [Browsable(true)]
-        public void CommitObject() {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put();
-            }
-        }
-        
-        [Browsable(true)]
-        public void CommitObject(System.Management.PutOptions putOptions) {
-            if ((isEmbedded == false)) {
-                PrivateLateBoundObject.Put(putOptions);
-            }
-        }
-        
-        private void Initialize() {
-            AutoCommitProp = true;
-            isEmbedded = false;
-        }
-        
-        private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) {
-            string strPath = "ROOT\\virtualization:Msvm_VmLANEndpoint";
-            strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemCreationClassName=", string.Concat("\"", string.Concat(keySystemCreationClassName, "\""))));
-            strPath = string.Concat(strPath, string.Concat(",SystemName=", string.Concat("\"", string.Concat(keySystemName, "\""))));
-            return strPath;
-        }
-        
-        private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
-            Initialize();
-            if ((path != null)) {
-                if ((CheckIfProperClass(mgmtScope, path, getOptions) != true)) {
-                    throw new System.ArgumentException("Class name does not match.");
-                }
-            }
-            PrivateLateBoundObject = new System.Management.ManagementObject(mgmtScope, path, getOptions);
-            PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject);
-            curObj = PrivateLateBoundObject;
-        }
-        
-        // Different overloads of GetInstances() help in enumerating instances of the WMI class.
-        public static VmLANEndpointCollection GetInstances() {
-            return GetInstances(null, null, null);
-        }
-        
-        public static VmLANEndpointCollection GetInstances(string condition) {
-            return GetInstances(null, condition, null);
-        }
-        
-        public static VmLANEndpointCollection GetInstances(string[] selectedProperties) {
-            return GetInstances(null, null, selectedProperties);
-        }
-        
-        public static VmLANEndpointCollection GetInstances(string condition, string[] selectedProperties) {
-            return GetInstances(null, condition, selectedProperties);
-        }
-        
-        public static VmLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
-            pathObj.ClassName = "Msvm_VmLANEndpoint";
-            pathObj.NamespacePath = "root\\virtualization";
-            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
-            if ((enumOptions == null)) {
-                enumOptions = new System.Management.EnumerationOptions();
-                enumOptions.EnsureLocatable = true;
-            }
-            return new VmLANEndpointCollection(clsObject.GetInstances(enumOptions));
-        }
-        
-        public static VmLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
-            return GetInstances(mgmtScope, condition, null);
-        }
-        
-        public static VmLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
-            return GetInstances(mgmtScope, null, selectedProperties);
-        }
-        
-        public static VmLANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
-            if ((mgmtScope == null)) {
-                if ((statMgmtScope == null)) {
-                    mgmtScope = new System.Management.ManagementScope();
-                    mgmtScope.Path.NamespacePath = "root\\virtualization";
-                }
-                else {
-                    mgmtScope = statMgmtScope;
-                }
-            }
-            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Msvm_VmLANEndpoint", condition, selectedProperties));
-            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
-            enumOptions.EnsureLocatable = true;
-            ObjectSearcher.Options = enumOptions;
-            return new VmLANEndpointCollection(ObjectSearcher.Get());
-        }
-        
-        [Browsable(true)]
-        public static VmLANEndpoint CreateInstance() {
-            System.Management.ManagementScope mgmtScope = null;
-            if ((statMgmtScope == null)) {
-                mgmtScope = new System.Management.ManagementScope();
-                mgmtScope.Path.NamespacePath = CreatedWmiNamespace;
-            }
-            else {
-                mgmtScope = statMgmtScope;
-            }
-            System.Management.ManagementPath mgmtPath = new System.Management.ManagementPath(CreatedClassName);
-            System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null);
-            return new VmLANEndpoint(tmpMgmtClass.CreateInstance());
-        }
-        
-        [Browsable(true)]
-        public void Delete() {
-            PrivateLateBoundObject.Delete();
-        }
-        
-        public uint BroadcastReset() {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("BroadcastReset", inParams, null);
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Converts a given time interval in DMTF format to System.TimeSpan object.
-        static System.TimeSpan ToTimeSpan(string dmtfTimespan) {
-            int days = 0;
-            int hours = 0;
-            int minutes = 0;
-            int seconds = 0;
-            long ticks = 0;
-            if ((dmtfTimespan == null)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length == 0)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Length != 25)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            if ((dmtfTimespan.Substring(21, 4) != ":000")) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            try {
-                string tempString = string.Empty;
-                tempString = dmtfTimespan.Substring(0, 8);
-                days = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(8, 2);
-                hours = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(10, 2);
-                minutes = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(12, 2);
-                seconds = int.Parse(tempString);
-                tempString = dmtfTimespan.Substring(15, 6);
-                ticks = (long.Parse(tempString) * ((long)((System.TimeSpan.TicksPerMillisecond / 1000))));
-            }
-            catch (System.Exception e) {
-                throw new System.ArgumentOutOfRangeException(null, e.Message);
-            }
-            System.TimeSpan timespan = new System.TimeSpan(days, hours, minutes, seconds, 0);
-            System.TimeSpan tsTemp = System.TimeSpan.FromTicks(ticks);
-            timespan = timespan.Add(tsTemp);
-            return timespan;
-        }
-        
-        // Converts a given System.TimeSpan object to DMTF Time interval format.
-        static string ToDmtfTimeInterval(System.TimeSpan timespan) {
-            string dmtftimespan = ((int)(timespan.Days)).ToString().PadLeft(8, '0');
-            System.TimeSpan maxTimeSpan = System.TimeSpan.MaxValue;
-            if ((timespan.Days > maxTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            System.TimeSpan minTimeSpan = System.TimeSpan.MinValue;
-            if ((timespan.Days < minTimeSpan.Days)) {
-                throw new System.ArgumentOutOfRangeException();
-            }
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Hours)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Minutes)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ((int)(timespan.Seconds)).ToString().PadLeft(2, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ".");
-            System.TimeSpan tsTemp = new System.TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0);
-            long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) 
-                        * 1000) 
-                        / System.TimeSpan.TicksPerMillisecond)));
-            string strMicroSec = ((long)(microsec)).ToString();
-            if ((strMicroSec.Length > 6)) {
-                strMicroSec = strMicroSec.Substring(0, 6);
-            }
-            dmtftimespan = string.Concat(dmtftimespan, strMicroSec.PadLeft(6, '0'));
-            dmtftimespan = string.Concat(dmtftimespan, ":000");
-            return dmtftimespan;
-        }
-        
-        public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod, out System.Management.ManagementPath Job) {
-            if ((isEmbedded == false)) {
-                System.Management.ManagementBaseObject inParams = null;
-                inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfTimeInterval(((System.TimeSpan)(TimeoutPeriod)));
-                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
-                Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
-                }
-                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
-            }
-            else {
-                Job = null;
-                return System.Convert.ToUInt32(0);
-            }
-        }
-        
-        // Enumerator implementation for enumerating instances of the class.
-        public class VmLANEndpointCollection : object, ICollection {
-            
-            private ManagementObjectCollection privColObj;
-            
-            public VmLANEndpointCollection(ManagementObjectCollection objCollection) {
-                privColObj = objCollection;
-            }
-            
-            public virtual int Count {
-                get {
-                    return privColObj.Count;
-                }
-            }
-            
-            public virtual bool IsSynchronized {
-                get {
-                    return privColObj.IsSynchronized;
-                }
-            }
-            
-            public virtual object SyncRoot {
-                get {
-                    return this;
-                }
-            }
-            
-            public virtual void CopyTo(System.Array array, int index) {
-                privColObj.CopyTo(array, index);
-                int nCtr;
-                for (nCtr = 0; (nCtr < array.Length); nCtr = (nCtr + 1)) {
-                    array.SetValue(new VmLANEndpoint(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
-                }
-            }
-            
-            public virtual System.Collections.IEnumerator GetEnumerator() {
-                return new VmLANEndpointEnumerator(privColObj.GetEnumerator());
-            }
-            
-            public class VmLANEndpointEnumerator : object, System.Collections.IEnumerator {
-                
-                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
-                
-                public VmLANEndpointEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
-                    privObjEnum = objEnum;
-                }
-                
-                public virtual object Current {
-                    get {
-                        return new VmLANEndpoint(((System.Management.ManagementObject)(privObjEnum.Current)));
-                    }
-                }
-                
-                public virtual bool MoveNext() {
-                    return privObjEnum.MoveNext();
-                }
-                
-                public virtual void Reset() {
-                    privObjEnum.Reset();
-                }
-            }
-        }
-        
-        // TypeConverter to handle null values for ValueType properties
-        public class WMIValueTypeConverter : TypeConverter {
-            
-            private TypeConverter baseConverter;
-            
-            private System.Type baseType;
-            
-            public WMIValueTypeConverter(System.Type inBaseType) {
-                baseConverter = TypeDescriptor.GetConverter(inBaseType);
-                baseType = inBaseType;
-            }
-            
-            public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) {
-                return baseConverter.CanConvertFrom(context, srcType);
-            }
-            
-            public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) {
-                return baseConverter.CanConvertTo(context, destinationType);
-            }
-            
-            public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
-                return baseConverter.ConvertFrom(context, culture, value);
-            }
-            
-            public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) {
-                return baseConverter.CreateInstance(context, dictionary);
-            }
-            
-            public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetCreateInstanceSupported(context);
-            }
-            
-            public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) {
-                return baseConverter.GetProperties(context, value, attributeVar);
-            }
-            
-            public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetPropertiesSupported(context);
-            }
-            
-            public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValues(context);
-            }
-            
-            public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesExclusive(context);
-            }
-            
-            public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) {
-                return baseConverter.GetStandardValuesSupported(context);
-            }
-            
-            public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) {
-                if ((baseType.BaseType == typeof(System.Enum))) {
-                    if ((value.GetType() == destinationType)) {
-                        return value;
-                    }
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return  "NULL_ENUM_VALUE" ;
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((baseType == typeof(bool)) 
-                            && (baseType.BaseType == typeof(System.ValueType)))) {
-                    if ((((value == null) 
-                                && (context != null)) 
-                                && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                        return "";
-                    }
-                    return baseConverter.ConvertTo(context, culture, value, destinationType);
-                }
-                if (((context != null) 
-                            && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) {
-                    return "";
-                }
-                return baseConverter.ConvertTo(context, culture, value, destinationType);
-            }
-        }
-        
-        // Embedded class to represent WMI system Properties.
-        [TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
-        public class ManagementSystemProperties {
-            
-            private System.Management.ManagementBaseObject PrivateLateBoundObject;
-            
-            public ManagementSystemProperties(System.Management.ManagementBaseObject ManagedObject) {
-                PrivateLateBoundObject = ManagedObject;
-            }
-            
-            [Browsable(true)]
-            public int GENUS {
-                get {
-                    return ((int)(PrivateLateBoundObject["__GENUS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string CLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__CLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SUPERCLASS {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SUPERCLASS"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string DYNASTY {
-                get {
-                    return ((string)(PrivateLateBoundObject["__DYNASTY"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string RELPATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__RELPATH"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public int PROPERTY_COUNT {
-                get {
-                    return ((int)(PrivateLateBoundObject["__PROPERTY_COUNT"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string[] DERIVATION {
-                get {
-                    return ((string[])(PrivateLateBoundObject["__DERIVATION"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string SERVER {
-                get {
-                    return ((string)(PrivateLateBoundObject["__SERVER"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string NAMESPACE {
-                get {
-                    return ((string)(PrivateLateBoundObject["__NAMESPACE"]));
-                }
-            }
-            
-            [Browsable(true)]
-            public string PATH {
-                get {
-                    return ((string)(PrivateLateBoundObject["__PATH"]));
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1601498b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ComputerSystem.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ComputerSystem.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ComputerSystem.cs
index 7c5b078..e5b2258 100755
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ComputerSystem.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ComputerSystem.cs
@@ -1447,8 +1447,8 @@
                 inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestReplicationStateChange", inParams, null);
                 Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null) {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }
@@ -1462,12 +1462,13 @@
             if ((isEmbedded == false)) {
                 System.Management.ManagementBaseObject inParams = null;
                 inParams = PrivateLateBoundObject.GetMethodParameters("RequestStateChange");
-                inParams["RequestedState"] = ((ushort)(RequestedState));
-                inParams["TimeoutPeriod"] = ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
+                inParams["RequestedState"] = RequestedState;
+                inParams["TimeoutPeriod"] = null; // ToDmtfDateTime(((System.DateTime)(TimeoutPeriod)));
                 System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RequestStateChange", inParams, null);
                 Job = null;
-                if ((outParams.Properties["Job"] != null)) {
-                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                if ((outParams.Properties["Job"] != null) && outParams.Properties["Job"].Value != null)
+                {
+                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].Value.ToString());
                 }
                 return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
             }