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

[01/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Updated Branches:
  refs/heads/hyperv [created] a27899aae


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..fddd23a
--- /dev/null
+++ b/plugins/hypervisors/hyperv/test/com/cloud/hypervisor/hyperv/test/HypervDirectConnectResourceTest.java
@@ -0,0 +1,938 @@
+// 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.
+package com.cloud.hypervisor.hyperv.test;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.OutputStream;
+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;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.CreateStoragePoolCommand;
+import com.cloud.agent.api.DeleteStoragePoolCommand;
+import com.cloud.agent.api.GetHostStatsAnswer;
+import com.cloud.agent.api.GetHostStatsCommand;
+import com.cloud.agent.api.GetStorageStatsAnswer;
+import com.cloud.agent.api.GetStorageStatsCommand;
+import com.cloud.agent.api.GetVmStatsAnswer;
+import com.cloud.agent.api.GetVmStatsCommand;
+import com.cloud.agent.api.ModifyStoragePoolCommand;
+import com.cloud.agent.api.StartAnswer;
+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.StopAnswer;
+import com.cloud.agent.api.StopCommand;
+import com.cloud.agent.api.storage.CreateAnswer;
+import com.cloud.agent.api.storage.CreateCommand;
+import com.cloud.agent.api.storage.DestroyCommand;
+import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
+import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.hypervisor.hyperv.resource.HypervDirectConnectResource;
+import com.cloud.network.Networks.RouterPrivateIpStrategy;
+import com.cloud.serializer.GsonHelper;
+import com.cloud.storage.Storage;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.utils.PropertiesUtil;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+/**
+ * Functional test suit for Hyper-V plugin.
+ *
+ * mvn clean build -DskipTests=false
+ **/
+public class HypervDirectConnectResourceTest {
+
+    private static final Logger s_logger = Logger
+            .getLogger(HypervDirectConnectResourceTest.class.getName());
+
+    // TODO: make this a config parameter
+    private static final String sampleLegitDiskImageURL = "http://s3-eu-west-1.amazonaws.com/cshv3eu/SmallDisk.vhdx";
+    private static final Gson s_gson = GsonHelper.getGson();
+    private static final HypervDirectConnectResource s_hypervresource =
+            new HypervDirectConnectResource();
+
+    private static String s_testLocalStoreUUID =
+            "5fe2bad3-d785-394e-9949-89786b8a63d2";
+    private static String s_testLocalStorePath = "." + File.separator
+            + "var" + File.separator + "test" + File.separator + "storagepool";
+    private static String s_testSecondaryStoreLocalPath = "."
+            + File.separator
+            + "var" + File.separator + "test" + File.separator + "secondary";
+
+    // TODO: differentiate between NFS and HTTP template URLs.
+    private static String s_testSampleTemplateUUID =
+            "TestCopiedLocalTemplate.vhdx";
+    private static String s_testSampleTemplateURL = s_testSampleTemplateUUID;
+
+    // test volumes are both a minimal size vhdx. Changing the extension to .vhd
+    // makes on corrupt.
+    private static String s_testSampleVolumeWorkingUUID =
+            "TestVolumeLegit.vhdx";
+    private static String s_testSampleVolumeWorkingUUIDNoExt =
+            "TestVolumeLegit";
+    private static String s_testSampleVolumeCorruptUUID =
+            "TestVolumeCorrupt.vhd";
+    private static String s_testSampleVolumeTempUUID =
+            "TestVolumeTemp.vhdx";
+    private static String s_testSampleVolumeWorkingURIJSON;
+    private static String s_testSampleVolumeCorruptURIJSON;
+    private static String s_testSampleVolumeTempURIJSON;
+
+    private static String s_testSampleTemplateURLJSON;
+    private static String s_testLocalStorePathJSON;
+    private static String s_agentExecutable;
+    private static Process s_agentProc;
+    private static String s_testPrimaryDataStoreHost;
+
+    public HypervDirectConnectResourceTest() {
+    }
+
+    /**
+     * Prep test environment.
+     **/
+    @Before
+    public final void setUp() throws ConfigurationException {
+        // Obtain script locations from agent.properties
+        final Map<String, Object> params =
+                PropertiesUtil.toMap(loadProperties());
+        // Used to create existing StoragePool in preparation for the
+        // ModifyStoragePool
+        params.put("local.storage.uuid", s_testLocalStoreUUID);
+
+        // Make sure secondary store is available.
+        File testSecondarStoreDir = new File(s_testSecondaryStoreLocalPath);
+        if (!testSecondarStoreDir.exists()) {
+            testSecondarStoreDir.mkdirs();
+        }
+        Assert.assertTrue("Need to be able to create the folder "
+                + s_testSecondaryStoreLocalPath,
+                testSecondarStoreDir.exists());
+        try {
+            params.put("local.secondary.storage.path",
+                    testSecondarStoreDir.getCanonicalPath());
+        } catch (IOException e1) {
+            // TODO Auto-generated catch block
+            Assert.fail("No canonical path for "
+                    + testSecondarStoreDir.getAbsolutePath());
+        }
+
+        // Clean up old test files in local storage folder:
+        File testPoolDir = new File(s_testLocalStorePath);
+        if (!testPoolDir.exists()) {
+            testPoolDir.mkdirs();
+        }
+        Assert.assertTrue(
+                "To simulate local file system Storage Pool, "
+                        + " you need folder at "
+                        + testPoolDir.getPath(), testPoolDir.exists()
+                        && testPoolDir.isDirectory());
+        try {
+            s_testLocalStorePath = testPoolDir.getCanonicalPath();
+        } catch (IOException e) {
+            Assert.fail("No canonical path for "
+                    + testPoolDir.getAbsolutePath());
+        }
+        params.put("local.storage.path", s_testLocalStorePath);
+
+        File testVolWorks =
+                new File(s_testLocalStorePath + File.separator
+                        + s_testSampleVolumeWorkingUUID);
+        if (!testVolWorks.exists()) {
+            ReadableByteChannel rbc;
+            try {
+                URL sampleLegitDiskImageURL = new URL("http://s3-eu-west-1.amazonaws.com/cshv3eu/SmallDisk.vhdx");
+                rbc = Channels.newChannel(sampleLegitDiskImageURL.openStream());
+                FileOutputStream fos = new FileOutputStream(testVolWorks);
+                fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+		}
+        Assert.assertTrue(
+                "Need to put a sample working virtual disk at "
+                        + testVolWorks.getPath(), testVolWorks.exists());
+        try {
+            s_testSampleVolumeWorkingURIJSON =
+                    s_gson.toJson(testVolWorks.getCanonicalPath());
+        } catch (IOException e) {
+            Assert.fail("No canonical path for "
+                    + testPoolDir.getAbsolutePath());
+        }
+
+        FilenameFilter vhdsFilt = new FilenameFilter() {
+            @Override
+            public boolean accept(final File directory, final String fileName) {
+                return fileName.endsWith(".vhdx") || fileName.endsWith(".vhd");
+            }
+        };
+        for (File file : testPoolDir.listFiles(vhdsFilt)) {
+            if (file.getName().equals(testVolWorks.getName())) {
+                continue;
+            }
+            Assert.assertTrue("Should have deleted file " + file.getPath(),
+                    file.delete());
+            s_logger.info("Cleaned up by delete file " + file.getPath());
+        }
+
+        s_testSampleVolumeTempURIJSON =
+                createTestDiskImageFromExistingImage(testVolWorks,
+                        s_testLocalStorePath, s_testSampleVolumeTempUUID);
+        s_logger.info("Created " + s_testSampleVolumeTempURIJSON);
+        s_testSampleVolumeCorruptURIJSON =
+                createTestDiskImageFromExistingImage(testVolWorks,
+                        s_testLocalStorePath, s_testSampleVolumeCorruptUUID);
+        s_logger.info("Created " + s_testSampleVolumeCorruptURIJSON);
+        createTestDiskImageFromExistingImage(testVolWorks,
+                s_testLocalStorePath,
+                s_testSampleTemplateUUID);
+        s_testSampleTemplateURLJSON = s_testSampleTemplateUUID;
+        s_logger.info("Created " + s_testSampleTemplateURLJSON
+                + " in local storage.");
+
+        // Create secondary storage template:
+        createTestDiskImageFromExistingImage(testVolWorks,
+                testSecondarStoreDir.getAbsolutePath(),
+                "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx");
+        s_logger.info("Created " + "af39aa7f-2b12-37e1-86d3-e23f2f005101.vhdx"
+                + " in secondary (NFS) storage.");
+
+        s_testLocalStorePathJSON = s_gson.toJson(s_testLocalStorePath);
+
+        String agentIp = (String) params.get("ipaddress");
+        s_logger.info("Test using agent IP address " + agentIp);
+        params.put("agentIp", agentIp);
+        setTestJsonResult(params);
+        s_hypervresource.configure("hypervresource", params);
+        // Verify sample template is in place storage pool
+        s_logger.info("setUp complete, sample StoragePool at "
+                + s_testLocalStorePathJSON
+                + " sample template at " + s_testSampleTemplateURLJSON);
+
+        s_agentExecutable = (String) params.get("agent.executable");
+        s_testPrimaryDataStoreHost = (String) params.get("ipaddress");
+        agentCreation();
+    }
+
+    private String createTestDiskImageFromExistingImage(final File srcFile,
+            final String dstPath,
+            final String dstFileName) {
+        String newFileURIJSON = null;
+        File testVolTemp = new File(dstPath + File.separator + dstFileName);
+        try {
+            Files.copy(srcFile.toPath(), testVolTemp.toPath());
+        } catch (IOException e) {
+            ; // NOP
+        }
+        Assert.assertTrue(
+                "Should be a temporary file created from the valid volume) at "
+                        + testVolTemp.getPath(), testVolTemp.exists());
+        try {
+            newFileURIJSON = s_gson.toJson(testVolTemp.getCanonicalPath());
+        } catch (IOException e) {
+            Assert.fail("No file at " + testVolTemp.getAbsolutePath());
+        }
+        return newFileURIJSON;
+    }
+
+    @Test
+    public final void testGetVmStatsCommand() {
+        // Sample GetVmStatsCommand
+        List<String> vmNames = new ArrayList<String>();
+        vmNames.add("i-2-11-VM");
+        GetVmStatsCommand cmd =
+                new GetVmStatsCommand(vmNames, "1", "localhost");
+
+        s_hypervresource.executeRequest(cmd);
+        GetVmStatsAnswer ans =
+                (GetVmStatsAnswer) s_hypervresource.executeRequest(cmd);
+        Assert.assertTrue(ans.getDetails(), ans.getResult());
+    }
+
+    public final void testStartupCommand() {
+        StartupRoutingCommand defaultStartRoutCmd = new StartupRoutingCommand(
+                0, 0, 0, 0, null, Hypervisor.HypervisorType.Hyperv,
+                RouterPrivateIpStrategy.HostLocal,
+                new HashMap<String, VmState>());
+
+        // Identity within the data centre is decided by CloudStack kernel,
+        // and passed via ServerResource.configure()
+        defaultStartRoutCmd.setDataCenter("1");
+        defaultStartRoutCmd.setPod("1");
+        defaultStartRoutCmd.setCluster("1");
+        defaultStartRoutCmd.setGuid("1");
+        defaultStartRoutCmd.setName("1");
+        defaultStartRoutCmd.setPrivateIpAddress("1");
+        defaultStartRoutCmd.setStorageIpAddress("1");
+        defaultStartRoutCmd.setCpus(12);
+
+        // TODO: does version need to be hard coded.
+        defaultStartRoutCmd.setVersion("4.2.0");
+
+        StartupCommand scmd = defaultStartRoutCmd;
+
+        Command[] cmds = {scmd};
+        String cmdsStr = s_gson.toJson(cmds);
+        s_logger.debug("Commands[] toJson is " + cmdsStr);
+
+        Command[] result = s_gson.fromJson(cmdsStr, Command[].class);
+        s_logger.debug("Commands[] fromJson is " + s_gson.toJson(result));
+        s_logger.debug("Commands[] first element has type"
+                + result[0].toString());
+    }
+
+    // @Test
+    public final void testJson() {
+        StartupStorageCommand sscmd = null;
+        com.cloud.agent.api.StoragePoolInfo pi =
+                new com.cloud.agent.api.StoragePoolInfo(
+                        "test123", "192.168.0.1", "c:\\", "c:\\",
+                        StoragePoolType.Filesystem, 100L, 50L);
+
+        sscmd = new StartupStorageCommand();
+        sscmd.setPoolInfo(pi);
+        sscmd.setGuid(pi.getUuid());
+        sscmd.setDataCenter("foo");
+        sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
+        s_logger.debug("StartupStorageCommand fromJson is "
+                + s_gson.toJson(sscmd));
+    }
+
+    @Test
+    public final void testBadGetVmStatsCommand() {
+        // Sample GetVmStatsCommand
+        List<String> vmNames = new ArrayList<String>();
+        vmNames.add("FakeVM");
+        GetVmStatsCommand vmStatsCmd =
+                new GetVmStatsCommand(vmNames, "1", "localhost");
+        GetVmStatsAnswer ans =
+                (GetVmStatsAnswer) s_hypervresource.executeRequest(vmStatsCmd);
+        Assert.assertTrue(ans.getDetails(), ans.getResult());
+    }
+
+    @Test
+    public final void testCreateStoragePoolCommand() {
+        String folderName = "." + File.separator + "Dummy";
+        StoragePoolVO pool = createTestStoragePoolVO(folderName);
+
+        CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
+        s_logger.debug("TestCreateStoragePoolCommand sending "
+                + s_gson.toJson(cmd));
+
+        Answer ans = s_hypervresource.executeRequest(cmd);
+        Assert.assertTrue(ans.getResult());
+    }
+
+    @Test
+    public final void testModifyStoragePoolCommand() {
+        // Create dummy folder
+        String folderName = "." + File.separator + "Dummy";
+        StoragePoolVO pool = createTestStoragePoolVO(folderName);
+
+        ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(
+                true, pool, folderName);
+        Answer ans = s_hypervresource.executeRequest(cmd);
+        Assert.assertTrue(ans.getResult());
+
+        DeleteStoragePoolCommand delCmd =
+                new DeleteStoragePoolCommand(pool, folderName);
+        Answer ans2 = s_hypervresource.executeRequest(delCmd);
+        Assert.assertTrue(ans2.getResult());
+    }
+
+    // Check
+    @Test
+    public final void testModifyStoragePoolCommand2() {
+        // Should return existing pool
+        // Create dummy folder
+        String folderName = "." + File.separator + "Dummy";
+        File folder = new File(folderName);
+        if (!folder.exists()) {
+            if (!folder.mkdir()) {
+                Assert.assertTrue(false);
+            }
+        }
+
+        // Use same spec for pool
+        s_logger.info("Createing pool at : " + folderName);
+
+        StoragePoolVO pool = new StoragePoolVO(StoragePoolType.Filesystem,
+                "127.0.0.1", -1, folderName);
+        pool.setUuid(s_testLocalStoreUUID);
+
+        ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(
+                true, pool, folderName);
+        Answer ans = s_hypervresource.executeRequest(cmd);
+        Assert.assertTrue(ans.getResult());
+
+        DeleteStoragePoolCommand delCmd =
+                new DeleteStoragePoolCommand(pool, folderName);
+        Answer ans2 = s_hypervresource.executeRequest(delCmd);
+        Assert.assertTrue(ans2.getResult());
+    }
+
+    public final StoragePoolVO createTestStoragePoolVO(
+            final String folderName) {
+        File folder = new File(folderName);
+        if (!folder.exists()) {
+            if (!folder.mkdir()) {
+                Assert.assertTrue(false);
+            }
+        }
+
+        // Use same spec for pool
+        s_logger.info("Createing pool at : " + folderName);
+
+        StoragePoolVO pool = new StoragePoolVO(StoragePoolType.Filesystem,
+                "127.0.0.1", -1, folderName);
+        return pool;
+    }
+
+    @Test
+    public final void testInitialize() {
+        StartupCommand[] startCmds = s_hypervresource.initialize();
+        Command[] cmds = new Command[] {startCmds[0], startCmds[1]};
+        String result = s_gson.toJson(cmds);
+        if (result == null) {
+            result = "NULL";
+        }
+        s_logger.debug("TestInitialize returned " + result);
+        s_logger.debug("TestInitialize expected " + _setTestJsonResultStr);
+        Assert.assertTrue("StartupCommand[] not what we expected",
+                _setTestJsonResultStr.equals(result));
+        return;
+    }
+
+    @Test
+    public final void testPrimaryStorageDownloadCommandHTTP() {
+        PrimaryStorageDownloadCommand cmd = samplePrimaryDownloadCommand();
+        cmd.setUrl("http://s3-eu-west-1.amazonaws.com/cshv3eu/SmallDisk.vhdx");
+        corePrimaryStorageDownloadCommandTestCycle(cmd);
+    }
+
+    private void corePrimaryStorageDownloadCommandTestCycle(
+            final PrimaryStorageDownloadCommand cmd) {
+        PrimaryStorageDownloadAnswer ans =
+                (PrimaryStorageDownloadAnswer) s_hypervresource
+                        .executeRequest(cmd);
+        if (!ans.getResult()) {
+            s_logger.error(ans.getDetails());
+        } else {
+            s_logger.debug(ans.getDetails());
+        }
+
+        Assert.assertTrue(ans.getDetails(), ans.getResult());
+        // Test that returned URL works.
+        // CreateCommand createCmd = CreateCommandSample();
+        // CreateCommand testCreateCmd = new
+        // CreateCommand(createCmd.getDiskCharacteristics(),
+        // ans.getInstallPath(), createCmd.getPool());
+        // CreateAnswer ans2 =
+        // (CreateAnswer)s_hypervresource.executeRequest(testCreateCmd);
+        // Assert.assertTrue(ans2.getDetails(), ans2.getResult());
+    }
+
+    private PrimaryStorageDownloadCommand samplePrimaryDownloadCommand() {
+        String cmdJson =
+                "{\"localPath\":"
+                        + s_testLocalStorePathJSON
+                        + ",\"poolUuid\":\""
+                        + s_testLocalStoreUUID
+                        + "\",\"poolId\":201,"
+                        + "\"secondaryStorageUrl\":"
+                        + "\"nfs://10.70.176.36/mnt/cshv3/secondarystorage\","
+                        + "\"primaryStorageUrl\":"
+                        + "\"nfs://10.70.176.29E:\\\\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}";
+        PrimaryStorageDownloadCommand cmd = s_gson.fromJson(cmdJson,
+                PrimaryStorageDownloadCommand.class);
+        return cmd;
+    }
+
+    public final CreateCommand createCommandSample() {
+        String sample =
+                "{\"volId\":17,\"pool\":{\"id\":201,\"uuid\":\""
+                        + s_testLocalStoreUUID
+                        + "\",\"host\":\"10.70.176.29\""
+                        + ",\"path\":"
+                        + s_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\":"
+                        + s_testSampleTemplateURLJSON + ",\"wait\":0}";
+        CreateCommand cmd = s_gson.fromJson(sample, CreateCommand.class);
+        return cmd;
+    }
+
+    @Test
+    public final void testCreateCommand() {
+        String sample =
+                "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\""
+                        + s_testLocalStoreUUID
+                        + "\",\"host\":\"10.70.176.29\""
+                        + ",\"path\":"
+                        + s_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\":"
+                        + s_testSampleTemplateURLJSON
+                        + ",\"contextMap\":{},\"wait\":0}";
+
+        File destDir = new File(s_testLocalStorePath);
+        Assert.assertTrue(destDir.isDirectory());
+        File testSampleTemplateURLFile =
+                new File(s_testLocalStorePath
+                        + File.separator
+                        + s_gson.fromJson(s_testSampleTemplateURLJSON,
+                                String.class));
+        Assert.assertTrue(
+                "The template that create should make"
+                        + " volumes from is missing from path "
+                        + testSampleTemplateURLFile.getPath(),
+                testSampleTemplateURLFile.exists());
+
+        int fileCount = destDir.listFiles().length;
+        s_logger.debug(" test local store has " + fileCount + "files");
+        // Test requires there to be a template at the tempalteUrl, which is its
+        // location in the local file system.
+        CreateCommand cmd = s_gson.fromJson(sample, CreateCommand.class);
+        CreateAnswer ans = (CreateAnswer) s_hypervresource.executeRequest(cmd);
+        Assert.assertTrue(ans.getDetails(), ans.getResult());
+        Assert.assertTrue("CreateCommand should add a file to the folder",
+                fileCount + 1 == destDir.listFiles().length);
+        File newFile = new File(ans.getVolume().getPath());
+        Assert.assertTrue("The new file should have a size greater than zero",
+                newFile.length() > 0);
+        newFile.delete();
+    }
+
+    @Test
+    public final void testStartCommandCorruptDiskImage() {
+        String sampleStart =
+                "{\"vm\":{\"id\":16,\"name\":\"i-3-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\":["
+                        + "{\"id\":18,\"name\":\""
+                        + s_testSampleVolumeCorruptUUID
+                        + "\","
+                        + "\"mountPoint\":"
+                        + s_testSampleVolumeCorruptURIJSON
+                        + ","
+                        + "\"path\":"
+                        + s_testSampleVolumeCorruptURIJSON
+                        + ",\"size\":0,"
+                        + "\"type\":\"ROOT\","
+                        + "\"storagePoolType\":\"Filesystem\","
+                        + "\"storagePoolUuid\":\""
+                        + s_testLocalStoreUUID
+                        + "\""
+                        + ",\"deviceId\":0},"
+                        + "{\"id\":16,\"name\":\"Hyper-V Sample2\",\"size\":0,"
+                        + "\"type\":\"ISO\",\"storagePoolType\":\"ISO\","
+                        + "\"deviceId\":3}],"
+                        + "\"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}";
+
+        StartCommand cmd = s_gson.fromJson(sampleStart, StartCommand.class);
+        StartAnswer ans =
+                (StartAnswer) s_hypervresource.executeRequest(cmd);
+        Assert.assertFalse(ans.getDetails(), ans.getResult());
+    }
+
+    @Test
+    public final void testStartStopCommand() {
+        String sample = getSampleStartCommand();
+        StartAnswer sans = simpleVmStart(sample);
+        Assert.assertTrue(sans.getDetails(), sans.getResult());
+        StopAnswer stopAns = simpleVmStop();
+        Assert.assertTrue(stopAns.getDetails(), stopAns.getResult());
+    }
+
+    @Test
+    public final void testStartStartCommand() {
+        String sample = getSampleStartCommand();
+
+        StartAnswer sans = simpleVmStart(sample);
+        Assert.assertTrue(sans.getDetails(), sans.getResult());
+        simpleVmStart(sample);
+
+        StopAnswer ans = simpleVmStop();
+        Assert.assertTrue(ans.getDetails(), ans.getResult());
+    }
+
+    private StopAnswer simpleVmStop() {
+        String sampleStop =
+                "{\"isProxy\":false,\"vmName\":\"i-2-17-VM\","
+                        + "\"contextMap\":{},\"wait\":0}";
+        StopCommand cmd = s_gson.fromJson(sampleStop, StopCommand.class);
+        StopAnswer ans = (StopAnswer) s_hypervresource.executeRequest(cmd);
+        return ans;
+    }
+
+    private StartAnswer simpleVmStart(final String sample) {
+        StartCommand cmd = s_gson.fromJson(sample, StartCommand.class);
+        s_logger.info("StartCommand sample " + s_gson.toJson(cmd));
+        StartAnswer ans =
+                (StartAnswer) s_hypervresource.executeRequest(cmd);
+        return ans;
+    }
+
+    @Test
+    public final void testDestroyCommand() {
+        // TODO: how does the command vary when we are only deleting a vm versus
+        // deleting a volume?
+
+//        String sample2 = "{\"volume\":" + getSampleVolumeObjectTO() + "}";
+
+        String sample2 =
+                "{\"volume\":{\"name\":\"" + s_testSampleVolumeWorkingUUIDNoExt
+                        + "\",\"storagePoolType\":\"Filesystem\","
+                        + "\"mountPoint\":"
+                        + s_testLocalStorePathJSON
+                        + ",\"path\":" + s_testSampleVolumeTempURIJSON
+                        + ",\"storagePoolUuid\":\"" + s_testLocalStoreUUID
+                        + "\","
+                        + "\"type\":\"ROOT\",\"id\":9,\"size\":0}}";
+        DestroyCommand cmd = s_gson.fromJson(sample2, DestroyCommand.class);
+        Answer ans = (Answer) s_hypervresource.executeRequest(cmd);
+        Assert.assertTrue(ans.getDetails(), ans.getResult());
+    }
+
+    @Test
+    public final void testGetStorageStatsCommand() {
+        // TODO: Update sample data to unsure it is using correct info.
+        String sample =
+                "{\"id\":\""
+                        + s_testLocalStoreUUID
+                        + "\",\"localPath\":"
+                        + s_testLocalStorePathJSON
+                        + ","
+                        + "\"pooltype\":\"Filesystem\","
+                        + "\"contextMap\":{},\"wait\":0}";
+
+        s_logger.info("Sample JSON: " + sample);
+
+        GetStorageStatsCommand cmd =
+                s_gson.fromJson(sample, GetStorageStatsCommand.class);
+        s_hypervresource.executeRequest(cmd);
+        GetStorageStatsAnswer ans =
+                (GetStorageStatsAnswer) s_hypervresource.executeRequest(cmd);
+        Assert.assertTrue(ans.getDetails(), ans.getResult());
+        Assert.assertTrue(ans.getByteUsed() != ans.getCapacityBytes());
+    }
+
+    @After
+    public final void agentTerminate() {
+        // Write carriage return line feed to script's stdin
+        OutputStream scriptInput = s_agentProc.getOutputStream();
+        OutputStreamWriter siw = new OutputStreamWriter(scriptInput);
+        try {
+            BufferedWriter writer = new BufferedWriter(siw);
+            writer.write("\r\n");
+            writer.flush();
+            writer.close();
+        } catch (IOException ex) {
+            s_logger.debug("Error closing agent at " + s_agentExecutable
+                    + " message " + ex.getMessage());
+        }
+    }
+
+    private void agentCreation() {
+        // Launch script
+        try {
+            List<String> exeArgs = new ArrayList<String>();
+
+            exeArgs.add(s_agentExecutable);
+            exeArgs.add("--console");
+
+            // when we launch from the shell, we need to use Cygwin's path to
+            // the exe
+            ProcessBuilder builder = new ProcessBuilder(exeArgs);
+            builder.redirectErrorStream(true);
+            s_agentProc = builder.start();
+            Thread.sleep(4000);
+        } catch (Exception ex) {
+            s_logger.debug("Error calling starting aget at "
+                    + s_agentExecutable
+                    + " message " + ex.getMessage());
+        }
+    }
+
+    @Test
+    public final void testGetHostStatsCommand() {
+        // Arrange
+        long hostIdVal = 123;
+        GetHostStatsCommand cmd = new GetHostStatsCommand("1", "testHost",
+                hostIdVal);
+
+        // Act
+        GetHostStatsAnswer ans = (GetHostStatsAnswer) s_hypervresource
+                .executeRequest(cmd);
+
+        // Assert
+        Assert.assertTrue(ans.getResult());
+        Assert.assertTrue(0.0 < ans.getTotalMemoryKBs());
+        Assert.assertTrue(0.0 < ans.getFreeMemoryKBs());
+        Assert.assertTrue(0.0 <= ans.getNetworkReadKBs());
+        Assert.assertTrue(0.0 <= ans.getNetworkWriteKBs());
+        Assert.assertTrue(0.0 <= ans.getCpuUtilization());
+        Assert.assertTrue(100 >= ans.getCpuUtilization());
+        Assert.assertTrue(ans.getEntityType().equals("host"));
+        Assert.assertTrue(ans.getDetails() == null);
+    }
+
+    public static Properties loadProperties() throws ConfigurationException {
+        Properties properties = new Properties();
+        final File file = PropertiesUtil.findConfigFile("agent.properties");
+        if (file == null) {
+            throw new ConfigurationException(
+                    "Unable to find agent.properties.");
+        }
+
+        s_logger.info("agent.properties found at " + file.getAbsolutePath());
+
+        try {
+            properties.load(new FileInputStream(file));
+        } catch (final FileNotFoundException ex) {
+            throw new CloudRuntimeException("Cannot find the file: "
+                    + file.getAbsolutePath(), ex);
+        } catch (final IOException ex) {
+            throw new CloudRuntimeException("IOException in reading "
+                    + file.getAbsolutePath(), ex);
+        }
+        return properties;
+    }
+
+    private String _setTestJsonResultStr = null;
+
+    public final void setTestJsonResult(final Map<String, Object> params) {
+        File dir = new File((String) params.get("DefaultVirtualDiskFolder"));
+        long usableCapacity = dir.getUsableSpace() - 4294967296L;
+        long totalSpace = dir.getTotalSpace() - 4294967296L;
+
+        // TODO: add test to verify capacity statistics change
+        _setTestJsonResultStr =
+                String.format(
+                        "[{\"com.cloud.agent.api.StartupRoutingCommand\":{"
+                            + "\"cpus\":%s,"
+                    + "\"speed\":%s,"
+                    + "\"memory\":%s,"
+                    + "\"dom0MinMemory\":%s,"
+                    + "\"poolSync\":false,"
+                    + "\"vms\":{},"
+                    + "\"caps\":\"hvm\","
+                    + "\"hypervisorType\":\"Hyperv\","
+                    + "\"hostDetails\":{"
+                    + "\"com.cloud.network.Networks.RouterPrivateIpStrategy\":"
+                    + "\"HostLocal\""
+                    + "},"
+                    + "\"type\":\"Routing\","
+                    + "\"dataCenter\":%s,"
+                    + "\"pod\":%s,"
+                    + "\"cluster\":%s,"
+                    + "\"guid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\","
+                    + "\"name\":\"hypervresource\","
+                    + "\"version\":\"4.2.0\","
+                    + "\"privateIpAddress\":%s,"
+                    + "\"privateMacAddress\":%s,"
+                    + "\"privateNetmask\":%s,"
+                    + "\"storageIpAddress\":%s,"
+                    + "\"storageNetmask\":%s,"
+                    + "\"storageMacAddress\":%s,"
+                    + "\"gatewayIpAddress\":%s,"
+                    + "\"contextMap\":{},"
+                    + "\"wait\":0"
+                    + "}},"
+                    + "{\"com.cloud.agent.api.StartupStorageCommand\":{"
+                    + "\"totalSize\":0,"
+                    + "\"poolInfo\":{"
+                    + "\"uuid\":\"16f85622-4508-415e-b13a-49a39bb14e4d\","
+                    + "\"host\":%s,"
+                    + "\"localPath\":%s,"
+                    + "\"hostPath\":%s,"
+                    + "\"poolType\":\"Filesystem\","
+                    + "\"capacityBytes\":%s,"
+                    + "\"availableBytes\":%s"
+                    + "},"
+                    + "\"resourceType\":\"STORAGE_POOL\","
+                    + "\"hostDetails\":{},"
+                    + "\"type\":\"Storage\","
+                    + "\"dataCenter\":\"1\","
+                    + "\"guid\":"
+                    + "\"16f85622-4508-415e-b13a-49a39bb14e4d\","
+                    + "\"contextMap\":{},"
+                    + "\"wait\":0"
+                    + "}}]",
+                        params.get("TestCoreCount"),
+                        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
+                                .get("private.mac.address")),
+                        s_gson.toJson((String) params.get(
+                                "private.ip.netmask")),
+                        s_gson.toJson((String) params.get("ipaddress")),
+                        s_gson.toJson((String) params.get(
+                                "private.ip.netmask")),
+                        s_gson.toJson((String) params
+                                .get("private.mac.address")),
+                        s_gson.toJson((String) params.get(
+                                "gateway.ip.address")),
+                        s_gson.toJson((String) params.get("ipaddress")),
+                        s_gson.toJson((String) params
+                                .get("DefaultVirtualDiskFolder")),
+                        s_gson.toJson((String) params
+                                .get("DefaultVirtualDiskFolder")),
+                        s_gson.toJson(totalSpace),
+                        s_gson.toJson(usableCapacity)
+                        );
+    }
+
+    public static String getSamplePrimaryDataStoreInfo() {
+        String samplePrimaryDataStoreInfo =
+                "{\"org.apache.cloudstack.storage.to.PrimaryDataStoreTO\":"
+                        + "{\"uuid\":\"" + s_testLocalStoreUUID + "\","
+                        + "\"id\":201,"
+                        + "\"host\":\"" + s_testPrimaryDataStoreHost + "\","
+                        + "\"type\":\"Filesystem\"," // Not used in
+                                                     // PrimaryDataStoreTO
+                        + "\"poolType\":\"Filesystem\"," // Not used in
+                        // PrimaryDataStoreTO
+                        + "\"path\":" + s_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\":\"" + s_testSampleVolumeWorkingUUIDNoExt + "\","
+                        + "\"size\":52428800,"
+                        + "\"volumeId\":10,"
+                        // "\"vmName\":\"i-3-5-VM\"," + // TODO: required?
+                        + "\"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/1d0a931d/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index ca41dff..829064d 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -40,6 +40,7 @@
     <module>event-bus/rabbitmq</module>
     <module>hypervisors/baremetal</module>
     <module>hypervisors/ucs</module>
+    <module>hypervisors/hyperv</module>
     <module>network-elements/elastic-loadbalancer</module>
     <module>network-elements/ovs</module>
     <module>network-elements/nicira-nvp</module>
@@ -119,6 +120,17 @@
       </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>


[04/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..040882e
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VmLANEndpoint.cs
@@ -0,0 +1,1342 @@
+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/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Readme.txt
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Readme.txt b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Readme.txt
new file mode 100644
index 0000000..0fc8d7c
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Readme.txt
@@ -0,0 +1,20 @@
+Classes were generated on a hyper-v server using the Visual Studio GUI, but you can do the same using
+mgmtclassgen.exe.  Below are some examples:
+
+mgmtclassgen.exe Msvm_ComputerSystem /N root\virtualization /L CS /O CloudStack.Plugin.WmiWrappers /P ComputerSystem.cs
+mgmtclassgen.exe Msvm_VirtualSystemManagementService /N root\virtualization /L CS /O CloudStack.Plugin.WmiWrappers /P VirtualSystemManagementService.cs
+mgmtclassgen.exe Msvm_VirtualSystemGlobalSettingData /N root\virtualization /L CS /O CloudStack.Plugin.WmiWrappers /P VirtualSystemGlobalSettingData.cs
+
+
+BUT, you have to tweak the generated code, because it does not deal with NULL method parameters properly.
+E.g. when a method completes immediately, the returned out parameters include a "Job" property that has a NULL value.
+The generated code will attempt to call ToString() on this NULL value.
+
+ALSO, you have to tweak the generated code to expose useful details such as the WMI name for the class.
+E.g. the generated code creates a wrapper called class ComputerSystem for WMI objects of class Msvm_ComputerSystem.
+Thus, there is a mismatch in the class name and the corresponding WMI class, and the WMI class name is a private
+constant static member.  The tweak involves making this member public.
+
+
+
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..57fe6f3
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
@@ -0,0 +1,146 @@
+<?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>
+  </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="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" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <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>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="Readme.txt" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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>


[37/54] Add ability to pass kvp data via the key cloudstack-vm-userdata

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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
new file mode 100755
index 0000000..7c5b078
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ComputerSystem.cs
@@ -0,0 +1,1800 @@
+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_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\\v2";
+        
+        // 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\\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 IsFailedOverReplicationTypeNull {
+            get {
+                if ((curObj["FailedOverReplicationType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Type of failover that was performed for the virtual machine.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public FailedOverReplicationTypeValues FailedOverReplicationType {
+            get {
+                if ((curObj["FailedOverReplicationType"] == null)) {
+                    return ((FailedOverReplicationTypeValues)(System.Convert.ToInt32(4)));
+                }
+                return ((FailedOverReplicationTypeValues)(System.Convert.ToInt32(curObj["FailedOverReplicationType"])));
+            }
+        }
+        
+        [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 IsLastApplicationConsistentReplicationTimeNull {
+            get {
+                if ((curObj["LastApplicationConsistentReplicationTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The time at which the last application consistent replication is received on reco" +
+            "very for the virtual machine.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime LastApplicationConsistentReplicationTime {
+            get {
+                if ((curObj["LastApplicationConsistentReplicationTime"] != null)) {
+                    return ToDateTime(((string)(curObj["LastApplicationConsistentReplicationTime"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLastReplicationTimeNull {
+            get {
+                if ((curObj["LastReplicationTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The time at which the last replication is received on recovery for the virtual ma" +
+            "chine.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime LastReplicationTime {
+            get {
+                if ((curObj["LastReplicationTime"] != null)) {
+                    return ToDateTime(((string)(curObj["LastReplicationTime"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLastReplicationTypeNull {
+            get {
+                if ((curObj["LastReplicationType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Type of the last replication that was received for the virtual machine.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public LastReplicationTypeValues LastReplicationType {
+            get {
+                if ((curObj["LastReplicationType"] == null)) {
+                    return ((LastReplicationTypeValues)(System.Convert.ToInt32(4)));
+                }
+                return ((LastReplicationTypeValues)(System.Convert.ToInt32(curObj["LastReplicationType"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLastSuccessfulBackupTimeNull {
+            get {
+                if ((curObj["LastSuccessfulBackupTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The time at which the last successful backup has completed for the virtual machin" +
+            "e.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime LastSuccessfulBackupTime {
+            get {
+                if ((curObj["LastSuccessfulBackupTime"] != null)) {
+                    return ToDateTime(((string)(curObj["LastSuccessfulBackupTime"])));
+                }
+                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 IsNumberOfNumaNodesNull {
+            get {
+                if ((curObj["NumberOfNumaNodes"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The number of non-uniform memory access (NUMA) nodes of the computer system. When Msvm_ComputerSystem represents the hosting computer system, this property contains the count of physical NUMA nodes. When Msvm_ComputerSystem represents a virtual computer system, this property contains the number of virtual NUMA nodes that are presented to the guest OS through the ACPI System Resource Affinity Table (SRAT).")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort NumberOfNumaNodes {
+            get {
+                if ((curObj["NumberOfNumaNodes"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["NumberOfNumaNodes"]));
+            }
+        }
+        
+        [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(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 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 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(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;
+                }
+            }
+        }
+        
+        [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 ShouldSerializeFailedOverReplicationType() {
+            if ((this.IsFailedOverReplicationTypeNull == 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 ShouldSerializeLastApplicationConsistentReplicationTime() {
+            if ((this.IsLastApplicationConsistentReplicationTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLastReplicationTime() {
+            if ((this.IsLastReplicationTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLastReplicationType() {
+            if ((this.IsLastReplicationTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLastSuccessfulBackupTime() {
+            if ((this.IsLastSuccessfulBackupTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumberOfNumaNodes() {
+            if ((this.IsNumberOfNumaNodesNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOnTimeInMilliseconds() {
+            if ((this.IsOnTimeInMillisecondsNull == 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 ShouldSerializeProcessID() {
+            if ((this.IsProcessIDNull == 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 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;
+        }
+        
+        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_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\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_ComputerSystem";
+            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 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\\v2";
+                }
+                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();
+        }
+        
+        public uint RequestReplicationStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RequestReplicationStateChange");
+                inParams["RequestedState"] = ((ushort)(RequestedState));
+                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());
+                }
+                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(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);
+            }
+        }
+        
+        public enum FailedOverReplicationTypeValues {
+            
+            None = 0,
+            
+            Regular = 1,
+            
+            Application_consistent = 2,
+            
+            Planned = 3,
+            
+            NULL_ENUM_VALUE = 4,
+        }
+        
+        public enum LastReplicationTypeValues {
+            
+            None = 0,
+            
+            Regular = 1,
+            
+            Application_consistent = 2,
+            
+            Planned = 3,
+            
+            NULL_ENUM_VALUE = 4,
+        }
+        
+        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 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"]));
+                }
+            }
+        }
+    }
+}


[07/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..bb484c2
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemGlobalSettingData.cs
@@ -0,0 +1,1513 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[21/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..1264906
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_IDEController.cs
@@ -0,0 +1,1610 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[11/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..d5c0bb0
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpoint.cs
@@ -0,0 +1,1390 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[36/54] Add ability to pass kvp data via the key cloudstack-vm-userdata

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ConcreteJob.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ConcreteJob.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ConcreteJob.cs
new file mode 100755
index 0000000..72989e1
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ConcreteJob.cs
@@ -0,0 +1,1826 @@
+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.
+    // 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.
+        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_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\\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 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 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 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 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(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 IsJobTypeNull {
+            get {
+                if ((curObj["JobType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates the type of Job being tracked by this object.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort JobType {
+            get {
+                if ((curObj["JobType"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["JobType"]));
+            }
+        }
+        
+        [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(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 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 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 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 ShouldSerializeCommunicationStatus() {
+            if ((this.IsCommunicationStatusNull == 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 ShouldSerializeDeleteOnCompletion() {
+            if ((this.IsDeleteOnCompletionNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDetailedStatus() {
+            if ((this.IsDetailedStatusNull == 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 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;
+        }
+        
+        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 ShouldSerializeJobType() {
+            if ((this.IsJobTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLocalOrUtcTime() {
+            if ((this.IsLocalOrUtcTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOperatingStatus() {
+            if ((this.IsOperatingStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentComplete() {
+            if ((this.IsPercentCompleteNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePrimaryStatus() {
+            if ((this.IsPrimaryStatusNull == 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\\v2: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\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_ConcreteJob";
+            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 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\\v2";
+                }
+                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"]));
+                }
+            }
+        }
+    }
+}


[54/54] git commit: updated refs/heads/hyperv to a27899a

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


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

Branch: refs/heads/hyperv
Commit: a27899aae12ceaf39f662864c87e164af7e47ee2
Parents: d0f764b
Author: Anshul Gangwar <an...@citrix.com>
Authored: Mon Oct 28 10:47:04 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Mon Oct 28 11:31:01 2013 +0530

----------------------------------------------------------------------
 .../hyperv/DotNet/ServerResource/.gitignore     |   1 +
 .../DotNet/ServerResource/.nuget/NuGet.Config   |   6 +
 .../DotNet/ServerResource/.nuget/NuGet.targets  | 136 +++++++++
 .../AgentShell/AgentSettings.Designer.cs        |   2 +-
 .../AgentShell/AgentSettings.settings           |   2 +-
 .../ServerResource/AgentShell/AgentShell.csproj |   9 +
 .../ServerResource/AgentShell/packages.config   |   3 +
 .../HypervResource/HypervResource.csproj        |   4 +-
 .../HypervResource/HypervResourceController.cs  |  33 +-
 .../ServerResource/HypervResource/IWmiCalls.cs  |  44 +++
 .../HypervResource/IWmiCallsV2.cs               |  22 ++
 .../ServerResource/HypervResource/WmiCalls.cs   | 103 ++++---
 .../ServerResource/HypervResource/WmiCallsV2.cs |  21 +-
 .../HypervResource/packages.config              |   2 +
 .../ServerResource.Tests/App.config             |  29 +-
 .../HypervResourceController1Test.cs            | 298 +++++++++++++++++++
 .../HypervResourceControllerTest.cs             | 209 ++++++-------
 .../ServerResource.Tests.csproj                 |  15 +
 .../ServerResource.Tests/packages.config        |   3 +
 .../WmiWrappers/WmiWrappers.csproj              |  20 +-
 plugins/hypervisors/hyperv/buildagent.sh        |   2 +-
 .../storagepool/TestCopiedLocalTemplate.vhdx    |   1 +
 22 files changed, 774 insertions(+), 191 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a27899aa/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/a27899aa/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/a27899aa/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/a27899aa/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 281f169..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"]));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a27899aa/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/a27899aa/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 2a3c0db..a813124 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" />
@@ -83,6 +89,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">

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a27899aa/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/a27899aa/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/a27899aa/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 2d61a6c..bdb0eae 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -118,6 +118,9 @@ namespace HypervResource
         {
         }
 
+        public IWmiCalls wmiCalls { get; set; }
+        public IWmiCallsV2 wmiCallsV2 { get; set;}
+
         // GET api/HypervResource
         public string Get()
         {
@@ -152,7 +155,7 @@ namespace HypervResource
                     share.uri = new Uri(uriStr);
 
                     string systemVmIso = (string)cmd.systemVmIso;
-                    string defaultDataPath = WmiCallsV2.GetDefaultDataRoot();
+                    string defaultDataPath = wmiCallsV2.GetDefaultDataRoot();
                     string isoPath = Path.Combine(defaultDataPath, Path.GetFileName(systemVmIso));
                     if (!File.Exists(isoPath))
                     {
@@ -195,7 +198,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;
                 }
@@ -288,7 +291,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)
                         {
@@ -367,7 +370,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;
@@ -632,7 +635,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;
@@ -831,7 +834,7 @@ namespace HypervResource
 
                 try
                 {
-                    WmiCalls.DeployVirtualMachine(cmd, systemVmIso);
+                    wmiCalls.DeployVirtualMachine(cmd, systemVmIso);
                     result = true;
                 }
                 catch (Exception wmiEx)
@@ -863,7 +866,7 @@ namespace HypervResource
 
                 try
                 {
-                    WmiCalls.DestroyVm(cmd);
+                    wmiCalls.DestroyVm(cmd);
                     result = true;
                 }
                 catch (Exception wmiEx)
@@ -962,13 +965,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);
                 }
 
@@ -982,7 +985,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);
 
@@ -1315,8 +1318,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;
@@ -1379,12 +1382,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
@@ -1395,7 +1398,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/a27899aa/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/a27899aa/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/a27899aa/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 65b726e..1d8d58a 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -30,8 +30,13 @@ using System.IO;
 
 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 +47,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 +89,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 +163,8 @@ namespace HypervResource
         /// <summary>
         /// Create new VM.  By default we start it. 
         /// </summary>
-        public static ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso)
+
+        public ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso)
         {
             var vmInfo = jsonObj.vm;
             string vmName = vmInfo.name;
@@ -209,7 +215,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)
             {
@@ -319,12 +325,11 @@ 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);
+                wmiCallsV2.AddUserData(vm, bootargs);
             }
 
             // call patch systemvm iso only for systemvms
@@ -352,11 +357,13 @@ namespace HypervResource
         /// this method is to add a dvd drive and attach the systemvm iso.
         /// 
 
-        public static void patchSystemVmIso(String vmName, String systemVmIso)
+
+        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, systemVmIso);
+
+            AttachIso(vmName, systemVmIso);
         }
 
         /// <summary>
@@ -365,7 +372,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,
@@ -406,7 +413,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);
@@ -453,7 +460,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);
@@ -490,7 +497,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);
@@ -524,7 +531,7 @@ namespace HypervResource
                     vhdfile);
         }
 
-        private static ResourceAllocationSettingData CloneResourceAllocationSetting(string wmiQuery)
+        private ResourceAllocationSettingData CloneResourceAllocationSetting(string wmiQuery)
         {
             var defaultDiskDriveSettingsObjs = ResourceAllocationSettingData.GetInstances(wmiQuery);
 
@@ -541,7 +548,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);
 
@@ -557,7 +564,7 @@ namespace HypervResource
             }
         }
 
-        public static void DestroyVm(dynamic jsonObj)
+        public void DestroyVm(dynamic jsonObj)
         {
             string vmToDestroy = jsonObj.vmName;
             DestroyVm(vmToDestroy);
@@ -567,7 +574,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);
 
@@ -614,7 +621,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}", 
@@ -657,7 +664,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
@@ -683,7 +690,7 @@ namespace HypervResource
         }
 
         // Add new 
-        private static ManagementPath[] AddVirtualResource(string[] resourceSettings, ComputerSystem vm )
+        private ManagementPath[] AddVirtualResource(string[] resourceSettings, ComputerSystem vm )
         {
             var virtSysMgmtSvc = GetVirtualisationSystemManagementService();
 
@@ -715,7 +722,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(
@@ -740,7 +747,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);
 
@@ -749,7 +756,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);
@@ -791,7 +798,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");
@@ -857,7 +864,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;
@@ -883,7 +890,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.
@@ -936,7 +943,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.
@@ -952,7 +959,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;
@@ -976,7 +983,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.
@@ -994,7 +1001,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.
@@ -1016,7 +1023,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(;;)
@@ -1044,7 +1051,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;
@@ -1057,7 +1064,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\"");
@@ -1072,14 +1079,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;
@@ -1099,7 +1106,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);
@@ -1112,7 +1119,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();
@@ -1129,7 +1136,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.
@@ -1154,7 +1161,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.
@@ -1179,7 +1186,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static ResourceAllocationSettingData GetDvdDriveSettings(VirtualSystemSettingData vmSettings)
+        public  ResourceAllocationSettingData GetDvdDriveSettings(VirtualSystemSettingData vmSettings)
         {
             var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
 
@@ -1199,7 +1206,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr)
+        public  ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr)
         {
             var wmiObjCollection = GetResourceAllocationSettings(vmSettings);
 
@@ -1228,7 +1235,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.
@@ -1253,7 +1260,7 @@ namespace HypervResource
             throw ex;
         }
 
-        public static SwitchPort[] GetSwitchPorts(ComputerSystem vm)
+        public  SwitchPort[] GetSwitchPorts(ComputerSystem vm)
         {
             var virtSwitchMgmtSvc = GetVirtualSwitchManagementService();
             // Get NIC path
@@ -1274,7 +1281,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.
@@ -1316,7 +1323,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.
@@ -1343,7 +1350,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/a27899aa/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 f95c337..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";
 
@@ -54,7 +54,7 @@ namespace HypervResource
         /// <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();
@@ -95,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();
@@ -132,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.
@@ -182,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);
@@ -195,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();
@@ -212,7 +212,7 @@ namespace HypervResource
             return result;
         }
 
-        public static string GetDefaultDataRoot()
+        public string GetDefaultDataRoot()
         {
             string defaultRootPath = null;
             VirtualSystemManagementServiceSettingData vs_mgmt_data = VirtualSystemManagementServiceSettingData.CreateInstance();
@@ -224,8 +224,9 @@ namespace HypervResource
 
             return defaultRootPath;
         }
-
-        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.
@@ -256,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/a27899aa/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/a27899aa/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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a27899aa/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..6f8aa4b
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs
@@ -0,0 +1,298 @@
+// 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()
+        {
+            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();
+            rsrcServer.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();
+        }
+
+        /// <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();
+            rsrcServer.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();
+            rsrcServer.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;
+        }        
+    }
+}


[35/54] Add ability to pass kvp data via the key cloudstack-vm-userdata

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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
new file mode 100755
index 0000000..187699d
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs
@@ -0,0 +1,1597 @@
+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_KvpExchangeComponent
+    public class KvpExchangeComponent : 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_KvpExchangeComponent";
+        
+        // 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 KvpExchangeComponent() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public KvpExchangeComponent(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(null, new System.Management.ManagementPath(KvpExchangeComponent.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(KvpExchangeComponent.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null);
+        }
+        
+        public KvpExchangeComponent(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public KvpExchangeComponent(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public KvpExchangeComponent(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public KvpExchangeComponent(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 KvpExchangeComponent(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[] 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 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 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(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"An array of embedded Msvm_KvpExchangeDataItem instances which contain the set of key-value pairs that components running within the guest operating system have pushed up to be available for access by external clients. This array will not contain any intrinsic items that are pushed by the integration component directly.")]
+        public string[] GuestExchangeItems {
+            get {
+                return ((string[])(curObj["GuestExchangeItems"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"An array of embedded Msvm_KvpExchangeDataItem instances which contain the set of key-value pairs that the guest operating system has pushed up to be available for access by external clients. This array will not contain any data items pushed by other components running within the guest operating system.")]
+        public string[] GuestIntrinsicExchangeItems {
+            get {
+                return ((string[])(curObj["GuestIntrinsicExchangeItems"]));
+            }
+        }
+        
+        [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 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 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(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[] 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(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(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 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"]));
+            }
+        }
+        
+        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 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 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 ShouldSerializeMaxQuiesceTime() {
+            if ((this.IsMaxQuiesceTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOperatingStatus() {
+            if ((this.IsOperatingStatusNull == 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 ShouldSerializeRequestedState() {
+            if ((this.IsRequestedStateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeStatusInfo() {
+            if ((this.IsStatusInfoNull == 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;
+        }
+        
+        [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_KvpExchangeComponent";
+            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 KvpExchangeComponentCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static KvpExchangeComponentCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static KvpExchangeComponentCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static KvpExchangeComponentCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static KvpExchangeComponentCollection 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_KvpExchangeComponent";
+            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 KvpExchangeComponentCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static KvpExchangeComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static KvpExchangeComponentCollection 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_KvpExchangeComponent", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new KvpExchangeComponentCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static KvpExchangeComponent 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 KvpExchangeComponent(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)) {
+                    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 KvpExchangeComponentCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public KvpExchangeComponentCollection(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 KvpExchangeComponent(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new KvpExchangeComponentEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class KvpExchangeComponentEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public KvpExchangeComponentEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new KvpExchangeComponent(((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"]));
+                }
+            }
+        }
+    }
+}


[49/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Implemented VR network commands to provide the necessary services from VR


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

Branch: refs/heads/hyperv
Commit: 62098f76c0884e31b76c32f07ecefd3508fe00d8
Parents: f74e9aa
Author: Rajesh Battala <ra...@citrix.com>
Authored: Tue Oct 22 12:41:13 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Tue Oct 22 12:41:13 2013 +0530

----------------------------------------------------------------------
 .../resource/HypervDirectConnectResource.java   | 587 ++++++++++++++++++-
 1 file changed, 567 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/62098f76/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 9d46322..6d6dc1f 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
@@ -42,6 +42,10 @@ import org.apache.http.util.EntityUtils;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.CheckRouterAnswer;
+import com.cloud.agent.api.CheckRouterCommand;
+import com.cloud.agent.api.CheckS2SVpnConnectionsAnswer;
+import com.cloud.agent.api.CheckS2SVpnConnectionsCommand;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.GetDomRVersionAnswer;
 import com.cloud.agent.api.GetDomRVersionCmd;
@@ -49,6 +53,7 @@ import com.cloud.agent.api.NetworkUsageAnswer;
 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.StartupCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
 import com.cloud.agent.api.StartupStorageCommand;
@@ -57,22 +62,37 @@ 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;
+import com.cloud.agent.api.routing.DeleteIpAliasCommand;
 import com.cloud.agent.api.routing.DhcpEntryCommand;
 import com.cloud.agent.api.routing.DnsMasqConfigCommand;
 import com.cloud.agent.api.routing.IpAliasTO;
 import com.cloud.agent.api.routing.IpAssocAnswer;
 import com.cloud.agent.api.routing.IpAssocCommand;
+import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
 import com.cloud.agent.api.routing.NetworkElementCommand;
 import com.cloud.agent.api.routing.SavePasswordCommand;
 import com.cloud.agent.api.routing.SetFirewallRulesAnswer;
 import com.cloud.agent.api.routing.SetFirewallRulesCommand;
+import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer;
+import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
+import com.cloud.agent.api.routing.SetSourceNatAnswer;
+import com.cloud.agent.api.routing.SetSourceNatCommand;
+import com.cloud.agent.api.routing.SetStaticNatRulesAnswer;
+import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
+import com.cloud.agent.api.routing.SetStaticRouteAnswer;
+import com.cloud.agent.api.routing.SetStaticRouteCommand;
+import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand;
 import com.cloud.agent.api.routing.VmDataCommand;
 import com.cloud.agent.api.to.DhcpTO;
 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.dc.DataCenter.NetworkType;
 import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor;
+import com.cloud.network.HAProxyConfigurator;
+import com.cloud.network.LoadBalancerConfigurator;
 import com.cloud.network.Networks.RouterPrivateIpStrategy;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.resource.ServerResource;
@@ -369,16 +389,31 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
             answer = execute((SavePasswordCommand) cmd);
         } else  if (clazz == SetFirewallRulesCommand.class) {
             answer = execute((SetFirewallRulesCommand)cmd);
-        } 
-
+        } else if (clazz == LoadBalancerConfigCommand.class) {
+            answer = execute((LoadBalancerConfigCommand) cmd);
+        } else if (clazz == DeleteIpAliasCommand.class) {
+            return execute((DeleteIpAliasCommand) cmd);
+        } else if (clazz == PingTestCommand.class) {
+            answer = execute((PingTestCommand) cmd);
+        } else if (clazz == SetStaticNatRulesCommand.class) {
+            answer = execute((SetStaticNatRulesCommand) cmd);
+        }  else if (clazz == CheckRouterCommand.class) {
+            answer = execute((CheckRouterCommand) cmd);
+        } else if (clazz == SetPortForwardingRulesCommand.class) {
+            answer = execute((SetPortForwardingRulesCommand) cmd);
+        } else if (clazz == SetSourceNatCommand.class) {
+            answer = execute((SetSourceNatCommand) cmd);
+        } else if (clazz == Site2SiteVpnCfgCommand.class) {
+            answer = execute((Site2SiteVpnCfgCommand) cmd);
+        } else if (clazz == CheckS2SVpnConnectionsCommand.class) {
+            answer = execute((CheckS2SVpnConnectionsCommand) cmd);
+        } else if (clazz == SetStaticRouteCommand.class) {
+            answer = execute((SetStaticRouteCommand) cmd);
+        }
         else {
-
         // Else send the cmd to hyperv agent.
-
         String ansStr = postHttpRequest(s_gson.toJson(cmd), agentUri);
-
         if (ansStr == null) {
-            // return null;
            return Answer.createUnsupportedCommandAnswer(cmd);
         }
         // Only Answer instances are returned by remote agents.
@@ -393,6 +428,529 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         return answer;
     }
 
+    private SetStaticRouteAnswer execute(SetStaticRouteCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource SetStaticRouteCommand: " + s_gson.toJson(cmd));
+        }
+
+        boolean endResult = true;
+
+        String controlIp = getRouterSshControlIp(cmd);
+        String args = "";
+        String[] results = new String[cmd.getStaticRoutes().length];
+        int i = 0;
+
+        // Extract and build the arguments for the command to be sent to the VR.
+        String[][] rules = cmd.generateSRouteRules();
+        StringBuilder sb = new StringBuilder();
+        String[] srRules = rules[0];
+        for (int j = 0; j < srRules.length; j++) {
+            sb.append(srRules[j]).append(',');
+        }
+        args += " -a " + sb.toString();
+
+        // Send over the command for execution, via ssh, to the VR.
+        try {
+            Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                    "/opt/cloud/bin/vpc_staticroute.sh " + args);
+
+            if (s_logger.isDebugEnabled())
+                s_logger.debug("Executing script on domain router " + controlIp + ": /opt/cloud/bin/vpc_staticroute.sh " + args);
+
+            if (!result.first()) {
+                s_logger.error("SetStaticRouteCommand failure on setting one rule. args: " + args);
+                results[i++] = "Failed";
+                endResult = false;
+            } else {
+                results[i++] = null;
+            }
+        } catch (Throwable e) {
+            s_logger.error("SetStaticRouteCommand(args: " + args + ") failed on setting one rule due to " + e);
+            results[i++] = "Failed";
+            endResult = false;
+        }
+        return new SetStaticRouteAnswer(cmd, endResult, results);
+
+    }
+
+    protected CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Executing resource CheckS2SVpnConnectionsCommand: " + s_gson.toJson(cmd));
+            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/checkbatchs2svpn.sh ");
+        }
+
+        Pair<Boolean, String> result;
+        try {
+            String controlIp = getRouterSshControlIp(cmd);
+            String cmdline = "/opt/cloud/bin/checkbatchs2svpn.sh ";
+            for (String ip : cmd.getVpnIps()) {
+                cmdline += " " + ip;
+            }
+
+            result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, cmdline);
+
+            if (!result.first()) {
+                s_logger.error("check site-to-site vpn connections command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " failed, message: "
+                        + result.second());
+
+                return new CheckS2SVpnConnectionsAnswer(cmd, false, result.second());
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("check site-to-site vpn connections command on domain router " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " completed");
+            }
+        } catch (Throwable e) {
+            String msg = "CheckS2SVpnConnectionsCommand failed due to " + e;
+            s_logger.error(msg, e);
+            return new CheckS2SVpnConnectionsAnswer(cmd, false, "CheckS2SVpnConneciontsCommand failed");
+        }
+        return new CheckS2SVpnConnectionsAnswer(cmd, true, result.second());
+    }
+
+    protected Answer execute(Site2SiteVpnCfgCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource Site2SiteVpnCfgCommand " + s_gson.toJson(cmd));
+        }
+
+        String routerIp = getRouterSshControlIp(cmd);
+
+        String args = "";
+        if (cmd.isCreate()) {
+            args += " -A";
+            args += " -l ";
+            args += cmd.getLocalPublicIp();
+            args += " -n ";
+            args += cmd.getLocalGuestCidr();
+            args += " -g ";
+            args += cmd.getLocalPublicGateway();
+            args += " -r ";
+            args += cmd.getPeerGatewayIp();
+            args += " -N ";
+            args += cmd.getPeerGuestCidrList();
+            args += " -e ";
+            args += "\"" + cmd.getEspPolicy() + "\"";
+            args += " -i ";
+            args += "\"" + cmd.getIkePolicy() + "\"";
+            args += " -t ";
+            args += Long.toString(cmd.getIkeLifetime());
+            args += " -T ";
+            args += Long.toString(cmd.getEspLifetime());
+            args += " -s ";
+            args += "\"" + cmd.getIpsecPsk() + "\"";
+            args += " -d ";
+            if (cmd.getDpd()) {
+                args += "1";
+            } else {
+                args += "0";
+            }
+        } else {
+            args += " -D";
+            args += " -r ";
+            args += cmd.getPeerGatewayIp();
+            args += " -n ";
+            args += cmd.getLocalGuestCidr();
+            args += " -N ";
+            args += cmd.getPeerGuestCidrList();
+        }
+
+        Pair<Boolean, String> result;
+        try {
+            result = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                    "/opt/cloud/bin/ipsectunnel.sh " + args);
+
+            if (!result.first()) {
+                s_logger.error("Setup site2site VPN " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " failed, message: " + result.second());
+
+                return new Answer(cmd, false, "Setup site2site VPN falied due to " + result.second());
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("setup site 2 site vpn on router " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " completed");
+            }
+        } catch (Throwable e) {
+            String msg = "Setup site2site VPN falied due to " + e.getMessage();
+            s_logger.error(msg, e);
+            return new Answer(cmd, false, "Setup site2site VPN failed due to " + e.getMessage());
+        }
+        return new Answer(cmd, true, result.second());
+    }
+
+    protected SetSourceNatAnswer execute(SetSourceNatCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource SetSourceNatCommand " + s_gson.toJson(cmd));
+        }
+
+        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        String routerIp = getRouterSshControlIp(cmd);
+        IpAddressTO pubIp = cmd.getIpAddress();
+        try {
+            int ethDeviceNum = findRouterEthDeviceIndex(routerName, routerIp, pubIp.getVifMacAddress());
+            String args = "";
+            args += " -A ";
+            args += " -l ";
+            args += pubIp.getPublicIp();
+
+            args += " -c ";
+            args += "eth" + ethDeviceNum;
+
+            Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                    "/opt/cloud/bin/vpc_snat.sh " + args);
+
+            if (!result.first()) {
+                String msg = "SetupGuestNetworkCommand on domain router " + routerIp + " failed. message: " + result.second();
+                s_logger.error(msg);
+
+                return new SetSourceNatAnswer(cmd, false, msg);
+            }
+
+            return new SetSourceNatAnswer(cmd, true, "success");
+        } catch (Exception e) {
+            String msg = "Ip SNAT failure due to " + e.toString();
+            s_logger.error(msg, e);
+            return new SetSourceNatAnswer(cmd, false, msg);
+        }
+    }
+
+    //
+    // find mac address of a specified ethx device
+    //    ip address show ethx | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2
+    // returns
+    //      eth0:xx.xx.xx.xx
+
+    //
+    // list IP with eth devices
+    //  ifconfig ethx |grep -B1 "inet addr" | awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }'
+    //     | awk -F: '{ print $1 ": " $3 }'
+    //
+    // returns
+    //      eth0:xx.xx.xx.xx
+    //
+    //
+
+    private int findRouterEthDeviceIndex(String domrName, String routerIp, String mac) throws Exception {
+
+        s_logger.info("findRouterEthDeviceIndex. mac: " + mac);
+
+        // TODO : this is a temporary very inefficient solution, will refactor it later
+        Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                "ls /proc/sys/net/ipv4/conf");
+
+        // when we dynamically plug in a new NIC into virtual router, it may take time to show up in guest OS
+        // we use a waiting loop here as a workaround to synchronize activities in systems
+        long startTick = System.currentTimeMillis();
+        while (System.currentTimeMillis() - startTick < 15000) {
+            if (result.first()) {
+                String[] tokens = result.second().split("\\s+");
+                for (String token : tokens) {
+                    if (!("all".equalsIgnoreCase(token) || "default".equalsIgnoreCase(token) || "lo".equalsIgnoreCase(token))) {
+                        String cmd = String.format("ip address show %s | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2", token);
+
+                        if (s_logger.isDebugEnabled())
+                            s_logger.debug("Run domr script " + cmd);
+                        Pair<Boolean, String> result2 = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                                // TODO need to find the dev index inside router based on IP address
+                                cmd);
+                        if (s_logger.isDebugEnabled())
+                            s_logger.debug("result: " + result2.first() + ", output: " + result2.second());
+
+                        if (result2.first() && result2.second().trim().equalsIgnoreCase(mac.trim()))
+                            return Integer.parseInt(token.substring(3));
+                    }
+                }
+            }
+
+            s_logger.warn("can not find intereface associated with mac: " + mac + ", guest OS may still at loading state, retry...");
+
+            try {
+                Thread.currentThread().sleep(1000);
+            } catch (InterruptedException e) {
+            }
+        }
+
+        return -1;
+    }
+
+    protected Answer execute(SetPortForwardingRulesCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource SetPortForwardingRulesCommand: " + s_gson.toJson(cmd));
+        }
+
+        String controlIp = getRouterSshControlIp(cmd);
+        String args = "";
+        String[] results = new String[cmd.getRules().length];
+        int i = 0;
+
+        boolean endResult = true;
+        for (PortForwardingRuleTO rule : cmd.getRules()) {
+            args += rule.revoked() ? " -D " : " -A ";
+            args += " -P " + rule.getProtocol().toLowerCase();
+            args += " -l " + rule.getSrcIp();
+            args += " -p " + rule.getStringSrcPortRange();
+            args += " -r " + rule.getDstIp();
+            args += " -d " + rule.getStringDstPortRange();
+
+            try {
+                Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/firewall.sh " + args);
+
+                if (s_logger.isDebugEnabled())
+                    s_logger.debug("Executing script on domain router " + controlIp + ": /root/firewall.sh " + args);
+
+                if (!result.first()) {
+                    s_logger.error("SetPortForwardingRulesCommand failure on setting one rule. args: " + args);
+                    results[i++] = "Failed";
+                    endResult = false;
+                } else {
+                    results[i++] = null;
+                }
+            } catch (Throwable e) {
+                s_logger.error("SetPortForwardingRulesCommand(args: " + args + ") failed on setting one rule due to " + e.getMessage());
+                results[i++] = "Failed";
+                endResult = false;
+            }
+        }
+
+        return new SetPortForwardingRulesAnswer(cmd, results, endResult);
+    }
+
+    protected Answer execute(CheckRouterCommand cmd) {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Executing resource CheckRouterCommand: " + s_gson.toJson(cmd));
+            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/checkrouter.sh ");
+        }
+
+        Pair<Boolean, String> result;
+        try {
+
+            String controlIp = getRouterSshControlIp(cmd);
+            result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                    "/opt/cloud/bin/checkrouter.sh ");
+
+            if (!result.first()) {
+                s_logger.error("check router command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " failed, message: " + result.second());
+
+                return new CheckRouterAnswer(cmd, "CheckRouter failed due to " + result.second());
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("check router command on domain router " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " completed");
+            }
+        } catch (Throwable e) {
+            String msg = "CheckRouterCommand failed due to " + e.getMessage();
+            s_logger.error(msg, e);
+            return new CheckRouterAnswer(cmd, msg);
+        }
+        return new CheckRouterAnswer(cmd, result.second(), true);
+    }
+
+    protected Answer execute(SetStaticNatRulesCommand cmd) {
+
+        if (cmd.getVpcId() != null) {
+            //return SetVPCStaticNatRules(cmd);
+        }
+
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource SetFirewallRuleCommand: " + s_gson.toJson(cmd));
+        }
+
+        String args = null;
+        String[] results = new String[cmd.getRules().length];
+        int i = 0;
+        boolean endResult = true;
+        for (StaticNatRuleTO rule : cmd.getRules()) {
+            // 1:1 NAT needs instanceip;publicip;domrip;op
+            args = rule.revoked() ? " -D " : " -A ";
+
+            args += " -l " + rule.getSrcIp();
+            args += " -r " + rule.getDstIp();
+
+            if (rule.getProtocol() != null) {
+                args += " -P " + rule.getProtocol().toLowerCase();
+            }
+
+            args += " -d " + rule.getStringSrcPortRange();
+            args += " -G ";
+
+            try {
+                String controlIp = getRouterSshControlIp(cmd);
+                Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/firewall.sh " + args);
+
+                if (s_logger.isDebugEnabled())
+                    s_logger.debug("Executing script on domain router " + controlIp + ": /root/firewall.sh " + args);
+
+                if (!result.first()) {
+                    s_logger.error("SetStaticNatRulesCommand failure on setting one rule. args: " + args);
+                    results[i++] = "Failed";
+                    endResult = false;
+                } else {
+                    results[i++] = null;
+                }
+            } catch (Throwable e) {
+                s_logger.error("SetStaticNatRulesCommand (args: " + args + ") failed on setting one rule due to " + e.getMessage());
+                results[i++] = "Failed";
+                endResult = false;
+            }
+        }
+        return new SetStaticNatRulesAnswer(cmd, results, endResult);
+    }
+
+    protected Answer execute(PingTestCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource PingTestCommand: " + s_gson.toJson(cmd));
+        }
+        String controlIp = cmd.getRouterIp();
+        String args = " -c 1 -n -q " + cmd.getPrivateIp();
+        try {
+            Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/bin/ping" + args);
+            if (result.first())
+                return new Answer(cmd);
+        } catch (Exception e) {
+            s_logger.error("Unable to execute ping command on DomR (" + controlIp + "), domR may not be ready yet. failure due to "
+                    + e.getMessage());
+        }
+        return new Answer(cmd, false, "PingTestCommand failed");
+    }
+
+    protected Answer execute(final DeleteIpAliasCommand cmd) {
+        cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
+        List<IpAliasTO> activeIpAliasTOs = cmd.getCreateIpAliasTos();
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing deleteIpAlias command: " + s_gson.toJson(cmd));
+        }
+        String args = "";
+        for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
+            args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
+        }
+        args = args + "- ";
+        for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
+            args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
+        }
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/deleteIpAlias " + args);
+        }
+
+        try {
+            String controlIp = getRouterSshControlIp(cmd);
+            Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                    "/root/deleteIpAlias.sh " + args);
+
+            if (!result.first()) {
+                s_logger.error("deleteIpAlias command on domr " + controlIp + " failed, message: " + result.second());
+
+                return new Answer(cmd, false, "deleteIpAlias failed due to " + result.second());
+            }
+
+            if (s_logger.isInfoEnabled()) {
+                s_logger.info("deleteIpAlias command on domain router " + controlIp + " completed");
+            }
+
+        } catch (Throwable e) {
+            String msg = "deleteIpAlias failed due to " + e.getMessage();
+            s_logger.error(msg, e);
+            return new Answer(cmd, false, msg);
+        }
+
+        return new Answer(cmd);
+    }
+
+    protected Answer execute(final LoadBalancerConfigCommand cmd) {
+
+        if (cmd.getVpcId() != null) {
+            //return VPCLoadBalancerConfig(cmd);
+        }
+
+        File keyFile = getSystemVMKeyFile();
+
+        String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        String controlIp = getRouterSshControlIp(cmd);
+
+        assert (controlIp != null);
+
+        LoadBalancerConfigurator cfgtr = new HAProxyConfigurator();
+        String[] config = cfgtr.generateConfiguration(cmd);
+
+        String[][] rules = cfgtr.generateFwRules(cmd);
+        String tmpCfgFilePath = "/tmp/" + routerIp.replace('.', '_') + ".cfg";
+        String tmpCfgFileContents = "";
+        for (int i = 0; i < config.length; i++) {
+            tmpCfgFileContents += config[i];
+            tmpCfgFileContents += "\n";
+        }
+
+        try {
+            SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", keyFile, null, "/tmp/", tmpCfgFileContents.getBytes(), routerIp.replace('.', '_') + ".cfg", null);
+
+            try {
+                String[] addRules = rules[LoadBalancerConfigurator.ADD];
+                String[] removeRules = rules[LoadBalancerConfigurator.REMOVE];
+                String[] statRules = rules[LoadBalancerConfigurator.STATS];
+
+                String args = "";
+                args += "-i " + routerIp;
+                args += " -f " + tmpCfgFilePath;
+
+                StringBuilder sb = new StringBuilder();
+                if (addRules.length > 0) {
+                    for (int i = 0; i < addRules.length; i++) {
+                        sb.append(addRules[i]).append(',');
+                    }
+
+                    args += " -a " + sb.toString();
+                }
+
+                sb = new StringBuilder();
+                if (removeRules.length > 0) {
+                    for (int i = 0; i < removeRules.length; i++) {
+                        sb.append(removeRules[i]).append(',');
+                    }
+
+                    args += " -d " + sb.toString();
+                }
+
+                sb = new StringBuilder();
+                if (statRules.length > 0) {
+                    for (int i = 0; i < statRules.length; i++) {
+                        sb.append(statRules[i]).append(',');
+                    }
+
+                    args += " -s " + sb.toString();
+                }
+
+                Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "scp " + tmpCfgFilePath
+                        + " /etc/haproxy/haproxy.cfg.new");
+
+                if (!result.first()) {
+                    s_logger.error("Unable to copy haproxy configuration file");
+                    return new Answer(cmd, false, "LoadBalancerConfigCommand failed due to uanble to copy haproxy configuration file");
+                }
+
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("Run command on domain router " + routerIp + ",  /root/loadbalancer.sh " + args);
+                }
+
+                result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/loadbalancer.sh " + args);
+
+                if (!result.first()) {
+                    String msg = "LoadBalancerConfigCommand on domain router " + routerIp + " failed. message: " + result.second();
+                    s_logger.error(msg);
+
+                    return new Answer(cmd, false, msg);
+                }
+
+                if (s_logger.isInfoEnabled()) {
+                    s_logger.info("LoadBalancerConfigCommand on domain router " + routerIp + " completed");
+                }
+            } finally {
+                SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "rm " + tmpCfgFilePath);
+            }
+
+            return new Answer(cmd);
+        } catch (Throwable e) {
+            s_logger.error("Unexpected exception: " + e.toString(), e);
+            return new Answer(cmd, false, "LoadBalancerConfigCommand failed due to " + e.getMessage());
+        }
+    }
+
     protected Answer execute(SavePasswordCommand cmd) {
         if (s_logger.isInfoEnabled()) {
 
@@ -413,7 +971,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
 
         args += " -p " + password;
 
-
         try {
 
             Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/savepassword.sh " + args);
@@ -436,7 +993,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         return new Answer(cmd);
     }
 
-
     protected SetFirewallRulesAnswer execute(SetFirewallRulesCommand cmd) {
         String controlIp = getRouterSshControlIp(cmd);
         String[] results = new String[cmd.getRules().length];
@@ -577,7 +1133,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         return new Answer(cmd);
     }
 
-
     private String encodeDataArgs(String[] dataArgs) {
         StringBuilder sb = new StringBuilder();
 
@@ -652,10 +1207,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         return new Answer(cmd);
     }
 
-
-
-
-
     protected Answer execute(final CreateIpAliasCommand cmd) {
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing createIpAlias command: " + s_gson.toJson(cmd));
@@ -694,7 +1245,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         return new Answer(cmd);
     }
 
-
     protected Answer execute(final DnsMasqConfigCommand cmd) {
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing dnsmasqConfig command: " + s_gson.toJson(cmd));
@@ -734,8 +1284,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         return new Answer(cmd);
     }
 
-
-
     protected Answer execute(IpAssocCommand cmd) {
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing resource IPAssocCommand: " + s_gson.toJson(cmd));
@@ -852,7 +1400,6 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         }
     }
 
-
    protected Answer execute(GetDomRVersionCmd cmd) {
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Executing resource GetDomRVersionCmd: " + s_gson.toJson(cmd));
@@ -905,10 +1452,10 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
     }
 
     protected Answer execute(NetworkUsageCommand cmd) {
-/*        if ( cmd.isForVpc() ) {
-            return VPCNetworkUsage(cmd);
+        if ( cmd.isForVpc() ) {
+            //return VPCNetworkUsage(cmd);
         }
-*/        if (s_logger.isInfoEnabled()) {
+        if (s_logger.isInfoEnabled()) {
             s_logger.info("Executing resource NetworkUsageCommand "+ s_gson.toJson(cmd));
         }
         if(cmd.getOption()!=null && cmd.getOption().equals("create") ){


[10/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..faab8d4
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VLANEndpointSettingData.cs
@@ -0,0 +1,885 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[44/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
modifified cloud-early-config to configure, when the VR boots up in HyperV Environment


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

Branch: refs/heads/hyperv
Commit: 33e19bf1875b3a01d4ef3b790a92a152da1773f4
Parents: f1c2c50
Author: Rajesh Battala <ra...@citrix.com>
Authored: Fri Oct 11 12:13:41 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Oct 11 16:43:32 2013 +0530

----------------------------------------------------------------------
 .../debian/config/etc/init.d/cloud-early-config    | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/33e19bf1/systemvm/patches/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-early-config b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
index 88ecc11..1cc399f 100755
--- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config
+++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
@@ -130,12 +130,11 @@ get_boot_params() {
      vmware)
           vmtoolsd --cmd 'machine.id.get' > /var/cache/cloud/cmdline 
           ;;
-     virtualpc)
-          # Hyper-V is recognized as virtualpc hypervisor type. Boot args are passed in the NTFS data-disk
-          mkdir -p $EXTRA_MOUNT
-          mount -t ntfs /dev/sdb1 $EXTRA_MOUNT
-          cp -f $EXTRA_MOUNT/cmdline /var/cache/cloud/cmdline
-          umount $EXTRA_MOUNT
+     virtualpc|hyperv)
+          # Hyper-V is recognized as virtualpc hypervisor type. Boot args are passed using KVP Daemon
+          #waiting for the hv_kvp_daemon to start up
+          #sleep 30 need to fix the race condition of hv_kvp_daemon and cloud-early-config
+          cp -f /var/opt/hyperv/.kvp_pool_0 /var/cache/cloud/cmdline
           ;;
   esac
 
@@ -157,6 +156,10 @@ patch() {
        cdrom_dev=/dev/cdrom
   elif [ -e /dev/cdrom1 ]; then
        cdrom_dev=/dev/cdrom1
+  elif [ -e /dev/cdrom2 ]; then
+       cdrom_dev=/dev/cdrom2
+  elif [ -e /dev/cdrom3 ]; then
+       cdrom_dev=/dev/cdrom3
   fi
   [ -f /var/cache/cloud/authorized_keys ] && privkey=/var/cache/cloud/authorized_keys
 
@@ -718,7 +721,7 @@ setup_dnsmasq() {
   [ $ETH0_IP ] && echo "dhcp-option=6,$NS" >> /etc/dnsmasq.conf
   [ $ETH0_IP6 ] && echo "dhcp-option=option6:dns-server,$NS6" >> /etc/dnsmasq.conf
 #adding the name data-server to the /etc/hosts for allowing the access to user-data service and ssh-key reset in every subnet.
-  //removing the existing entires to avoid duplicates on restarts.
+#removing the existing entires to avoid duplicates on restarts.
   sed -i  '/data-server/d' /etc/hosts
   if [ -n "$ETH0_IP" ]
           then


[19/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..3e5d903
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_MemorySettingData.cs
@@ -0,0 +1,1083 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[15/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..75d20ca
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchLANEndpoint.cs
@@ -0,0 +1,1342 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[45/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Implemented commands that are required for VR to bootup and Vm deployment to work


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

Branch: refs/heads/hyperv
Commit: 16422cbc0eaa9c0bb4e65e526dd341ec6e6c6a64
Parents: 33e19bf
Author: Rajesh Battala <ra...@citrix.com>
Authored: Fri Oct 11 13:42:42 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Oct 11 16:43:32 2013 +0530

----------------------------------------------------------------------
 .../resource/HypervDirectConnectResource.java   | 690 ++++++++++++++++++-
 1 file changed, 689 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16422cbc/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 e22f284..57a9dfd 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
@@ -16,11 +16,18 @@
 // under the License.
 package com.cloud.hypervisor.hyperv.resource;
 
+import java.io.File;
 import java.io.IOException;
+import java.net.ConnectException;
+import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.channels.SocketChannel;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 import javax.naming.ConfigurationException;
 
@@ -36,6 +43,10 @@ import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
+import com.cloud.agent.api.GetDomRVersionAnswer;
+import com.cloud.agent.api.GetDomRVersionCmd;
+import com.cloud.agent.api.NetworkUsageAnswer;
+import com.cloud.agent.api.NetworkUsageCommand;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.PingRoutingCommand;
 import com.cloud.agent.api.StartupCommand;
@@ -43,12 +54,31 @@ import com.cloud.agent.api.StartupRoutingCommand;
 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;
+import com.cloud.agent.api.routing.DhcpEntryCommand;
+import com.cloud.agent.api.routing.DnsMasqConfigCommand;
+import com.cloud.agent.api.routing.IpAliasTO;
+import com.cloud.agent.api.routing.IpAssocAnswer;
+import com.cloud.agent.api.routing.IpAssocCommand;
+import com.cloud.agent.api.routing.NetworkElementCommand;
+import com.cloud.agent.api.routing.SavePasswordCommand;
+import com.cloud.agent.api.routing.VmDataCommand;
+import com.cloud.agent.api.to.DhcpTO;
+import com.cloud.agent.api.to.IpAddressTO;
+import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor;
 import com.cloud.network.Networks.RouterPrivateIpStrategy;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.ServerResourceBase;
 import com.cloud.serializer.GsonHelper;
+import com.cloud.utils.Pair;
+import com.cloud.utils.StringUtils;
+import com.cloud.utils.net.NetUtils;
+import com.cloud.utils.ssh.SshHelper;
+import com.cloud.vm.VirtualMachineName;
 import com.google.gson.Gson;
 
 /**
@@ -68,6 +98,11 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
     private String _guid;
     private String _agentIp;
     private int _port = DEFAULT_AGENT_PORT;
+    protected final long _ops_timeout = 900000;  // 15 minutes time out to time
+
+    protected final int _retry = 24;
+    protected final int _sleep = 10000;
+    protected final int DEFAULT_DOMR_SSHPORT = 3922;
 
     private String _clusterGuid;
 
@@ -296,6 +331,8 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         // Using java.net.URI, see
         // http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URI.html
         URI agentUri = null;
+        Class<? extends Command> clazz = cmd.getClass();
+        Answer answer = null;
         try {
             String cmdName = cmd.getClass().getName();
             agentUri =
@@ -307,10 +344,36 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
             s_logger.error(errMsg, e);
             return null;
         }
+
+        if (clazz == CheckSshCommand.class) {
+            answer = execute((CheckSshCommand) cmd);
+        } else if (clazz == GetDomRVersionCmd.class) {
+            answer = execute((GetDomRVersionCmd)cmd);
+        } else if (cmd instanceof NetworkUsageCommand) {
+           answer = execute((NetworkUsageCommand) cmd);
+        } else if (clazz == IpAssocCommand.class) {
+           answer = execute((IpAssocCommand) cmd);
+        } else if (clazz == DnsMasqConfigCommand.class) {
+            return execute((DnsMasqConfigCommand) cmd);
+        } else if (clazz == CreateIpAliasCommand.class) {
+            return execute((CreateIpAliasCommand) cmd);
+        } else if (clazz == DhcpEntryCommand.class) {
+            answer = execute((DhcpEntryCommand) cmd);
+        } else if (clazz == VmDataCommand.class) {
+            answer = execute((VmDataCommand) cmd);
+        } else if (clazz == SavePasswordCommand.class) {
+            answer = execute((SavePasswordCommand) cmd);
+        }
+
+        else {
+
+        // Else send the cmd to hyperv agent.
+
         String ansStr = postHttpRequest(s_gson.toJson(cmd), agentUri);
 
         if (ansStr == null) {
-            return null;
+            // return null;
+           return Answer.createUnsupportedCommandAnswer(cmd);
         }
         // Only Answer instances are returned by remote agents.
         // E.g. see Response.getAnswers()
@@ -320,9 +383,586 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
         if (result.length > 0) {
             return result[0];
         }
+        }
+        return answer;
+    }
+
+    protected Answer execute(SavePasswordCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+
+            s_logger.info("Executing resource SavePasswordCommand. vmName: " + cmd.getVmName() + ", vmIp: " + cmd.getVmIpAddress() + ", password: "
+                    + StringUtils.getMaskedPasswordForDisplay(cmd.getPassword()));
+        }
+
+        String controlIp = getRouterSshControlIp(cmd);
+        final String password = cmd.getPassword();
+        final String vmIpAddress = cmd.getVmIpAddress();
+
+        // Run save_password_to_domr.sh
+        String args = " -v " + vmIpAddress;
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Run command on domain router " + controlIp + ", /root/savepassword.sh " + args + " -p " + StringUtils.getMaskedPasswordForDisplay(cmd.getPassword()));
+        }
+
+        args += " -p " + password;
+
+
+        try {
+
+            Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/root/savepassword.sh " + args);
+
+            if (!result.first()) {
+                s_logger.error("savepassword command on domain router " + controlIp + " failed, message: " + result.second());
+
+                return new Answer(cmd, false, "SavePassword failed due to " + result.second());
+            }
+
+            if (s_logger.isInfoEnabled()) {
+                s_logger.info("savepassword command on domain router " + controlIp + " completed");
+            }
+
+        } catch (Throwable e) {
+            String msg = "SavePasswordCommand failed due to " + e;
+            s_logger.error(msg, e);
+            return new Answer(cmd, false, msg);
+        }
+        return new Answer(cmd);
+    }
+
+
+
+    protected Answer execute(VmDataCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource VmDataCommand: " + s_gson.toJson(cmd));
+        }
+
+        String routerPrivateIpAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        String controlIp = getRouterSshControlIp(cmd);
+
+        String vmIpAddress = cmd.getVmIpAddress();
+        List<String[]> vmData = cmd.getVmData();
+        String[] vmDataArgs = new String[vmData.size() * 2 + 4];
+        vmDataArgs[0] = "routerIP";
+        vmDataArgs[1] = routerPrivateIpAddress;
+        vmDataArgs[2] = "vmIP";
+        vmDataArgs[3] = vmIpAddress;
+        int i = 4;
+        for (String[] vmDataEntry : vmData) {
+            String folder = vmDataEntry[0];
+            String file = vmDataEntry[1];
+            String contents = (vmDataEntry[2] != null) ? vmDataEntry[2] : "none";
+
+            vmDataArgs[i] = folder + "," + file;
+            vmDataArgs[i + 1] = contents;
+            i += 2;
+        }
+
+        String content = encodeDataArgs(vmDataArgs);
+        String tmpFileName = UUID.randomUUID().toString();
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Run vm_data command on domain router " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", data: " + content);
+        }
+
+        try {
+            SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/tmp", content.getBytes(), tmpFileName, null);
+
+            try {
+                Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                        "/root/userdata.py " + tmpFileName);
+
+                if (!result.first()) {
+                    s_logger.error("vm_data command on domain router " + controlIp + " failed. messge: " + result.second());
+                    return new Answer(cmd, false, "VmDataCommand failed due to " + result.second());
+                }
+            } finally {
+
+                SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "rm /tmp/" + tmpFileName);
+            }
+
+            if (s_logger.isInfoEnabled()) {
+                s_logger.info("vm_data command on domain router " + controlIp + " completed");
+            }
+
+        } catch (Throwable e) {
+            String msg = "VmDataCommand failed due to " + e;
+            s_logger.error(msg, e);
+            return new Answer(cmd, false, msg);
+        }
+        return new Answer(cmd);
+    }
+
+
+    private String encodeDataArgs(String[] dataArgs) {
+        StringBuilder sb = new StringBuilder();
+
+        for (String arg : dataArgs) {
+            sb.append(arg);
+            sb.append("\n");
+        }
+
+        return sb.toString();
+    }
+
+
+    protected Answer execute(DhcpEntryCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource DhcpEntryCommand: " + s_gson.toJson(cmd));
+        }
+
+        // ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$domr "/root/edithosts.sh $mac $ip $vm $dfltrt $ns $staticrt" >/dev/null
+
+        String args = " -m " + cmd.getVmMac();
+        if (cmd.getVmIpAddress() != null) {
+            args += " -4 " + cmd.getVmIpAddress();
+        }
+        args += " -h " + cmd.getVmName();
+
+        if (cmd.getDefaultRouter() != null) {
+            args += " -d " + cmd.getDefaultRouter();
+        }
+
+        if (cmd.getDefaultDns() != null) {
+            args += " -n " + cmd.getDefaultDns();
+        }
+
+        if (cmd.getStaticRoutes() != null) {
+            args += " -s " + cmd.getStaticRoutes();
+        }
+
+        if (cmd.getVmIp6Address() != null) {
+            args += " -6 " + cmd.getVmIp6Address();
+            args += " -u " + cmd.getDuid();
+        }
+
+        if (!cmd.isDefault()) {
+            args += " -N";
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/edithosts.sh " + args);
+        }
+
+        try {
+            String controlIp = getRouterSshControlIp(cmd);
+            Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                    "/root/edithosts.sh " + args);
+
+            if (!result.first()) {
+                s_logger.error("dhcp_entry command on domR " + controlIp + " failed, message: " + result.second());
+
+                return new Answer(cmd, false, "DhcpEntry failed due to " + result.second());
+            }
+
+            if (s_logger.isInfoEnabled()) {
+                s_logger.info("dhcp_entry command on domain router " + controlIp + " completed");
+            }
+
+        } catch (Throwable e) {
+            String msg = "DhcpEntryCommand failed due to " + e;
+            s_logger.error(msg, e);
+            return new Answer(cmd, false, msg);
+        }
+
+        return new Answer(cmd);
+    }
+
+
+
+
+
+    protected Answer execute(final CreateIpAliasCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing createIpAlias command: " + s_gson.toJson(cmd));
+        }
+        cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
+        String args="";
+        for (IpAliasTO ipaliasto : ipAliasTOs) {
+            args = args + ipaliasto.getAlias_count()+":"+ipaliasto.getRouterip()+":"+ipaliasto.getNetmask()+"-";
+        }
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/createIpAlias " + args);
+        }
+
+        try {
+            String controlIp = getRouterSshControlIp(cmd);
+            Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                    "/root/createIpAlias.sh " + args);
+
+            if (!result.first()) {
+                s_logger.error("CreateIpAlias command on domr " + controlIp + " failed, message: " + result.second());
+
+                return new Answer(cmd, false, "createipAlias failed due to " + result.second());
+            }
+
+            if (s_logger.isInfoEnabled()) {
+                s_logger.info("createIpAlias command on domain router " + controlIp + " completed");
+            }
+
+        } catch (Throwable e) {
+            String msg = "createIpAlias failed due to " + e;
+            s_logger.error(msg, e);
+            return new Answer(cmd, false, msg);
+        }
+
+        return new Answer(cmd);
+    }
+
+
+    protected Answer execute(final DnsMasqConfigCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing dnsmasqConfig command: " + s_gson.toJson(cmd));
+        }
+        String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        String controlIp = getRouterSshControlIp(cmd);
+
+        assert(controlIp != null);
+
+        List<DhcpTO> dhcpTos = cmd.getIps();
+        String args ="";
+        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);
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Run command on domain router " + routerIp + ",  /root/dnsmasq.sh");
+            }
+
+            if (!result.first()) {
+                s_logger.error("Unable update dnsmasq config file");
+                return new Answer(cmd, false, "dnsmasq config update failed due to: " + result.second());
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("dnsmasq config command on domain router " + routerIp + " completed");
+            }
+        }catch (Throwable e) {
+            String msg = "Dnsmasqconfig command failed due to " + e.getMessage();
+            s_logger.error(msg, e);
+            return new Answer(cmd, false, msg);
+        }
+
+        return new Answer(cmd);
+    }
+
+
+
+    protected Answer execute(IpAssocCommand cmd) {
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource IPAssocCommand: " + s_gson.toJson(cmd));
+        }
+
+        int i = 0;
+        String[] results = new String[cmd.getIpAddresses().length];
+
+        try {
+
+            IpAddressTO[] ips = cmd.getIpAddresses();
+            String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+            String controlIp = getRouterSshControlIp(cmd);
+            for (IpAddressTO ip : ips) {
+                assignPublicIpAddress(routerName, controlIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(), ip.getVlanGateway(), ip.getVlanNetmask(),ip.getVifMacAddress());
+                results[i++] = ip.getPublicIp() + " - success";
+            }
+
+            for (; i < cmd.getIpAddresses().length; i++) {
+                results[i++] = IpAssocAnswer.errorResult;
+            }
+            } catch (Throwable e) {
+            s_logger.error("Unexpected exception: " + e.toString() + " will shortcut rest of IPAssoc commands", e);
+
+            for (; i < cmd.getIpAddresses().length; i++) {
+                results[i++] = IpAssocAnswer.errorResult;
+            }
+        }
+
+        return new IpAssocAnswer(cmd, results);
+    }
+
+    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 (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) {
+            args = " -A ";
+        } else {
+            args = " -D ";
+        }
+
+        if (sourceNat) {
+            args += " -s ";
+        }
+        if (firstIP) {
+            args += " -f ";
+        }
+        String cidrSize = Long.toString(NetUtils.getCidrSize(vlanNetmask));
+        args += " -l ";
+        args += publicIpAddress + "/" + cidrSize;
+
+        args += " -c ";
+        args += "eth" +"2";  // currently hardcoding to eth 2 (which is default public ipd)//publicNicInfo.first();
+
+        args += " -g ";
+        args += vlanGateway;
+
+        if (addVif) {
+            args += " -n ";
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Run command on domain router " + privateIpAddress + ", /opt/cloud/bin/ipassoc.sh " + args);
+        }
+
+        Pair<Boolean, String> result = SshHelper.sshExecute(privateIpAddress, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/opt/cloud/bin/ipassoc.sh " + args);
+
+        if (!result.first()) {
+            s_logger.error("ipassoc command on domain router " + privateIpAddress + " failed. message: " + result.second());
+            throw new Exception("ipassoc failed due to " + result.second());
+        }
+
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("ipassoc command on domain router " + privateIpAddress + " completed");
+        }
+    }
+
+
+   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 ");
+        }
+
+        Pair<Boolean, String> result;
+        try {
+            String controlIp = getRouterSshControlIp(cmd);
+            result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null,
+                    "/opt/cloud/bin/get_template_version.sh ");
+
+            if (!result.first()) {
+                s_logger.error("GetDomRVersionCmd on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " failed, message: " + result.second());
+
+                return new GetDomRVersionAnswer(cmd, "GetDomRVersionCmd failed due to " + result.second());
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("GetDomRVersionCmd on domain router " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + " completed");
+            }
+        } catch (Throwable e) {
+            String msg = "GetDomRVersionCmd failed due to " + e;
+            s_logger.error(msg, e);
+            return new GetDomRVersionAnswer(cmd, msg);
+        }
+        String[] lines = result.second().split("&");
+        if (lines.length != 2) {
+            return new GetDomRVersionAnswer(cmd, result.second());
+        }
+        return new GetDomRVersionAnswer(cmd, result.second(), lines[0], lines[1]);
+    }
+
+
+    private static String getRouterSshControlIp(NetworkElementCommand cmd) {
+        String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        String routerGuestIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
+        String zoneNetworkType = cmd.getAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE);
+
+        if(routerGuestIp != null && zoneNetworkType != null && NetworkType.valueOf(zoneNetworkType) == NetworkType.Basic) {
+            if(s_logger.isDebugEnabled())
+                s_logger.debug("In Basic zone mode, use router's guest IP for SSH control. guest IP : " + routerGuestIp);
+
+            return routerGuestIp;
+        }
+
+        if(s_logger.isDebugEnabled())
+            s_logger.debug("Use router's private IP for SSH control. IP : " + routerIp);
+        return routerIp;
+    }
+
+    protected Answer execute(NetworkUsageCommand cmd) {
+/*        if ( cmd.isForVpc() ) {
+            return VPCNetworkUsage(cmd);
+        }
+*/        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Executing resource NetworkUsageCommand "+ s_gson.toJson(cmd));
+        }
+        if(cmd.getOption()!=null && cmd.getOption().equals("create") ){
+            String result = networkUsage(cmd.getPrivateIP(), "create", null);
+            NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, "true", 0L, 0L);
+            return answer;
+        }
+        long[] stats = getNetworkStats(cmd.getPrivateIP());
+
+        NetworkUsageAnswer answer = new NetworkUsageAnswer(cmd, "", stats[0], stats[1]);
+        return answer;
+    }
+    private long[] getNetworkStats(String privateIP) {
+        String result = networkUsage(privateIP, "get", null);
+        long[] stats = new long[2];
+        if (result != null) {
+            try {
+                String[] splitResult = result.split(":");
+                int i = 0;
+                while (i < splitResult.length - 1) {
+                    stats[0] += (new Long(splitResult[i++])).longValue();
+                    stats[1] += (new Long(splitResult[i++])).longValue();
+                }
+            } catch (Throwable e) {
+                s_logger.warn("Unable to parse return from script return of network usage command: " + e.toString(), e);
+            }
+        }
+        return stats;
+    }
+
+
+    protected CheckSshAnswer execute(CheckSshCommand cmd) {
+        String vmName = cmd.getName();
+        String privateIp = cmd.getIp();
+        int cmdPort = cmd.getPort();
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Ping command port, " + privateIp + ":" + cmdPort);
+        }
+
+        try {
+            String result = connect(cmd.getName(), privateIp, cmdPort);
+            if (result != null) {
+                s_logger.error("Can not ping System vm " + vmName + "due to:" + result);
+                return new CheckSshAnswer(cmd, "Can not ping System vm " + vmName + "due to:" + result);
+            }
+        } catch (Exception e) {
+            s_logger.error("Can not ping System vm " + vmName + "due to exception");
+            return new CheckSshAnswer(cmd, e);
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Ping command port succeeded for vm " + vmName);
+        }
+
+        if (VirtualMachineName.isValidRouterName(vmName)) {
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Execute network usage setup command on " + vmName);
+            }
+            networkUsage(privateIp, "create", null);
+        }
+
+        return new CheckSshAnswer(cmd);
+    }
+
+
+    protected String networkUsage(final String privateIpAddress, final String option, final String ethName) {
+        String args = null;
+        if (option.equals("get")) {
+            args = "-g";
+        } else if (option.equals("create")) {
+            args = "-c";
+        } else if (option.equals("reset")) {
+            args = "-r";
+        } else if (option.equals("addVif")) {
+            args = "-a";
+            args += ethName;
+        } else if (option.equals("deleteVif")) {
+            args = "-d";
+            args += ethName;
+        }
+
+        try {
+            if (s_logger.isTraceEnabled()) {
+                s_logger.trace("Executing /opt/cloud/bin/netusage.sh " + args + " on DomR " + privateIpAddress);
+            }
+
+            Pair<Boolean, String> result = SshHelper.sshExecute(privateIpAddress, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/opt/cloud/bin/netusage.sh " + args);
+
+            if (!result.first()) {
+                return null;
+            }
+
+            return result.second();
+        } catch (Throwable e) {
+            s_logger.error("Unable to execute NetworkUsage command on DomR (" + privateIpAddress + "), domR may not be ready yet. failure due to "
+                    + e);
+        }
+
         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;
+        if ( url != null ){
+            keyFile = new File(url.getPath());
+        }
+        if (keyFile == null || !keyFile.exists()) {
+            keyFile = new File("/usr/share/cloudstack-common/scripts/vm/systemvm/id_rsa.cloud");
+        }
+        assert(keyFile != null);
+        if(!keyFile.exists()) {
+            s_logger.error("Unable to locate id_rsa.cloud in your setup at " + keyFile.toString());
+        }
+        return keyFile;
+    }
+
+
     public static String postHttpRequest(final String jsonCmd,
             final URI agentUri) {
         // Using Apache's HttpClient for HTTP POST
@@ -450,5 +1090,53 @@ 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();
+
+        // wait until we have at least been waiting for _ops_timeout time or
+        // at least have tried _retry times, this is to coordinate with system
+        // VM patching/rebooting time that may need
+        int retry = _retry;
+        while (System.currentTimeMillis() - startTick <= _ops_timeout || --retry > 0) {
+            SocketChannel sch = null;
+            try {
+                s_logger.info("Trying to connect to " + ipAddress);
+                sch = SocketChannel.open();
+                sch.configureBlocking(true);
+                sch.socket().setSoTimeout(5000);
+
+                InetSocketAddress addr = new InetSocketAddress(ipAddress, port);
+                sch.connect(addr);
+                return null;
+            } catch (IOException e) {
+                s_logger.info("Could not connect to " + ipAddress + " due to " + e.toString());
+                if (e instanceof ConnectException) {
+                    // if connection is refused because of VM is being started,
+                    // we give it more sleep time
+                    // to avoid running out of retry quota too quickly
+                    try {
+                        Thread.sleep(5000);
+                    } catch (InterruptedException ex) {
+                    }
+                }
+            } finally {
+                if (sch != null) {
+                    try {
+                        sch.close();
+                    } catch (IOException e) {
+                    }
+                }
+            }
+
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ex) {
+            }
+        }
+
+        s_logger.info("Unable to logon to " + ipAddress);
+
+        return "Unable to connect";
+    }
 
 }


[23/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..1b4e293
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ConcreteJob.cs
@@ -0,0 +1,1665 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[20/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..0b8962d
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ImageManagementService.cs
@@ -0,0 +1,1401 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[17/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..28e7696
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ResourceAllocationSettingData.cs
@@ -0,0 +1,976 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[31/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
A plugin for Hyper-V control is available for CloudStack.  The plugin implements basic VM control;  however, its
architecture allows additional functionality to be easily added.  Incorporating the plugin in CloudStack will allow
the community to participate in improving the features available with Hyper-V.

The plugin uses a Director Connect Agent architecture described here: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Progress


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

Branch: refs/heads/hyperv
Commit: 1d0a931dea701442a03785475faf226271607754
Parents: 4590813
Author: Donal Lafferty <do...@citrix.com>
Authored: Wed Oct 2 14:15:42 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Wed Oct 2 14:37:22 2013 +0530

----------------------------------------------------------------------
 client/pom.xml                                  |   11 +
 client/tomcatconf/applicationContext.xml.in     |    8 +
 client/tomcatconf/componentContext.xml.in       |    1 +
 .../tomcatconf/simulatorComponentContext.xml.in |    1 +
 .../hyperv/DotNet/ServerResource/.gitignore     |    8 +
 .../AgentShell/AgentService.Designer.cs         |   53 +
 .../ServerResource/AgentShell/AgentService.cs   |  131 +
 .../AgentShell/AgentSettings.Designer.cs        |  371 +++
 .../AgentShell/AgentSettings.settings           |  102 +
 .../ServerResource/AgentShell/AgentShell.csproj |  135 +
 .../AgentShell/AgentShellException.cs           |   28 +
 .../DotNet/ServerResource/AgentShell/App.config |  145 +
 .../DotNet/ServerResource/AgentShell/Program.cs |   58 +
 .../AgentShell/Properties/AssemblyInfo.cs       |   39 +
 .../ServerResource/AgentShell/packages.config   |   10 +
 .../ServerResource/HypervResource/App.config    |  128 +
 .../HypervResource/CloudStackTypes.cs           |  642 +++++
 .../HypervResource/HypervResource.csproj        |  102 +
 .../HypervResource/HypervResourceController.cs  | 1399 ++++++++++
 .../HypervResource/Properties/AssemblyInfo.cs   |   36 +
 .../ServerResource/HypervResource/Utils.cs      |  110 +
 .../ServerResource/HypervResource/WmiCalls.cs   | 1469 ++++++++++
 .../HypervResource/packages.config              |    7 +
 .../ServerResource.Tests/App.config             |  128 +
 .../HypervResourceControllerTest.cs             | 1064 ++++++++
 .../Properties/AssemblyInfo.cs                  |   35 +
 .../ServerResource.Tests.csproj                 |  124 +
 .../ServerResource.Tests/packages.config        |    6 +
 .../DotNet/ServerResource/ServerResource.sln    |   61 +
 .../WmiWrappers/Properties/AssemblyInfo.cs      |   36 +
 .../ROOT.CIMV2.Win32_OperatingSystem.cs         | 2435 +++++++++++++++++
 .../WmiWrappers/ROOT.CIMV2.Win32_Processor.cs   | 2523 ++++++++++++++++++
 .../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 ++++++++++
 .../ServerResource/WmiWrappers/Readme.txt       |   20 +
 .../WmiWrappers/WmiWrappers.csproj              |  146 +
 ...rmattedData_Counters_ProcessorInformation.cs | 1737 ++++++++++++
 plugins/hypervisors/hyperv/buildagent.sh        |   22 +
 .../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              |  158 ++
 .../hyperv/scripts/dev_extra_setup.sh           |    8 +
 .../discoverer/HypervServerDiscoverer.java      |  467 ++++
 .../hypervisor/hyperv/guru/HypervGuru.java      |   68 +
 .../resource/HypervDirectConnectResource.java   |  454 ++++
 .../test/HypervDirectConnectResourceTest.java   |  938 +++++++
 plugins/pom.xml                                 |   12 +
 71 files changed, 45731 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index fd1f13a..2297182 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -143,6 +143,17 @@
     </dependency>
     <dependency>
       <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>
       <artifactId>cloud-plugin-storage-allocator-random</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 9b6636a..44ab97e 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -532,6 +532,10 @@
     <property name="name" value="Lxc Discover"/>
   </bean>
 
+  <bean id="HypervServerDiscoverer" class="com.cloud.hypervisor.hyperv.discoverer.HypervServerDiscoverer">
+    <property name="name" value="Hyper-V Agent"/>
+  </bean>
+
   <bean id="OvmDiscoverer" class="com.cloud.ovm.hypervisor.OvmDiscoverer">
     <property name="name" value="Ovm Discover"/>
   </bean>
@@ -609,6 +613,10 @@
     <property name="name" value="OvmGuru"/>
   </bean>
 
+  <bean id="HypervGuru" class="com.cloud.hypervisor.hyperv.guru.HypervGuru">
+    <property name="name" value="HypervGuru"/>
+  </bean> 
+
   <!--=====================================================================================================-->
   <!--                                                                                                     -->
   <!--                           Storage Subsystem Components and Helpers                                  -->

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index df5b002..1f1d072 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -167,6 +167,7 @@
           <ref bean="SecondaryStorageDiscoverer"/>
           <ref bean="KvmServerDiscoverer"/>
           <ref bean="LxcServerDiscoverer"/>
+          <ref bean="HypervServerDiscoverer"/>
           <ref bean="BareMetalDiscoverer"/>
           <ref bean="OvmDiscoverer"/>
       </list>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/client/tomcatconf/simulatorComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/simulatorComponentContext.xml.in b/client/tomcatconf/simulatorComponentContext.xml.in
index 82ff433..b2ba6c6 100644
--- a/client/tomcatconf/simulatorComponentContext.xml.in
+++ b/client/tomcatconf/simulatorComponentContext.xml.in
@@ -104,6 +104,7 @@
     <property name="Adapters">
       <list>
         <ref bean="SimulatorDiscoverer"/>
+        <ref bean="HypervServerDiscoverer"/>
         <ref bean="SimulatorSecondaryDiscoverer"/>
         <ref bean="XcpServerDiscoverer"/>
         <ref bean="SecondaryStorageDiscoverer"/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore b/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore
new file mode 100644
index 0000000..cf9cb85
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/.gitignore
@@ -0,0 +1,8 @@
+packages
+*.suo
+*/obj/*
+WmiWrappers/bin/*
+AgentShell/bin/*
+ServerResource*/bin/*
+*.user
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.Designer.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.Designer.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.Designer.cs
new file mode 100644
index 0000000..8544277
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.Designer.cs
@@ -0,0 +1,53 @@
+// 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.
+namespace CloudStack.Plugin.AgentShell
+{
+    partial class AgentService
+    {
+        /// <summary> 
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Component Designer generated code
+
+        /// <summary> 
+        /// Required method for Designer support - do not modify 
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            components = new System.ComponentModel.Container();
+            this.ServiceName = "CloudStack ServerResource";
+        }
+
+        #endregion
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..781014c
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs
@@ -0,0 +1,131 @@
+// 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.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Linq;
+using System.ServiceProcess;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web.Http.SelfHost;
+using System.Web.Http;
+using log4net;
+using HypervResource;
+
+namespace CloudStack.Plugin.AgentShell
+{
+    public partial class AgentService : ServiceBase
+    {
+        [System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
+        static extern bool AllocConsole();
+
+        [System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
+        static extern bool FreeConsole();
+
+        HttpSelfHostServer server;
+
+        private static ILog logger = LogManager.GetLogger(typeof(AgentService));
+
+        public AgentService()
+        {
+            logger.Info("Starting CloudStack agent");
+            InitializeComponent();
+
+            UriBuilder baseUri = new UriBuilder("http", AgentSettings.Default.private_ip_address, AgentSettings.Default.port);
+
+            var config = new HttpSelfHostConfiguration(baseUri.Uri);
+
+           // Allow ActionName to be applied to methods in ApiController, which allows it to serve multiple POST URLs
+            config.Routes.MapHttpRoute(
+                  "API Default", "api/{controller}/{action}",
+                  new { action = RouteParameter.Optional }
+                    );
+
+            // Load controller assemblies that we want to config to route to.
+            ConfigServerResource();
+            AssertControllerAssemblyAvailable(config, typeof(HypervResourceController), "Cannot load Controller of type" + typeof(HypervResourceController));
+
+            server = new HttpSelfHostServer(config);
+        }
+
+        public static void ConfigServerResource()
+        {
+            // For simplicity, ServerResource config and settings file are tightly coupled.
+            // An alternative is to pass a dictionary to the server resource and let it find 
+            // required settings.  In contrast, the approach below is strongly typed and makes
+            // use of VisualStudio settings designer.  The designer allows us to avoid
+            // accessing config using their key strings.
+            HypervResourceControllerConfig rsrcCnf = new HypervResourceControllerConfig();
+            rsrcCnf.PrivateIpAddress = AgentSettings.Default.private_ip_address;
+            rsrcCnf.GatewayIpAddress = AgentSettings.Default.gateway_ip_address;
+            rsrcCnf.RootDeviceReservedSpaceBytes = AgentSettings.Default.RootDeviceReservedSpaceBytes;
+            rsrcCnf.RootDeviceName = AgentSettings.Default.RootDeviceName;
+            rsrcCnf.ParentPartitionMinMemoryMb = AgentSettings.Default.dom0MinMemory;
+            rsrcCnf.LocalSecondaryStoragePath = AgentSettings.Default.local_secondary_storage_path;
+
+            // Side effect:  loads the assembly containing HypervResourceController, which
+            // allows HttpSelfHostServer to route requests to the controller.
+            HypervResourceController.Configure(rsrcCnf);
+
+        }
+
+        // TODO:  update to examine not the assembly resolver, but the list of available controllers themselves!
+        private static bool AssertControllerAssemblyAvailable(HttpSelfHostConfiguration config, Type controllerType, string errorMessage)
+        {
+            var assemblies = config.Services.GetAssembliesResolver().GetAssemblies();
+            foreach (var assembly in assemblies)
+            {
+                string name = assembly.GetName().Name;
+                if (controllerType.Assembly.GetName().Name.Equals(name))
+                {
+                    logger.DebugFormat("Controller {0} is available", controllerType.Name);
+                    return true;
+                }
+            }
+
+            logger.Error(errorMessage);
+            throw new AgentShellException(errorMessage);
+        }
+
+        protected override void OnStart(string[] args)
+        {
+            server.OpenAsync().Wait();
+        }
+
+        protected override void OnStop()
+        {
+            server.CloseAsync().Wait();
+        }
+
+        internal void RunConsole(string[] args)
+        {
+            OnStart(args);
+
+            AllocConsole();
+
+            Console.WriteLine("Service running ... press <ENTER> to stop");
+
+            Console.ReadLine();
+
+            FreeConsole();
+
+            OnStop();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..44df706
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
@@ -0,0 +1,371 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.17929
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace CloudStack.Plugin.AgentShell {
+    
+    
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    public sealed partial class AgentSettings : global::System.Configuration.ApplicationSettingsBase {
+        
+        private static AgentSettings defaultInstance = ((AgentSettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new AgentSettings())));
+        
+        public static AgentSettings Default {
+            get {
+                return defaultInstance;
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("8")]
+        public int cpus {
+            get {
+                return ((int)(this["cpus"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("Routing")]
+        public string type {
+            get {
+                return ((string)(this["type"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("5fe2bad3-d785-394e-9949-89786b8a63d2")]
+        public global::System.Guid local_storage_uuid {
+            get {
+                return ((global::System.Guid)(this["local_storage_uuid"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("hvm")]
+        public string capabilities {
+            get {
+                return ((string)(this["capabilities"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("2130")]
+        public int Settingcpuspeed {
+            get {
+                return ((int)(this["Settingcpuspeed"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("8250")]
+        public int port {
+            get {
+                return ((int)(this["port"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("34359738368")]
+        public long memory {
+            get {
+                return ((long)(this["memory"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("camldonall01.citrite.net")]
+        public string host {
+            get {
+                return ((string)(this["host"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("1")]
+        public int pod {
+            get {
+                return ((int)(this["pod"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("10.1.1.1")]
+        public string gateway_ip_address {
+            get {
+                return ((string)(this["gateway_ip_address"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        public global::System.Guid guid {
+            get {
+                return ((global::System.Guid)(this["guid"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("2")]
+        public int cluster {
+            get {
+                return ((int)(this["cluster"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("1")]
+        public int zone {
+            get {
+                return ((int)(this["zone"]));
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("c:\\Secondary")]
+        public string local_secondary_storage_path {
+            get {
+                return ((string)(this["local_secondary_storage_path"]));
+            }
+            set {
+                this["local_secondary_storage_path"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("E:\\Disks\\Disks")]
+        public string local_storage_path {
+            get {
+                return ((string)(this["local_storage_path"]));
+            }
+            set {
+                this["local_storage_path"] = value;
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("5")]
+        public int workers {
+            get {
+                return ((int)(this["workers"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("255.255.240.0")]
+        public string private_ip_netmask {
+            get {
+                return ((string)(this["private_ip_netmask"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("4294967296")]
+        public long RootDeviceReservedSpaceBytes {
+            get {
+                return ((long)(this["RootDeviceReservedSpaceBytes"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("..\\..\\..\\..\\..\\")]
+        public string hyperv_plugin_root {
+            get {
+                return ((string)(this["hyperv_plugin_root"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("e:\\")]
+        public string RootDeviceName {
+            get {
+                return ((string)(this["RootDeviceName"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("101F742C6B88")]
+        public string private_mac_address {
+            get {
+                return ((string)(this["private_mac_address"]));
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute(".\\var\\test\\storagepool")]
+        public string testLocalStorePath {
+            get {
+                return ((string)(this["testLocalStorePath"]));
+            }
+            set {
+                this["testLocalStorePath"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("testS3Bucket")]
+        public string testS3Bucket {
+            get {
+                return ((string)(this["testS3Bucket"]));
+            }
+            set {
+                this["testS3Bucket"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("testS3Endpoint")]
+        public string testS3Endpoint {
+            get {
+                return ((string)(this["testS3Endpoint"]));
+            }
+            set {
+                this["testS3Endpoint"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("testS3AccessKey")]
+        public string testS3AccessKey {
+            get {
+                return ((string)(this["testS3AccessKey"]));
+            }
+            set {
+                this["testS3AccessKey"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("testS3SecretKey")]
+        public string testS3SecretKey {
+            get {
+                return ((string)(this["testS3SecretKey"]));
+            }
+            set {
+                this["testS3SecretKey"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("206-2-73592258-559a-3b38-8f66-b667aab143eb")]
+        public string testS3TemplateName {
+            get {
+                return ((string)(this["testS3TemplateName"]));
+            }
+            set {
+                this["testS3TemplateName"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("5fe2bad3-d785-394e-9949-89786b8a63d2")]
+        public string testLocalStoreUUID {
+            get {
+                return ((string)(this["testLocalStoreUUID"]));
+            }
+            set {
+                this["testLocalStoreUUID"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("acton-systemvm-02062012.vhd.bz2")]
+        public string testSystemVMTemplateName {
+            get {
+                return ((string)(this["testSystemVMTemplateName"]));
+            }
+            set {
+                this["testSystemVMTemplateName"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("acton-systemvm-02062012")]
+        public string testSystemVMTemplateNameNoExt {
+            get {
+                return ((string)(this["testSystemVMTemplateNameNoExt"]));
+            }
+            set {
+                this["testSystemVMTemplateNameNoExt"] = value;
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("2048")]
+        public ulong dom0MinMemory {
+            get {
+                return ((ulong)(this["dom0MinMemory"]));
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("10.1.1.1")]
+        public string private_ip_address {
+            get {
+                return ((string)(this["private_ip_address"]));
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("cifs://10.1.1.1/secondary?user\\u003dadministrator\\u0026password\\u003d1pass%40w" +
+            "ord1")]
+        public string testCifsUrl {
+            get {
+                return ((string)(this["testCifsUrl"]));
+            }
+            set {
+                this["testCifsUrl"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("template/tmpl/2/201/61d5316a-3cc4-30cf-a557-78691ff5c143.vhd")]
+        public string testCifsPath {
+            get {
+                return ((string)(this["testCifsPath"]));
+            }
+            set {
+                this["testCifsPath"] = value;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..0d54f44
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.settings
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="CloudStack.Plugin.AgentShell" GeneratedClassName="AgentSettings">
+  <Profiles />
+  <Settings>
+    <Setting Name="cpus" Type="System.Int32" Scope="Application">
+      <Value Profile="(Default)">8</Value>
+    </Setting>
+    <Setting Name="private_ip_address" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">10.70.176.29</Value>
+    </Setting>
+    <Setting Name="type" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">Routing</Value>
+    </Setting>
+    <Setting Name="local_storage_uuid" Type="System.Guid" Scope="Application">
+      <Value Profile="(Default)">5fe2bad3-d785-394e-9949-89786b8a63d2</Value>
+    </Setting>
+    <Setting Name="capabilities" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">hvm</Value>
+    </Setting>
+    <Setting Name="Settingcpuspeed" Type="System.Int32" Scope="Application">
+      <Value Profile="(Default)">2130</Value>
+    </Setting>
+    <Setting Name="port" Type="System.Int32" Scope="Application">
+      <Value Profile="(Default)">8250</Value>
+    </Setting>
+    <Setting Name="memory" Type="System.Int64" Scope="Application">
+      <Value Profile="(Default)">34359738368</Value>
+    </Setting>
+    <Setting Name="host" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">camldonall01.citrite.net</Value>
+    </Setting>
+    <Setting Name="pod" Type="System.Int32" Scope="Application">
+      <Value Profile="(Default)">1</Value>
+    </Setting>
+    <Setting Name="gateway_ip_address" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">10.70.176.1</Value>
+    </Setting>
+    <Setting Name="guid" Type="System.Guid" Scope="Application">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="cluster" Type="System.Int32" Scope="Application">
+      <Value Profile="(Default)">2</Value>
+    </Setting>
+    <Setting Name="zone" Type="System.Int32" Scope="Application">
+      <Value Profile="(Default)">1</Value>
+    </Setting>
+    <Setting Name="local_secondary_storage_path" Type="System.String" Scope="User">
+      <Value Profile="(Default)">c:\Secondary</Value>
+    </Setting>
+    <Setting Name="local_storage_path" Type="System.String" Scope="User">
+      <Value Profile="(Default)">E:\Disks\Disks</Value>
+    </Setting>
+    <Setting Name="workers" Type="System.Int32" Scope="Application">
+      <Value Profile="(Default)">5</Value>
+    </Setting>
+    <Setting Name="private_ip_netmask" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">255.255.240.0</Value>
+    </Setting>
+    <Setting Name="RootDeviceReservedSpaceBytes" Type="System.Int64" Scope="Application">
+      <Value Profile="(Default)">4294967296</Value>
+    </Setting>
+    <Setting Name="hyperv_plugin_root" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">..\..\..\..\..\</Value>
+    </Setting>
+    <Setting Name="RootDeviceName" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">e:\</Value>
+    </Setting>
+    <Setting Name="private_mac_address" Type="System.String" Scope="Application">
+      <Value Profile="(Default)">101F742C6B88</Value>
+    </Setting>
+    <Setting Name="testLocalStorePath" Type="System.String" Scope="User">
+      <Value Profile="(Default)">.\var\test\storagepool</Value>
+    </Setting>
+    <Setting Name="testS3Bucket" Type="System.String" Scope="User">
+      <Value Profile="(Default)">testS3Bucket</Value>
+    </Setting>
+    <Setting Name="testS3Endpoint" Type="System.String" Scope="User">
+      <Value Profile="(Default)">testS3Endpoint</Value>
+    </Setting>
+    <Setting Name="testS3AccessKey" Type="System.String" Scope="User">
+      <Value Profile="(Default)">testS3AccessKey</Value>
+    </Setting>
+    <Setting Name="testS3SecretKey" Type="System.String" Scope="User">
+      <Value Profile="(Default)">testS3SecretKey</Value>
+    </Setting>
+    <Setting Name="testS3TemplateName" Type="System.String" Scope="User">
+      <Value Profile="(Default)">206-2-73592258-559a-3b38-8f66-b667aab143eb</Value>
+    </Setting>
+    <Setting Name="testLocalStoreUUID" Type="System.String" Scope="User">
+      <Value Profile="(Default)">5fe2bad3-d785-394e-9949-89786b8a63d2</Value>
+    </Setting>
+    <Setting Name="testSystemVMTemplateName" Type="System.String" Scope="User">
+      <Value Profile="(Default)">acton-systemvm-02062012.vhd.bz2</Value>
+    </Setting>
+    <Setting Name="testSystemVMTemplateNameNoExt" Type="System.String" Scope="User">
+      <Value Profile="(Default)">acton-systemvm-02062012</Value>
+    </Setting>
+    <Setting Name="dom0MinMemory" Type="System.UInt64" Scope="Application">
+      <Value Profile="(Default)">2048</Value>
+    </Setting>
+  </Settings>
+</SettingsFile>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..fe055d0
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj
@@ -0,0 +1,135 @@
+<?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>{9060B539-62D0-4E71-A6C6-5944828774E9}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>CloudStack.Plugin.AgentShell</RootNamespace>
+    <AssemblyName>AgentShell</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' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <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' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <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>
+    <Prefer32Bit>true</Prefer32Bit>
+  </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>
+    <Prefer32Bit>true</Prefer32Bit>
+  </PropertyGroup>
+  <ItemGroup>
+    <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.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>
+    <Reference Include="System.Web.Http.SelfHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.AspNet.WebApi.SelfHost.4.0.20918.0\lib\net40\System.Web.Http.SelfHost.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.ServiceProcess" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AgentService.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="AgentService.Designer.cs">
+      <DependentUpon>AgentService.cs</DependentUpon>
+    </Compile>
+    <Compile Include="AgentShellException.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="AgentSettings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+      <DependentUpon>AgentSettings.settings</DependentUpon>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <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>
+      <SubType>Designer</SubType>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <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="$(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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShellException.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShellException.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShellException.cs
new file mode 100644
index 0000000..14d9e97
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShellException.cs
@@ -0,0 +1,28 @@
+// 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;
+
+namespace CloudStack.Plugin.AgentShell
+{
+    class AgentShellException : Exception
+    {
+        public AgentShellException(string errMsg) : base(errMsg) { }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..444f641
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/App.config
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <configSections>
+    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
+    <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" >
+      <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>
+
+  <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+
+  <log4net>
+    <appender name="FileAppender" type="log4net.Appender.FileAppender">
+      <file value="cloudstack-agent.log" />
+      <appendToFile value="true" />
+      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
+      <layout type="log4net.Layout.PatternLayout">
+        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
+      </layout>
+    </appender>
+    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
+      <appendToFile value="true" />
+      <layout type="log4net.Layout.PatternLayout">
+        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
+      </layout>
+    </appender>
+    <root>
+      <level value="ALL"/>
+      <appender-ref ref="FileAppender"/>
+    </root>
+  </log4net>
+  
+  <applicationSettings>
+    <CloudStack.Plugin.AgentShell.AgentSettings>
+      <setting name="cpus" serializeAs="String">
+        <value>8</value>
+      </setting>
+      <setting name="type" serializeAs="String">
+        <value>Routing</value>
+      </setting>
+      <setting name="local_storage_uuid" serializeAs="String">
+        <value>5fe2bad3-d785-394e-9949-89786b8a63d2</value>
+      </setting>
+      <setting name="capabilities" serializeAs="String">
+        <value>hvm</value>
+      </setting>
+      <setting name="Settingcpuspeed" serializeAs="String">
+        <value>2130</value>
+      </setting>
+      <setting name="port" serializeAs="String">
+        <value>8250</value>
+      </setting>
+      <setting name="memory" serializeAs="String">
+        <value>34359738368</value>
+      </setting>
+      <setting name="host" serializeAs="String">
+        <value>camldonall01.citrite.net</value>
+      </setting>
+      <setting name="pod" serializeAs="String">
+        <value>1</value>
+      </setting>
+      <setting name="gateway_ip_address" serializeAs="String">
+        <value>10.70.176.1</value>
+      </setting>
+      <setting name="cluster" serializeAs="String">
+        <value>2</value>
+      </setting>
+      <setting name="zone" serializeAs="String">
+        <value>1</value>
+      </setting>
+      <setting name="workers" serializeAs="String">
+        <value>5</value>
+      </setting>
+      <setting name="private_ip_netmask" serializeAs="String">
+        <value>255.255.240.0</value>
+      </setting>
+      <setting name="RootDeviceReservedSpaceBytes" serializeAs="String">
+        <value>4294967296</value>
+      </setting>
+      <setting name="hyperv_plugin_root" serializeAs="String">
+        <value>..\..\..\..\..\</value>
+      </setting>
+      <setting name="RootDeviceName" serializeAs="String">
+        <value>e:\</value>
+      </setting>
+      <setting name="private_mac_address" serializeAs="String">
+        <value>101F742C6B88</value>
+      </setting>
+      <setting name="dom0MinMemory" serializeAs="String">
+        <value>2048</value>
+      </setting>
+      <setting name="private_ip_address" serializeAs="String">
+        <value>10.70.1.1</value>
+      </setting>
+    </CloudStack.Plugin.AgentShell.AgentSettings>
+   </applicationSettings>
+  <userSettings>
+    <CloudStack.Plugin.AgentShell.AgentSettings>
+      <setting name="local_secondary_storage_path" serializeAs="String">
+        <value>c:\Secondary</value>
+      </setting>
+      <setting name="local_storage_path" serializeAs="String">
+        <value>E:\Disks\Disks</value>
+      </setting>
+      <setting name="testLocalStorePath" serializeAs="String">
+        <value>.\var\test\storagepool</value>
+      </setting>
+      <setting name="testS3Bucket" serializeAs="String">
+        <value>testS3Bucket</value>
+      </setting>
+      <setting name="testS3Endpoint" serializeAs="String">
+        <value>testS3Endpoint</value>
+      </setting>
+      <setting name="testS3AccessKey" serializeAs="String">
+        <value>testS3AccessKey</value>
+      </setting>
+      <setting name="testS3SecretKey" serializeAs="String">
+        <value>testS3SecretKey</value>
+      </setting>
+      <setting name="testS3TemplateName" serializeAs="String">
+        <value>206-2-73592258-559a-3b38-8f66-b667aab143eb</value>
+      </setting>
+      <setting name="testLocalStoreUUID" serializeAs="String">
+        <value>5fe2bad3-d785-394e-9949-89786b8a63d2</value>
+      </setting>
+      <setting name="testSystemVMTemplateName" serializeAs="String">
+        <value>acton-systemvm-02062012.vhd.bz2</value>
+      </setting>
+      <setting name="testSystemVMTemplateNameNoExt" serializeAs="String">
+        <value>acton-systemvm-02062012</value>
+      </setting>
+      <setting name="testCifsUrl" serializeAs="String">
+        <value>cifs://10.70.1.1/secondary?user\u003dadministrator\u0026password\u003d1pass%40word1</value>
+      </setting>
+      <setting name="testCifsPath" serializeAs="String">
+        <value>template/tmpl/2/201/61d5316a-3cc4-30cf-a557-78691ff5c143.vhd</value>
+      </setting>
+    </CloudStack.Plugin.AgentShell.AgentSettings>
+  </userSettings>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Program.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Program.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Program.cs
new file mode 100644
index 0000000..1066370
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Program.cs
@@ -0,0 +1,58 @@
+// 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 log4net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.ServiceProcess;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CloudStack.Plugin.AgentShell
+{
+    static class Program
+    {
+        private static ILog logger = LogManager.GetLogger(typeof(Program));
+
+        /// <summary>
+        /// Application entry point allows service to run in console application or as a Windows service.
+        /// Add '--console' to the commandline for the former, the latter is the default.
+        /// </summary>
+        static void Main(params string[] args)
+        {
+            string arg1 = string.Empty;
+
+            if (args.Length > 0)
+            {
+                arg1 = args[0];
+                logger.DebugFormat("CloudStack ServerResource arg is ", arg1);
+            }
+
+            if (string.Compare(arg1, "--console", true) == 0)
+            {
+                logger.InfoFormat("CloudStack ServerResource running as console app");
+                new AgentService().RunConsole(args);
+            }
+            else
+            {
+                logger.InfoFormat("CloudStack ServerResource running as Windows Service");
+                ServiceBase[] ServicesToRun = new ServiceBase[] { new AgentService() };
+                ServiceBase.Run(ServicesToRun);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Properties/AssemblyInfo.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..ca7a23b
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Properties/AssemblyInfo.cs
@@ -0,0 +1,39 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AgentShell")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AgentShell")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a6d8469a-c815-4765-a4a1-4927d4e3c583")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+
+[assembly: log4net.Config.XmlConfigurator(Watch = true)]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..f5f47e6
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/packages.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <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" />
+  <package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net45" />
+  <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" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
new file mode 100644
index 0000000..1bf17d4
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/App.config
@@ -0,0 +1,128 @@
+<?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" >
+      <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" >
+      <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>
+
+  <applicationSettings>
+    <CloudStack.Plugin.AgentShell.AgentSettings>
+      <setting name="cpus" serializeAs="String">
+        <value>8</value>
+      </setting>
+      <setting name="private_ip_address" serializeAs="String">
+        <value>10.1.1.1</value>
+      </setting>
+      <setting name="type" serializeAs="String">
+        <value>Routing</value>
+      </setting>
+      <setting name="local_storage_uuid" serializeAs="String">
+        <value>5fe2bad3-d785-394e-9949-89786b8a63d2</value>
+      </setting>
+      <setting name="capabilities" serializeAs="String">
+        <value>hvm</value>
+      </setting>
+      <setting name="Settingcpuspeed" serializeAs="String">
+        <value>2130</value>
+      </setting>
+      <setting name="port" serializeAs="String">
+        <value>8250</value>
+      </setting>
+      <setting name="memory" serializeAs="String">
+        <value>34359738368</value>
+      </setting>
+      <setting name="host" serializeAs="String">
+        <value>camldonall01.citrite.net</value>
+      </setting>
+      <setting name="pod" serializeAs="String">
+        <value>1</value>
+      </setting>
+      <setting name="gateway_ip_address" serializeAs="String">
+        <value>10.70.176.1</value>
+      </setting>
+      <setting name="cluster" serializeAs="String">
+        <value>2</value>
+      </setting>
+      <setting name="zone" serializeAs="String">
+        <value>1</value>
+      </setting>
+      <setting name="local_storage_path" serializeAs="String">
+        <value>E:\Disks\Disks</value>
+      </setting>
+      <setting name="workers" serializeAs="String">
+        <value>5</value>
+      </setting>
+      <setting name="private_ip_netmask" serializeAs="String">
+        <value>255.255.240.0</value>
+      </setting>
+      <setting name="RootDeviceReservedSpaceBytes" serializeAs="String">
+        <value>4294967296</value>
+      </setting>
+      <setting name="hyperv_plugin_root" serializeAs="String">
+        <value>..\..\..\..\..\</value>
+      </setting>
+      <setting name="RootDeviceName" serializeAs="String">
+        <value>e:\</value>
+      </setting>
+      <setting name="dom0MinMemory" serializeAs="String">
+        <value>2048</value>
+      </setting>
+      <setting name="private_mac_address" serializeAs="String">
+        <value>101F742C6B88</value>
+      </setting>
+    </CloudStack.Plugin.AgentShell.AgentSettings>
+  </applicationSettings>
+  <userSettings>
+    <CloudStack.Plugin.AgentShell.AgentSettings>
+      <setting name="local_secondary_storage_path" serializeAs="String">
+        <value>c:\Secondary</value>
+      </setting>
+      <setting name="local_storage_path" serializeAs="String">
+        <value>E:\Disks\Disks</value>
+      </setting>
+      <setting name="testLocalStoreUUID" serializeAs="String">
+        <value>5fe2bad3-d785-394e-9949-89786b8a63d2</value>
+      </setting>
+      <setting name="testLocalStorePath" serializeAs="String">
+        <value>.\var\test\storagepool</value>
+      </setting>
+      <setting name="testS3Bucket" serializeAs="String">
+        <value>cshv3eu</value>
+      </setting>
+      <setting name="testS3Endpoint" serializeAs="String">
+        <value>s3.amazonaws.com</value>
+      </setting>
+      <setting name="testS3AccessKey" serializeAs="String">
+        <value>testS3AccessKey</value>
+      </setting>
+      <setting name="testS3SecretKey" serializeAs="String">
+        <value>testS3SecretKey</value>
+      </setting>
+      <setting name="testS3TemplateName" serializeAs="String">
+        <value>206-2-73592258-559a-3b38-8f66-b667aab143eb</value>
+      </setting>
+      <setting name="testCifsTemplateName" serializeAs="String">
+        <value>206-2-73592258-559a-3b38-8f66-b667aab143eb</value>
+      </setting>
+      <setting name="testCifsUrl" serializeAs="String">
+        <value>cifs://10.1.1.1/secondary?user\u003dadministrator\u0026password\u003d1pass%40word1</value>
+      </setting>
+      <setting name="testCifsPath" serializeAs="String">
+        <value>template/tmpl/2/201/6dda6631-4daa-3150-a49a-d5a4b0a4c4b6.vhd</value>
+      </setting>
+    </CloudStack.Plugin.AgentShell.AgentSettings>
+  </userSettings>
+</configuration>


[05/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..fde04ac
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementServiceSettingData.cs
@@ -0,0 +1,731 @@
+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/1d0a931d/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
new file mode 100644
index 0000000..ae2b7f8
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemSettingData.cs
@@ -0,0 +1,1206 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[22/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..a479c60
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ExternalEthernetPort.cs
@@ -0,0 +1,1996 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[26/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_OperatingSystem.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_OperatingSystem.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_OperatingSystem.cs
new file mode 100644
index 0000000..58fb610
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_OperatingSystem.cs
@@ -0,0 +1,2435 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 {
+    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.Win32_OperatingSystem
+    public class OperatingSystem0 : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\CIMV2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Win32_OperatingSystem";
+        
+        // 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 OperatingSystem0() {
+            this.InitializeObject(null, new System.Management.ManagementPath(OperatingSystem0.ConstructPath()), null);
+        }
+        
+        public OperatingSystem0(System.Management.ManagementScope mgmtScope) {
+            this.InitializeObject(mgmtScope, new System.Management.ManagementPath(OperatingSystem0.ConstructPath()), null);
+        }
+        
+        public OperatingSystem0(System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, new System.Management.ManagementPath(OperatingSystem0.ConstructPath()), getOptions);
+        }
+        
+        public OperatingSystem0(System.Management.ManagementScope mgmtScope, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, new System.Management.ManagementPath(OperatingSystem0.ConstructPath()), getOptions);
+        }
+        
+        public OperatingSystem0(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public OperatingSystem0(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public OperatingSystem0(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 OperatingSystem0(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\\CIMV2";
+            }
+        }
+        
+        [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 BootDevice property indicates the name of the disk drive from which the Win32" +
+            " operating system boots. \nExample: \\\\Device\\Harddisk0.")]
+        public string BootDevice {
+            get {
+                return ((string)(curObj["BootDevice"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The BuildNumber property indicates the build number of the operating system.  It " +
+            "can be used for more precise versioning information than product release version" +
+            " numbers\nExample: 1381")]
+        public string BuildNumber {
+            get {
+                return ((string)(curObj["BuildNumber"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The BuildType property indicates the type of build used for the operating system." +
+            " Examples are retail build and checked build.")]
+        public string BuildType {
+            get {
+                return ((string)(curObj["BuildType"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Caption property is a short textual description (one-line string) of the obje" +
+            "ct.")]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The CodeSet property indicates the code page value used by the operating system. A code page contains a character table used by the operating system to translate strings for different languages. The American National Standards Institute (ANSI) lists values that represent defined code pages. If the operating system does not use an ANSI code page, this member will be set to 0. The CodeSet string can use up to six characters to define the code page value.
+Example: 1255.")]
+        public string CodeSet {
+            get {
+                return ((string)(curObj["CodeSet"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The CountryCode property indicates the code for the country/regionused by the operating system. Values are based on international phone dialing prefixes (also referred to as IBM country/region codes). The CountryCode string can use up to six characters to define the country/region code value.
+Example: 1 for the United States)")]
+        public string CountryCode {
+            get {
+                return ((string)(curObj["CountryCode"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("CreationClassName indicates the name of the class or the subclass used in the cre" +
+            "ation of an instance. When used with the other key properties of this class, thi" +
+            "s property allows all instances of this class and its subclasses to be uniquely " +
+            "identified.")]
+        public string CreationClassName {
+            get {
+                return ((string)(curObj["CreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("CSCreationClassName contains the scoping computer system\'s creation class name.")]
+        public string CSCreationClassName {
+            get {
+                return ((string)(curObj["CSCreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The CSDVersion property contains a null-terminated string, that indicates the latest Service Pack installed on the computer system. If no Service Pack is installed, the string is NULL. For computer systems running Windows 95, this property contains a null-terminated string that provides arbitrary additional information about the operating system.
+Example: Service Pack 3.")]
+        public string CSDVersion {
+            get {
+                return ((string)(curObj["CSDVersion"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("CSName contains the scoping computer system\'s name.")]
+        public string CSName {
+            get {
+                return ((string)(curObj["CSName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCurrentTimeZoneNull {
+            get {
+                if ((curObj["CurrentTimeZone"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("CurrentTimeZone indicates the number of minutes the operating system is offset fr" +
+            "om Greenwich Mean Time. Either the number is positive, negative or zero.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public short CurrentTimeZone {
+            get {
+                if ((curObj["CurrentTimeZone"] == null)) {
+                    return System.Convert.ToInt16(0);
+                }
+                return ((short)(curObj["CurrentTimeZone"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDataExecutionPrevention_32BitApplicationsNull {
+            get {
+                if ((curObj["DataExecutionPrevention_32BitApplications"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("If true, indicates that 32-bit applications are running with Data Execution Preve" +
+            "ntion (DEP) applied. (false if DataExecutionPrevention_Available = false)")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool DataExecutionPrevention_32BitApplications {
+            get {
+                if ((curObj["DataExecutionPrevention_32BitApplications"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["DataExecutionPrevention_32BitApplications"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDataExecutionPrevention_AvailableNull {
+            get {
+                if ((curObj["DataExecutionPrevention_Available"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"If true, indicates that the hardware supports Windows Data Execution Prevention (DEP) technology. DEP ensures that all memory locations are marked with a non-executable attribute unless the memory location explicitly contains executable code.  This can help mitigate certain types of buffer overrun security exploits.  If DEP is available, 64-bit applications are automatically protected.  To determine if DEP has been enabled for 32-bit applications and drivers, use the DataExecutionPrevention_ properties ")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool DataExecutionPrevention_Available {
+            get {
+                if ((curObj["DataExecutionPrevention_Available"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["DataExecutionPrevention_Available"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDataExecutionPrevention_DriversNull {
+            get {
+                if ((curObj["DataExecutionPrevention_Drivers"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("If true, indicates that drivers are running with Data Execution Prevention (DEP) " +
+            "applied. (false if DataExecutionPrevention_Available = false)")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool DataExecutionPrevention_Drivers {
+            get {
+                if ((curObj["DataExecutionPrevention_Drivers"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["DataExecutionPrevention_Drivers"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDataExecutionPrevention_SupportPolicyNull {
+            get {
+                if ((curObj["DataExecutionPrevention_SupportPolicy"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The DataExecutionPrevention_SupportPolicy indicates which one of four Data Execution Prevention (DEP) settings is applied. Each setting varies by the extent to which DEP is applied to 32-bit applications.  Note that DEP is always applied to the Windows kernel. Always On (not available in the user interface) indicates that DEP is enabled for all 32-bit applications on the machine with no exceptions. OptOut indicates DEP is on by default for all 32-bit applications and that a user or administrator must explicitly remove support for a 32-bit application by adding to an exceptions list. OptIn indicates DEP is on for a limited number of binaries, the kernel, and all Windows services but it is off by default for all 32-bit applications; a user or administrator must explicitly choose the AlwaysOn (not available in the user interface) or OptOut setting before DEP can be applied to 32-bit applications.  AlwaysOff (not available in the user interface) indicates DEP is t
 urned off for all 32-bit applications on the machine. ")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public DataExecutionPrevention_SupportPolicyValues DataExecutionPrevention_SupportPolicy {
+            get {
+                if ((curObj["DataExecutionPrevention_SupportPolicy"] == null)) {
+                    return ((DataExecutionPrevention_SupportPolicyValues)(System.Convert.ToInt32(4)));
+                }
+                return ((DataExecutionPrevention_SupportPolicyValues)(System.Convert.ToInt32(curObj["DataExecutionPrevention_SupportPolicy"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDebugNull {
+            get {
+                if ((curObj["Debug"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The Debug property indicates whether the operating system is a checked (debug) build. Checked builds provide error checking, argument verification, and system debugging code. Additional code in a checked binary generates a kernel debugger error message and breaks into the debugger. This helps  immediately determine the cause and location of the error. Performance suffers in the checked build due to the additional code that is executed.
+Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.exe is installed.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool Debug {
+            get {
+                if ((curObj["Debug"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["Debug"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Description property provides a description of the Windows operating system. " +
+            "Some user interfaces (those that allow editing of this description) limit its le" +
+            "ngth to 48 characters.")]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+            set {
+                curObj["Description"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDistributedNull {
+            get {
+                if ((curObj["Distributed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Boolean indicating whether the operating system is distributed across several com" +
+            "puter system nodes. If so, these nodes should be grouped as a cluster.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool Distributed {
+            get {
+                if ((curObj["Distributed"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["Distributed"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEncryptionLevelNull {
+            get {
+                if ((curObj["EncryptionLevel"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The EncryptionLevel property specifies if the encryption level for secure transac" +
+            "tions is 40-bit, 128-bit, or n-bit encryption.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public EncryptionLevelValues EncryptionLevel {
+            get {
+                if ((curObj["EncryptionLevel"] == null)) {
+                    return ((EncryptionLevelValues)(System.Convert.ToInt32(3)));
+                }
+                return ((EncryptionLevelValues)(System.Convert.ToInt32(curObj["EncryptionLevel"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsForegroundApplicationBoostNull {
+            get {
+                if ((curObj["ForegroundApplicationBoost"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The ForegroundApplicationBoost property indicates the increase in priority given to the foreground application. On computer systems running Windows NT 4.0 and Windows 2000, application boost is implemented by giving an application more execution time slices (quantum lengths). A ForegroundApplicationBoost value of 0 indicates the system boosts the quantum length by 6; if 1, then 12; and if 2 then 18. On Windows NT 3.51 and earlier, application boost is implemented by increasing the scheduling priority. For these systems, the scheduling priority is increased by the value of this property. The default value is 2.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ForegroundApplicationBoostValues ForegroundApplicationBoost {
+            get {
+                if ((curObj["ForegroundApplicationBoost"] == null)) {
+                    return ((ForegroundApplicationBoostValues)(System.Convert.ToInt32(3)));
+                }
+                return ((ForegroundApplicationBoostValues)(System.Convert.ToInt32(curObj["ForegroundApplicationBoost"])));
+            }
+            set {
+                if ((ForegroundApplicationBoostValues.NULL_ENUM_VALUE == value)) {
+                    curObj["ForegroundApplicationBoost"] = null;
+                }
+                else {
+                    curObj["ForegroundApplicationBoost"] = value;
+                }
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFreePhysicalMemoryNull {
+            get {
+                if ((curObj["FreePhysicalMemory"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Number of kilobytes of physical memory currently unused and available")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong FreePhysicalMemory {
+            get {
+                if ((curObj["FreePhysicalMemory"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["FreePhysicalMemory"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFreeSpaceInPagingFilesNull {
+            get {
+                if ((curObj["FreeSpaceInPagingFiles"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The total number of KBytes that can be mapped into the OperatingSystem\'s paging f" +
+            "iles without causing any other pages to be swapped out. 0 indicates that there a" +
+            "re no paging files.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong FreeSpaceInPagingFiles {
+            get {
+                if ((curObj["FreeSpaceInPagingFiles"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["FreeSpaceInPagingFiles"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFreeVirtualMemoryNull {
+            get {
+                if ((curObj["FreeVirtualMemory"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Number of kilobytes of virtual memory currently unused and available. For example" +
+            ", this may be calculated by adding the amount of free RAM to the amount of free " +
+            "paging space (i.e., adding the properties, FreePhysicalMemory and FreeSpaceInPag" +
+            "ingFiles).")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong FreeVirtualMemory {
+            get {
+                if ((curObj["FreeVirtualMemory"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["FreeVirtualMemory"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInstallDateNull {
+            get {
+                if ((curObj["InstallDate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The InstallDate property is datetime value indicating when the object was install" +
+            "ed. A lack of a value does not indicate that the object is not installed.")]
+        [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 IsLargeSystemCacheNull {
+            get {
+                if ((curObj["LargeSystemCache"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The LargeSystemCache property indicates whether to optimize memory for applicatio" +
+            "ns (value=0) or for system performance (value=1).")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public LargeSystemCacheValues LargeSystemCache {
+            get {
+                if ((curObj["LargeSystemCache"] == null)) {
+                    return ((LargeSystemCacheValues)(System.Convert.ToInt32(2)));
+                }
+                return ((LargeSystemCacheValues)(System.Convert.ToInt32(curObj["LargeSystemCache"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLastBootUpTimeNull {
+            get {
+                if ((curObj["LastBootUpTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Time when the operating system was last booted")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime LastBootUpTime {
+            get {
+                if ((curObj["LastBootUpTime"] != null)) {
+                    return ToDateTime(((string)(curObj["LastBootUpTime"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLocalDateTimeNull {
+            get {
+                if ((curObj["LocalDateTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Operating system\'s notion of the local date and time of day.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime LocalDateTime {
+            get {
+                if ((curObj["LocalDateTime"] != null)) {
+                    return ToDateTime(((string)(curObj["LocalDateTime"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The Locale property indicates the language identifier used by the operating system. A language identifier is a standard international numeric abbreviation for a country or region. Each language has a unique language identifier (LANGID), a 16-bit value that consists of a primary language identifier and a secondary language identifier.")]
+        public string Locale {
+            get {
+                return ((string)(curObj["Locale"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Manufacturer property indicates the name of the operating system manufacturer" +
+            ".  For Win32 systems this value will be Microsoft Corporation.")]
+        public string Manufacturer {
+            get {
+                return ((string)(curObj["Manufacturer"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxNumberOfProcessesNull {
+            get {
+                if ((curObj["MaxNumberOfProcesses"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Maximum number of process contexts the operating system can support. If there is no fixed maximum, the value should be 0. On systems that have a fixed maximum, this object can help diagnose failures that occur when the maximum is reached. If unknown, enter -1.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint MaxNumberOfProcesses {
+            get {
+                if ((curObj["MaxNumberOfProcesses"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["MaxNumberOfProcesses"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxProcessMemorySizeNull {
+            get {
+                if ((curObj["MaxProcessMemorySize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Maximum number of kilobytes of memory that can be allocated to a process. For operating systems with no virtual memory, this value is typically equal to the total amount of physical memory minus memory used by the BIOS and OS. For some operating systems, this value may be infinity - in which case, 0 should be entered. In other cases, this value could be a constant - for example, 2G or 4G.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong MaxProcessMemorySize {
+            get {
+                if ((curObj["MaxProcessMemorySize"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["MaxProcessMemorySize"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The MUILanguages property indicates the MUI Languages installed in the system. \n " +
+            "Example: en-us.")]
+        public string[] MUILanguages {
+            get {
+                return ((string[])(curObj["MUILanguages"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Name of the operating system instance within a computer system.")]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNumberOfLicensedUsersNull {
+            get {
+                if ((curObj["NumberOfLicensedUsers"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Number of user licenses for the operating system. If unlimited, enter 0. If unkno" +
+            "wn, enter -1.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint NumberOfLicensedUsers {
+            get {
+                if ((curObj["NumberOfLicensedUsers"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["NumberOfLicensedUsers"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNumberOfProcessesNull {
+            get {
+                if ((curObj["NumberOfProcesses"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Number of process contexts currently loaded or running on the operating system.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint NumberOfProcesses {
+            get {
+                if ((curObj["NumberOfProcesses"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["NumberOfProcesses"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNumberOfUsersNull {
+            get {
+                if ((curObj["NumberOfUsers"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Number of user sessions for which the operating system is currently storing state" +
+            " information")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint NumberOfUsers {
+            get {
+                if ((curObj["NumberOfUsers"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["NumberOfUsers"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOperatingSystemSKUNull {
+            get {
+                if ((curObj["OperatingSystemSKU"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The OperatingSystemSKU property identifies the SKU of the operating system.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint OperatingSystemSKU {
+            get {
+                if ((curObj["OperatingSystemSKU"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["OperatingSystemSKU"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Organization property indicates the registered user\'s (of the operating syste" +
+            "m) company name.\nExample: Microsoft Corporation.")]
+        public string Organization {
+            get {
+                return ((string)(curObj["Organization"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The OSArchitecture property indicates the Architecture of the operating system.Ex" +
+            "ample: 32-bit, 64-bit Intel, 64-bit AMD ")]
+        public string OSArchitecture {
+            get {
+                return ((string)(curObj["OSArchitecture"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOSLanguageNull {
+            get {
+                if ((curObj["OSLanguage"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The OSLanguage property indicates which language version of the operating system " +
+            "is installed.\nExample: 0x0807 (German, Switzerland)")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint OSLanguage {
+            get {
+                if ((curObj["OSLanguage"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["OSLanguage"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOSProductSuiteNull {
+            get {
+                if ((curObj["OSProductSuite"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The OSProductSuite property identifies installed and licensed system product addi" +
+            "tions to the operating system.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public OSProductSuiteValues OSProductSuite {
+            get {
+                if ((curObj["OSProductSuite"] == null)) {
+                    return ((OSProductSuiteValues)(System.Convert.ToInt32(256)));
+                }
+                return ((OSProductSuiteValues)(System.Convert.ToInt32(curObj["OSProductSuite"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsOSTypeNull {
+            get {
+                if ((curObj["OSType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("A integer indicating the type of operating system.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public OSTypeValues OSType {
+            get {
+                if ((curObj["OSType"] == null)) {
+                    return ((OSTypeValues)(System.Convert.ToInt32(63)));
+                }
+                return ((OSTypeValues)(System.Convert.ToInt32(curObj["OSType"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"A string describing the manufacturer and operating system type - used when the operating system property, OSType, is set to 1 (""Other""). The format of the string inserted in OtherTypeDescription should be similar in format to the Values strings defined for OSType.  OtherTypeDescription should be set to NULL when OSType is any value other than 1.")]
+        public string OtherTypeDescription {
+            get {
+                return ((string)(curObj["OtherTypeDescription"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPAEEnabledNull {
+            get {
+                if ((curObj["PAEEnabled"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool PAEEnabled {
+            get {
+                if ((curObj["PAEEnabled"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["PAEEnabled"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The PlusProductID property contains the product identification number for the Win" +
+            "dows Plus! operating system enhancement software (if installed).")]
+        public string PlusProductID {
+            get {
+                return ((string)(curObj["PlusProductID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The PlusVersionNumber property contains the version number of the Windows Plus! o" +
+            "perating system enhancement software (if installed).")]
+        public string PlusVersionNumber {
+            get {
+                return ((string)(curObj["PlusVersionNumber"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPortableOperatingSystemNull {
+            get {
+                if ((curObj["PortableOperatingSystem"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The PortableOperatingSystem property indicates if theOperating System is booting from a supported locally connected storagedevice.
+Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted from a supported locally connected storage device.
+")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool PortableOperatingSystem {
+            get {
+                if ((curObj["PortableOperatingSystem"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["PortableOperatingSystem"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPrimaryNull {
+            get {
+                if ((curObj["Primary"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Primary property determines whether this is the primary operating system.\nVal" +
+            "ues: TRUE or FALSE. A value of TRUE indicates this is the primary operating syst" +
+            "em.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool Primary {
+            get {
+                if ((curObj["Primary"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["Primary"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsProductTypeNull {
+            get {
+                if ((curObj["ProductType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The ProductType property indicates additional information about the system. This " +
+            "member can be one of the following values: \n1 - Work Station \n2 - Domain Control" +
+            "ler \n3 - Server")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ProductTypeValues ProductType {
+            get {
+                if ((curObj["ProductType"] == null)) {
+                    return ((ProductTypeValues)(System.Convert.ToInt32(0)));
+                }
+                return ((ProductTypeValues)(System.Convert.ToInt32(curObj["ProductType"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The RegisteredUser property indicates the name of the registered user of the oper" +
+            "ating system.\nExample: Jane Doe")]
+        public string RegisteredUser {
+            get {
+                return ((string)(curObj["RegisteredUser"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The SerialNumber property indicates the operating system product serial identific" +
+            "ation number.\nExample:10497-OEM-0031416-71674.")]
+        public string SerialNumber {
+            get {
+                return ((string)(curObj["SerialNumber"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsServicePackMajorVersionNull {
+            get {
+                if ((curObj["ServicePackMajorVersion"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The ServicePackMajorVersion property indicates the major version number of the service pack installed on the computer system. If no service pack has been installed, the value is zero. ServicePackMajorVersion is valid for computers running Windows 2000 and later (NULL otherwise).")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ServicePackMajorVersion {
+            get {
+                if ((curObj["ServicePackMajorVersion"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ServicePackMajorVersion"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsServicePackMinorVersionNull {
+            get {
+                if ((curObj["ServicePackMinorVersion"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The ServicePackMinorVersion property indicates the minor version number of the service pack installed on the computer system. If no service pack has been installed, the value is zero. ServicePackMinorVersion is valid for computers running Windows 2000 and later (NULL otherwise).")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort ServicePackMinorVersion {
+            get {
+                if ((curObj["ServicePackMinorVersion"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["ServicePackMinorVersion"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSizeStoredInPagingFilesNull {
+            get {
+                if ((curObj["SizeStoredInPagingFiles"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The total number of kilobytes that can be stored in the operating system\'s paging" +
+            " files. Note that this number does not represent the actual physical size of the" +
+            " paging file on disk.  0 indicates that there are no paging files.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong SizeStoredInPagingFiles {
+            get {
+                if ((curObj["SizeStoredInPagingFiles"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["SizeStoredInPagingFiles"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The Status property is a string indicating the current status of the object. Various operational and non-operational statuses can be defined. Operational statuses are ""OK"", ""Degraded"" and ""Pred Fail"". ""Pred Fail"" indicates that an element may be functioning properly but predicting a failure in the near future. An example is a SMART-enabled hard drive. Non-operational statuses can also be specified. These are ""Error"", ""Starting"", ""Stopping"" and ""Service"". The latter, ""Service"", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is on-line, yet the managed element is neither ""OK"" nor in one of the other states.")]
+        public string Status {
+            get {
+                return ((string)(curObj["Status"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSuiteMaskNull {
+            get {
+                if ((curObj["SuiteMask"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The SuiteMask property indicates a set of bit flags that identify the product suites available on the system. This member can be a combination of the following values: 
+0 - Windows Server 2003, Small Business Edition 
+1 - Windows Server 2003, Enterprise Edition 
+2 - Windows Server 2003, Backoffice Edition 
+3 - Windows Server 2003, Communications Edition 
+4 - Microsoft Terminal Services 
+5 - Windows Server 2003, Small Business Edition Restricted 
+6 - Windows XP Embedded 
+7 - Windows Server 2003, Datacenter Edition 
+8 - Single User 
+9 - Windows XP Home Edition 
+10 - Windows Server 2003, Web Edition")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public SuiteMaskValues SuiteMask {
+            get {
+                if ((curObj["SuiteMask"] == null)) {
+                    return ((SuiteMaskValues)(System.Convert.ToInt32(20)));
+                }
+                return ((SuiteMaskValues)(System.Convert.ToInt32(curObj["SuiteMask"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The SystemDevice property indicates the physical disk partition the operating sys" +
+            "tem is installed on.")]
+        public string SystemDevice {
+            get {
+                return ((string)(curObj["SystemDevice"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The SystemDirectory property indicates the system directory of the operating syst" +
+            "em.\nExample: C:\\WINDOWS\\SYSTEM32")]
+        public string SystemDirectory {
+            get {
+                return ((string)(curObj["SystemDirectory"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The SystemDrive property contains the letter of the disk drive that the operating" +
+            " system resides on.\nExample: C:")]
+        public string SystemDrive {
+            get {
+                return ((string)(curObj["SystemDrive"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTotalSwapSpaceSizeNull {
+            get {
+                if ((curObj["TotalSwapSpaceSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Total swap space in kilobytes. This value may be NULL (unspecified) if swap space is not distinguished from page files.  However, some operating systems distinguish these concepts.  For example, in UNIX, whole processes can be 'swapped out' when the free page list falls and remains below a specified amount.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong TotalSwapSpaceSize {
+            get {
+                if ((curObj["TotalSwapSpaceSize"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["TotalSwapSpaceSize"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTotalVirtualMemorySizeNull {
+            get {
+                if ((curObj["TotalVirtualMemorySize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Number of kilobytes of virtual memory. For example, this may be calculated by add" +
+            "ing the amount of total RAM to the amount of paging space (i.e., adding the amou" +
+            "nt of memory in/aggregated by the computer system to the property, SizeStoredInP" +
+            "agingFiles.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong TotalVirtualMemorySize {
+            get {
+                if ((curObj["TotalVirtualMemorySize"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["TotalVirtualMemorySize"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTotalVisibleMemorySizeNull {
+            get {
+                if ((curObj["TotalVisibleMemorySize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The total amount of physical memory (in Kbytes) available to the OperatingSystem." +
+            " This value does not necessarily indicate the true amount of physical memory, bu" +
+            "t what is reported to the OperatingSystem as available to it.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong TotalVisibleMemorySize {
+            get {
+                if ((curObj["TotalVisibleMemorySize"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["TotalVisibleMemorySize"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Version property indicates the version number of the operating system.\nExampl" +
+            "e: 4.0")]
+        public string Version {
+            get {
+                return ((string)(curObj["Version"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The WindowsDirectory property indicates the Windows directory of the operating sy" +
+            "stem.\nExample: C:\\WINDOWS")]
+        public string WindowsDirectory {
+            get {
+                return ((string)(curObj["WindowsDirectory"]));
+            }
+        }
+        
+        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 ShouldSerializeCurrentTimeZone() {
+            if ((this.IsCurrentTimeZoneNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDataExecutionPrevention_32BitApplications() {
+            if ((this.IsDataExecutionPrevention_32BitApplicationsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDataExecutionPrevention_Available() {
+            if ((this.IsDataExecutionPrevention_AvailableNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDataExecutionPrevention_Drivers() {
+            if ((this.IsDataExecutionPrevention_DriversNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDataExecutionPrevention_SupportPolicy() {
+            if ((this.IsDataExecutionPrevention_SupportPolicyNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDebug() {
+            if ((this.IsDebugNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetDescription() {
+            curObj["Description"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeDistributed() {
+            if ((this.IsDistributedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeEncryptionLevel() {
+            if ((this.IsEncryptionLevelNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeForegroundApplicationBoost() {
+            if ((this.IsForegroundApplicationBoostNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetForegroundApplicationBoost() {
+            curObj["ForegroundApplicationBoost"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeFreePhysicalMemory() {
+            if ((this.IsFreePhysicalMemoryNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeFreeSpaceInPagingFiles() {
+            if ((this.IsFreeSpaceInPagingFilesNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeFreeVirtualMemory() {
+            if ((this.IsFreeVirtualMemoryNull == 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 ShouldSerializeLargeSystemCache() {
+            if ((this.IsLargeSystemCacheNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLastBootUpTime() {
+            if ((this.IsLastBootUpTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLocalDateTime() {
+            if ((this.IsLocalDateTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxNumberOfProcesses() {
+            if ((this.IsMaxNumberOfProcessesNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxProcessMemorySize() {
+            if ((this.IsMaxProcessMemorySizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumberOfLicensedUsers() {
+            if ((this.IsNumberOfLicensedUsersNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumberOfProcesses() {
+            if ((this.IsNumberOfProcessesNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumberOfUsers() {
+            if ((this.IsNumberOfUsersNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOperatingSystemSKU() {
+            if ((this.IsOperatingSystemSKUNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOSLanguage() {
+            if ((this.IsOSLanguageNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOSProductSuite() {
+            if ((this.IsOSProductSuiteNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeOSType() {
+            if ((this.IsOSTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePAEEnabled() {
+            if ((this.IsPAEEnabledNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePortableOperatingSystem() {
+            if ((this.IsPortableOperatingSystemNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePrimary() {
+            if ((this.IsPrimaryNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeProductType() {
+            if ((this.IsProductTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeServicePackMajorVersion() {
+            if ((this.IsServicePackMajorVersionNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeServicePackMinorVersion() {
+            if ((this.IsServicePackMinorVersionNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSizeStoredInPagingFiles() {
+            if ((this.IsSizeStoredInPagingFilesNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSuiteMask() {
+            if ((this.IsSuiteMaskNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTotalSwapSpaceSize() {
+            if ((this.IsTotalSwapSpaceSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTotalVirtualMemorySize() {
+            if ((this.IsTotalVirtualMemorySizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTotalVisibleMemorySize() {
+            if ((this.IsTotalVisibleMemorySizeNull == 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() {
+            return "ROOT\\CIMV2:Win32_OperatingSystem=@";
+        }
+        
+        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;
+        }
+        
+        [Browsable(true)]
+        public static OperatingSystem0 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 OperatingSystem0(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        public uint Reboot() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                bool EnablePrivileges = PrivateLateBoundObject.Scope.Options.EnablePrivileges;
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = true;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Reboot", inParams, null);
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = EnablePrivileges;
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint SetDateTime(System.DateTime LocalDateTime) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                bool EnablePrivileges = PrivateLateBoundObject.Scope.Options.EnablePrivileges;
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = true;
+                inParams = PrivateLateBoundObject.GetMethodParameters("SetDateTime");
+                inParams["LocalDateTime"] = ToDmtfDateTime(((System.DateTime)(LocalDateTime)));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("SetDateTime", inParams, null);
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = EnablePrivileges;
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint Shutdown() {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                bool EnablePrivileges = PrivateLateBoundObject.Scope.Options.EnablePrivileges;
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = true;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Shutdown", inParams, null);
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = EnablePrivileges;
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint Win32Shutdown(int Flags, int Reserved) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                bool EnablePrivileges = PrivateLateBoundObject.Scope.Options.EnablePrivileges;
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = true;
+                inParams = PrivateLateBoundObject.GetMethodParameters("Win32Shutdown");
+                inParams["Flags"] = ((int)(Flags));
+                inParams["Reserved"] = ((int)(Reserved));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Win32Shutdown", inParams, null);
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = EnablePrivileges;
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint Win32ShutdownTracker(string Comment, int Flags, uint ReasonCode, uint Timeout) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                bool EnablePrivileges = PrivateLateBoundObject.Scope.Options.EnablePrivileges;
+                PrivateLateBoundObject.Scope.Options.EnablePrivileges = true;
+                inParams = PrivateLateBoundObject.GetMethodParameters("Win32ShutdownTracker");
+                inParams["Comment"] = ((string)(Comment));
+                inParams["Flags"] = ((int)(Flags));
+                inParams["ReasonCode"] = ((uint)(ReasonCode));
+                inParams["Timeout"] = ((uint)(Timeout));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("Win32ShutdownTracker", inParams, n

<TRUNCATED>

[39/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Rearrange code to make it clearer what .NET objects are being used.


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

Branch: refs/heads/hyperv
Commit: 1edd300966ce11e1d59e4b1ff9feaaa77f531f5b
Parents: 53fd4e8
Author: Donal Lafferty <do...@citrix.com>
Authored: Thu Oct 10 18:13:52 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Thu Oct 10 18:16:16 2013 +0530

----------------------------------------------------------------------
 .../hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1edd3009/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 3f2761f..7557320 100755
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -56,11 +56,10 @@ namespace HypervResource
             kvpItem.LateBoundObject["Source"] = 0;
             logger.Debug("VM " + vm.Name + " gets userdata " + userData);
 
-            String kvpStr = kvpItem.LateBoundObject.GetText(TextFormat.CimDtd20);
-
             // Update the resource settings for the VM.
-            ManagementPath jobPath;
-
+            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


[25/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_Processor.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_Processor.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_Processor.cs
new file mode 100644
index 0000000..d06eb52
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_Processor.cs
@@ -0,0 +1,2523 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2
+{
+    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.Win32_Processor
+    public class Processor : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "ROOT\\CIMV2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Win32_Processor";
+        
+        // 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 Processor() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public Processor(string keyDeviceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(Processor.ConstructPath(keyDeviceID)), null);
+        }
+        
+        public Processor(System.Management.ManagementScope mgmtScope, string keyDeviceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(Processor.ConstructPath(keyDeviceID)), null);
+        }
+        
+        public Processor(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public Processor(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public Processor(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public Processor(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public Processor(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 Processor(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\\CIMV2";
+            }
+        }
+        
+        [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 IsAddressWidthNull {
+            get {
+                if ((curObj["AddressWidth"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Processor address width in bits.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort AddressWidth {
+            get {
+                if ((curObj["AddressWidth"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["AddressWidth"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsArchitectureNull {
+            get {
+                if ((curObj["Architecture"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Architecture property specifies the processor architecture used by this platf" +
+            "orm. It returns one of the following        integer values:\n0 - x86 \n1 - MIPS \n2" +
+            " - Alpha \n3 - PowerPC \n6 - ia64 \n9 - x64 \n")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ArchitectureValues Architecture {
+            get {
+                if ((curObj["Architecture"] == null)) {
+                    return ((ArchitectureValues)(System.Convert.ToInt32(10)));
+                }
+                return ((ArchitectureValues)(System.Convert.ToInt32(curObj["Architecture"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAvailabilityNull {
+            get {
+                if ((curObj["Availability"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The availability and status of the device.  For example, the Availability property indicates that the device is running and has full power (value=3), or is in a warning (4), test (5), degraded (10) or power save state (values 13-15 and 17). Regarding the power saving states, these are defined as follows: Value 13 (""Power Save - Unknown"") indicates that the device is known to be in a power save mode, but its exact status in this mode is unknown; 14 (""Power Save - Low Power Mode"") indicates that the device is in a power save state but still functioning, and may exhibit degraded performance; 15 (""Power Save - Standby"") describes that the device is not functioning but could be brought to full power 'quickly'; and value 17 (""Power Save - Warning"") indicates that the device is in a warning state, though also in a power save mode.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public AvailabilityValues Availability {
+            get {
+                if ((curObj["Availability"] == null)) {
+                    return ((AvailabilityValues)(System.Convert.ToInt32(0)));
+                }
+                return ((AvailabilityValues)(System.Convert.ToInt32(curObj["Availability"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Caption property is a short textual description (one-line string) of the obje" +
+            "ct.")]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConfigManagerErrorCodeNull {
+            get {
+                if ((curObj["ConfigManagerErrorCode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates the Win32 Configuration Manager error code.  The following values may b" +
+            "e returned: \n0      This device is working properly. \n1      This device is not " +
+            "configured correctly. \n2      Windows cannot load the driver for this device. \n3" +
+            "      The driver for this device might be corrupted, or your system may be runni" +
+            "ng low on memory or other resources. \n4      This device is not working properly" +
+            ". One of its drivers or your registry might be corrupted. \n5      The driver for" +
+            " this device needs a resource that Windows cannot manage. \n6      The boot confi" +
+            "guration for this device conflicts with other devices. \n7      Cannot filter. \n8" +
+            "      The driver loader for the device is missing. \n9      This device is not wo" +
+            "rking properly because the controlling firmware is reporting the resources for t" +
+            "he device incorrectly. \n10     This device cannot start. \n11     This device fai" +
+            "led. \n12     This device cannot find enough free resources that it can use. \n13 " +
+            "    Windows cannot verify this device\'s resources. \n14     This device cannot wo" +
+            "rk properly until you restart your computer. \n15     This device is not working " +
+            "properly because there is probably a re-enumeration problem. \n16     Windows can" +
+            "not identify all the resources this device uses. \n17     This device is asking f" +
+            "or an unknown resource type. \n18     Reinstall the drivers for this device. \n19 " +
+            "    Your registry might be corrupted. \n20     Failure using the VxD loader. \n21 " +
+            "    System failure: Try changing the driver for this device. If that does not wo" +
+            "rk, see your hardware documentation. Windows is removing this device. \n22     Th" +
+            "is device is disabled. \n23     System failure: Try changing the driver for this " +
+            "device. If that doesn\'t work, see your hardware documentation. \n24     This devi" +
+            "ce is not present, is not working properly, or does not have all its drivers ins" +
+            "talled. \n25     Windows is still setting up this device. \n26     Windows is stil" +
+            "l setting up this device. \n27     This device does not have valid log configurat" +
+            "ion. \n28     The drivers for this device are not installed. \n29     This device " +
+            "is disabled because the firmware of the device did not give it the required reso" +
+            "urces. \n30     This device is using an Interrupt Request (IRQ) resource that ano" +
+            "ther device is using. \n31     This device is not working properly because Window" +
+            "s cannot load the drivers required for this device.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ConfigManagerErrorCodeValues ConfigManagerErrorCode {
+            get {
+                if ((curObj["ConfigManagerErrorCode"] == null)) {
+                    return ((ConfigManagerErrorCodeValues)(System.Convert.ToInt32(32)));
+                }
+                return ((ConfigManagerErrorCodeValues)(System.Convert.ToInt32(curObj["ConfigManagerErrorCode"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsConfigManagerUserConfigNull {
+            get {
+                if ((curObj["ConfigManagerUserConfig"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates whether the device is using a user-defined configuration.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool ConfigManagerUserConfig {
+            get {
+                if ((curObj["ConfigManagerUserConfig"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["ConfigManagerUserConfig"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCpuStatusNull {
+            get {
+                if ((curObj["CpuStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The CpuStatus property specifies the current status of the processor. Changes in " +
+            "status arise from processor usage, not the physical condition of the processor.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public CpuStatusValues CpuStatus {
+            get {
+                if ((curObj["CpuStatus"] == null)) {
+                    return ((CpuStatusValues)(System.Convert.ToInt32(8)));
+                }
+                return ((CpuStatusValues)(System.Convert.ToInt32(curObj["CpuStatus"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("CreationClassName indicates the name of the class or the subclass used in the cre" +
+            "ation of an instance. When used with the other key properties of this class, thi" +
+            "s property allows all instances of this class and its subclasses to be uniquely " +
+            "identified.")]
+        public string CreationClassName {
+            get {
+                return ((string)(curObj["CreationClassName"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCurrentClockSpeedNull {
+            get {
+                if ((curObj["CurrentClockSpeed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The current speed (in MHz) of this processor.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint CurrentClockSpeed {
+            get {
+                if ((curObj["CurrentClockSpeed"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["CurrentClockSpeed"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsCurrentVoltageNull {
+            get {
+                if ((curObj["CurrentVoltage"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The CurrentVoltage specifies the voltage of the processor. bits 0-6 of the field contain the processor's current voltage times 10. This value is only set when SMBIOS designates a voltage value. For specific values, see VoltageCaps.
+Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + (1.8 x 10) = 80h + 18 = 80h + 12h.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort CurrentVoltage {
+            get {
+                if ((curObj["CurrentVoltage"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["CurrentVoltage"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDataWidthNull {
+            get {
+                if ((curObj["DataWidth"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Processor data width in bits.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort DataWidth {
+            get {
+                if ((curObj["DataWidth"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["DataWidth"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Description property provides a textual description of the object. ")]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The DeviceID property contains a string uniquely identifying the processor with o" +
+            "ther devices on the system.")]
+        public string DeviceID {
+            get {
+                return ((string)(curObj["DeviceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsErrorClearedNull {
+            get {
+                if ((curObj["ErrorCleared"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("ErrorCleared is a boolean property indicating that the error reported in LastErro" +
+            "rCode property is now cleared.")]
+        [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)]
+        [Description("ErrorDescription is a free-form string supplying more information about the error" +
+            " recorded in LastErrorCode property, and information on any corrective actions t" +
+            "hat may be taken.")]
+        public string ErrorDescription {
+            get {
+                return ((string)(curObj["ErrorDescription"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsExtClockNull {
+            get {
+                if ((curObj["ExtClock"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The ExtClock property specifies the external clock frequency. If the frequency is" +
+            " unknown this property is set to null.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint ExtClock {
+            get {
+                if ((curObj["ExtClock"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["ExtClock"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFamilyNull {
+            get {
+                if ((curObj["Family"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The processor family type. For example, values include \"Pentium(R) processor with" +
+            " MMX(TM) technology\" (14) and \"68040\" (96).")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public FamilyValues Family {
+            get {
+                if ((curObj["Family"] == null)) {
+                    return ((FamilyValues)(System.Convert.ToInt32(0)));
+                }
+                return ((FamilyValues)(System.Convert.ToInt32(curObj["Family"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInstallDateNull {
+            get {
+                if ((curObj["InstallDate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The InstallDate property is datetime value indicating when the object was install" +
+            "ed. A lack of a value does not indicate that the object is not installed.")]
+        [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 IsL2CacheSizeNull {
+            get {
+                if ((curObj["L2CacheSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The L2CacheSize property specifies the size of the processor\'s Level 2 cache. A L" +
+            "evel 2 cache is an external memory area that has a faster access times than the " +
+            "main RAM memory.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint L2CacheSize {
+            get {
+                if ((curObj["L2CacheSize"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["L2CacheSize"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsL2CacheSpeedNull {
+            get {
+                if ((curObj["L2CacheSpeed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The L2CacheSpeed property specifies the clockspeed of the processor\'s Level 2 cac" +
+            "he. A Level 2 cache is an external memory area that has a faster access times th" +
+            "an the main RAM memory.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint L2CacheSpeed {
+            get {
+                if ((curObj["L2CacheSpeed"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["L2CacheSpeed"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsL3CacheSizeNull {
+            get {
+                if ((curObj["L3CacheSize"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The L3CacheSize property specifies the size of the processor\'s Level 3 cache. A L" +
+            "evel 3 cache is an external memory area that has a faster access times than the " +
+            "main RAM memory.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint L3CacheSize {
+            get {
+                if ((curObj["L3CacheSize"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["L3CacheSize"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsL3CacheSpeedNull {
+            get {
+                if ((curObj["L3CacheSpeed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The L3CacheSpeed property specifies the clockspeed of the processor\'s Level 3 cac" +
+            "he. A Level 3 cache is an external memory area that has a faster access times th" +
+            "an the main RAM memory.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint L3CacheSpeed {
+            get {
+                if ((curObj["L3CacheSpeed"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["L3CacheSpeed"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLastErrorCodeNull {
+            get {
+                if ((curObj["LastErrorCode"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("LastErrorCode captures the last error code reported by the logical device.")]
+        [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 IsLevelNull {
+            get {
+                if ((curObj["Level"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Level property further defines the processor type. The value  depends on the " +
+            "architecture of the processor.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort Level {
+            get {
+                if ((curObj["Level"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["Level"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsLoadPercentageNull {
+            get {
+                if ((curObj["LoadPercentage"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The LoadPercentage property specifies each processor\'s load capacity averaged ove" +
+            "r the last second. The term \'processor loading\' refers to the total computing bu" +
+            "rden each processor carries at one time.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort LoadPercentage {
+            get {
+                if ((curObj["LoadPercentage"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["LoadPercentage"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Manufacturer property specifies the name of the processor\'s manufacturer.\nExa" +
+            "mple: GenuineSilicon")]
+        public string Manufacturer {
+            get {
+                return ((string)(curObj["Manufacturer"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsMaxClockSpeedNull {
+            get {
+                if ((curObj["MaxClockSpeed"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The maximum speed (in MHz) of this processor.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint MaxClockSpeed {
+            get {
+                if ((curObj["MaxClockSpeed"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["MaxClockSpeed"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Name property defines the label by which the object is known. When subclassed" +
+            ", the Name property can be overridden to be a Key property.")]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNumberOfCoresNull {
+            get {
+                if ((curObj["NumberOfCores"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The NumberOfCores property contains a Processor\'s total number of cores. e.g dual" +
+            " core machine will have NumberOfCores = 2.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint NumberOfCores {
+            get {
+                if ((curObj["NumberOfCores"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["NumberOfCores"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsNumberOfLogicalProcessorsNull {
+            get {
+                if ((curObj["NumberOfLogicalProcessors"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The NumberOfLogicalProcessors property specifies the total number of logical proc" +
+            "essors.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint NumberOfLogicalProcessors {
+            get {
+                if ((curObj["NumberOfLogicalProcessors"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["NumberOfLogicalProcessors"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("A string describing the processor family type - used when the family property is " +
+            "set to 1 (\"Other\"). This string should be set to NULL when the family property i" +
+            "s any value other than 1.")]
+        public string OtherFamilyDescription {
+            get {
+                return ((string)(curObj["OtherFamilyDescription"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates the Win32 Plug and Play device ID of the logical device.  Example: *PNP" +
+            "030b")]
+        public string PNPDeviceID {
+            get {
+                return ((string)(curObj["PNPDeviceID"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Indicates the specific power-related capabilities of the logical device. The array values, 0=""Unknown"", 1=""Not Supported"" and 2=""Disabled"" are self-explanatory. The value, 3=""Enabled"" indicates that the power management features are currently enabled but the exact feature set is unknown or the information is unavailable. ""Power Saving Modes Entered Automatically"" (4) describes that a device can change its power state based on usage or other criteria. ""Power State Settable"" (5) indicates that the SetPowerState method is supported. ""Power Cycling Supported"" (6) indicates that the SetPowerState method can be invoked with the PowerState input variable set to 5 (""Power Cycle""). ""Timed Power On Supported"" (7) indicates that the SetPowerState method can be invoked with the PowerState input variable set to 5 (""Power Cycle"") and the Time parameter set to a specific date and time, or interval, for power-on.")]
+        public PowerManagementCapabilitiesValues[] PowerManagementCapabilities {
+            get {
+                System.Array arrEnumVals = ((System.Array)(curObj["PowerManagementCapabilities"]));
+                PowerManagementCapabilitiesValues[] enumToRet = new PowerManagementCapabilitiesValues[arrEnumVals.Length];
+                int counter = 0;
+                for (counter = 0; (counter < arrEnumVals.Length); counter = (counter + 1)) {
+                    enumToRet[counter] = ((PowerManagementCapabilitiesValues)(System.Convert.ToInt32(arrEnumVals.GetValue(counter))));
+                }
+                return enumToRet;
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPowerManagementSupportedNull {
+            get {
+                if ((curObj["PowerManagementSupported"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Boolean indicating that the Device can be power managed - ie, put into a power save state. This boolean does not indicate that power management features are currently enabled, or if enabled, what features are supported. Refer to the PowerManagementCapabilities array for this information. If this boolean is false, the integer value 1, for the string, ""Not Supported"", should be the only entry in the PowerManagementCapabilities array.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool PowerManagementSupported {
+            get {
+                if ((curObj["PowerManagementSupported"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["PowerManagementSupported"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The ProcessorId property contains processor-specific information that describes the processor's features. For x86 class CPUs, the field's format depends on the processor's support of the CPUID instruction. If the instruction is supported, the ProcessorId property contains two DWORD-formatted values. The first (offsets 08h-0Bh) is the EAX value returned by a CPUID instruction with input EAX set to 1. The second (offsets 0Ch-0Fh) is the EDX value returned by that instruction. Only the first two bytes of the ProcessorID property are significant (all others are set to 0) and contain (in WORD-format) the contents of the DX register at CPU reset.")]
+        public string ProcessorId {
+            get {
+                return ((string)(curObj["ProcessorId"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsProcessorTypeNull {
+            get {
+                if ((curObj["ProcessorType"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The ProcessorType property specifies the processor\'s primary function.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ProcessorTypeValues ProcessorType {
+            get {
+                if ((curObj["ProcessorType"] == null)) {
+                    return ((ProcessorTypeValues)(System.Convert.ToInt32(0)));
+                }
+                return ((ProcessorTypeValues)(System.Convert.ToInt32(curObj["ProcessorType"])));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsRevisionNull {
+            get {
+                if ((curObj["Revision"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Revision property specifies the system\'s architecture-dependent revision leve" +
+            "l. The meaning of this value depends on the architecture of the processor. It co" +
+            "ntains the same values as the \"Version\" member, but in a numerical format.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort Revision {
+            get {
+                if ((curObj["Revision"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["Revision"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("A free form string describing the role of the processor - for example, \"Central P" +
+            "rocessor\"\' or \"Math Processor\"")]
+        public string Role {
+            get {
+                return ((string)(curObj["Role"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSecondLevelAddressTranslationExtensionsNull {
+            get {
+                if ((curObj["SecondLevelAddressTranslationExtensions"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The SecondLevelAddressTranslationExtensions property determines whether the proce" +
+            "ssor supports address translation extensions used for virtualization.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool SecondLevelAddressTranslationExtensions {
+            get {
+                if ((curObj["SecondLevelAddressTranslationExtensions"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["SecondLevelAddressTranslationExtensions"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The SocketDesignation property contains the type of chip socket used on the circu" +
+            "it.\nExample: J202")]
+        public string SocketDesignation {
+            get {
+                return ((string)(curObj["SocketDesignation"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The Status property is a string indicating the current status of the object. Various operational and non-operational statuses can be defined. Operational statuses are ""OK"", ""Degraded"" and ""Pred Fail"". ""Pred Fail"" indicates that an element may be functioning properly but predicting a failure in the near future. An example is a SMART-enabled hard drive. Non-operational statuses can also be specified. These are ""Error"", ""Starting"", ""Stopping"" and ""Service"". The latter, ""Service"", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is on-line, yet the managed element is neither ""OK"" nor in one of the other states.")]
+        public string Status {
+            get {
+                return ((string)(curObj["Status"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsStatusInfoNull {
+            get {
+                if ((curObj["StatusInfo"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("StatusInfo is a string indicating whether the logical device is in an enabled (va" +
+            "lue = 3), disabled (value = 4) or some other (1) or unknown (2) state. If this p" +
+            "roperty does not apply to the logical device, the value, 5 (\"Not Applicable\"), s" +
+            "hould be used.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public StatusInfoValues StatusInfo {
+            get {
+                if ((curObj["StatusInfo"] == null)) {
+                    return ((StatusInfoValues)(System.Convert.ToInt32(0)));
+                }
+                return ((StatusInfoValues)(System.Convert.ToInt32(curObj["StatusInfo"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Stepping is a free-form string indicating the revision level of the processor wit" +
+            "hin the processor family.")]
+        public string Stepping {
+            get {
+                return ((string)(curObj["Stepping"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The scoping System\'s CreationClassName.")]
+        public string SystemCreationClassName {
+            get {
+                return ((string)(curObj["SystemCreationClassName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The scoping System\'s Name.")]
+        public string SystemName {
+            get {
+                return ((string)(curObj["SystemName"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("A globally unique identifier for the processor.  This identifier may only be uniq" +
+            "ue within a processor family.")]
+        public string UniqueId {
+            get {
+                return ((string)(curObj["UniqueId"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsUpgradeMethodNull {
+            get {
+                if ((curObj["UpgradeMethod"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("CPU socket information including data on how this Processor can be upgraded (if u" +
+            "pgrades are supported). This property is an integer enumeration.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public UpgradeMethodValues UpgradeMethod {
+            get {
+                if ((curObj["UpgradeMethod"] == null)) {
+                    return ((UpgradeMethodValues)(System.Convert.ToInt32(0)));
+                }
+                return ((UpgradeMethodValues)(System.Convert.ToInt32(curObj["UpgradeMethod"])));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Version property specifies an architecture-dependent processor revision numbe" +
+            "r. Note: This member is not used in Windows 95.\nExample: Model 2, Stepping 12.")]
+        public string Version {
+            get {
+                return ((string)(curObj["Version"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVirtualizationFirmwareEnabledNull {
+            get {
+                if ((curObj["VirtualizationFirmwareEnabled"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The VirtualizationFirmwareEnabled property determines whether the Firmware has en" +
+            "abled virtualization extensions.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool VirtualizationFirmwareEnabled {
+            get {
+                if ((curObj["VirtualizationFirmwareEnabled"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["VirtualizationFirmwareEnabled"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVMMonitorModeExtensionsNull {
+            get {
+                if ((curObj["VMMonitorModeExtensions"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The VMMonitorModeExtensions property determines whether the processor supports In" +
+            "tel or AMD Virtual Machine Monitor extensions.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool VMMonitorModeExtensions {
+            get {
+                if ((curObj["VMMonitorModeExtensions"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["VMMonitorModeExtensions"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsVoltageCapsNull {
+            get {
+                if ((curObj["VoltageCaps"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The VoltageCaps property specifies the voltage capabilities of the processor. Bits 0-3 of the field represent specific voltages that the processor socket can accept. All other bits should be set to zero. The socket is configurable if multiple bits are being set. For a range of voltages see CurrentVoltage. If the property is NULL, then the voltage capabilities are unknown.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public VoltageCapsValues VoltageCaps {
+            get {
+                if ((curObj["VoltageCaps"] == null)) {
+                    return ((VoltageCapsValues)(System.Convert.ToInt32(8)));
+                }
+                return ((VoltageCapsValues)(System.Convert.ToInt32(curObj["VoltageCaps"])));
+            }
+        }
+        
+        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 ShouldSerializeAddressWidth() {
+            if ((this.IsAddressWidthNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeArchitecture() {
+            if ((this.IsArchitectureNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAvailability() {
+            if ((this.IsAvailabilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConfigManagerErrorCode() {
+            if ((this.IsConfigManagerErrorCodeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeConfigManagerUserConfig() {
+            if ((this.IsConfigManagerUserConfigNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCpuStatus() {
+            if ((this.IsCpuStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCurrentClockSpeed() {
+            if ((this.IsCurrentClockSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeCurrentVoltage() {
+            if ((this.IsCurrentVoltageNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDataWidth() {
+            if ((this.IsDataWidthNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeErrorCleared() {
+            if ((this.IsErrorClearedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeExtClock() {
+            if ((this.IsExtClockNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeFamily() {
+            if ((this.IsFamilyNull == 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 ShouldSerializeL2CacheSize() {
+            if ((this.IsL2CacheSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeL2CacheSpeed() {
+            if ((this.IsL2CacheSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeL3CacheSize() {
+            if ((this.IsL3CacheSizeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeL3CacheSpeed() {
+            if ((this.IsL3CacheSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLastErrorCode() {
+            if ((this.IsLastErrorCodeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLevel() {
+            if ((this.IsLevelNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeLoadPercentage() {
+            if ((this.IsLoadPercentageNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeMaxClockSpeed() {
+            if ((this.IsMaxClockSpeedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumberOfCores() {
+            if ((this.IsNumberOfCoresNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeNumberOfLogicalProcessors() {
+            if ((this.IsNumberOfLogicalProcessorsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePowerManagementSupported() {
+            if ((this.IsPowerManagementSupportedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeProcessorType() {
+            if ((this.IsProcessorTypeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeRevision() {
+            if ((this.IsRevisionNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeSecondLevelAddressTranslationExtensions() {
+            if ((this.IsSecondLevelAddressTranslationExtensionsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeStatusInfo() {
+            if ((this.IsStatusInfoNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeUpgradeMethod() {
+            if ((this.IsUpgradeMethodNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVirtualizationFirmwareEnabled() {
+            if ((this.IsVirtualizationFirmwareEnabledNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVMMonitorModeExtensions() {
+            if ((this.IsVMMonitorModeExtensionsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVoltageCaps() {
+            if ((this.IsVoltageCapsNull == 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 keyDeviceID) {
+            string strPath = "ROOT\\CIMV2:Win32_Processor";
+            strPath = string.Concat(strPath, string.Concat(".DeviceID=", string.Concat("\"", string.Concat(keyDeviceID, "\""))));
+            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 ProcessorCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static ProcessorCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static ProcessorCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static ProcessorCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static ProcessorCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\CIMV2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Win32_Processor";
+            pathObj.NamespacePath = "root\\CIMV2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new ProcessorCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static ProcessorCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static ProcessorCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static ProcessorCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\CIMV2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Win32_Processor", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new ProcessorCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static Processor 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 Processor(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        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 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);
+            }
+        }
+        
+        public enum ArchitectureValues {
+            
+            X86 = 0,
+            
+            MIPS = 1,
+            
+            Alpha = 2,
+            
+            PowerPC = 3,
+            
+            Ia64 = 6,
+            
+            X64 = 9,
+            
+            NULL_ENUM_VALUE = 10,
+        }
+        
+        public enum AvailabilityValues {
+            
+            Other0 = 1,
+            
+            Unknown0 = 2,
+            
+            Running_Full_Power = 3,
+            
+            Warning = 4,
+            
+            In_Test = 5,
+            
+            Not_Applicable = 6,
+            
+            Power_Off = 7,
+            
+            Off_Line = 8,
+            
+            Off_Duty = 9,
+            
+            Degraded = 10,
+            
+            Not_Installed = 11,
+            
+            Install_Error = 12,
+            
+            Power_Save_Unknown = 13,
+            
+            Power_Save_Low_Power_Mode = 14,
+            
+            Power_Save_Standby = 15,
+            
+            Power_Cycle = 16,
+            
+            Power_Save_Warning = 17,
+            
+            Paused = 18,
+            
+            Not_Ready = 19,
+            
+            Not_Configured = 20,
+            
+            Quiesced = 21,
+            
+            NULL_ENUM_VALUE = 0,
+        }
+        
+        public enum ConfigManagerErrorCodeValues {
+            
+            This_device_is_working_properly_ = 0,
+            
+            This_device_is_not_configured_correctly_ = 1,
+            
+            Windows_cannot_load_the_driver_for_this_device_ = 2,
+            
+            The_driver_for_this_device_might_be_corrupted_or_your_system_may_be_running_low_on_memory_or_other_resources_ = 3,
+            
+            This_device_is_not_working_properly_One_of_its_drivers_or_your_registry_might_be_corrupted_ = 4,
+            
+            The_driver_for_this_device_needs_a_resource_that_Windows_cannot_manage_ = 5,
+            
+            The_boot_configuration_for_this_device_conflicts_with_other_devices_ = 6,
+            
+            Cannot_filter_ = 7,
+            
+            The_driver_loader_for_the_device_is_missing_ = 8,
+            
+            This_device_is_not_working_properly_because_the_controlling_firmware_is_reporting_the_resources_for_the_device_incorrectly_ = 9,
+            
+            This_device_cannot_start_ = 10,
+            
+            This_device_failed_ = 11,
+            
+            This_device_cannot_find_enough_free_resources_that_it_can_use_ = 12,
+            
+            Windows_cannot_verify_this_device_s_resources_ = 13,
+            
+            This_device_cannot_work_properly_until_you_restart_your_computer_ = 14,
+            
+            This_device_is_not_working_properly_because_there_is_probably_a_re_enumeration_problem_ = 15,
+            
+            Windows_cannot_identify_all_the_resources_this_device_uses_ = 16,
+            
+            This_device_is_asking_for_an_unknown_resource_type_ = 17,
+            
+            Reinstall_the_drivers_for_this_device_ = 18,
+            
+            Failure_using_the_VxD_loader_ = 19,
+            
+            Your_registry_might_be_corrupted_ = 20,
+            
+            System_failure_Try_changing_the_driver_for_this_device_If_that_does_not_work_see_your_hardware_documentation_Windows_is_removing_this_device_ = 21,
+            
+            This_device_is_disabled_ = 22,
+            
+            System_failure_Try_changing_the_driver_for_this_device_If_that_doesn_t_work_see_your_hardware_documentation_ = 23,
+            
+            This_device_is_not_present_is_not_working_properly_or_does_not_have_all_its_drivers_installed_ = 24,
+            
+            Windows_is_still_setting_up_this_device_ = 25,
+            
+            Windows_is_still_setting_up_this_device_0 = 26,
+            
+            This_device_does_not_have_valid_log_configuration_ = 27,
+            
+            The_drivers_for_this_device_are_not_installed_ = 28,
+            
+            This_device_is_disabled_because_the_firmware_of_the_device_did_not_give_it_the_required_resources_ = 29,
+            
+            This_device_is_using_an_Interrupt_Request_IRQ_resource_that_another_device_is_using_ = 30,
+            
+            This_device_is_not_working_properly_because_Windows_cannot_load_the_drivers_required_for_this_device_ = 31,
+            
+            NULL_ENUM_VALUE = 32,
+        }
+        
+        public enum CpuStatusValues {
+            
+            Unknown0 = 0,
+            
+            CPU_Enabled = 1,
+            
+            CPU_Disabled_by_User_via_BIOS_Setup = 2,
+            
+            CPU_Disabled_By_BIOS_POST_Error_ = 3,
+            
+            CPU_is_Idle = 4,
+            
+            Reserved = 5,
+            
+            Reserved0 = 6,
+            
+            Other0 = 7,
+            
+            NULL_ENUM_VALUE = 8,
+        }
+        
+        public enum FamilyValues {
+            
+            Other0 = 1,
+            
+            Unknown0 = 2,
+            
+            Val_8086 = 3,
+            
+            Val_80286 = 4,
+            
+            Val_80386 = 5,
+            
+            Val_80486 = 6,
+            
+            Val_8087 = 7,
+            
+            Val_80287 = 8,
+            
+            Val_80387 = 9,
+            
+            Val_80487 = 10,
+            
+            Pentium_R_brand = 11,
+            
+            Pentium_R_Pro = 12,
+            
+            Pentium_R_II = 13,
+            
+            Pentium_R_processor_with_MMX_TM_technology = 14,
+            
+            Celeron_TM_ = 15,
+            
+            Pentium_R_II_Xeon_TM_ = 16,
+            
+            Pentium_R_III = 17,
+            
+            M1_Family = 18,
+            
+            M2_Family = 19,
+            
+            K5_Family = 24,
+            
+            K6_Family = 25,
+            
+            K6_2 = 26,
+            
+            K6_3 = 27,
+            
+            AMD_Athlon_TM_Processor_Family = 28,
+            
+            AMD_R_Duron_TM_Processor = 29,
+            
+            AMD29000_Family = 30,
+            
+            K6_2_ = 31,
+            
+            Power_PC_Family = 32,
+            
+            Power_PC_601 = 33,
+            
+            Power_PC_603 = 34,
+            
+            Power_PC_603_ = 35,
+            
+            Power_PC_604 = 36,
+            
+            Power_PC_620 = 37,
+            
+            Power_PC_X704 = 38,
+            
+            Power_PC_750 = 39,
+            
+            Alpha_Family = 48,
+            
+            Alpha_21064 = 49,
+            
+            Alpha_21066 = 50,
+            
+            Alpha_21164 = 51,
+            
+            Alpha_21164PC = 52,
+            
+            Alpha_21164a = 53,
+            
+            Alpha_21264 = 54,
+            
+            Alpha_21364 = 55,
+            
+            MIPS_Family = 64,
+            
+            MIPS_R4000 = 65,
+            
+            MIPS_R4200 = 66,
+            
+            MIPS_R4400 = 67,
+            
+            MIPS_R4600 = 68,
+            
+            MIPS_R10000 = 69,
+            
+            SPARC_Family = 80,
+            
+            SuperSPARC = 81,
+            
+            MicroSPARC_II = 82,
+            
+            MicroSPARC_IIep = 83,
+            
+            UltraSPARC = 84,
+            
+            UltraSPARC_II = 85,
+            
+            UltraSPARC_IIi = 86,
+            
+            UltraSPARC_III0 = 87,
+            
+            UltraSPARC_IIIi = 88,
+            
+            Val_68040 = 96,
+            
+            Val_68xxx_Family = 97,
+            
+            Val_68000 = 98,
+            
+            Val_68010 = 99,
+            
+            Val_68020 = 100,
+            
+            Val_68030 = 101,
+            
+            Hobbit_Family = 112,
+            
+            Crusoe_TM_TM5000_Family = 120,
+            
+            Crusoe_TM_TM3000_Family = 121,
+            
+            Efficeon_TM_TM8000_Family = 122,
+            
+            Weitek = 128,
+            
+            Itanium_TM_Processor = 130,
+            
+            AMD_Athlon_TM_64_Processor_Family = 131,
+            
+            AMD_Opteron_TM_Family = 132,
+            
+            PA_RISC_Family = 144,
+            
+            PA_RISC_8500 = 145,
+            
+            PA_RISC_8000 = 146,
+            
+            PA_RISC_7300LC = 147,
+            
+            PA_RISC_7200 = 148,
+            
+            PA_RISC_7100LC = 149,
+            
+            PA_RISC_7100 = 150,
+            
+            V30_Family = 160,
+            
+            Pentium_R_III_Xeon_TM_ = 176,
+            
+            Pentium_R_III_Processor_with_Intel_R_SpeedStep_TM_Technology = 177,
+            
+            Pentium_R_4 = 178,
+            
+            Intel_R_Xeon_TM_ = 179,
+            
+            AS400_Family = 180,
+            
+            Intel_R_Xeon_TM_processor_MP = 181,
+            
+            AMD_AthlonXP_TM_Family = 182,
+            
+            AMD_AthlonMP_TM_Family = 183,
+            
+            Intel_R_Itanium_R_2 = 184,
+            
+            Intel_Pentium_M_Processor = 185,
+            
+            K7 = 190,
+            
+            IBM390_Family = 200,
+            
+            G4 = 201,
+            
+      

<TRUNCATED>

[38/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Add ability to pass kvp data via the key cloudstack-vm-userdata


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

Branch: refs/heads/hyperv
Commit: 53fd4e8c7244d8db148fd248613b748e422b8639
Parents: 1d0a931
Author: Devdeep Singh <de...@gmail.com>
Authored: Thu Oct 10 18:11:58 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Thu Oct 10 18:11:58 2013 +0530

----------------------------------------------------------------------
 .../AgentShell/AgentSettings.Designer.cs        |   12 +
 .../AgentShell/AgentSettings.settings           |   11 +-
 .../HypervResource/HypervResource.csproj        |    3 +-
 .../HypervResource/HypervResourceController.cs  |    4 +-
 .../ServerResource/HypervResource/WmiCalls.cs   |  219 --
 .../ServerResource/HypervResource/WmiCallsV2.cs |  501 +++++
 .../HypervResourceControllerTest.cs             |   84 +
 ...OOT.virtualization.v2.Msvm_ComputerSystem.cs | 1800 ++++++++++++++++
 .../ROOT.virtualization.v2.Msvm_ConcreteJob.cs  | 1826 +++++++++++++++++
 ...rtualization.v2.Msvm_KvpExchangeComponent.cs | 1597 +++++++++++++++
 ...n.v2.Msvm_KvpExchangeComponentSettingData.cs | 1037 ++++++++++
 ...irtualization.v2.Msvm_KvpExchangeDataItem.cs |  653 ++++++
 ...on.v2.Msvm_VirtualSystemManagementService.cs | 1916 ++++++++++++++++++
 ...lization.v2.Msvm_VirtualSystemSettingData.cs | 1673 +++++++++++++++
 .../WmiWrappers/WmiWrappers.csproj              |   21 +
 15 files changed, 11134 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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 44df706..a73e6bb 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
@@ -367,5 +367,17 @@ namespace CloudStack.Plugin.AgentShell {
                 this["testCifsPath"] = value;
             }
         }
+
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("CentOS64")]
+        public string testKvpVmName {
+            get {
+                return ((string)(this["testKvpVmName"]));
+            }
+            set {
+                this["testKvpVmName"] = value;
+            }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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 0d54f44..435b8e0 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.settings
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.settings
@@ -98,5 +98,14 @@
     <Setting Name="dom0MinMemory" Type="System.UInt64" Scope="Application">
       <Value Profile="(Default)">2048</Value>
     </Setting>
+    <Setting Name="testCifsUrl" Type="System.String" Scope="User">
+      <Value Profile="(Default)">cifs://10.1.1.1/secondary?user\u003dadministrator\u0026password\u003d1pass%40word1</Value>
+    </Setting>
+    <Setting Name="testCifsPath" Type="System.String" Scope="User">
+      <Value Profile="(Default)">template/tmpl/2/201/61d5316a-3cc4-30cf-a557-78691ff5c143.vhd</Value>
+    </Setting>
+    <Setting Name="testKvpVmName" Type="System.String" Scope="User">
+      <Value Profile="(Default)">CentOS64</Value>
+    </Setting>
   </Settings>
-</SettingsFile>
\ No newline at end of file
+</SettingsFile>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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 48cf5a5..dbd7b15 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
@@ -76,6 +76,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="CloudStackTypes.cs" />
+    <Compile Include="WmiCallsV2.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="HypervResourceController.cs" />
     <Compile Include="Utils.cs" />
@@ -99,4 +100,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
\ No newline at end of file
+</Project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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 afceced..cce40e1 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -754,7 +754,7 @@ namespace HypervResource
             }
         }
 
-        // POST api/HypervResource/StartCommand
+        // POST api/HypervResource/StopCommand
         [HttpPost]
         [ActionName(CloudStackTypes.StopCommand)]
         public JContainer StopCommand([FromBody]dynamic cmd)
@@ -1396,4 +1396,4 @@ namespace HypervResource
             }
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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 0442be3..ad43d1f 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -1247,223 +1247,4 @@ namespace HypervResource
             throw ex;
         }
     }
-
-    public class WmiException : Exception
-    {
-        public WmiException()
-        {
-        }
-
-        public WmiException(string message)
-            : base(message)
-        {
-        }
-
-        public WmiException(string message, Exception inner)
-            : base(message, inner)
-        {
-        }
-    }
-
-    /// <summary>
-    /// http://msdn.microsoft.com/en-us/library/hh850031%28v=vs.85%29.aspx
-    /// </summary>
-    public static class ReturnCode
-    {
-        public const UInt32 Completed = 0;
-        public const UInt32 Started = 4096;
-        public const UInt32 Failed = 32768;
-        public const UInt32 AccessDenied = 32769;
-        public const UInt32 NotSupported = 32770;
-        public const UInt32 Unknown = 32771;
-        public const UInt32 Timeout = 32772;
-        public const UInt32 InvalidParameter = 32773;
-        public const UInt32 SystemInUse = 32774;
-        public const UInt32 InvalidState = 32775;
-        public const UInt32 IncorrectDataType = 32776;
-        public const UInt32 SystemNotAvailable = 32777;
-        public const UInt32 OutofMemory = 32778;
-        public static string ToString(UInt32 value)
-        {
-            string result = "Unknown return code";
-            switch (value)
-            {
-                case Completed: result = "Completed"; break;
-                case Started: result = "Started"; break;
-                case Failed: result = "Failed"; break;
-                case AccessDenied: result = "AccessDenied"; break;
-                case NotSupported: result = "NotSupported"; break;
-                case Unknown: result = "Unknown"; break;
-                case Timeout: result = "Timeout"; break;
-                case InvalidParameter: result = "InvalidParameter"; break;
-                case SystemInUse: result = "SystemInUse"; break;
-                case InvalidState: result = "InvalidState"; break;
-                case IncorrectDataType: result = "IncorrectDataType"; break;
-                case SystemNotAvailable: result = "SystemNotAvailable"; break;
-                case OutofMemory: result = "OutofMemory"; break;
-            }
-            return result;
-        }
-    }
-
-    /// <summary>
-    /// http://msdn.microsoft.com/en-us/library/hh850031%28v=vs.85%29.aspx
-    /// </summary>
-    public static class JobState
-    {
-        public const UInt16 New = 2;
-        public const UInt16 Starting = 3;
-        public const UInt16 Running = 4;
-        public const UInt16 Suspended = 5;
-        public const UInt16 ShuttingDown = 6;
-        public const UInt16 Completed = 7;
-        public const UInt16 Terminated = 8;
-        public const UInt16 Killed = 9;
-        public const UInt16 Exception = 10;
-        public const UInt16 Service = 11;
-        public static string ToString(UInt16 value)
-        {
-            string result = "Unknown JobState code";
-            switch (value)
-            {
-                case New: result = "New"; break;
-                case Starting: result = "Starting"; break;
-                case Running: result = "Running"; break;
-                case Suspended: result = "Suspended"; break;
-                case ShuttingDown: result = "ShuttingDown"; break;
-                case Completed: result = "Completed"; break;
-                case Terminated: result = "Terminated"; break;
-                case Killed: result = "Killed"; break;
-                case Exception: result = "Exception"; break;
-                case Service: result = "Service"; break;
-            }
-            return result;
-        }
-    }
-
-    /// <summary>
-    /// http://msdn.microsoft.com/en-us/library/cc723874%28v=vs.85%29.aspx
-    /// </summary>
-    public class RequiredState
-    {
-        public const UInt16 Enabled = 2;        // Turns the VM on.
-        public const UInt16 Disabled = 3;       // Turns the VM off.
-        public const UInt16 Reboot = 10;        // A hard reset of the VM.
-        public const UInt16 Reset = 11;         // For future use.
-        public const UInt16 Paused = 32768;     // Pauses the VM.
-        public const UInt16 Suspended = 32769;  // Saves the state of the VM.
-        public static string ToString(UInt16 value)
-        {
-            string result = "Unknown RequiredState code";
-            switch (value)
-            {
-                case Enabled: result = "Enabled"; break;
-                case Disabled: result = "Disabled"; break;
-                case Reboot: result = "Reboot"; break;
-                case Reset: result = "Reset"; break;
-                case Paused: result = "Paused"; break;
-                case Suspended: result = "Suspended"; break;
-            }
-            return result;
-        }
-    }
-
-    /// <summary>
-    /// http://msdn.microsoft.com/en-us/library/cc136822%28v=vs.85%29.aspx
-    /// </summary>
-        public class EnabledState
-    {
-            /// <summary>
-            /// The state of the VM could not be determined.
-            /// </summary>
-        public const UInt16 Unknown = 0;
-            /// <summary>
-            /// The VM is running.
-            /// </summary>
-        public const UInt16 Enabled = 2;
-            /// <summary>
-            /// The VM is turned off.
-            /// </summary>
-        public const UInt16 Disabled = 3;
-            /// <summary>
-            /// The VM is paused.
-            /// </summary>
-        public const UInt16 Paused = 32768;
-            /// <summary>
-            /// The VM is in a saved state.
-            /// </summary>
-        public const UInt16 Suspended = 32769;
-            /// <summary>
-            /// The VM is starting. This is a transitional state between 3 (Disabled)
-            /// or 32769 (Suspended) and 2 (Enabled) initiated by a call to the 
-            /// RequestStateChange method with a RequestedState parameter of 2 (Enabled).
-            /// </summary>
-        public const UInt16 Starting = 32770;
-            /// <summary>
-            /// Starting with Windows Server 2008 R2 this value is not supported. 
-            /// If the VM is performing a snapshot operation, the element at index 1 
-            /// of the OperationalStatus property array will contain 32768 (Creating Snapshot), 
-            /// 32769 (Applying Snapshot), or 32770 (Deleting Snapshot).
-            /// </summary>
-        public const UInt16 Snapshotting = 32771;
-            /// <summary>
-            /// The VM is saving its state. This is a transitional state between 2 (Enabled)
-            /// and 32769 (Suspended) initiated by a call to the RequestStateChange method 
-            /// with a RequestedState parameter of 32769 (Suspended).
-            /// </summary>
-        public const UInt16 Saving = 32773;
-            /// <summary>
-            /// The VM is turning off. This is a transitional state between 2 (Enabled) 
-            /// and 3 (Disabled) initiated by a call to the RequestStateChange method 
-            /// with a RequestedState parameter of 3 (Disabled) or a guest operating system 
-            /// initiated power off.
-            /// </summary>
-        public const UInt16 Stopping = 32774;
-            /// <summary>
-            /// The VM is pausing. This is a transitional state between 2 (Enabled) and 32768 (Paused) initiated by a call to the RequestStateChange method with a RequestedState parameter of 32768 (Paused).
-            /// </summary>
-        public const UInt16 Pausing = 32776;
-            /// <summary>
-            /// The VM is resuming from a paused state. This is a transitional state between 32768 (Paused) and 2 (Enabled).
-            /// </summary>
-        public const UInt16 Resuming = 32777;
-
-        public static string ToString(UInt16 value)
-        {
-            string result = "Unknown";
-            switch (value)
-            {
-                case Enabled: result = "Enabled"; break;
-                case Disabled: result = "Disabled"; break;
-                case Paused: result = "Paused"; break;
-                case Suspended: result = "Suspended"; break;
-                case Starting: result = "Starting"; break;
-                case Snapshotting: result = "Snapshotting"; break; // NOT used
-                case Saving: result = "Saving"; break;
-                case Stopping: result = "Stopping"; break;
-                case Pausing: result = "Pausing"; break;
-                case Resuming: result = "Resuming"; break;
-            }
-            return result;
-        }
-
-        public static string ToCloudStackState(UInt16 value)
-        {
-            string result = "Unknown";
-            switch (value)
-            {
-                case Enabled: result = "Running"; break;
-                case Disabled: result = "Stopped"; break;
-                case Paused: result = "Unknown"; break;
-                case Suspended: result = "Unknown"; break;
-                case Starting: result = "Starting"; break;
-                case Snapshotting: result = "Unknown"; break; // NOT used
-                case Saving: result = "Saving"; break;
-                case Stopping: result = "Stopping"; break;
-                case Pausing: result = "Unknown"; break;
-                case Resuming: result = "Starting"; break; 
-            }
-            return result;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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
new file mode 100755
index 0000000..3f2761f
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -0,0 +1,501 @@
+// 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.V2;
+using log4net;
+using System.Globalization;
+using System.Management;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using CloudStack.Plugin.WmiWrappers.ROOT.CIMV2;
+using System.IO;
+
+namespace HypervResource
+{
+    public class WmiCallsV2
+    {
+        public static String CloudStackUserDataKey = "cloudstack-vm-userdata";
+
+        public static void Initialize()
+        {
+            // Trigger assembly load into curren appdomain
+        }
+
+        private static ILog logger = LogManager.GetLogger(typeof(WmiCallsV2));
+
+        /// <summary>
+        /// Returns ComputerSystem lacking any NICs and VOLUMEs
+        /// </summary>
+        public static ComputerSystem AddUserData(ComputerSystem vm, string userData)
+        {
+            // 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"] = userData;
+            kvpItem.LateBoundObject["Source"] = 0;
+            logger.Debug("VM " + vm.Name + " gets userdata " + userData);
+
+            String kvpStr = kvpItem.LateBoundObject.GetText(TextFormat.CimDtd20);
+
+            // Update the resource settings for the VM.
+            ManagementPath jobPath;
+
+            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 static 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.
+            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)
+            {
+                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 static 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 static 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 static 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 static 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 static 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.VirtualSystemType == "Microsoft:Hyper-V:System:Realized" ||
+                    wmiObj.VirtualSystemType == "Microsoft:Hyper-V:System:Planned")
+                {
+                    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;
+        }
+
+        public static 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.
+            // 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, KvpExchangeComponentSettingData.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 KvpExchangeComponentSettingData.KvpExchangeComponentSettingDataCollection(wmiObjectSearch.Get());
+
+            foreach (KvpExchangeComponentSettingData wmiObj in wmiObjCollection)
+            {
+                return wmiObj;
+            }
+
+            var errMsg = string.Format("No KvpExchangeComponentSettingData in VirtualSystemSettingData {0}", vmSettings.Path.Path);
+            var ex = new WmiException(errMsg);
+            logger.Error(errMsg, ex);
+            throw ex;
+        }
+    }
+
+    public class WmiException : Exception
+    {
+        public WmiException()
+        {
+        }
+
+        public WmiException(string message)
+            : base(message)
+        {
+        }
+
+        public WmiException(string message, Exception inner)
+            : base(message, inner)
+        {
+        }
+    }
+
+    /// <summary>
+    /// Covers V2 API, see
+    /// http://msdn.microsoft.com/en-us/library/hh850031%28v=vs.85%29.aspx
+    /// </summary>
+    public static class ReturnCode
+    {
+        public const UInt32 Completed = 0;
+        public const UInt32 Started = 4096;
+        public const UInt32 Failed = 32768;
+        public const UInt32 AccessDenied = 32769;
+        public const UInt32 NotSupported = 32770;
+        public const UInt32 Unknown = 32771;
+        public const UInt32 Timeout = 32772;
+        public const UInt32 InvalidParameter = 32773;
+        public const UInt32 SystemInUse = 32774;
+        public const UInt32 InvalidState = 32775;
+        public const UInt32 IncorrectDataType = 32776;
+        public const UInt32 SystemNotAvailable = 32777;
+        public const UInt32 OutofMemory = 32778;
+        public static string ToString(UInt32 value)
+        {
+            string result = "Unknown return code";
+            switch (value)
+            {
+                case Completed: result = "Completed"; break;
+                case Started: result = "Started"; break;
+                case Failed: result = "Failed"; break;
+                case AccessDenied: result = "AccessDenied"; break;
+                case NotSupported: result = "NotSupported"; break;
+                case Unknown: result = "Unknown"; break;
+                case Timeout: result = "Timeout"; break;
+                case InvalidParameter: result = "InvalidParameter"; break;
+                case SystemInUse: result = "SystemInUse"; break;
+                case InvalidState: result = "InvalidState"; break;
+                case IncorrectDataType: result = "IncorrectDataType"; break;
+                case SystemNotAvailable: result = "SystemNotAvailable"; break;
+                case OutofMemory: result = "OutofMemory"; break;
+            }
+            return result;
+        }
+    }
+
+    /// <summary>
+    /// Covers V2 API, see
+    /// http://msdn.microsoft.com/en-us/library/hh850031%28v=vs.85%29.aspx
+    /// </summary>
+    public static class JobState
+    {
+        public const UInt16 New = 2;
+        public const UInt16 Starting = 3;
+        public const UInt16 Running = 4;
+        public const UInt16 Suspended = 5;
+        public const UInt16 ShuttingDown = 6;
+        public const UInt16 Completed = 7;
+        public const UInt16 Terminated = 8;
+        public const UInt16 Killed = 9;
+        public const UInt16 Exception = 10;
+        public const UInt16 Service = 11;
+        public static string ToString(UInt16 value)
+        {
+            string result = "Unknown JobState code";
+            switch (value)
+            {
+                case New: result = "New"; break;
+                case Starting: result = "Starting"; break;
+                case Running: result = "Running"; break;
+                case Suspended: result = "Suspended"; break;
+                case ShuttingDown: result = "ShuttingDown"; break;
+                case Completed: result = "Completed"; break;
+                case Terminated: result = "Terminated"; break;
+                case Killed: result = "Killed"; break;
+                case Exception: result = "Exception"; break;
+                case Service: result = "Service"; break;
+            }
+            return result;
+        }
+    }
+
+    /// <summary>
+    /// V2 API (see http://msdn.microsoft.com/en-us/library/hh850279(v=vs.85).aspx)
+    /// has removed 'Paused' and 'Suspended' as compared to the
+    /// V1 API (see http://msdn.microsoft.com/en-us/library/cc723874%28v=vs.85%29.aspx)
+    /// However, Paused and Suspended appear on the VM state transition table
+    /// (see http://msdn.microsoft.com/en-us/library/hh850116(v=vs.85).aspx#methods)
+    /// </summary>
+    public class RequiredState
+    {
+        public const UInt16 Enabled = 2;        // Turns the VM on.
+        public const UInt16 Disabled = 3;       // Turns the VM off.
+        public const UInt16 ShutDown = 4;
+        public const UInt16 Offline = 6;
+        public const UInt16 Test = 7;
+        public const UInt16 Defer = 8;
+        public const UInt16 Quiesce = 9;
+        public const UInt16 Reboot = 10;        // A hard reset of the VM.
+        public const UInt16 Reset = 11;         // For future use.
+        public const UInt16 Paused = 32768;     // Pauses the VM.
+        public const UInt16 Suspended = 32769;  // Saves the state of the VM.
+
+        public static string ToString(UInt16 value)
+        {
+            string result = "Unknown RequiredState code";
+            switch (value)
+            {
+                case Enabled: result = "Enabled"; break;
+                case Disabled: result = "Disabled"; break;
+                case ShutDown: result = "ShutDown"; break;
+                case Offline: result = "Offline"; break;
+                case Test: result = "Test"; break;
+                case Defer: result = "Defer"; break;
+                case Quiesce: result = "Quiesce"; break;
+                case Reboot: result = "Reboot"; break;
+                case Reset: result = "Reset"; break;
+            }
+            return result;
+        }
+    }
+
+    /// <summary>
+    /// V2 API specifies the states below in its  state transition graph at
+    /// http://msdn.microsoft.com/en-us/library/hh850116(v=vs.85).aspx#methods
+    /// However, the CIM standard has additional possibilities based on the description
+    /// of EnabledState.
+    /// The previous V1 API is described by 
+    /// http://msdn.microsoft.com/en-us/library/cc136822%28v=vs.85%29.aspx
+    /// </summary>
+        public class EnabledState
+    {
+            /// <summary>
+            /// The state of the VM could not be determined.
+            /// </summary>
+        public const UInt16 Unknown = 0;
+            /// <summary>
+            /// The VM is running.
+            /// </summary>
+        public const UInt16 Enabled = 2;
+            /// <summary>
+            /// The VM is turned off.
+            /// </summary>
+        public const UInt16 Disabled = 3;
+            /// <summary>
+            /// The VM is paused.
+            /// </summary>
+        public const UInt16 Paused = 32768;
+            /// <summary>
+            /// The VM is in a saved state.
+            /// </summary>
+        public const UInt16 Suspended = 32769;
+            /// <summary>
+            /// The VM is starting. This is a transitional state between 3 (Disabled)
+            /// or 32769 (Suspended) and 2 (Enabled) initiated by a call to the 
+            /// RequestStateChange method with a RequestedState parameter of 2 (Enabled).
+            /// </summary>
+        public const UInt16 Starting = 32770;
+            /// <summary>
+            /// Starting with Windows Server 2008 R2 this value is not supported. 
+            /// If the VM is performing a snapshot operation, the element at index 1 
+            /// of the OperationalStatus property array will contain 32768 (Creating Snapshot), 
+            /// 32769 (Applying Snapshot), or 32770 (Deleting Snapshot).
+            /// </summary>
+        public const UInt16 Snapshotting = 32771;
+            /// <summary>
+            /// The VM is saving its state. This is a transitional state between 2 (Enabled)
+            /// and 32769 (Suspended) initiated by a call to the RequestStateChange method 
+            /// with a RequestedState parameter of 32769 (Suspended).
+            /// </summary>
+        public const UInt16 Saving = 32773;
+            /// <summary>
+            /// The VM is turning off. This is a transitional state between 2 (Enabled) 
+            /// and 3 (Disabled) initiated by a call to the RequestStateChange method 
+            /// with a RequestedState parameter of 3 (Disabled) or a guest operating system 
+            /// initiated power off.
+            /// </summary>
+        public const UInt16 Stopping = 32774;
+            /// <summary>
+            /// The VM is pausing. This is a transitional state between 2 (Enabled) and 32768 (Paused) initiated by a call to the RequestStateChange method with a RequestedState parameter of 32768 (Paused).
+            /// </summary>
+        public const UInt16 Pausing = 32776;
+            /// <summary>
+            /// The VM is resuming from a paused state. This is a transitional state between 32768 (Paused) and 2 (Enabled).
+            /// </summary>
+        public const UInt16 Resuming = 32777;
+
+        public static string ToString(UInt16 value)
+        {
+            string result = "Unknown";
+            switch (value)
+            {
+                case Enabled: result = "Enabled"; break;
+                case Disabled: result = "Disabled"; break;
+                case Paused: result = "Paused"; break;
+                case Suspended: result = "Suspended"; break;
+                case Starting: result = "Starting"; break;
+                case Snapshotting: result = "Snapshotting"; break; // NOT used
+                case Saving: result = "Saving"; break;
+                case Stopping: result = "Stopping"; break;
+                case Pausing: result = "Pausing"; break;
+                case Resuming: result = "Resuming"; break;
+            }
+            return result;
+        }
+
+        public static string ToCloudStackState(UInt16 value)
+        {
+            string result = "Unknown";
+            switch (value)
+            {
+                case Enabled: result = "Running"; break;
+                case Disabled: result = "Stopped"; break;
+                case Paused: result = "Unknown"; break;
+                case Suspended: result = "Unknown"; break;
+                case Starting: result = "Starting"; break;
+                case Snapshotting: result = "Unknown"; break; // NOT used
+                case Saving: result = "Saving"; break;
+                case Stopping: result = "Stopping"; break;
+                case Pausing: result = "Unknown"; break;
+                case Resuming: result = "Starting"; break; 
+            }
+            return result;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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 7513311..7d7f627 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
@@ -25,6 +25,7 @@ using log4net;
 using HypervResource;
 using CloudStack.Plugin.AgentShell;
 using System.Collections.Generic;
+using System.Xml;
 
 namespace ServerResource.Tests
 {
@@ -761,6 +762,89 @@ namespace ServerResource.Tests
         }
 
         [TestMethod]
+        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.IsTrue(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;
+        }
+
+        [TestMethod]
         public void GetVmStatsCommandFail()
         {
             // Use WMI to find existing VMs


[42/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Fixed deletion on VM's on hyperv host when mgmt server gets restarted due to HA

Conflicts:

	server/src/com/cloud/ha/HighAvailabilityManagerImpl.java


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

Branch: refs/heads/hyperv
Commit: 3a5c7f1e4a995a083790eb2e16c3a3d1cdcb2a8f
Parents: 0d424d1
Author: Rajesh Battala <ra...@citrix.com>
Authored: Fri Oct 11 11:54:53 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Oct 11 11:58:20 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/ha/HighAvailabilityManagerImpl.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3a5c7f1e/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
index 464b952..d853b47 100755
--- a/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
+++ b/server/src/com/cloud/ha/HighAvailabilityManagerImpl.java
@@ -203,8 +203,8 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
             return;
         }
 
-        if(host.getHypervisorType() == HypervisorType.VMware) {
-            s_logger.info("Don't restart for VMs on host " + host.getId() + " as the host is VMware host");
+        if(host.getHypervisorType() == HypervisorType.VMware || host.getHypervisorType() == HypervisorType.Hyperv) {
+            s_logger.info("Don't restart for VMs on host " + host.getId() + " as the host is VMware host or on Hyperv Host");
             return;
         }
 
@@ -299,6 +299,11 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
             return;
         }
 
+        if(vm.getHypervisorType() == HypervisorType.VMware || vm.getHypervisorType() == HypervisorType.Hyperv) {
+            s_logger.info("Skip HA for VMware VM or Hyperv VM" + vm.getInstanceName());
+            return;
+        }
+
         if (!investigate) {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("VM does not require investigation so I'm marking it as Stopped: " + vm.toString());


[27/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..7513311
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
@@ -0,0 +1,1064 @@
+// 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 Microsoft.VisualStudio.TestTools.UnitTesting;
+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;
+
+namespace ServerResource.Tests
+{
+    [TestClass]
+    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;
+
+        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>
+        [TestInitializeAttribute]
+        public void setUp()
+        {
+            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)
+                {
+                    Assert.Fail("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.IsTrue(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.IsTrue(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.IsFalse(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.IsTrue(newFileInfo.Exists, "Attempted to create " + newFullname + " from " + newFileInfo.FullName);
+
+            return JsonConvert.SerializeObject(newFileInfo.FullName);
+        }
+
+        [TestMethod]
+        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.IsTrue((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.IsTrue((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");
+            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;
+        }
+
+        [TestMethod]
+        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.IsTrue((bool)ans.result, "DestroyCommand did not succeed " + ans.details);
+            Assert.IsTrue(!File.Exists(path), "Failed to delete file " + path);
+        }
+
+        [TestMethod]
+        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.IsTrue(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);
+            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.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);
+            FileInfo newFile = new FileInfo((string)ans.volume.path);
+            Assert.IsTrue(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]
+        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;
+        }
+
+
+        [TestMethod]
+        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);
+        }
+
+        [TestMethod]
+        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.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);
+        }
+
+        private static void DownloadTemplateToPrimaryStorage(HypervResourceController rsrcServer, dynamic jsonDownloadCopyCmd, string dwnldDest)
+        {
+            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);
+        }
+
+        [TestMethod]
+        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;
+        }
+
+        [TestMethod]
+        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.IsTrue((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.IsTrue((bool)ans2.result, (string)ans2.details);  // always succeeds
+        }
+
+        [TestMethod]
+        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.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds
+        }
+
+        [TestMethod]
+        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.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds
+        }
+
+        [TestMethod]
+        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.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds
+        }
+
+        [TestMethod]
+        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.IsTrue((bool)ans.result, (string)ans.details);  // always succeeds, fake VM means no answer for the named VM
+        }
+
+        [TestMethod]
+        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.IsTrue((bool)ans.result, (string)ans.details);
+        }
+
+        [TestMethod]
+        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.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.
+        }
+
+        // TODO: can we speed up this command?  The logic takes over a second.
+        [TestMethod]
+        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.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));
+        }
+
+        [TestMethod]
+        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.IsFalse((bool)ans.result);
+            Assert.IsNull((string)ans.hostStats);
+            Assert.IsNotNull(ans.details);
+        }
+
+        [TestMethod]
+        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.AreEqual(expected, actual, "StartupRoutingCommand not populated properly");
+        }
+
+
+        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.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);
+            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.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);
+
+            // examine NIC
+            SyntheticEthernetPortSettingData[] nicSettingsViaVm = WmiCalls.GetEthernetPorts(vm);
+            Assert.IsTrue(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 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.AreEqual(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.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);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/Properties/AssemblyInfo.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..1a2b6e6
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ServerResource.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ServerResource.Tests")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("727beb1c-6e7c-49b2-8fbd-f03dbe481b08")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers 
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..381245e
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
@@ -0,0 +1,124 @@
+<?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="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="Newtonsoft.Json">
+      <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.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="System.Net.Http.WebRequest">
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <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>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..08ef691
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/packages.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <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" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.sln
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.sln b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.sln
new file mode 100644
index 0000000..fa0eb30
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.sln
@@ -0,0 +1,61 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerResource.Tests", "ServerResource.Tests\ServerResource.Tests.csproj", "{925FD1DE-6211-4E10-9949-3751B8ABDF59}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgentShell", "AgentShell\AgentShell.csproj", "{9060B539-62D0-4E71-A6C6-5944828774E9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WmiWrappers", "WmiWrappers\WmiWrappers.csproj", "{DB824727-BDC3-437C-A364-7A811D8A160F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HypervResource", "HypervResource\HypervResource.csproj", "{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{3481E04E-4BB9-4E0B-94A9-DB70A4F4D218}"
+	ProjectSection(SolutionItems) = preProject
+		.nuget\NuGet.Config = .nuget\NuGet.Config
+		.nuget\NuGet.exe = .nuget\NuGet.exe
+		.nuget\NuGet.targets = .nuget\NuGet.targets
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		NoUnitTests|Any CPU = NoUnitTests|Any CPU
+		NoUnitTestsDebug|Any CPU = NoUnitTestsDebug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{925FD1DE-6211-4E10-9949-3751B8ABDF59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{925FD1DE-6211-4E10-9949-3751B8ABDF59}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{925FD1DE-6211-4E10-9949-3751B8ABDF59}.NoUnitTests|Any CPU.ActiveCfg = NoUnitTests|Any CPU
+		{925FD1DE-6211-4E10-9949-3751B8ABDF59}.NoUnitTestsDebug|Any CPU.ActiveCfg = NoUnitTestsDebug|Any CPU
+		{925FD1DE-6211-4E10-9949-3751B8ABDF59}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{925FD1DE-6211-4E10-9949-3751B8ABDF59}.Release|Any CPU.Build.0 = Release|Any CPU
+		{9060B539-62D0-4E71-A6C6-5944828774E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{9060B539-62D0-4E71-A6C6-5944828774E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{9060B539-62D0-4E71-A6C6-5944828774E9}.NoUnitTests|Any CPU.ActiveCfg = NoUnitTests|Any CPU
+		{9060B539-62D0-4E71-A6C6-5944828774E9}.NoUnitTests|Any CPU.Build.0 = NoUnitTests|Any CPU
+		{9060B539-62D0-4E71-A6C6-5944828774E9}.NoUnitTestsDebug|Any CPU.ActiveCfg = NoUnitTestsDebug|Any CPU
+		{9060B539-62D0-4E71-A6C6-5944828774E9}.NoUnitTestsDebug|Any CPU.Build.0 = NoUnitTestsDebug|Any CPU
+		{9060B539-62D0-4E71-A6C6-5944828774E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{9060B539-62D0-4E71-A6C6-5944828774E9}.Release|Any CPU.Build.0 = Release|Any CPU
+		{DB824727-BDC3-437C-A364-7A811D8A160F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{DB824727-BDC3-437C-A364-7A811D8A160F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{DB824727-BDC3-437C-A364-7A811D8A160F}.NoUnitTests|Any CPU.ActiveCfg = NoUnitTests|Any CPU
+		{DB824727-BDC3-437C-A364-7A811D8A160F}.NoUnitTests|Any CPU.Build.0 = NoUnitTests|Any CPU
+		{DB824727-BDC3-437C-A364-7A811D8A160F}.NoUnitTestsDebug|Any CPU.ActiveCfg = NoUnitTestsDebug|Any CPU
+		{DB824727-BDC3-437C-A364-7A811D8A160F}.NoUnitTestsDebug|Any CPU.Build.0 = NoUnitTestsDebug|Any CPU
+		{DB824727-BDC3-437C-A364-7A811D8A160F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{DB824727-BDC3-437C-A364-7A811D8A160F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}.NoUnitTests|Any CPU.ActiveCfg = NoUnitTests|Any CPU
+		{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}.NoUnitTests|Any CPU.Build.0 = NoUnitTests|Any CPU
+		{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}.NoUnitTestsDebug|Any CPU.ActiveCfg = NoUnitTestsDebug|Any CPU
+		{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}.NoUnitTestsDebug|Any CPU.Build.0 = NoUnitTestsDebug|Any CPU
+		{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{C963DFFF-65BA-4E71-ADA5-526A4DA4E0B2}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Properties/AssemblyInfo.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..ef230d5
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("WmiWrappers")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WmiWrappers")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e78f4bad-16a9-4e0e-8f46-083c093492db")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]


[13/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..b303127
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPort.cs
@@ -0,0 +1,1960 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[14/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..a2e44a4
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SwitchPort.cs
@@ -0,0 +1,1708 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[02/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/conf/log4j-cloud.xml.in
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/conf/log4j-cloud.xml.in b/plugins/hypervisors/hyperv/conf/log4j-cloud.xml.in
new file mode 100644
index 0000000..fdbba19
--- /dev/null
+++ b/plugins/hypervisors/hyperv/conf/log4j-cloud.xml.in
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+   <!-- ================================= -->
+   <!-- Preserve messages in a local file -->
+   <!-- ================================= -->
+
+   <!-- A time/date based rolling appender -->
+   <appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
+      <param name="Append" value="true"/>
+      <param name="Threshold" value="INFO"/>
+      <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
+        <param name="FileNamePattern" value="@AGENTLOG@.%d{yyyy-MM-dd}.gz"/>
+        <param name="ActiveFileName" value="@AGENTLOG@"/>
+      </rollingPolicy>
+      <layout class="org.apache.log4j.EnhancedPatternLayout">
+         <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{3}] (%t:%x) %m%n"/>
+      </layout>
+   </appender>
+   
+   <!-- ============================== -->
+   <!-- Append messages to the console -->
+   <!-- ============================== -->
+
+   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <param name="Target" value="System.out"/>
+      <param name="Threshold" value="INFO"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <param name="ConversionPattern" value="%d{ISO8601}{GMT} %-5p [%c{3}] (%t:%x) %m%n"/>
+      </layout>
+   </appender>
+
+   <!-- ================ -->
+   <!-- Limit categories -->
+   <!-- ================ -->
+
+   <category name="com.cloud">
+     <priority value="INFO"/>
+   </category>
+   
+   <category name="com.cloud.agent.metrics">
+     <priority value="INFO"/>
+   </category>
+   
+   <category name="com.cloud.agent.resource.computing.ComputingResource$StorageMonitorTask">
+     <priority value="INFO"/>
+   </category>
+
+   <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+   <category name="org.apache">
+      <priority value="INFO"/>
+   </category>
+
+   <category name="org">
+      <priority value="INFO"/>
+   </category>
+   
+   <category name="net">
+     <priority value="INFO"/>
+   </category>
+
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+      <level value="INFO"/>
+      <appender-ref ref="CONSOLE"/>
+      <appender-ref ref="FILE"/>
+   </root>
+
+</log4j:configuration>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/conf/log4j.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/conf/log4j.xml b/plugins/hypervisors/hyperv/conf/log4j.xml
new file mode 100644
index 0000000..1e97ce9
--- /dev/null
+++ b/plugins/hypervisors/hyperv/conf/log4j.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+   <!-- ================================= -->
+   <!-- Preserve messages in a local file -->
+   <!-- ================================= -->
+
+   <!-- A time/date based rolling appender -->
+   <appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
+      <param name="Append" value="true"/>
+      <param name="Threshold" value="TRACE"/>
+      <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
+        <param name="FileNamePattern" value="log/@AGENTLOG@.%d{yyyy-MM-dd}.gz"/>
+        <param name="ActiveFileName" value="log/@AGENTLOG@"/>
+      </rollingPolicy>
+      <layout class="org.apache.log4j.EnhancedPatternLayout">
+         <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{3}] (%t:%x) %m%n"/>
+      </layout>
+   </appender>
+   
+   <!-- ============================== -->
+   <!-- Append messages to the console -->
+   <!-- ============================== -->
+
+   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <param name="Target" value="System.out"/>
+      <param name="Threshold" value="TRACE"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <param name="ConversionPattern" value="%d{ISO8601}{GMT} %-5p [%c{3}] (%t:%x) %m%n"/>
+      </layout>
+   </appender>
+
+   <!-- ================ -->
+   <!-- Limit categories -->
+   <!-- ================ -->
+
+   <category name="com.cloud">
+     <priority value="TRACE"/>
+   </category>
+   
+   <category name="com.cloud.agent.metrics">
+     <priority value="TRACE"/>
+   </category>
+   
+   <category name="com.cloud.agent.resource.computing.ComputingResource$StorageMonitorTask">
+     <priority value="TRACE"/>
+   </category>
+
+   <!-- Limit the org.apache category to TRACE as its DEBUG is verbose -->
+   <category name="org.apache">
+      <priority value="TRACE"/>
+   </category>
+
+   <category name="org">
+      <priority value="TRACE"/>
+   </category>
+   
+   <category name="net">
+     <priority value="TRACE"/>
+   </category>
+
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+      <level value="TRACE"/>
+      <appender-ref ref="CONSOLE"/>
+      <appender-ref ref="FILE"/>
+   </root>
+
+</log4j:configuration>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/pom.xml b/plugins/hypervisors/hyperv/pom.xml
new file mode 100644
index 0000000..e9f0371
--- /dev/null
+++ b/plugins/hypervisors/hyperv/pom.xml
@@ -0,0 +1,158 @@
+<!--
+  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.
+-->
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-plugin-hypervisor-hyperv</artifactId>
+  <name>Apache CloudStack Plugin - Hypervisor Hyper-V</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.3.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+  <properties>
+    <skipTests>true</skipTests>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-agent</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <version>6.1.26</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-utils</artifactId>
+      <version>${project.version}</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <sourceDirectory>src</sourceDirectory>
+    <testSourceDirectory>test</testSourceDirectory>
+    <resources>
+      <resource>
+        <directory>conf</directory>
+      </resource>
+    </resources>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.2.1</version>
+        <configuration>
+          <executable>java</executable>
+          <mainClass>com.cloud.agent.AgentShell</mainClass>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.12</version>
+        <configuration>
+          <!-- Exclude tests that require an agent, they appear under a different profile -->
+            <excludes>
+              <exclude>**/HypervDirectConnectResourceTest.*</exclude>
+            </excludes>
+            <includes>
+              <include>none</include>
+            </includes>
+            <skipTests>${skipTests}</skipTests>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <profiles>
+    <!-- Hyper-V plugin is built using mono -->
+    <profile>
+      <id>hyperv-agent</id>
+      <activation>
+        <property>
+          <name>hyperv-agent</name>
+        </property>
+      </activation>
+<!--      <dependencies>
+          <dependency>
+              <groupId>org.apache.cloudstack</groupId>
+              <artifactId>cloud-plugin-hypervisor-hyperv</artifactId>
+              <version>${project.version}</version>
+          </dependency>
+      </dependencies> --> 
+      <build>
+      <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.2.1</version>
+        <executions>
+          <execution>
+            <phase>compile</phase>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <executable>bash</executable>
+          <arguments>
+            <argument>./buildagent.sh</argument>
+          </arguments>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.12</version>
+        <configuration>
+            <excludes>
+              <exclude>none</exclude>
+            </excludes>            
+            <includes>
+              <include>**/HypervDirectConnectResourceTest.java</include>
+            </includes>
+            <skipTests>${skipTests}</skipTests>            
+        </configuration>
+      </plugin>
+      </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/scripts/dev_extra_setup.sh
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/scripts/dev_extra_setup.sh b/plugins/hypervisors/hyperv/scripts/dev_extra_setup.sh
new file mode 100644
index 0000000..aa77c4b
--- /dev/null
+++ b/plugins/hypervisors/hyperv/scripts/dev_extra_setup.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+mvn -P developer -pl developer -Ddeploydb
+cp client/target/cloud-client-ui-4.2.0-SNAPSHOT/WEB-INF/classes/log4j{-cloud,}.xml
+mysql --user=root --password="" cloud -e "update configuration set value='false' where name='developer';"
+mysql --user=root --password="" cloud -e "INSERT INTO configuration (instance, name,value) VALUE('DEFAULT','system.vm.use.local.storage', 'true');" 
+update template_view set url='http://10.70.176.29/pub/systemvmtemplate-2013-07-04-master-hyperv.vhd' where  name='SystemVM Template (HyperV)';
+export MAVEN_OPTS="-XX:MaxPermSize=256m -Xmx1g"
+mvn -pl :cloud-client-ui jetty:run

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..11df222
--- /dev/null
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java
@@ -0,0 +1,467 @@
+// 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.
+package com.cloud.hypervisor.hyperv.discoverer;
+
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.Listener;
+import com.cloud.agent.api.AgentControlAnswer;
+import com.cloud.agent.api.AgentControlCommand;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.ReadyCommand;
+import com.cloud.agent.api.SetupAnswer;
+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.dc.ClusterDetailsDao;
+import com.cloud.dc.ClusterVO;
+import com.cloud.dc.DataCenterVO;
+import com.cloud.dc.HostPodVO;
+import com.cloud.dc.dao.ClusterDao;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.dc.dao.HostPodDao;
+import com.cloud.exception.AgentUnavailableException;
+import com.cloud.exception.ConnectionException;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.exception.OperationTimedoutException;
+import com.cloud.host.Host;
+import com.cloud.host.HostEnvironment;
+import com.cloud.host.HostVO;
+import com.cloud.host.Status;
+import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.hypervisor.hyperv.resource.HypervDirectConnectResource;
+import com.cloud.resource.Discoverer;
+import com.cloud.resource.DiscovererBase;
+import com.cloud.resource.ResourceManager;
+import com.cloud.resource.ResourceStateAdapter;
+import com.cloud.resource.ServerResource;
+import com.cloud.resource.UnableDeleteHostException;
+
+/**
+ * Methods to discover and managem a Hyper-V agent. Prepares a
+ * HypervDirectConnectResource corresponding to the agent on a Hyper-V
+ * hypervisor and manages its lifecycle.
+ */
+@Local(value = Discoverer.class)
+public class HypervServerDiscoverer extends DiscovererBase implements
+        Discoverer, Listener, ResourceStateAdapter {
+    private static final Logger s_logger = Logger
+            .getLogger(HypervServerDiscoverer.class);
+
+    @Inject
+    private HostDao _hostDao = null;
+    @Inject
+    private ClusterDao _clusterDao;
+    @Inject
+    private ClusterDetailsDao _clusterDetailsDao;
+    @Inject
+    private ResourceManager _resourceMgr;
+    @Inject
+    private HostPodDao _podDao;
+    @Inject
+    private DataCenterDao _dcDao;
+
+    // TODO: AgentManager and AlertManager not being used to transmit info,
+    // may want to reconsider.
+    @Inject
+    private AgentManager _agentMgr;
+    @Inject
+    private AlertManager _alertMgr;
+
+    // Listener interface methods
+
+    @Override
+    public final boolean processAnswers(final long agentId, final long seq,
+            final Answer[] answers) {
+        return false;
+    }
+
+    @Override
+    public final boolean processCommands(final long agentId, final long seq,
+            final Command[] commands) {
+        return false;
+    }
+
+    @Override
+    public final AgentControlAnswer processControlCommand(final long agentId,
+            final AgentControlCommand cmd) {
+        return null;
+    }
+
+    @Override
+    public final void processConnect(final Host agent,
+            final StartupCommand cmd, final boolean forRebalance)
+            throws ConnectionException {
+        // Limit the commands we can process
+        if (!(cmd instanceof StartupRoutingCommand)) {
+            return;
+        }
+
+        StartupRoutingCommand startup = (StartupRoutingCommand) cmd;
+
+        // assert
+        if (startup.getHypervisorType() != HypervisorType.Hyperv) {
+            s_logger.debug("Not Hyper-V hypervisor, so moving on.");
+            return;
+        }
+
+        long agentId = agent.getId();
+        HostVO host = _hostDao.findById(agentId);
+
+        // Our Hyper-V machines are not participating in pools, and the pool id
+        // we provide them is not persisted.
+        // This means the pool id can vary.
+        ClusterVO cluster = _clusterDao.findById(host.getClusterId());
+        if (cluster.getGuid() == null) {
+            cluster.setGuid(startup.getPool());
+            _clusterDao.update(cluster.getId(), cluster);
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Setting up host " + agentId);
+        }
+
+        HostEnvironment env = new HostEnvironment();
+        SetupCommand setup = new SetupCommand(env);
+        if (!host.isSetup()) {
+            setup.setNeedSetup(true);
+        }
+
+        try {
+            SetupAnswer answer = (SetupAnswer) _agentMgr.send(agentId, setup);
+            if (answer != null && answer.getResult()) {
+                host.setSetup(true);
+                // TODO: clean up magic numbers below
+                host.setLastPinged((System.currentTimeMillis() >> 10) - 5 * 60);
+                _hostDao.update(host.getId(), host);
+                if (answer.needReconnect()) {
+                    throw new ConnectionException(false,
+                            "Reinitialize agent after setup.");
+                }
+                return;
+            } else {
+                String reason = answer.getDetails();
+                if (reason == null) {
+                    reason = " details were null";
+                }
+                s_logger.warn("Unable to setup agent " + agentId + " due to "
+                        + reason);
+            }
+            // Error handling borrowed from XcpServerDiscoverer, may need to be
+            // updated.
+        } catch (AgentUnavailableException e) {
+            s_logger.warn("Unable to setup agent " + agentId
+                    + " because it became unavailable.", e);
+        } catch (OperationTimedoutException e) {
+            s_logger.warn("Unable to setup agent " + agentId
+                    + " because it timed out", e);
+        }
+        throw new ConnectionException(true, "Reinitialize agent after setup.");
+    }
+
+    @Override
+    public final boolean processDisconnect(final long agentId,
+            final Status state) {
+        return false;
+    }
+
+    @Override
+    public final boolean isRecurring() {
+        return false;
+    }
+
+    @Override
+    public final int getTimeout() {
+        return 0;
+    }
+
+    @Override
+    public final boolean processTimeout(final long agentId, final long seq) {
+        return false;
+    }
+
+    // End Listener implementation
+
+    // Returns server component used by server manager to operate the plugin.
+    // Server component is a ServerResource. If a connected agent is used, the
+    // ServerResource is
+    // ignored in favour of another created in response to
+    @Override
+    public final Map<? extends ServerResource, Map<String, String>> find(
+            final long dcId, final Long podId, final Long clusterId,
+            final URI uri, final String username, final String password,
+            final List<String> hostTags) throws DiscoveryException {
+
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info("Discover host. dc(zone): " + dcId + ", pod: "
+                    + podId + ", cluster: " + clusterId + ", uri host: "
+                    + uri.getHost());
+        }
+
+        // Assertions
+        if (podId == null) {
+            if (s_logger.isInfoEnabled()) {
+                s_logger.info("No pod is assigned, skipping the discovery in"
+                        + " Hyperv discoverer");
+            }
+            return null;
+        }
+        ClusterVO cluster = _clusterDao.findById(clusterId); // ClusterVO exists
+        // in the
+        // database
+        if (cluster == null) {
+            if (s_logger.isInfoEnabled()) {
+                s_logger.info("No cluster in database for cluster id "
+                        + clusterId);
+            }
+            return null;
+        }
+        if (cluster.getHypervisorType() != HypervisorType.Hyperv) {
+            if (s_logger.isInfoEnabled()) {
+                s_logger.info("Cluster " + clusterId
+                        + "is not for Hyperv hypervisors");
+            }
+            return null;
+        }
+        if (!uri.getScheme().equals("http")) {
+            String msg = "urlString is not http so we're not taking care of"
+                    + " the discovery for this: " + uri;
+            s_logger.debug(msg);
+            return null;
+        }
+
+        try {
+            String hostname = uri.getHost();
+            InetAddress ia = InetAddress.getByName(hostname);
+            String agentIp = ia.getHostAddress();
+            String uuidSeed = agentIp;
+            String guidWithTail = calcServerResourceGuid(uuidSeed)
+                    + "-HypervResource";
+
+            if (_resourceMgr.findHostByGuid(guidWithTail) != null) {
+                s_logger.debug("Skipping " + agentIp + " because "
+                        + guidWithTail + " is already in the database.");
+                return null;
+            }
+
+            s_logger.info("Creating"
+                    + HypervDirectConnectResource.class.getName()
+                    + " HypervDummyResourceBase for zone/pod/cluster " + dcId
+                    + "/" + podId + "/" + clusterId);
+
+            // Some Hypervisors organise themselves in pools.
+            // The startup command tells us what pool they are using.
+            // In the meantime, we have to place a GUID corresponding to the
+            // pool in the database
+            // This GUID may change.
+            if (cluster.getGuid() == null) {
+                cluster.setGuid(UUID.nameUUIDFromBytes(
+                        String.valueOf(clusterId).getBytes()).toString());
+                _clusterDao.update(clusterId, cluster);
+            }
+
+            // Settings required by all server resources managing a hypervisor
+            Map<String, Object> params = new HashMap<String, Object>();
+            params.put("zone", Long.toString(dcId));
+            params.put("pod", Long.toString(podId));
+            params.put("cluster", Long.toString(clusterId));
+            params.put("guid", guidWithTail);
+            params.put("ipaddress", agentIp);
+
+            // Hyper-V specific settings
+            Map<String, String> details = new HashMap<String, String>();
+            details.put("url", uri.getHost());
+            details.put("username", username);
+            details.put("password", password);
+            details.put("cluster.guid", cluster.getGuid());
+
+            params.putAll(details);
+
+            HypervDirectConnectResource resource =
+                    new HypervDirectConnectResource();
+            resource.configure(agentIp, params);
+
+            // Assert
+            // TODO: test by using bogus URL and bogus virtual path in URL
+            ReadyCommand ping = new ReadyCommand();
+            Answer pingAns = resource.executeRequest(ping);
+            if (pingAns == null || !pingAns.getResult()) {
+                String errMsg =
+                        "Agent not running, or no route to agent on at "
+                                + uri;
+                s_logger.debug(errMsg);
+                throw new DiscoveryException(errMsg);
+            }
+
+            Map<HypervDirectConnectResource, Map<String, String>> resources =
+                    new HashMap<HypervDirectConnectResource,
+                    Map<String, String>>();
+            resources.put(resource, details);
+
+            // TODO: does the resource have to create a connection?
+            return resources;
+        } catch (ConfigurationException e) {
+            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId,
+                    "Unable to add " + uri.getHost(),
+                    "Error is " + e.getMessage());
+            s_logger.warn("Unable to instantiate " + uri.getHost(), e);
+        } catch (UnknownHostException e) {
+            _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId,
+                    "Unable to add " + uri.getHost(),
+                    "Error is " + e.getMessage());
+            s_logger.warn("Unable to instantiate " + uri.getHost(), e);
+        } catch (Exception e) {
+            String msg = " can't setup agent, due to " + e.toString() + " - "
+                    + e.getMessage();
+            s_logger.warn(msg);
+        }
+        return null;
+    }
+
+    /**
+     * Encapsulate GUID calculation in public method to allow access to test
+     * programs. Works by converting a string to a GUID using
+     * UUID.nameUUIDFromBytes
+     *
+     * @param uuidSeed
+     *            string to use to generate GUID
+     *
+     * @return GUID in form of a string.
+     */
+    public static String calcServerResourceGuid(final String uuidSeed) {
+        String guid = UUID.nameUUIDFromBytes(uuidSeed.getBytes()).toString();
+        return guid;
+    }
+
+    // Adapter implementation: (facilitates plug in loading)
+    // Required because Discoverer extends Adapter
+    // Overrides Adapter.configure to always return true
+    // Inherit Adapter.getName
+    // Inherit Adapter.stop
+    // Inherit Adapter.start
+    @Override
+    public final boolean configure(final String name,
+            final Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+
+        // TODO: allow timeout on we HTTPRequests to be configured
+        _agentMgr.registerForHostEvents(this, true, false, true);
+        _resourceMgr.registerResourceStateAdapter(this.getClass()
+                .getSimpleName(), this);
+        return true;
+    }
+
+    // end of Adapter
+
+    @Override
+    public void postDiscovery(final List<HostVO> hosts, final long msId)
+            throws DiscoveryException {
+    }
+
+    @Override
+    public final Hypervisor.HypervisorType getHypervisorType() {
+        return Hypervisor.HypervisorType.Hyperv;
+    }
+
+    // TODO: verify that it is okay to return true on null hypervisor
+    @Override
+    public final boolean matchHypervisor(final String hypervisor) {
+        if (hypervisor == null) {
+            return true;
+        }
+        return Hypervisor.HypervisorType.Hyperv.toString().equalsIgnoreCase(
+                hypervisor);
+    }
+
+    // end of Discoverer
+
+    // ResourceStateAdapter
+    @Override
+    public final HostVO createHostVOForConnectedAgent(final HostVO host,
+            final StartupCommand[] cmd) {
+        return null;
+    }
+
+    // TODO: add test for method
+    @Override
+    public final HostVO createHostVOForDirectConnectAgent(final HostVO host,
+            final StartupCommand[] startup, final ServerResource resource,
+            final Map<String, String> details, final List<String> hostTags) {
+        StartupCommand firstCmd = startup[0];
+        if (!(firstCmd instanceof StartupRoutingCommand)) {
+            return null;
+        }
+
+        StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
+        if (ssCmd.getHypervisorType() != HypervisorType.Hyperv) {
+            return null;
+        }
+
+        s_logger.info("Host: " + host.getName()
+                + " connected with hypervisor type: " + HypervisorType.Hyperv
+                + ". Checking CIDR...");
+
+        HostPodVO pod = _podDao.findById(host.getPodId());
+        DataCenterVO dc = _dcDao.findById(host.getDataCenterId());
+
+        _resourceMgr.checkCIDR(pod, dc, ssCmd.getPrivateIpAddress(),
+                ssCmd.getPrivateNetmask());
+
+        return _resourceMgr.fillRoutingHostVO(host, ssCmd,
+                HypervisorType.Hyperv, details, hostTags);
+    }
+
+    // TODO: add test for method
+    @Override
+    public final DeleteHostAnswer deleteHost(final HostVO host,
+            final boolean isForced, final boolean isForceDeleteStorage)
+            throws UnableDeleteHostException {
+        // assert
+        if (host.getType() != Host.Type.Routing
+                || host.getHypervisorType() != HypervisorType.Hyperv) {
+            return null;
+        }
+        _resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
+        return new DeleteHostAnswer(true);
+    }
+
+    @Override
+    public final boolean stop() {
+        _resourceMgr.unregisterResourceStateAdapter(this.getClass()
+                .getSimpleName());
+        return super.stop();
+    }
+    // end of ResourceStateAdapter
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/guru/HypervGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/guru/HypervGuru.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/guru/HypervGuru.java
new file mode 100644
index 0000000..8b79cae
--- /dev/null
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/guru/HypervGuru.java
@@ -0,0 +1,68 @@
+// 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.
+package com.cloud.hypervisor.hyperv.guru;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.hypervisor.HypervisorGuru;
+import com.cloud.hypervisor.HypervisorGuruBase;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.GuestOSVO;
+import com.cloud.storage.dao.GuestOSDao;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+/**
+ * Implementation of Hypervisor guru for Hyper-V.
+ **/
+@Local(value = HypervisorGuru.class)
+public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru {
+
+    @Inject
+    private GuestOSDao _guestOsDao;
+
+    @Override
+    public final HypervisorType getHypervisorType() {
+        return HypervisorType.Hyperv;
+    }
+    /**
+     * Prevent direct creation.
+     */
+    protected HypervGuru() {
+        super();
+    }
+
+    @Override
+    public final VirtualMachineTO implement(
+            VirtualMachineProfile vm) {
+        VirtualMachineTO to = toVirtualMachineTO(vm);
+
+        // Determine the VM's OS description
+        GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine()
+                .getGuestOSId());
+        to.setOs(guestOS.getDisplayName());
+
+        return to;
+    }
+
+    @Override
+    public final boolean trackVmHostChange() {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..e22f284
--- /dev/null
+++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java
@@ -0,0 +1,454 @@
+// 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.
+package com.cloud.hypervisor.hyperv.resource;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.http.HttpResponse;
+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;
+import org.apache.http.util.EntityUtils;
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.PingCommand;
+import com.cloud.agent.api.PingRoutingCommand;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.agent.api.StartupRoutingCommand;
+import com.cloud.agent.api.StartupStorageCommand;
+import com.cloud.agent.api.UnsupportedAnswer;
+import com.cloud.agent.api.StartupRoutingCommand.VmState;
+import com.cloud.host.Host.Type;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.network.Networks.RouterPrivateIpStrategy;
+import com.cloud.resource.ServerResource;
+import com.cloud.resource.ServerResourceBase;
+import com.cloud.serializer.GsonHelper;
+import com.google.gson.Gson;
+
+/**
+ * Implementation of dummy resource to be returned from discoverer.
+ **/
+
+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());
+
+    private static final Gson s_gson = GsonHelper.getGson();
+    private String _zoneId;
+    private String _podId;
+    private String _clusterId;
+    private String _guid;
+    private String _agentIp;
+    private int _port = DEFAULT_AGENT_PORT;
+
+    private String _clusterGuid;
+
+    // Used by initialize to assert object configured before
+    // initialize called.
+    private boolean _configureCalled = false;
+
+    private String _username;
+    private String _password;
+
+    @Override
+    public final Type getType() {
+        return Type.Routing;
+    }
+
+    @Override
+    public final StartupCommand[] initialize() {
+        // assert
+        if (!_configureCalled) {
+            String errMsg =
+                    this.getClass().getName()
+                            + " requires configure() be called before"
+                            + " initialize()";
+            s_logger.error(errMsg);
+        }
+
+        // Create default StartupRoutingCommand, then customise
+        StartupRoutingCommand defaultStartRoutCmd =
+                new StartupRoutingCommand(0, 0, 0, 0, null,
+                        Hypervisor.HypervisorType.Hyperv,
+                        RouterPrivateIpStrategy.HostLocal,
+                        new HashMap<String, VmState>());
+
+        // Identity within the data centre is decided by CloudStack kernel,
+        // and passed via ServerResource.configure()
+        defaultStartRoutCmd.setDataCenter(_zoneId);
+        defaultStartRoutCmd.setPod(_podId);
+        defaultStartRoutCmd.setCluster(_clusterId);
+        defaultStartRoutCmd.setGuid(_guid);
+        defaultStartRoutCmd.setName(_name);
+        defaultStartRoutCmd.setPrivateIpAddress(_agentIp);
+        defaultStartRoutCmd.setStorageIpAddress(_agentIp);
+        defaultStartRoutCmd.setPool(_clusterGuid);
+
+        s_logger.debug("Generated StartupRoutingCommand for _agentIp \""
+                + _agentIp + "\"");
+
+        // TODO: does version need to be hard coded.
+        defaultStartRoutCmd.setVersion("4.2.0");
+
+        // Specifics of the host's resource capacity and network configuration
+        // comes from the host itself. CloudStack sanity checks network
+        // configuration
+        // and uses capacity info for resource allocation.
+        Command[] startCmds =
+                requestStartupCommand(new Command[] {defaultStartRoutCmd});
+
+        // TODO: may throw, is this okay?
+        StartupRoutingCommand startCmd = (StartupRoutingCommand) startCmds[0];
+
+        // Assert that host identity is consistent with existing values.
+        if (startCmd == null) {
+            String errMsg =
+                    String.format("Host %s (IP %s)"
+                            + "did not return a StartupRoutingCommand",
+                            _name, _agentIp);
+            s_logger.error(errMsg);
+            // TODO: valid to return null, or should we throw?
+            return null;
+        }
+        if (!startCmd.getDataCenter().equals(
+                defaultStartRoutCmd.getDataCenter())) {
+            String errMsg =
+                    String.format(
+                            "Host %s (IP %s) changed zone/data center.  Was "
+                                    + defaultStartRoutCmd.getDataCenter()
+                                    + " NOW its " + startCmd.getDataCenter(),
+                            _name, _agentIp);
+            s_logger.error(errMsg);
+            // TODO: valid to return null, or should we throw?
+            return null;
+        }
+        if (!startCmd.getPod().equals(defaultStartRoutCmd.getPod())) {
+            String errMsg =
+                    String.format("Host %s (IP %s) changed pod.  Was "
+                            + defaultStartRoutCmd.getPod() + " NOW its "
+                            + startCmd.getPod(), _name, _agentIp);
+            s_logger.error(errMsg);
+            // TODO: valid to return null, or should we throw?
+            return null;
+        }
+        if (!startCmd.getCluster().equals(defaultStartRoutCmd.getCluster())) {
+            String errMsg =
+                    String.format("Host %s (IP %s) changed cluster.  Was "
+                            + defaultStartRoutCmd.getCluster() + " NOW its "
+                            + startCmd.getCluster(), _name, _agentIp);
+            s_logger.error(errMsg);
+            // TODO: valid to return null, or should we throw?
+            return null;
+        }
+        if (!startCmd.getGuid().equals(defaultStartRoutCmd.getGuid())) {
+            String errMsg =
+                    String.format("Host %s (IP %s) changed guid.  Was "
+                            + defaultStartRoutCmd.getGuid() + " NOW its "
+                            + startCmd.getGuid(), _name, _agentIp);
+            s_logger.error(errMsg);
+            // TODO: valid to return null, or should we throw?
+            return null;
+        }
+        if (!startCmd.getPrivateIpAddress().equals(
+                defaultStartRoutCmd.getPrivateIpAddress())) {
+            String errMsg =
+                    String.format("Host %s (IP %s) IP address.  Was "
+                            + defaultStartRoutCmd.getPrivateIpAddress()
+                            + " NOW its " + startCmd.getPrivateIpAddress(),
+                            _name, _agentIp);
+            s_logger.error(errMsg);
+            // TODO: valid to return null, or should we throw?
+            return null;
+        }
+        if (!startCmd.getName().equals(defaultStartRoutCmd.getName())) {
+            String errMsg =
+                    String.format(
+                            "Host %s (IP %s) name.  Was " + startCmd.getName()
+                                    + " NOW its "
+                                    + defaultStartRoutCmd.getName(), _name,
+                            _agentIp);
+            s_logger.error(errMsg);
+            // TODO: valid to return null, or should we throw?
+            return null;
+        }
+
+        // Host will also supply details of an existing StoragePool if it has
+        // been configured with one.
+        //
+        // NB: if the host was configured
+        // with a local storage pool, CloudStack may not be able to use it
+        // unless
+        // it is has service offerings configured to recognise this storage
+        // type.
+        StartupStorageCommand storePoolCmd = null;
+        if (startCmds.length > 1) {
+            storePoolCmd = (StartupStorageCommand) startCmds[1];
+            // TODO: is this assertion required?
+            if (storePoolCmd == null) {
+                String frmtStr =
+                        "Host %s (IP %s) sent incorrect Command, "
+                                + "second parameter should be a "
+                                + "StartupStorageCommand";
+                String errMsg = String.format(frmtStr, _name, _agentIp);
+                s_logger.error(errMsg);
+                // TODO: valid to return null, or should we throw?
+                return null;
+            }
+            s_logger.info("Host " + _name + " (IP " + _agentIp
+                    + ") already configured with a storeage pool, details "
+                    + s_gson.toJson(startCmds[1]));
+        } else {
+            s_logger.info("Host " + _name + " (IP " + _agentIp
+                    + ") already configured with a storeage pool, details ");
+        }
+        return new StartupCommand[] {startCmd, storePoolCmd};
+    }
+
+    @Override
+    public final PingCommand getCurrentStatus(final long id) {
+        PingCommand pingCmd = new PingRoutingCommand(getType(), id, null);
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Ping host " + _name + " (IP " + _agentIp + ")");
+        }
+
+        Answer pingAns = this.executeRequest(pingCmd);
+
+        if (pingAns == null || !pingAns.getResult()) {
+            s_logger.info("Cannot ping host " + _name + " (IP " + _agentIp
+                    + "), pingAns (blank means null) is:" + pingAns);
+            return null;
+        }
+        return pingCmd;
+    }
+
+    // TODO: Is it valid to return NULL, or should we throw on error?
+    // Returns StartupCommand with fields revised with values known only to the
+    // host
+    public final Command[] requestStartupCommand(final Command[] cmd) {
+        // Set HTTP POST destination URI
+        // Using java.net.URI, see
+        // http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URI.html
+        URI agentUri = null;
+        try {
+            String cmdName = StartupCommand.class.getName();
+            agentUri =
+                    new URI("http", null, _agentIp, _port,
+                            "/api/HypervResource/" + cmdName, null, null);
+        } catch (URISyntaxException e) {
+            // TODO add proper logging
+            String errMsg = "Could not generate URI for Hyper-V agent";
+            s_logger.error(errMsg, e);
+            return null;
+        }
+        String incomingCmd = postHttpRequest(s_gson.toJson(cmd), agentUri);
+
+        if (incomingCmd == null) {
+            return null;
+        }
+        Command[] result = null;
+        try {
+            result = s_gson.fromJson(incomingCmd, Command[].class);
+        } catch (Exception ex) {
+            String errMsg = "Failed to deserialize Command[] " + incomingCmd;
+            s_logger.error(errMsg, ex);
+        }
+        s_logger.debug("requestStartupCommand received response "
+                + s_gson.toJson(result));
+        if (result.length > 0) {
+            return result;
+        }
+        return null;
+    }
+
+    // TODO: Is it valid to return NULL, or should we throw on error?
+    @Override
+    public final Answer executeRequest(final Command cmd) {
+        // Set HTTP POST destination URI
+        // Using java.net.URI, see
+        // http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URI.html
+        URI agentUri = null;
+        try {
+            String cmdName = cmd.getClass().getName();
+            agentUri =
+                    new URI("http", null, _agentIp, _port,
+                            "/api/HypervResource/" + cmdName, null, null);
+        } catch (URISyntaxException e) {
+            // TODO add proper logging
+            String errMsg = "Could not generate URI for Hyper-V agent";
+            s_logger.error(errMsg, e);
+            return null;
+        }
+        String ansStr = postHttpRequest(s_gson.toJson(cmd), agentUri);
+
+        if (ansStr == null) {
+            return null;
+        }
+        // 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 null;
+    }
+
+    public static String postHttpRequest(final String jsonCmd,
+            final URI agentUri) {
+        // Using Apache's HttpClient for HTTP POST
+        // Java-only approach discussed at on StackOverflow concludes with
+        // comment to use Apache HttpClient
+        // http://stackoverflow.com/a/2793153/939250, but final comment is to
+        // use Apache.
+        s_logger.debug("POST request to" + agentUri.toString()
+                + " with contents" + jsonCmd);
+
+        // Create request
+        HttpClient httpClient = new DefaultHttpClient();
+        String result = null;
+
+        // TODO: are there timeout settings and worker thread settings to tweak?
+        try {
+            HttpPost request = new HttpPost(agentUri);
+
+            // JSON encode command
+            // Assumes command sits comfortably in a string, i.e. not used for
+            // large data transfers
+            StringEntity cmdJson = new StringEntity(jsonCmd);
+            request.addHeader("content-type", "application/json");
+            request.setEntity(cmdJson);
+            s_logger.debug("Sending cmd to " + agentUri.toString()
+                    + " cmd data:" + jsonCmd);
+            HttpResponse response = httpClient.execute(request);
+
+            // Unsupported commands will not route.
+            if (response.getStatusLine().getStatusCode()
+                == HttpStatus.SC_NOT_FOUND) {
+                String errMsg =
+                        "Failed to send : HTTP error code : "
+                                + response.getStatusLine().getStatusCode();
+                s_logger.error(errMsg);
+                String unsupportMsg =
+                        "Unsupported command "
+                                + agentUri.getPath()
+                                + ".  Are you sure you got the right type of"
+                                + " server?";
+                Answer ans = new UnsupportedAnswer(null, unsupportMsg);
+                s_logger.error(ans);
+                result = s_gson.toJson(new Answer[] {ans});
+            } else if (response.getStatusLine().getStatusCode()
+                != HttpStatus.SC_OK) {
+                String errMsg =
+                        "Failed send to " + agentUri.toString()
+                                + " : HTTP error code : "
+                                + response.getStatusLine().getStatusCode();
+                s_logger.error(errMsg);
+                return null;
+            } else {
+                result = EntityUtils.toString(response.getEntity());
+                s_logger.debug("POST response is" + result);
+            }
+        } catch (ClientProtocolException protocolEx) {
+            // Problem with HTTP message exchange
+            s_logger.error(protocolEx);
+        } catch (IOException connEx) {
+            // Problem with underlying communications
+            s_logger.error(connEx);
+        } finally {
+            httpClient.getConnectionManager().shutdown();
+        }
+        return result;
+    }
+
+    @Override
+    protected final String getDefaultScriptsDir() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    // NB: 'params' can come from one of two places.
+    // For a new host, HypervServerDiscoverer.find().
+    // For an existing host, DiscovererBase.reloadResource().
+    // In the later case, the params Map is populated with predefined keys
+    // and custom keys from the database that were passed out by the find()
+    // call.
+    // the custom keys go by the variable name 'details'.
+    // Thus, in find(), you see that 'details' are added to the params Map.
+    @Override
+    public final boolean configure(final String name,
+            final Map<String, Object> params) throws ConfigurationException {
+        /* todo: update, make consistent with the xen server equivalent. */
+        _guid = (String) params.get("guid");
+        _zoneId = (String) params.get("zone");
+        _podId = (String) params.get("pod");
+        _clusterId = (String) params.get("cluster");
+        _agentIp = (String) params.get("ipaddress"); // was agentIp
+        _name = name;
+
+        _clusterGuid = (String) params.get("cluster.guid");
+        _username = (String) params.get("url");
+        _password = (String) params.get("password");
+        _username = (String) params.get("username");
+
+        _configureCalled = true;
+        return true;
+    }
+
+    @Override
+    public void setName(final String name) {
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public void setConfigParams(final Map<String, Object> params) {
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public final Map<String, Object> getConfigParams() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public final int getRunLevel() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setRunLevel(final int level) {
+        // TODO Auto-generated method stub
+    }
+
+}


[08/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..9a4b5d2
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitchManagementService.cs
@@ -0,0 +1,1379 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[30/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
new file mode 100644
index 0000000..ae595fc
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs
@@ -0,0 +1,642 @@
+// 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 log4net;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+// C# versions of certain CloudStack types to simplify JSON serialisation.
+// Limit to the number of types, becasue they are written and maintained manually.
+// JsonProperty used to identify property name when serialised, which allows
+// later adoption of C# naming conventions if requried. 
+namespace HypervResource
+{
+    public class PrimaryDataStoreTO
+    {
+        public string path;
+
+        public static PrimaryDataStoreTO ParseJson(dynamic json)
+        {
+            PrimaryDataStoreTO result = null;
+
+            if (json == null)
+            {
+                return result;
+            }
+            dynamic primaryDataStoreTOJson = json[CloudStackTypes.PrimaryDataStoreTO];
+            if (primaryDataStoreTOJson != null)
+            {
+                result = new PrimaryDataStoreTO()
+                {
+                    path = (string)primaryDataStoreTOJson.path
+                };
+            }
+            return result;
+        }
+    }
+
+    public class VolumeObjectTO
+    {
+        private static ILog logger = LogManager.GetLogger(typeof(VolumeObjectTO));
+
+        public string FullFileName
+        {
+            get
+            {
+                String result = Path.Combine(this.primaryDataStore.path, this.name);
+                if (this.format != null)
+                {
+                    result = result + "." + this.format.ToLowerInvariant();
+                }
+                return result;
+            }
+        }
+
+        public dynamic dataStore;
+        public string format;
+        public string name;
+        public string uuid;
+        public PrimaryDataStoreTO primaryDataStore;
+
+        public static VolumeObjectTO ParseJson(dynamic json)
+        {
+            VolumeObjectTO result = null;
+
+            if (json == null)
+            {
+                return result;
+            }
+
+            dynamic volumeObjectTOJson = json[CloudStackTypes.VolumeObjectTO];
+            if (volumeObjectTOJson != null)
+            {
+                result = new VolumeObjectTO()
+                {
+                    dataStore = volumeObjectTOJson.dataStore,
+                    format = ((string)volumeObjectTOJson.format),
+                    name = (string)volumeObjectTOJson.name,
+                    uuid = (string)volumeObjectTOJson.uuid
+                };
+                result.primaryDataStore = PrimaryDataStoreTO.ParseJson(volumeObjectTOJson.dataStore);
+
+                // Assert
+                if (result.dataStore == null || result.primaryDataStore == null)
+                {
+                    String errMsg = "VolumeObjectTO missing primary dataStore in spec " + volumeObjectTOJson.ToString();
+                    logger.Error(errMsg);
+                    throw new ArgumentNullException(errMsg);
+                }
+
+                GuessFileExtension(result);
+            }
+            return result;
+        }
+
+        private static void GuessFileExtension(VolumeObjectTO volInfo)
+        {
+            if (String.IsNullOrEmpty(volInfo.format))
+            {
+                logger.Info("No image format in VolumeObjectTO, going to use format from first file that matches " + volInfo.FullFileName);
+
+                string[] choices = Directory.GetFiles(volInfo.primaryDataStore.path, volInfo.name + ".vhd*");
+
+                if (choices.Length != 1)
+                {
+                    String errMsg = "Tried to guess file extension, but cannot find file corresponding to " + Path.Combine(volInfo.primaryDataStore.path, volInfo.name); // format being guessed.
+                    logger.Debug(errMsg);
+                }
+                else
+                {
+                    string[] splitFileName = choices[0].Split(new char[] { '.' });
+                    volInfo.format = splitFileName[splitFileName.Length - 1];
+                }
+                logger.Debug("Going to use file " + volInfo.FullFileName);
+            }
+        }
+    }
+
+    public class TemplateObjectTO
+    {
+        /// <summary>
+        /// Full file name varies depending on whether the TemplateObjectTO has a path or not.
+        /// If it has a path, we use that.  Otherwise, we build it from the name, extension and data store path.
+        /// </summary>
+        public string FullFileName
+        {
+            get
+            {
+                if (String.IsNullOrEmpty(this.path))
+                {
+                    return Path.Combine(this.primaryDataStore.path, this.name) + '.' + this.format.ToLowerInvariant();
+                }
+                return this.path;
+            }
+        }
+
+        public dynamic imageDataStore;
+        public string format;
+        public string name;
+        public string uuid;
+        public S3TO s3DataStoreTO = null;
+        public NFSTO nfsDataStoreTO = null;
+        public PrimaryDataStoreTO primaryDataStore = null;
+        public string path;
+        public string checksum;
+
+        public static TemplateObjectTO ParseJson(dynamic json)
+        {
+            TemplateObjectTO result = null;
+            dynamic templateObjectTOJson = json[CloudStackTypes.TemplateObjectTO];
+            if (templateObjectTOJson != null)
+            {
+                result = new TemplateObjectTO()
+                {
+                    imageDataStore = templateObjectTOJson.imageDataStore,
+                    format = (string)templateObjectTOJson.format,
+                    name = (string)templateObjectTOJson.name,
+                    uuid = (string)templateObjectTOJson.uuid,
+                    path = (string)templateObjectTOJson.path,
+                    checksum = (string)templateObjectTOJson.checksum
+                };
+                result.s3DataStoreTO = S3TO.ParseJson(templateObjectTOJson.imageDataStore);
+                result.nfsDataStoreTO = NFSTO.ParseJson(templateObjectTOJson.imageDataStore);
+                result.primaryDataStore = PrimaryDataStoreTO.ParseJson(templateObjectTOJson.imageDataStore);
+            }
+
+            return result;
+        }
+    }
+
+    public class S3TO
+    {
+        public string bucketName;
+        public string secretKey;
+        public string accessKey;
+        public string endpoint;
+        public bool httpsFlag;
+
+        public static S3TO ParseJson(dynamic json)
+        {
+            S3TO result = null;
+            dynamic s3TOJson = json[CloudStackTypes.S3TO];
+            if (s3TOJson != null)
+            {
+                result = new S3TO()
+                {
+                    bucketName = (string)s3TOJson.bucketName,
+                    secretKey = (string)s3TOJson.secretKey,
+                    accessKey = (string)s3TOJson.accessKey,
+                    endpoint = (string)s3TOJson.endPoint,
+                    httpsFlag = (bool)s3TOJson.httpsFlag
+                };
+                // Delete security credentials in original command.  Prevents logger from spilling the beans, as it were.
+                s3TOJson.secretKey = string.Empty;
+                s3TOJson.accessKey = string.Empty;
+            }
+            return result;
+        }
+    }
+
+    public class NFSTO
+    {
+        public Uri uri;
+        public string _role;
+        public string UncPath
+        {
+            get
+            {
+                string uncPath = null;
+                if (uri.Scheme.Equals("cifs"))
+                {
+                    uncPath = @"\\" + uri.Host + uri.LocalPath;
+                }
+                return uncPath;
+            }
+        }
+        public string User
+        {
+            get
+            {
+                var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
+                return System.Web.HttpUtility.UrlDecode(queryDictionary["user"]);
+            }
+        }
+
+        public string Password
+        {
+            get
+            {
+                var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
+                return System.Web.HttpUtility.UrlDecode(queryDictionary["password"]);
+            }
+        }
+
+        public string Domain
+        {
+            get
+            {
+                var queryDictionary = System.Web.HttpUtility.ParseQueryString(uri.Query);
+                if (queryDictionary["domain"] != null)
+                {
+                    return System.Web.HttpUtility.UrlDecode(queryDictionary["domain"]);
+                }
+                else return uri.Host;
+            }
+        }
+        public static NFSTO ParseJson(dynamic json)
+        {
+            NFSTO result = null;
+            dynamic nfsTOJson = json[CloudStackTypes.NFSTO];
+            if (nfsTOJson != null)
+            {
+                result = new NFSTO()
+                {
+                    _role = (string)nfsTOJson._role,
+                };
+                // Delete security credentials in original command.  Prevents logger from spilling the beans, as it were.
+                String uriStr = (String)nfsTOJson._url;
+                result.uri = new Uri(uriStr);
+            }
+            return result;
+        }
+    }
+
+    enum VolumeType
+    {
+        UNKNOWN,
+        ROOT,
+        SWAP,
+        DATADISK,
+        ISO
+    };
+
+    public enum StoragePoolType
+    {
+        /// <summary>
+        /// local directory
+        /// </summary>
+        Filesystem,
+        /// <summary>
+        /// NFS or CIFS 
+        /// </summary>
+        NetworkFilesystem,
+        /// <summary>
+        /// shared LUN, with a clusterfs overlay 
+        /// </summary>
+        IscsiLUN,
+        /// <summary>
+        /// for e.g., ZFS Comstar 
+        /// </summary>
+        Iscsi,
+        /// <summary>
+        /// for iso image
+        /// </summary>
+        ISO,
+        /// <summary>
+        /// XenServer local LVM SR
+        /// </summary>
+        LVM,
+        /// <summary>
+        /// 
+        /// </summary>
+        CLVM,
+        /// <summary>
+        /// 
+        /// </summary>
+        RBD,
+        /// <summary>
+        /// 
+        /// </summary>
+        SharedMountPoint,
+        /// <summary>
+        /// VMware VMFS storage 
+        /// </summary>
+        VMFS,
+        /// <summary>
+        /// for XenServer, Storage Pool is set up by customers. 
+        /// </summary>
+        PreSetup,
+        /// <summary>
+        /// XenServer local EXT SR 
+        /// </summary>
+        EXT,
+        /// <summary>
+        /// 
+        /// </summary>
+        OCFS2
+    }
+
+    public enum StorageResourceType
+    {
+        STORAGE_POOL, STORAGE_HOST, SECONDARY_STORAGE, LOCAL_SECONDARY_STORAGE
+    }
+
+    public struct VolumeInfo
+    {
+        public long id;
+        public string type;
+        public string storagePoolType;
+        public string storagePoolUuid;
+        public string name;
+        public string mountPoint;
+        public string path;
+        long size;
+        string chainInfo;
+
+        public VolumeInfo(long id, string type, string poolType, String poolUuid, String name, String mountPoint, String path, long size, String chainInfo)
+        {
+            this.id = id;
+            this.name = name;
+            this.path = path;
+            this.size = size;
+            this.type = type;
+            this.storagePoolType = poolType;
+            this.storagePoolUuid = poolUuid;
+            this.mountPoint = mountPoint;
+            this.chainInfo = chainInfo;
+        }
+    }
+
+    public struct StoragePoolInfo
+    {
+        [JsonProperty("uuid")]
+        public String uuid;
+        [JsonProperty("host")]
+        String host;
+        [JsonProperty("localPath")]
+        String localPath;
+        [JsonProperty("hostPath")]
+        String hostPath;
+        [JsonProperty("poolType")]
+        string poolType;
+        [JsonProperty("capacityBytes")]
+        long capacityBytes;
+
+        // Management server copies this field to the 'used_byptes' in the database table 'storage_pool'.
+        [JsonProperty("availableBytes")]
+        long availableBytes;
+        [JsonProperty("details")]
+        Dictionary<String, String> details;
+
+        public StoragePoolInfo(String uuid, String host, String hostPath,
+                String localPath, string poolType, long capacityBytes,
+                long availableBytes)
+        {
+            this.uuid = uuid;
+            this.host = host;
+            this.localPath = localPath;
+            this.hostPath = hostPath;
+            this.poolType = poolType;
+            this.capacityBytes = capacityBytes;
+            this.availableBytes = availableBytes;
+            details = null;
+        }
+
+        public StoragePoolInfo(String uuid, String host, String hostPath,
+                String localPath, string poolType, long capacityBytes,
+                long availableBytes, Dictionary<String, String> details)
+            : this(uuid, host, hostPath, localPath, poolType, capacityBytes, availableBytes)
+        {
+            this.details = details;
+        }
+    }
+
+    public class VmStatsEntry
+    {
+        [JsonProperty("cpuUtilization")]
+        public double cpuUtilization;
+        [JsonProperty("networkReadKBs")]
+        public double networkReadKBs;
+        [JsonProperty("networkWriteKBs")]
+        public double networkWriteKBs;
+        [JsonProperty("numCPUs")]
+        public int numCPUs;
+        [JsonProperty("entityType")]
+        public String entityType;
+    }
+
+    /// <summary>
+    /// Fully qualified named for a number of types used in CloudStack.  Used to specify the intended type for JSON serialised objects. 
+    /// </summary>
+    public class CloudStackTypes
+    {
+        public const string Answer = "com.cloud.agent.api.Answer";
+        public const string AttachIsoCommand = "com.cloud.agent.api.AttachIsoCommand";
+        public const string AttachVolumeAnswer = "com.cloud.agent.api.AttachVolumeAnswer";
+        public const string AttachVolumeCommand = "com.cloud.agent.api.AttachVolumeCommand";
+        public const string AnsBackupSnapshotAnswerwer = "com.cloud.agent.api.BackupSnapshotAnswer";
+        public const string BackupSnapshotCommand = "com.cloud.agent.api.BackupSnapshotCommand";
+        public const string BumpUpPriorityCommand = "com.cloud.agent.api.BumpUpPriorityCommand";
+        public const string CheckHealthAnswer = "com.cloud.agent.api.CheckHealthAnswer";
+        public const string CheckHealthCommand = "com.cloud.agent.api.CheckHealthCommand";
+        public const string CheckNetworkAnswer = "com.cloud.agent.api.CheckNetworkAnswer";
+        public const string CheckNetworkCommand = "com.cloud.agent.api.CheckNetworkCommand";
+        public const string CheckOnHostAnswer = "com.cloud.agent.api.CheckOnHostAnswer";
+        public const string CheckOnHostCommand = "com.cloud.agent.api.CheckOnHostCommand";
+        public const string CheckRouterAnswer = "com.cloud.agent.api.CheckRouterAnswer";
+        public const string CheckRouterCommand = "com.cloud.agent.api.CheckRouterCommand";
+        public const string CheckS2SVpnConnectionsAnswer = "com.cloud.agent.api.CheckS2SVpnConnectionsAnswer";
+        public const string CheckS2SVpnConnectionsCommand = "com.cloud.agent.api.CheckS2SVpnConnectionsCommand";
+        public const string CheckVirtualMachineAnswer = "com.cloud.agent.api.CheckVirtualMachineAnswer";
+        public const string CheckVirtualMachineCommand = "com.cloud.agent.api.CheckVirtualMachineCommand";
+        public const string CleanupNetworkRulesCmd = "com.cloud.agent.api.CleanupNetworkRulesCmd";
+        public const string ClusterSyncAnswer = "com.cloud.agent.api.ClusterSyncAnswer";
+        public const string ClusterSyncCommand = "com.cloud.agent.api.ClusterSyncCommand";
+        public const string Command = "com.cloud.agent.api.Command";
+        public const string CreatePrivateTemplateFromSnapshotCommand = "com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand";
+        public const string CreatePrivateTemplateFromVolumeCommand = "com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand";
+        public const string CreateStoragePoolCommand = "com.cloud.agent.api.CreateStoragePoolCommand";
+        public const string CreateVMSnapshotAnswer = "com.cloud.agent.api.CreateVMSnapshotAnswer";
+        public const string CreateVMSnapshotCommand = "com.cloud.agent.api.CreateVMSnapshotCommand";
+        public const string CreateVolumeFromSnapshotAnswer = "com.cloud.agent.api.CreateVolumeFromSnapshotAnswer";
+        public const string CreateVolumeFromSnapshotCommand = "com.cloud.agent.api.CreateVolumeFromSnapshotCommand";
+        public const string DeleteStoragePoolCommand = "com.cloud.agent.api.DeleteStoragePoolCommand";
+        public const string DeleteVMSnapshotAnswer = "com.cloud.agent.api.DeleteVMSnapshotAnswer";
+        public const string DeleteVMSnapshotCommand = "com.cloud.agent.api.DeleteVMSnapshotCommand";
+        public const string GetDomRVersionAnswer = "com.cloud.agent.api.GetDomRVersionAnswer";
+        public const string GetDomRVersionCmd = "com.cloud.agent.api.GetDomRVersionCmd";
+        public const string GetHostStatsAnswer = "com.cloud.agent.api.GetHostStatsAnswer";
+        public const string GetHostStatsCommand = "com.cloud.agent.api.GetHostStatsCommand";
+        public const string GetStorageStatsAnswer = "com.cloud.agent.api.GetStorageStatsAnswer";
+        public const string GetStorageStatsCommand = "com.cloud.agent.api.GetStorageStatsCommand";
+        public const string GetVmDiskStatsAnswer = "com.cloud.agent.api.GetVmDiskStatsAnswer";
+        public const string GetVmDiskStatsCommand = "com.cloud.agent.api.GetVmDiskStatsCommand";
+        public const string GetVmStatsAnswer = "com.cloud.agent.api.GetVmStatsAnswer";
+        public const string GetVmStatsCommand = "com.cloud.agent.api.GetVmStatsCommand";
+        public const string GetVncPortAnswer = "com.cloud.agent.api.GetVncPortAnswer";
+        public const string GetVncPortCommand = "com.cloud.agent.api.GetVncPortCommand";
+        public const string HostStatsEntry = "com.cloud.agent.api.HostStatsEntry";
+        public const string MaintainAnswer = "com.cloud.agent.api.MaintainAnswer";
+        public const string MaintainCommand = "com.cloud.agent.api.MaintainCommand";
+        public const string ManageSnapshotAnswer = "com.cloud.agent.api.ManageSnapshotAnswer";
+        public const string ManageSnapshotCommand = "com.cloud.agent.api.ManageSnapshotCommand";
+        public const string MigrateAnswer = "com.cloud.agent.api.MigrateAnswer";
+        public const string MigrateCommand = "com.cloud.agent.api.MigrateCommand";
+        public const string ModifySshKeysCommand = "com.cloud.agent.api.ModifySshKeysCommand";
+        public const string ModifyStoragePoolAnswer = "com.cloud.agent.api.ModifyStoragePoolAnswer";
+        public const string ModifyStoragePoolCommand = "com.cloud.agent.api.ModifyStoragePoolCommand";
+        public const string NetworkRulesSystemVmCommand = "com.cloud.agent.api.NetworkRulesSystemVmCommand";
+        public const string NetworkRulesVmSecondaryIpCommand = "com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand";
+        public const string PingCommand = "com.cloud.agent.api.PingCommand";
+        public const string PingRoutingCommand = "com.cloud.agent.api.PingRoutingCommand";
+        public const string PingRoutingWithNwGroupsCommand = "com.cloud.agent.api.PingRoutingWithNwGroupsCommand";
+        public const string PingRoutingWithOvsCommand = "com.cloud.agent.api.PingRoutingWithOvsCommand";
+        public const string PingTestCommand = "com.cloud.agent.api.PingTestCommand";
+        public const string PlugNicAnswer = "com.cloud.agent.api.PlugNicAnswer";
+        public const string PlugNicCommand = "com.cloud.agent.api.PlugNicCommand";
+        public const string PoolEjectCommand = "com.cloud.agent.api.PoolEjectCommand";
+        public const string PrepareForMigrationAnswer = "com.cloud.agent.api.PrepareForMigrationAnswer";
+        public const string PrepareForMigrationCommand = "com.cloud.agent.api.PrepareForMigrationCommand";
+        public const string PvlanSetupCommand = "com.cloud.agent.api.PvlanSetupCommand";
+        public const string ReadyAnswer = "com.cloud.agent.api.ReadyAnswer";
+        public const string ReadyCommand = "com.cloud.agent.api.ReadyCommand";
+        public const string RebootAnswer = "com.cloud.agent.api.RebootAnswer";
+        public const string RebootCommand = "com.cloud.agent.api.RebootCommand";
+        public const string RebootRouterCommand = "com.cloud.agent.api.RebootRouterCommand";
+        public const string RevertToVMSnapshotAnswer = "com.cloud.agent.api.RevertToVMSnapshotAnswer";
+        public const string RevertToVMSnapshotCommand = "com.cloud.agent.api.RevertToVMSnapshotCommand";
+        public const string ScaleVmAnswer = "com.cloud.agent.api.ScaleVmAnswer";
+        public const string ScaleVmCommand = "com.cloud.agent.api.ScaleVmCommand";
+        public const string SecurityGroupRuleAnswer = "com.cloud.agent.api.SecurityGroupRuleAnswer";
+        public const string SecurityGroupRulesCmd = "com.cloud.agent.api.SecurityGroupRulesCmd";
+        public const string SetupAnswer = "com.cloud.agent.api.SetupAnswer";
+        public const string SetupCommand = "com.cloud.agent.api.SetupCommand";
+        public const string SetupGuestNetworkAnswer = "com.cloud.agent.api.SetupGuestNetworkAnswer";
+        public const string SetupGuestNetworkCommand = "com.cloud.agent.api.SetupGuestNetworkCommand";
+        public const string StartAnswer = "com.cloud.agent.api.StartAnswer";
+        public const string StartCommand = "com.cloud.agent.api.StartCommand";
+        public const string StartupCommand = "com.cloud.agent.api.StartupCommand";
+        public const string StartupRoutingCommand = "com.cloud.agent.api.StartupRoutingCommand";
+        public const string StartupStorageCommand = "com.cloud.agent.api.StartupStorageCommand";
+        public const string StopAnswer = "com.cloud.agent.api.StopAnswer";
+        public const string StopCommand = "com.cloud.agent.api.StopCommand";
+        public const string StoragePoolInfo = "com.cloud.agent.api.StoragePoolInfo";
+        public const string UnPlugNicAnswer = "com.cloud.agent.api.UnPlugNicAnswer";
+        public const string UnPlugNicCommand = "com.cloud.agent.api.UnPlugNicCommand";
+        public const string UpdateHostPasswordCommand = "com.cloud.agent.api.UpdateHostPasswordCommand";
+        public const string UpgradeSnapshotCommand = "com.cloud.agent.api.UpgradeSnapshotCommand";
+        public const string VmDiskStatsEntry = "com.cloud.agent.api.VmDiskStatsEntry";
+        public const string VmStatsEntry = "com.cloud.agent.api.VmStatsEntry";
+        public const string CheckSshAnswer = "com.cloud.agent.api.check.CheckSshAnswer";
+        public const string CheckSshCommand = "com.cloud.agent.api.check.CheckSshCommand";
+        public const string CheckConsoleProxyLoadCommand = "com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand";
+        public const string ConsoleProxyLoadAnswer = "com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer";
+        public const string WatchConsoleProxyLoadCommand = "com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand";
+        public const string CreateIpAliasCommand = "com.cloud.agent.api.routing.CreateIpAliasCommand";
+        public const string DeleteIpAliasCommand = "com.cloud.agent.api.routing.DeleteIpAliasCommand";
+        public const string DhcpEntryCommand = "com.cloud.agent.api.routing.DhcpEntryCommand";
+        public const string DnsMasqConfigCommand = "com.cloud.agent.api.routing.DnsMasqConfigCommand";
+        public const string IpAliasTO = "com.cloud.agent.api.routing.IpAliasTO";
+        public const string IpAssocAnswer = "com.cloud.agent.api.routing.IpAssocAnswer";
+        public const string IpAssocCommand = "com.cloud.agent.api.routing.IpAssocCommand";
+        public const string IpAssocVpcCommand = "com.cloud.agent.api.routing.IpAssocVpcCommand";
+        public const string LoadBalancerConfigCommand = "com.cloud.agent.api.routing.LoadBalancerConfigCommand";
+        public const string NetworkElementCommand = "com.cloud.agent.api.routing.NetworkElementCommand";
+        public const string RemoteAccessVpnCfgCommand = "com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand";
+        public const string SavePasswordCommand = "com.cloud.agent.api.routing.SavePasswordCommand";
+        public const string SetFirewallRulesAnswer = "com.cloud.agent.api.routing.SetFirewallRulesAnswer";
+        public const string SetFirewallRulesCommand = "com.cloud.agent.api.routing.SetFirewallRulesCommand";
+        public const string SetNetworkACLAnswer = "com.cloud.agent.api.routing.SetNetworkACLAnswer";
+        public const string SetNetworkACLCommand = "com.cloud.agent.api.routing.SetNetworkACLCommand";
+        public const string SetPortForwardingRulesAnswer = "com.cloud.agent.api.routing.SetPortForwardingRulesAnswer";
+        public const string SetPortForwardingRulesCommand = "com.cloud.agent.api.routing.SetPortForwardingRulesCommand";
+        public const string SetPortForwardingRulesVpcCommand = "com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand";
+        public const string SetSourceNatAnswer = "com.cloud.agent.api.routing.SetSourceNatAnswer";
+        public const string SetSourceNatCommand = "com.cloud.agent.api.routing.SetSourceNatCommand";
+        public const string SetStaticNatRulesAnswer = "com.cloud.agent.api.routing.SetStaticNatRulesAnswer";
+        public const string SetStaticNatRulesCommand = "com.cloud.agent.api.routing.SetStaticNatRulesCommand";
+        public const string SetStaticRouteAnswer = "com.cloud.agent.api.routing.SetStaticRouteAnswer";
+        public const string SetStaticRouteCommand = "com.cloud.agent.api.routing.SetStaticRouteCommand";
+        public const string Site2SiteVpnCfgCommand = "com.cloud.agent.api.routing.Site2SiteVpnCfgCommand";
+        public const string VmDataCommand = "com.cloud.agent.api.routing.VmDataCommand";
+        public const string VpnUsersCfgCommand = "com.cloud.agent.api.routing.VpnUsersCfgCommand";
+        public const string CopyVolumeAnswer = "com.cloud.agent.api.storage.CopyVolumeAnswer";
+        public const string CopyVolumeCommand = "com.cloud.agent.api.storage.CopyVolumeCommand";
+        public const string CreateAnswer = "com.cloud.agent.api.storage.CreateAnswer";
+        public const string CreateCommand = "com.cloud.agent.api.storage.CreateCommand";
+        public const string CreatePrivateTemplateAnswer = "com.cloud.agent.api.storage.CreatePrivateTemplateAnswer";
+        public const string DestroyCommand = "com.cloud.agent.api.storage.DestroyCommand";
+        public const string PrimaryStorageDownloadAnswer = "com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer";
+        public const string PrimaryStorageDownloadCommand = "com.cloud.agent.api.storage.PrimaryStorageDownloadCommand";
+        public const string ResizeVolumeAnswer = "com.cloud.agent.api.storage.ResizeVolumeAnswer";
+        public const string ResizeVolumeCommand = "com.cloud.agent.api.storage.ResizeVolumeCommand";
+        public const string FirewallRuleTO = "com.cloud.agent.api.to.FirewallRuleTO";
+        public const string IpAddressTO = "com.cloud.agent.api.to.IpAddressTO";
+        public const string NicTO = "com.cloud.agent.api.to.NicTO";
+        public const string PortForwardingRuleTO = "com.cloud.agent.api.to.PortForwardingRuleTO";
+        public const string S3TO = "com.cloud.agent.api.to.S3TO";
+        public const string NFSTO = "com.cloud.agent.api.to.NfsTO";
+        public const string StaticNatRuleTO = "com.cloud.agent.api.to.StaticNatRuleTO";
+        public const string StorageFilerTO = "com.cloud.agent.api.to.StorageFilerTO";
+        public const string SwiftTO = "com.cloud.agent.api.to.SwiftTO";
+        public const string VirtualMachineTO = "com.cloud.agent.api.to.VirtualMachineTO";
+        public const string VolumeTO = "com.cloud.agent.api.to.VolumeTO";
+        public const string InternalErrorException = "com.cloud.exception.InternalErrorException";
+        public const string HostType = "com.cloud.host.Host.Type";
+        public const string HypervisorType = "com.cloud.hypervisor.Hypervisor.HypervisorType";
+        public const string DnsMasqConfigurator = "com.cloud.network.DnsMasqConfigurator";
+        public const string HAProxyConfigurator = "com.cloud.network.HAProxyConfigurator";
+        public const string LoadBalancerConfigurator = "com.cloud.network.LoadBalancerConfigurator";
+        public const string Networks = "com.cloud.network.Networks";
+        public const string BroadcastDomainType = "com.cloud.network.Networks.BroadcastDomainType";
+        public const string IsolationType = "com.cloud.network.Networks.IsolationType";
+        public const string TrafficType = "com.cloud.network.Networks.TrafficType";
+        public const string PhysicalNetworkSetupInfo = "com.cloud.network.PhysicalNetworkSetupInfo";
+        public const string OvsCreateGreTunnelAnswer = "com.cloud.network.ovs.OvsCreateGreTunnelAnswer";
+        public const string OvsCreateGreTunnelCommand = "com.cloud.network.ovs.OvsCreateGreTunnelCommand";
+        public const string OvsCreateTunnelAnswer = "com.cloud.network.ovs.OvsCreateTunnelAnswer";
+        public const string OvsCreateTunnelCommand = "com.cloud.network.ovs.OvsCreateTunnelCommand";
+        public const string OvsDeleteFlowCommand = "com.cloud.network.ovs.OvsDeleteFlowCommand";
+        public const string OvsDestroyBridgeCommand = "com.cloud.network.ovs.OvsDestroyBridgeCommand";
+        public const string OvsDestroyTunnelCommand = "com.cloud.network.ovs.OvsDestroyTunnelCommand";
+        public const string OvsFetchInterfaceAnswer = "com.cloud.network.ovs.OvsFetchInterfaceAnswer";
+        public const string OvsFetchInterfaceCommand = "com.cloud.network.ovs.OvsFetchInterfaceCommand";
+        public const string OvsSetTagAndFlowAnswer = "com.cloud.network.ovs.OvsSetTagAndFlowAnswer";
+        public const string OvsSetTagAndFlowCommand = "com.cloud.network.ovs.OvsSetTagAndFlowCommand";
+        public const string OvsSetupBridgeCommand = "com.cloud.network.ovs.OvsSetupBridgeCommand";
+        public const string FirewallRule = "com.cloud.network.rules.FirewallRule";
+        public const string ServerResource = "com.cloud.resource.ServerResource";
+        public const string HypervisorResource = "com.cloud.resource.hypervisor.HypervisorResource";
+        public const string Storage = "com.cloud.storage.Storage";
+        public const string ImageFormat = "com.cloud.storage.Storage.ImageFormat";
+        public const string StoragePoolType = "com.cloud.storage.Storage.StoragePoolType";
+        public const string Volume = "com.cloud.storage.Volume";
+        public const string VolumeVO = "com.cloud.storage.VolumeVO";
+        public const string StorageSubsystemCommandHandler = "com.cloud.storage.resource.StorageSubsystemCommandHandler";
+        public const string StorageSubsystemCommandHandlerBase = "com.cloud.storage.resource.StorageSubsystemCommandHandlerBase";
+        public const string TemplateProp = "com.cloud.storage.template.TemplateProp";
+        public const string BootloaderType = "com.cloud.template.VirtualMachineTemplate.BootloaderType";
+        public const string VolumeObjectTO = "org.apache.cloudstack.storage.to.VolumeObjectTO";
+        public const string TemplateObjectTO = "org.apache.cloudstack.storage.to.TemplateObjectTO";
+        public const string PrimaryDataStoreTO = "org.apache.cloudstack.storage.to.PrimaryDataStoreTO";
+        public const string AttachAnswer = "org.apache.cloudstack.storage.command.AttachAnswer";
+        public const string AttachCommand = "org.apache.cloudstack.storage.command.AttachCommand";
+        public const string AttachPrimaryDataStoreAnswer = "org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer";
+        public const string AttachPrimaryDataStoreCmd = "org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd";
+        public const string CopyCmdAnswer = "org.apache.cloudstack.storage.command.CopyCmdAnswer";
+        public const string CopyCommand = "org.apache.cloudstack.storage.command.CopyCommand";
+        public const string CreateObjectAnswer = "org.apache.cloudstack.storage.command.CreateObjectAnswer";
+        public const string CreateObjectCommand = "org.apache.cloudstack.storage.command.CreateObjectCommand";
+        public const string DeleteCommand = "org.apache.cloudstack.storage.command.DeleteCommand";
+        public const string DettachAnswer = "org.apache.cloudstack.storage.command.DettachAnswer";
+        public const string DettachCommand = "org.apache.cloudstack.storage.command.DettachCommand";
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..48cf5a5
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResource.csproj
@@ -0,0 +1,102 @@
+<?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="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>
+  -->
+</Project>
\ No newline at end of file


[28/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..0442be3
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -0,0 +1,1469 @@
+// 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;
+
+namespace HypervResource
+{
+    public class WmiCalls
+    {
+        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 static 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 static 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 static ComputerSystem DeployVirtualMachine(dynamic jsonObj)
+        {
+            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;
+
+            // 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 = WmiCalls.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 nics
+            foreach (var nic in nicInfo)
+            {
+                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;
+                    }
+                }
+                CreateNICforVm(newVm, mac, vlan);
+            }
+
+            logger.DebugFormat("Starting VM {0}", vmName);
+            SetState(newVm, RequiredState.Enabled);
+            logger.InfoFormat("Started VM {0}", vmName);
+            return newVm;
+       }
+
+        /// <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 static 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 static 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];
+        }
+
+        private static 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 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static void GetMemoryResources(out ulong physicalRamKBs, out ulong freeMemoryKBs)
+        {
+            OperatingSystem0 os = new OperatingSystem0();
+            physicalRamKBs = os.TotalVisibleMemorySize;
+            freeMemoryKBs = os.FreePhysicalMemory;
+        }
+
+        public static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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;
+        }
+    }
+
+    public class WmiException : Exception
+    {
+        public WmiException()
+        {
+        }
+
+        public WmiException(string message)
+            : base(message)
+        {
+        }
+
+        public WmiException(string message, Exception inner)
+            : base(message, inner)
+        {
+        }
+    }
+
+    /// <summary>
+    /// http://msdn.microsoft.com/en-us/library/hh850031%28v=vs.85%29.aspx
+    /// </summary>
+    public static class ReturnCode
+    {
+        public const UInt32 Completed = 0;
+        public const UInt32 Started = 4096;
+        public const UInt32 Failed = 32768;
+        public const UInt32 AccessDenied = 32769;
+        public const UInt32 NotSupported = 32770;
+        public const UInt32 Unknown = 32771;
+        public const UInt32 Timeout = 32772;
+        public const UInt32 InvalidParameter = 32773;
+        public const UInt32 SystemInUse = 32774;
+        public const UInt32 InvalidState = 32775;
+        public const UInt32 IncorrectDataType = 32776;
+        public const UInt32 SystemNotAvailable = 32777;
+        public const UInt32 OutofMemory = 32778;
+        public static string ToString(UInt32 value)
+        {
+            string result = "Unknown return code";
+            switch (value)
+            {
+                case Completed: result = "Completed"; break;
+                case Started: result = "Started"; break;
+                case Failed: result = "Failed"; break;
+                case AccessDenied: result = "AccessDenied"; break;
+                case NotSupported: result = "NotSupported"; break;
+                case Unknown: result = "Unknown"; break;
+                case Timeout: result = "Timeout"; break;
+                case InvalidParameter: result = "InvalidParameter"; break;
+                case SystemInUse: result = "SystemInUse"; break;
+                case InvalidState: result = "InvalidState"; break;
+                case IncorrectDataType: result = "IncorrectDataType"; break;
+                case SystemNotAvailable: result = "SystemNotAvailable"; break;
+                case OutofMemory: result = "OutofMemory"; break;
+            }
+            return result;
+        }
+    }
+
+    /// <summary>
+    /// http://msdn.microsoft.com/en-us/library/hh850031%28v=vs.85%29.aspx
+    /// </summary>
+    public static class JobState
+    {
+        public const UInt16 New = 2;
+        public const UInt16 Starting = 3;
+        public const UInt16 Running = 4;
+        public const UInt16 Suspended = 5;
+        public const UInt16 ShuttingDown = 6;
+        public const UInt16 Completed = 7;
+        public const UInt16 Terminated = 8;
+        public const UInt16 Killed = 9;
+        public const UInt16 Exception = 10;
+        public const UInt16 Service = 11;
+        public static string ToString(UInt16 value)
+        {
+            string result = "Unknown JobState code";
+            switch (value)
+            {
+                case New: result = "New"; break;
+                case Starting: result = "Starting"; break;
+                case Running: result = "Running"; break;
+                case Suspended: result = "Suspended"; break;
+                case ShuttingDown: result = "ShuttingDown"; break;
+                case Completed: result = "Completed"; break;
+                case Terminated: result = "Terminated"; break;
+                case Killed: result = "Killed"; break;
+                case Exception: result = "Exception"; break;
+                case Service: result = "Service"; break;
+            }
+            return result;
+        }
+    }
+
+    /// <summary>
+    /// http://msdn.microsoft.com/en-us/library/cc723874%28v=vs.85%29.aspx
+    /// </summary>
+    public class RequiredState
+    {
+        public const UInt16 Enabled = 2;        // Turns the VM on.
+        public const UInt16 Disabled = 3;       // Turns the VM off.
+        public const UInt16 Reboot = 10;        // A hard reset of the VM.
+        public const UInt16 Reset = 11;         // For future use.
+        public const UInt16 Paused = 32768;     // Pauses the VM.
+        public const UInt16 Suspended = 32769;  // Saves the state of the VM.
+        public static string ToString(UInt16 value)
+        {
+            string result = "Unknown RequiredState code";
+            switch (value)
+            {
+                case Enabled: result = "Enabled"; break;
+                case Disabled: result = "Disabled"; break;
+                case Reboot: result = "Reboot"; break;
+                case Reset: result = "Reset"; break;
+                case Paused: result = "Paused"; break;
+                case Suspended: result = "Suspended"; break;
+            }
+            return result;
+        }
+    }
+
+    /// <summary>
+    /// http://msdn.microsoft.com/en-us/library/cc136822%28v=vs.85%29.aspx
+    /// </summary>
+        public class EnabledState
+    {
+            /// <summary>
+            /// The state of the VM could not be determined.
+            /// </summary>
+        public const UInt16 Unknown = 0;
+            /// <summary>
+            /// The VM is running.
+            /// </summary>
+        public const UInt16 Enabled = 2;
+            /// <summary>
+            /// The VM is turned off.
+            /// </summary>
+        public const UInt16 Disabled = 3;
+            /// <summary>
+            /// The VM is paused.
+            /// </summary>
+        public const UInt16 Paused = 32768;
+            /// <summary>
+            /// The VM is in a saved state.
+            /// </summary>
+        public const UInt16 Suspended = 32769;
+            /// <summary>
+            /// The VM is starting. This is a transitional state between 3 (Disabled)
+            /// or 32769 (Suspended) and 2 (Enabled) initiated by a call to the 
+            /// RequestStateChange method with a RequestedState parameter of 2 (Enabled).
+            /// </summary>
+        public const UInt16 Starting = 32770;
+            /// <summary>
+            /// Starting with Windows Server 2008 R2 this value is not supported. 
+            /// If the VM is performing a snapshot operation, the element at index 1 
+            /// of the OperationalStatus property array will contain 32768 (Creating Snapshot), 
+            /// 32769 (Applying Snapshot), or 32770 (Deleting Snapshot).
+            /// </summary>
+        public const UInt16 Snapshotting = 32771;
+            /// <summary>
+            /// The VM is saving its state. This is a transitional state between 2 (Enabled)
+            /// and 32769 (Suspended) initiated by a call to the RequestStateChange method 
+            /// with a RequestedState parameter of 32769 (Suspended).
+            /// </summary>
+        public const UInt16 Saving = 32773;
+            /// <summary>
+            /// The VM is turning off. This is a transitional state between 2 (Enabled) 
+            /// and 3 (Disabled) initiated by a call to the RequestStateChange method 
+            /// with a RequestedState parameter of 3 (Disabled) or a guest operating system 
+            /// initiated power off.
+            /// </summary>
+        public const UInt16 Stopping = 32774;
+            /// <summary>
+            /// The VM is pausing. This is a transitional state between 2 (Enabled) and 32768 (Paused) initiated by a call to the RequestStateChange method with a RequestedState parameter of 32768 (Paused).
+            /// </summary>
+        public const UInt16 Pausing = 32776;
+            /// <summary>
+            /// The VM is resuming from a paused state. This is a transitional state between 32768 (Paused) and 2 (Enabled).
+            /// </summary>
+        public const UInt16 Resuming = 32777;
+
+        public static string ToString(UInt16 value)
+        {
+            string result = "Unknown";
+            switch (value)
+            {
+                case Enabled: result = "Enabled"; break;
+                case Disabled: result = "Disabled"; break;
+                case Paused: result = "Paused"; break;
+                case Suspended: result = "Suspended"; break;
+                case Starting: result = "Starting"; break;
+                case Snapshotting: result = "Snapshotting"; break; // NOT used
+                case Saving: result = "Saving"; break;
+                case Stopping: result = "Stopping"; break;
+                case Pausing: result = "Pausing"; break;
+                case Resuming: result = "Resuming"; break;
+            }
+            return result;
+        }
+
+        public static string ToCloudStackState(UInt16 value)
+        {
+            string result = "Unknown";
+            switch (value)
+            {
+                case Enabled: result = "Running"; break;
+                case Disabled: result = "Stopped"; break;
+                case Paused: result = "Unknown"; break;
+                case Suspended: result = "Unknown"; break;
+                case Starting: result = "Starting"; break;
+                case Snapshotting: result = "Unknown"; break; // NOT used
+                case Saving: result = "Saving"; break;
+                case Stopping: result = "Stopping"; break;
+                case Pausing: result = "Unknown"; break;
+                case Resuming: result = "Starting"; break; 
+            }
+            return result;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..b0f2ace
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/packages.config
@@ -0,0 +1,7 @@
+<?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" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..1bf17d4
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/App.config
@@ -0,0 +1,128 @@
+<?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" >
+      <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" >
+      <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>
+
+  <applicationSettings>
+    <CloudStack.Plugin.AgentShell.AgentSettings>
+      <setting name="cpus" serializeAs="String">
+        <value>8</value>
+      </setting>
+      <setting name="private_ip_address" serializeAs="String">
+        <value>10.1.1.1</value>
+      </setting>
+      <setting name="type" serializeAs="String">
+        <value>Routing</value>
+      </setting>
+      <setting name="local_storage_uuid" serializeAs="String">
+        <value>5fe2bad3-d785-394e-9949-89786b8a63d2</value>
+      </setting>
+      <setting name="capabilities" serializeAs="String">
+        <value>hvm</value>
+      </setting>
+      <setting name="Settingcpuspeed" serializeAs="String">
+        <value>2130</value>
+      </setting>
+      <setting name="port" serializeAs="String">
+        <value>8250</value>
+      </setting>
+      <setting name="memory" serializeAs="String">
+        <value>34359738368</value>
+      </setting>
+      <setting name="host" serializeAs="String">
+        <value>camldonall01.citrite.net</value>
+      </setting>
+      <setting name="pod" serializeAs="String">
+        <value>1</value>
+      </setting>
+      <setting name="gateway_ip_address" serializeAs="String">
+        <value>10.70.176.1</value>
+      </setting>
+      <setting name="cluster" serializeAs="String">
+        <value>2</value>
+      </setting>
+      <setting name="zone" serializeAs="String">
+        <value>1</value>
+      </setting>
+      <setting name="local_storage_path" serializeAs="String">
+        <value>E:\Disks\Disks</value>
+      </setting>
+      <setting name="workers" serializeAs="String">
+        <value>5</value>
+      </setting>
+      <setting name="private_ip_netmask" serializeAs="String">
+        <value>255.255.240.0</value>
+      </setting>
+      <setting name="RootDeviceReservedSpaceBytes" serializeAs="String">
+        <value>4294967296</value>
+      </setting>
+      <setting name="hyperv_plugin_root" serializeAs="String">
+        <value>..\..\..\..\..\</value>
+      </setting>
+      <setting name="RootDeviceName" serializeAs="String">
+        <value>e:\</value>
+      </setting>
+      <setting name="dom0MinMemory" serializeAs="String">
+        <value>2048</value>
+      </setting>
+      <setting name="private_mac_address" serializeAs="String">
+        <value>101F742C6B88</value>
+      </setting>
+    </CloudStack.Plugin.AgentShell.AgentSettings>
+  </applicationSettings>
+  <userSettings>
+    <CloudStack.Plugin.AgentShell.AgentSettings>
+      <setting name="local_secondary_storage_path" serializeAs="String">
+        <value>c:\Secondary</value>
+      </setting>
+      <setting name="local_storage_path" serializeAs="String">
+        <value>E:\Disks\Disks</value>
+      </setting>
+      <setting name="testLocalStoreUUID" serializeAs="String">
+        <value>5fe2bad3-d785-394e-9949-89786b8a63d2</value>
+      </setting>
+      <setting name="testLocalStorePath" serializeAs="String">
+        <value>.\var\test\storagepool</value>
+      </setting>
+      <setting name="testS3Bucket" serializeAs="String">
+        <value>cshv3eu</value>
+      </setting>
+      <setting name="testS3Endpoint" serializeAs="String">
+        <value>s3.amazonaws.com</value>
+      </setting>
+      <setting name="testS3AccessKey" serializeAs="String">
+        <value>testS3AccessKey</value>
+      </setting>
+      <setting name="testS3SecretKey" serializeAs="String">
+        <value>testS3SecretKey</value>
+      </setting>
+      <setting name="testS3TemplateName" serializeAs="String">
+        <value>206-2-73592258-559a-3b38-8f66-b667aab143eb</value>
+      </setting>
+      <setting name="testCifsTemplateName" serializeAs="String">
+        <value>206-2-73592258-559a-3b38-8f66-b667aab143eb</value>
+      </setting>
+      <setting name="testCifsUrl" serializeAs="String">
+        <value>cifs://10.1.1.1/secondary?user\u003dadministrator\u0026password\u003d1pass%40word1</value>
+      </setting>
+      <setting name="testCifsPath" serializeAs="String">
+        <value>template/tmpl/2/201/6dda6631-4daa-3150-a49a-d5a4b0a4c4b6.vhd</value>
+      </setting>
+    </CloudStack.Plugin.AgentShell.AgentSettings>
+  </userSettings>
+</configuration>


[16/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..8c0df73
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SummaryInformation.cs
@@ -0,0 +1,1184 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[34/54] Add ability to pass kvp data via the key cloudstack-vm-userdata

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponentSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponentSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponentSettingData.cs
new file mode 100755
index 0000000..09391d1
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponentSettingData.cs
@@ -0,0 +1,1037 @@
+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_KvpExchangeComponentSettingData
+    public class KvpExchangeComponentSettingData : 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_KvpExchangeComponentSettingData";
+        
+        // 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 KvpExchangeComponentSettingData() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public KvpExchangeComponentSettingData(string keyInstanceID) {
+            this.InitializeObject(null, new System.Management.ManagementPath(KvpExchangeComponentSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public KvpExchangeComponentSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(KvpExchangeComponentSettingData.ConstructPath(keyInstanceID)), null);
+        }
+        
+        public KvpExchangeComponentSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public KvpExchangeComponentSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public KvpExchangeComponentSettingData(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public KvpExchangeComponentSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public KvpExchangeComponentSettingData(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 KvpExchangeComponentSettingData(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(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsEnabledStateNull {
+            get {
+                if ((curObj["EnabledState"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"The enabled and disabled states of an element.
+Valid values are 2 (enabled) and 3 (disabled). The default value is 2 (enabled).
+This is a read-only property, but it can be changed using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class.")]
+        [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("An array of Msvm_KvpExchangeDataItem instances.\nThis is a read-only property, but" +
+            " it can be changed using the AddKvpItems, ModifyKvpItems, and RemoveKvpItems met" +
+            "hods of the Msvm_VirtualSystemManagementService class.")]
+        public string[] HostExchangeItems {
+            get {
+                return ((string[])(curObj["HostExchangeItems"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"An array of Msvm_KvpExchangeDataItem instances containing the key/value pairs that are stored in the configuration file but not exchanged with the guest OS. This allows applications to store VM-specific data that does not need to be visible to the guest OS. The items are formatted the same as the items in the HostExchangeItems property except the Source property of the Msvm_KvpExchangeDataItem instance is set to 4. Each configuration file is limited to 128 key/value pairs, where each value field is allowed to be up to 16 KB in size and the key field is allowed to be up to512 bytes.")]
+        public string[] HostOnlyItems {
+            get {
+                return ((string[])(curObj["HostOnlyItems"]));
+            }
+        }
+        
+        [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(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 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 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_KvpExchangeComponentSettingData";
+            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 KvpExchangeComponentSettingDataCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static KvpExchangeComponentSettingDataCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static KvpExchangeComponentSettingDataCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static KvpExchangeComponentSettingDataCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static KvpExchangeComponentSettingDataCollection 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_KvpExchangeComponentSettingData";
+            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 KvpExchangeComponentSettingDataCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static KvpExchangeComponentSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static KvpExchangeComponentSettingDataCollection 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_KvpExchangeComponentSettingData", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new KvpExchangeComponentSettingDataCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static KvpExchangeComponentSettingData 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 KvpExchangeComponentSettingData(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class KvpExchangeComponentSettingDataCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public KvpExchangeComponentSettingDataCollection(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 KvpExchangeComponentSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new KvpExchangeComponentSettingDataEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class KvpExchangeComponentSettingDataEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public KvpExchangeComponentSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new KvpExchangeComponentSettingData(((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/53fd4e8c/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeDataItem.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeDataItem.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeDataItem.cs
new file mode 100755
index 0000000..5f54635
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeDataItem.cs
@@ -0,0 +1,653 @@
+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_KvpExchangeDataItem
+    public class KvpExchangeDataItem : 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_KvpExchangeDataItem";
+        
+        // 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 KvpExchangeDataItem() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public KvpExchangeDataItem(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public KvpExchangeDataItem(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public KvpExchangeDataItem(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public KvpExchangeDataItem(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public KvpExchangeDataItem(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 KvpExchangeDataItem(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 Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string Data {
+            get {
+                return ((string)(curObj["Data"]));
+            }
+        }
+        
+        [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)]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsSourceNull {
+            get {
+                if ((curObj["Source"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort Source {
+            get {
+                if ((curObj["Source"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["Source"]));
+            }
+        }
+        
+        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 ShouldSerializeSource() {
+            if ((this.IsSourceNull == 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_KvpExchangeDataItem";
+            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 KvpExchangeDataItemCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static KvpExchangeDataItemCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static KvpExchangeDataItemCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static KvpExchangeDataItemCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static KvpExchangeDataItemCollection 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_KvpExchangeDataItem";
+            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 KvpExchangeDataItemCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static KvpExchangeDataItemCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static KvpExchangeDataItemCollection 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_KvpExchangeDataItem", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new KvpExchangeDataItemCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static KvpExchangeDataItem 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 KvpExchangeDataItem(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class KvpExchangeDataItemCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public KvpExchangeDataItemCollection(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 KvpExchangeDataItem(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new KvpExchangeDataItemEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class KvpExchangeDataItemEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public KvpExchangeDataItemEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new KvpExchangeDataItem(((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/54] Add ability to pass kvp data via the key cloudstack-vm-userdata

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemSettingData.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemSettingData.cs
new file mode 100755
index 0000000..622a465
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemSettingData.cs
@@ -0,0 +1,1673 @@
+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_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\\v2";
+        
+        // Private 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\\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(@"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 IsAllowReducedFcRedundancyNull {
+            get {
+                if ((curObj["AllowReducedFcRedundancy"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Indicates whether live migration of a virtual machine that is configured with a virtual FC adapter is allowed to a destination machine, without doing any checks for the existence of paths to the storage devices on the destination 
+The default value of this property is FALSE. If set to TRUE, the VM can be live migrated to a target machine which may have no or reduced paths to the target FC devices. The guest operating system may lose connectivity to storage and may behave in an unpredictable manner. 
+ This property should be cleared after a live migration")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool AllowReducedFcRedundancy {
+            get {
+                if ((curObj["AllowReducedFcRedundancy"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["AllowReducedFcRedundancy"]));
+            }
+            set {
+                curObj["AllowReducedFcRedundancy"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticRecoveryActionNull {
+            get {
+                if ((curObj["AutomaticRecoveryAction"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort AutomaticRecoveryAction {
+            get {
+                if ((curObj["AutomaticRecoveryAction"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["AutomaticRecoveryAction"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticShutdownActionNull {
+            get {
+                if ((curObj["AutomaticShutdownAction"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort AutomaticShutdownAction {
+            get {
+                if ((curObj["AutomaticShutdownAction"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["AutomaticShutdownAction"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticStartupActionNull {
+            get {
+                if ((curObj["AutomaticStartupAction"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort AutomaticStartupAction {
+            get {
+                if ((curObj["AutomaticStartupAction"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["AutomaticStartupAction"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticStartupActionDelayNull {
+            get {
+                if ((curObj["AutomaticStartupActionDelay"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public System.DateTime AutomaticStartupActionDelay {
+            get {
+                if ((curObj["AutomaticStartupActionDelay"] != null)) {
+                    return ToDateTime(((string)(curObj["AutomaticStartupActionDelay"])));
+                }
+                else {
+                    return System.DateTime.MinValue;
+                }
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsAutomaticStartupActionSequenceNumberNull {
+            get {
+                if ((curObj["AutomaticStartupActionSequenceNumber"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ushort AutomaticStartupActionSequenceNumber {
+            get {
+                if ((curObj["AutomaticStartupActionSequenceNumber"] == null)) {
+                    return System.Convert.ToUInt16(0);
+                }
+                return ((ushort)(curObj["AutomaticStartupActionSequenceNumber"]));
+            }
+        }
+        
+        [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(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ConfigurationDataRoot {
+            get {
+                return ((string)(curObj["ConfigurationDataRoot"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ConfigurationFile {
+            get {
+                return ((string)(curObj["ConfigurationFile"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string ConfigurationID {
+            get {
+                return ((string)(curObj["ConfigurationID"]));
+            }
+        }
+        
+        [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(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsIncrementalBackupEnabledNull {
+            get {
+                if ((curObj["IncrementalBackupEnabled"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Indicates whether the Hyper-V VSS writer supports taking incremental backup of th" +
+            "is Virtual machine.\nThis is a read-write property.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool IncrementalBackupEnabled {
+            get {
+                if ((curObj["IncrementalBackupEnabled"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["IncrementalBackupEnabled"]));
+            }
+            set {
+                curObj["IncrementalBackupEnabled"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string InstanceID {
+            get {
+                return ((string)(curObj["InstanceID"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsIsSavedNull {
+            get {
+                if ((curObj["IsSaved"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"This property is set to TRUE if the configuration has a reference to a saved state file, FALSE if not. Note that this does not indicate the presence of such a file, only that the configuration specifies one.
+This is a read-only property, it cannot be changed.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool IsSaved {
+            get {
+                if ((curObj["IsSaved"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["IsSaved"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string LogDataRoot {
+            get {
+                return ((string)(curObj["LogDataRoot"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string[] Notes {
+            get {
+                return ((string[])(curObj["Notes"]));
+            }
+        }
+        
+        [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(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string RecoveryFile {
+            get {
+                return ((string)(curObj["RecoveryFile"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SnapshotDataRoot {
+            get {
+                return ((string)(curObj["SnapshotDataRoot"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SuspendDataRoot {
+            get {
+                return ((string)(curObj["SuspendDataRoot"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string SwapFileDataRoot {
+            get {
+                return ((string)(curObj["SwapFileDataRoot"]));
+            }
+        }
+        
+        [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 IsVirtualNumaEnabledNull {
+            get {
+                if ((curObj["VirtualNumaEnabled"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Indicates whether virtual non-uniform memory access (NUMA) nodes are projected into the virtual machine. If FALSE, the virtual machine will have a single node. If TRUE, the number of virtual NUMA nodes projected into the virtual machine is determined from the values of the Msvm_ProcessorSettingData.MaxProcessorsPerNumaNode and Msvm_MemorySettingData.MaxMemoryBlocksPerNumaNode properties.
+")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public bool VirtualNumaEnabled {
+            get {
+                if ((curObj["VirtualNumaEnabled"] == null)) {
+                    return System.Convert.ToBoolean(0);
+                }
+                return ((bool)(curObj["VirtualNumaEnabled"]));
+            }
+            set {
+                curObj["VirtualNumaEnabled"] = value;
+                if (((isEmbedded == false) 
+                            && (AutoCommitProp == true))) {
+                    PrivateLateBoundObject.Put();
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The name of the CIM_ComputerSystem to which this setting data belongs")]
+        public string VirtualSystemIdentifier {
+            get {
+                return ((string)(curObj["VirtualSystemIdentifier"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public string VirtualSystemType {
+            get {
+                return ((string)(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 ShouldSerializeAllowReducedFcRedundancy() {
+            if ((this.IsAllowReducedFcRedundancyNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetAllowReducedFcRedundancy() {
+            curObj["AllowReducedFcRedundancy"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeAutomaticRecoveryAction() {
+            if ((this.IsAutomaticRecoveryActionNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticShutdownAction() {
+            if ((this.IsAutomaticShutdownActionNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticStartupAction() {
+            if ((this.IsAutomaticStartupActionNull == 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 ShouldSerializeAutomaticStartupActionDelay() {
+            if ((this.IsAutomaticStartupActionDelayNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeAutomaticStartupActionSequenceNumber() {
+            if ((this.IsAutomaticStartupActionSequenceNumberNull == 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();
+            }
+        }
+        
+        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 bool ShouldSerializeIncrementalBackupEnabled() {
+            if ((this.IsIncrementalBackupEnabledNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetIncrementalBackupEnabled() {
+            curObj["IncrementalBackupEnabled"] = null;
+            if (((isEmbedded == false) 
+                        && (AutoCommitProp == true))) {
+                PrivateLateBoundObject.Put();
+            }
+        }
+        
+        private bool ShouldSerializeIsSaved() {
+            if ((this.IsIsSavedNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeVirtualNumaEnabled() {
+            if ((this.IsVirtualNumaEnabledNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private void ResetVirtualNumaEnabled() {
+            curObj["VirtualNumaEnabled"] = 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_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\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_VirtualSystemSettingData";
+            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 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\\v2";
+                }
+                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();
+        }
+        
+        public enum DebugPortEnabledValues {
+            
+            Val__Off = 0,
+            
+            On = 1,
+            
+            OnAutoAssigned = 2,
+            
+            NULL_ENUM_VALUE = 3,
+        }
+        
+        // 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"]));
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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 57fe6f3..d3baab4 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
@@ -131,6 +131,27 @@
     <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_VirtualSystemSettingData.cs">
+      <SubType>Component</SubType>
+    </Compile>
   </ItemGroup>
   <ItemGroup>
     <Content Include="Readme.txt" />


[29/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..afceced
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -0,0 +1,1399 @@
+// 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;
+    }
+
+    /// <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;
+        }
+
+        public static HypervResourceControllerConfig config = new HypervResourceControllerConfig();
+
+        private static ILog logger = LogManager.GetLogger(typeof(WmiCalls));
+
+        public static void Initialize()
+        {
+        }
+
+        // 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());
+
+                object ansContent = new
+                {
+                    result = true,
+                    details = "success - NOP",
+                    _reconnect = false
+                };
+
+                return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.SetupAnswer);
+            }
+        }
+
+
+        // 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);
+                    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/StartCommand
+        [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);
+                    }
+
+                    // 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 = newData
+                };
+                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;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Properties/AssemblyInfo.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..8ea504f
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HypervResource")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HypervResource")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f1eb80c1-36fb-438c-a70d-0de5d5e295fb")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..c24a1ae
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Utils.cs
@@ -0,0 +1,110 @@
+// 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 log4net;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Security.Principal;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HypervResource
+{
+    public class Utils
+    {
+        private static ILog s_logger = LogManager.GetLogger(typeof(Utils));
+
+        /// <summary>
+        /// Associate CloudStack object's content with a fully qualified type name.
+        /// </summary>
+        /// <param name="objType">Fully qualified type name, e.g. "org.apache.cloudstack.storage.to.TemplateObjectTO"</param>
+        /// <param name="objValue">Object's data, can be an anonymous object, e.g. </param>
+        /// <returns></returns>
+        public static JObject CreateCloudStackObject(string objType, object objValue)
+        {
+            JToken objContent = JToken.FromObject(objValue);
+            JProperty objTypeValuePairing = new JProperty(objType, objContent);
+
+            return new JObject(objTypeValuePairing);
+        }
+
+
+        /// <summary>
+        /// Copy file on network share to local volume.
+        /// </summary>
+        /// <remarks>
+        /// Access to the network share is acheived by logging into the domain corresponding to the user credentials provided.
+        /// Windows impersonation does not suffice, because impersonation is limited to domains with an established trust relationship.
+        /// We have had to import Win32 API calls to allow login.  There are a number of examples online.  We follow the
+        /// one at http://stackoverflow.com/a/2541569/939250 </remarks>
+        /// <param name="filePathRelativeToShare"></param>
+        /// <param name="cifsShareDetails"></param>
+        /// <param name="destFile"></param>
+        public static void DownloadCifsFileToLocalFile(string filePathRelativeToShare, NFSTO cifsShareDetails, string destFile)
+        {
+            try
+            {
+                IntPtr token = IntPtr.Zero;
+
+                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);
+                    s_logger.Info(CloudStackTypes.CopyCommand + ": copy " + Path.Combine(cifsShareDetails.UncPath, filePathRelativeToShare) + " to " + destFile);
+
+                    File.Copy(dest, destFile, true);
+                    remoteIdentity.Undo();
+                }
+            }
+            catch (UnauthorizedAccessException ex)
+            {
+                string errMsg = "Invalid user or password for the share " + cifsShareDetails.UncPath;
+                s_logger.Error(errMsg);
+
+                throw new ArgumentException(errMsg, ex);
+            }
+        }
+
+        // from http://stackoverflow.com/a/2541569/939250
+        #region imports
+        [DllImport("advapi32.dll", SetLastError = true)]
+        private static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
+
+        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+        private static extern bool CloseHandle(IntPtr handle);
+
+        [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+        public extern static bool DuplicateToken(IntPtr existingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr duplicateTokenHandle);
+        #endregion
+
+        #region logon consts
+        // logon types 
+        const int LOGON32_LOGON_INTERACTIVE = 2;
+        const int LOGON32_LOGON_NETWORK = 3;
+        const int LOGON32_LOGON_NEW_CREDENTIALS = 9;
+
+        // logon providers 
+        const int LOGON32_PROVIDER_DEFAULT = 0;
+        const int LOGON32_PROVIDER_WINNT50 = 3;
+        const int LOGON32_PROVIDER_WINNT40 = 2;
+        const int LOGON32_PROVIDER_WINNT35 = 1;
+        #endregion
+    }
+}


[43/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Implementation for attach iso command. Attaches an iso to a given vm.


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

Branch: refs/heads/hyperv
Commit: f1c2c502eccfea040538b67c2633685c0395b6f8
Parents: 3a5c7f1
Author: Devdeep Singh <de...@gmail.com>
Authored: Fri Oct 11 15:12:18 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Oct 11 15:12:18 2013 +0530

----------------------------------------------------------------------
 .../HypervResource/HypervResourceController.cs  | 70 +++++++++++++++++-
 .../ServerResource/HypervResource/WmiCalls.cs   | 78 ++++++++++++++++++++
 2 files changed, 147 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1c2c502/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 cce40e1..7a0c2db 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs
@@ -151,6 +151,74 @@ namespace HypervResource
             }
         }
 
+        // 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]
@@ -1078,7 +1146,7 @@ namespace HypervResource
                 {
                     result = result,
                     details = details,
-                    newData = newData
+                    newData = cmd.destTO 
                 };
                 return ReturnCloudStackTypedJArray(ansContent, CloudStackTypes.CopyCmdAnswer);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f1c2c502/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 ad43d1f..9b00c82 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -400,6 +400,48 @@ namespace HypervResource
             return newDrivePaths[0];
         }
 
+        /// <summary>
+        /// Attach iso to the vm
+        /// </summary>
+        /// <param name="vm"></param>
+        /// <param name="isoPath"></param>
+        private static 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 static 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
@@ -451,6 +493,22 @@ namespace HypervResource
             return new ResourceAllocationSettingData((ManagementBaseObject)defaultDiskDriveSettings.LateBoundObject.Clone());
         }
 
+        public static 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 static void DestroyVm(dynamic jsonObj)
         {
             string vmToDestroy = jsonObj.vmName;
@@ -1073,6 +1131,26 @@ namespace HypervResource
             throw ex;
         }
 
+        public static 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 static ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr)
         {
             var wmiObjCollection = GetResourceAllocationSettings(vmSettings);


[46/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Modified hyperv agent code, to deploy VR with Boot Args, boot args passed to VR using KVP Exchange Component.


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

Branch: refs/heads/hyperv
Commit: c15a295e91bf4335a111d6fabe793a54ab45fe0d
Parents: 16422cb
Author: Rajesh Battala <ra...@citrix.com>
Authored: Fri Oct 11 17:26:15 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Oct 11 17:26:15 2013 +0530

----------------------------------------------------------------------
 .../ServerResource/HypervResource/WmiCalls.cs   | 88 ++++++++++++++++----
 1 file changed, 73 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c15a295e/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 9b00c82..0fbb00b 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -167,6 +167,7 @@ namespace HypervResource
             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";
@@ -283,34 +284,91 @@ namespace HypervResource
                 AddDiskDriveToVm(newVm, vhdFile, ideCtrllr, driveResourceType);
             }
 
-            // add nics
-            foreach (var nic in nicInfo)
+            // Add the Nics to the VM in the deviceId order.
+            for (int i = 0; i <= 2; i++)
             {
-                string mac = nic.mac;
-                string vlan = null;
-                string isolationUri = nic.isolationUri;
-                if (isolationUri != null && isolationUri.StartsWith("vlan://") && !isolationUri.Equals("vlan://untagged"))
+                foreach (var nic in nicInfo)
                 {
-                    vlan = isolationUri.Substring("vlan://".Length);
-                    int tmp;
-                    if (!int.TryParse(vlan, out tmp))
+
+                    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"))
                     {
-                        // 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;
+                        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)
+                    {
+                        CreateNICforVm(newVm, mac, vlan);
+                        break;
                     }
                 }
-                CreateNICforVm(newVm, mac, 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 = 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;
+
+            }
+            // call patch systemvm iso only for systemvms
+            if (vmName.StartsWith("r-"))
+            {
+                patchSystemVmIso(vmName);
             }
 
             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(8000);
+                SetState(newVm, RequiredState.Reboot);
+            }
             logger.InfoFormat("Started VM {0}", vmName);
             return newVm;
        }
 
+        /// this method is to add a dvd drive and attach the systemvm iso.
+        /// 
+
+        public static void patchSystemVmIso(String vmName)
+        {
+            ComputerSystem vmObject = WmiCalls.GetComputerSystem(vmName);
+            AddDiskDriveToVm(vmObject, "", "1", IDE_ISO_DRIVE);
+            WmiCalls.AttachIso(vmName, "c:\\systemvm.iso");
+        }
+
         /// <summary>
         /// Create a disk and attach it to the vm
         /// </summary>


[47/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Fix for VR to boot up and get configured with boot args, Fixed issue in VolumeOrchestrator


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

Branch: refs/heads/hyperv
Commit: b24935f2f9f2a86c81e11079884fa34db7a24a1f
Parents: c15a295
Author: Rajesh Battala <ra...@citrix.com>
Authored: Sun Oct 13 09:10:14 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Sun Oct 13 09:10:14 2013 +0530

----------------------------------------------------------------------
 .../cloudstack/engine/orchestration/VolumeOrchestrator.java     | 5 ++++-
 .../hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs     | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b24935f2/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 7258e25..6453a1f 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -1167,8 +1167,11 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
     public void updateVolumeDiskChain(long volumeId, String path, String chainInfo) {
         VolumeVO vol = _volsDao.findById(volumeId);
         boolean needUpdate = false;
+        // Volume path is not getting updated in the DB, need to find reason and fix the issue.
+        if (vol.getPath() == null)
+            return;
         if(!vol.getPath().equalsIgnoreCase(path))
-        	needUpdate = true;
+            needUpdate = true;
         
         if(chainInfo != null && (vol.getChainInfo() == null || !chainInfo.equalsIgnoreCase(vol.getChainInfo())))
         	needUpdate = true;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b24935f2/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 0fbb00b..1b9e073 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -352,8 +352,10 @@ namespace HypervResource
             // we need to reboot to get the hv kvp daemon get started vr gets configured.
             if (vmName.StartsWith("r-"))
             {
-                System.Threading.Thread.Sleep(8000);
+                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;


[03/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/root.CIMV2.Win32_PerfFormattedData_Counters_ProcessorInformation.cs
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/root.CIMV2.Win32_PerfFormattedData_Counters_ProcessorInformation.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/root.CIMV2.Win32_PerfFormattedData_Counters_ProcessorInformation.cs
new file mode 100644
index 0000000..a1fb5f1
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/root.CIMV2.Win32_PerfFormattedData_Counters_ProcessorInformation.cs
@@ -0,0 +1,1737 @@
+namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 {
+    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.Win32_PerfFormattedData_Counters_ProcessorInformation
+    public class PerfFormattedData_Counters_ProcessorInformation : System.ComponentModel.Component {
+        
+        // Private property to hold the WMI namespace in which the class resides.
+        private static string CreatedWmiNamespace = "root\\CIMV2";
+        
+        // Private property to hold the name of WMI class which created this class.
+        private static string CreatedClassName = "Win32_PerfFormattedData_Counters_ProcessorInformation";
+        
+        // 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 PerfFormattedData_Counters_ProcessorInformation() {
+            this.InitializeObject(null, null, null);
+        }
+        
+        public PerfFormattedData_Counters_ProcessorInformation(string keyName) {
+            this.InitializeObject(null, new System.Management.ManagementPath(PerfFormattedData_Counters_ProcessorInformation.ConstructPath(keyName)), null);
+        }
+        
+        public PerfFormattedData_Counters_ProcessorInformation(System.Management.ManagementScope mgmtScope, string keyName) {
+            this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(PerfFormattedData_Counters_ProcessorInformation.ConstructPath(keyName)), null);
+        }
+        
+        public PerfFormattedData_Counters_ProcessorInformation(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(null, path, getOptions);
+        }
+        
+        public PerfFormattedData_Counters_ProcessorInformation(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) {
+            this.InitializeObject(mgmtScope, path, null);
+        }
+        
+        public PerfFormattedData_Counters_ProcessorInformation(System.Management.ManagementPath path) {
+            this.InitializeObject(null, path, null);
+        }
+        
+        public PerfFormattedData_Counters_ProcessorInformation(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) {
+            this.InitializeObject(mgmtScope, path, getOptions);
+        }
+        
+        public PerfFormattedData_Counters_ProcessorInformation(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 PerfFormattedData_Counters_ProcessorInformation(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\\CIMV2";
+            }
+        }
+        
+        [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 IsAverageIdleTimeNull {
+            get {
+                if ((curObj["AverageIdleTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Average Idle Time is the average idle duration in 100ns units observed between th" +
+            "e last two samples.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong AverageIdleTime {
+            get {
+                if ((curObj["AverageIdleTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["AverageIdleTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsC1TransitionsPersecNull {
+            get {
+                if ((curObj["C1TransitionsPersec"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"C1 Transitions/sec is the rate that the CPU enters the C1 low-power idle state. The CPU enters the C1 state when it is sufficiently idle and exits this state on any interrupt. This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong C1TransitionsPersec {
+            get {
+                if ((curObj["C1TransitionsPersec"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["C1TransitionsPersec"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsC2TransitionsPersecNull {
+            get {
+                if ((curObj["C2TransitionsPersec"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"C2 Transitions/sec is the rate that the CPU enters the C2 low-power idle state. The CPU enters the C2 state when it is sufficiently idle and exits this state on any interrupt. This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong C2TransitionsPersec {
+            get {
+                if ((curObj["C2TransitionsPersec"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["C2TransitionsPersec"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsC3TransitionsPersecNull {
+            get {
+                if ((curObj["C3TransitionsPersec"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"C3 Transitions/sec is the rate that the CPU enters the C3 low-power idle state. The CPU enters the C3 state when it is sufficiently idle and exits this state on any interrupt. This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong C3TransitionsPersec {
+            get {
+                if ((curObj["C3TransitionsPersec"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["C3TransitionsPersec"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("A short textual description (one-line string) for the statistic or metric.")]
+        public string Caption {
+            get {
+                return ((string)(curObj["Caption"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsClockInterruptsPersecNull {
+            get {
+                if ((curObj["ClockInterruptsPersec"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Clock Interrupts/sec is the average rate, in incidents per second, at which the processor received and serviced clock tick interrupts. This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint ClockInterruptsPersec {
+            get {
+                if ((curObj["ClockInterruptsPersec"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["ClockInterruptsPersec"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("A textual description of the statistic or metric.")]
+        public string Description {
+            get {
+                return ((string)(curObj["Description"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDPCRateNull {
+            get {
+                if ((curObj["DPCRate"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"DPC Rate is the rate at which deferred procedure calls (DPCs) were added to the processors DPC queues between the timer ticks of the processor clock. DPCs are interrupts that run at alower priority than standard interrupts.  Each processor has its own DPC queue. This counter measures the rate that DPCs were added to the queue, not the number of DPCs in the queue. This counter displays the last observed value only; it is not an average.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint DPCRate {
+            get {
+                if ((curObj["DPCRate"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["DPCRate"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsDPCsQueuedPersecNull {
+            get {
+                if ((curObj["DPCsQueuedPersec"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"DPCs Queued/sec is the average rate, in incidents per second, at which deferred procedure calls (DPCs) were added to the processor's DPC queue. DPCs are interrupts that run at a lower priority than standard interrupts.  Each processor has its own DPC queue. This counter measures the rate that DPCs are added to the queue, not the number of DPCs in the queue.  This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint DPCsQueuedPersec {
+            get {
+                if ((curObj["DPCsQueuedPersec"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["DPCsQueuedPersec"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFrequency_ObjectNull {
+            get {
+                if ((curObj["Frequency_Object"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Frequency_Object {
+            get {
+                if ((curObj["Frequency_Object"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Frequency_Object"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFrequency_PerfTimeNull {
+            get {
+                if ((curObj["Frequency_PerfTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Frequency_PerfTime {
+            get {
+                if ((curObj["Frequency_PerfTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Frequency_PerfTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsFrequency_Sys100NSNull {
+            get {
+                if ((curObj["Frequency_Sys100NS"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Frequency_Sys100NS {
+            get {
+                if ((curObj["Frequency_Sys100NS"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Frequency_Sys100NS"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsIdleBreakEventsPersecNull {
+            get {
+                if ((curObj["IdleBreakEventsPersec"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Idle Break Events/sec is the average rate, in incidents per second, at which the " +
+            "processor wakes from idle.  This counter displays the difference between the val" +
+            "ues observed in the last two samples, divided by the duration of the sample inte" +
+            "rval.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong IdleBreakEventsPersec {
+            get {
+                if ((curObj["IdleBreakEventsPersec"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["IdleBreakEventsPersec"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsInterruptsPersecNull {
+            get {
+                if ((curObj["InterruptsPersec"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Interrupts/sec is the average rate, in incidents per second, at which the processor received and serviced hardware interrupts. It does not include deferred procedure calls (DPCs), which are counted separately. This value is an indirect indicator of the activity of devices that generate interrupts, such as the system clock, the mouse, disk drivers, data communication lines, network interface cards, and other peripheral devices. These devices normally interrupt the processor when they have completed a task or require attention. Normal thread execution is suspended. The system clock typically interrupts the processor every 10 milliseconds, creating a background of interrupt activity. This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint InterruptsPersec {
+            get {
+                if ((curObj["InterruptsPersec"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["InterruptsPersec"]));
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("The Name property defines the label by which the statistic or metric is known. Wh" +
+            "en subclassed, the property can be overridden to be a Key property. ")]
+        public string Name {
+            get {
+                return ((string)(curObj["Name"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsParkingStatusNull {
+            get {
+                if ((curObj["ParkingStatus"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Parking Status represents whether a processor is parked or not.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint ParkingStatus {
+            get {
+                if ((curObj["ParkingStatus"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["ParkingStatus"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentC1TimeNull {
+            get {
+                if ((curObj["PercentC1Time"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% C1 Time is the percentage of time the processor spends in the C1 low-power idle state. % C1 Time is a subset of the total processor idle time. C1 low-power idle state enables the processor to maintain its entire context and quickly return to the running state. Not all systems support the % C1 state.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentC1Time {
+            get {
+                if ((curObj["PercentC1Time"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentC1Time"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentC2TimeNull {
+            get {
+                if ((curObj["PercentC2Time"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% C2 Time is the percentage of time the processor spends in the C2 low-power idle state. % C2 Time is a subset of the total processor idle time. C2 low-power idle state enables the processor to maintain the context of the system caches. The C2 power state is a lower power and higher exit latency state than C1. Not all systems support the C2 state.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentC2Time {
+            get {
+                if ((curObj["PercentC2Time"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentC2Time"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentC3TimeNull {
+            get {
+                if ((curObj["PercentC3Time"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% C3 Time is the percentage of time the processor spends in the C3 low-power idle state. % C3 Time is a subset of the total processor idle time. When the processor is in the C3 low-power idle state it is unable to maintain the coherency of its caches. The C3 power state is a lower power and higher exit latency state than C2. Not all systems support the C3 state.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentC3Time {
+            get {
+                if ((curObj["PercentC3Time"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentC3Time"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentDPCTimeNull {
+            get {
+                if ((curObj["PercentDPCTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% DPC Time is the percentage of time that the processor spent receiving and servicing deferred procedure calls (DPCs) during the sample interval. DPCs are interrupts that run at a lower priority than standard interrupts. % DPC Time is a component of % Privileged Time because DPCs are executed in privileged mode. They are counted separately and are not a component of the interrupt counters. This counter displays the average busy time as a percentage of the sample time.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentDPCTime {
+            get {
+                if ((curObj["PercentDPCTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentDPCTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentIdleTimeNull {
+            get {
+                if ((curObj["PercentIdleTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("% Idle Time is the percentage of time the processor is idle during the sample int" +
+            "erval")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentIdleTime {
+            get {
+                if ((curObj["PercentIdleTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentIdleTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentInterruptTimeNull {
+            get {
+                if ((curObj["PercentInterruptTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% Interrupt Time is the time the processor spends receiving and servicing hardware interrupts during sample intervals. This value is an indirect indicator of the activity of devices that generate interrupts, such as the system clock, the mouse, disk drivers, data communication lines, network interface cards and other peripheral devices. These devices normally interrupt the processor when they have completed a task or require attention. Normal thread execution is suspended during interrupts. Most system clocks interrupt the processor every 10 milliseconds, creating a background of interrupt activity. suspends normal thread execution during interrupts. This counter displays the average busy time as a percentage of the sample time.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentInterruptTime {
+            get {
+                if ((curObj["PercentInterruptTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentInterruptTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentofMaximumFrequencyNull {
+            get {
+                if ((curObj["PercentofMaximumFrequency"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("% of Maximum Frequency is the percentage of the current processor\'s maximum frequ" +
+            "ency.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint PercentofMaximumFrequency {
+            get {
+                if ((curObj["PercentofMaximumFrequency"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["PercentofMaximumFrequency"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentPerformanceLimitNull {
+            get {
+                if ((curObj["PercentPerformanceLimit"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% Performance Limit is the performance the processor guarantees it can provide, as a percentage of the nominal performance of the processor. Performance can be limited by Windows power policy, or by the platform as a result of a power budget, overheating, or other hardware issues.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint PercentPerformanceLimit {
+            get {
+                if ((curObj["PercentPerformanceLimit"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["PercentPerformanceLimit"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentPriorityTimeNull {
+            get {
+                if ((curObj["PercentPriorityTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% Priority Time is the percentage of elapsed time that the processor spends executing threads that are not low priority. It is calculated by measuring the percentage of time that the processor spends executing low priority threads or the idle thread and then subtracting that value from 100%. (Each processor has an idle thread to which time is accumulated when no other threads are ready to run). This counter displays the average percentage of busy time observed during the sample interval excluding low priority background work. It should be noted that the accounting calculation of whether the processor is idle is performed at an internal sampling interval of the system clock tick. % Priority Time can therefore underestimate the processor utilization as the processor may be spending a lot of time servicing threads between the system clock sampling interval. Workload based timer applications are one example  of applications  which are more likely to be measured in
 accurately as timers are signaled just after the sample is taken.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentPriorityTime {
+            get {
+                if ((curObj["PercentPriorityTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentPriorityTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentPrivilegedTimeNull {
+            get {
+                if ((curObj["PercentPrivilegedTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% Privileged Time is the percentage of elapsed time that the process threads spent executing code in privileged mode.  When a Windows system service in called, the service will often run in privileged mode to gain access to system-private data. Such data is protected from access by threads executing in user mode. Calls to the system can be explicit or implicit, such as page faults or interrupts. Unlike some early operating systems, Windows uses process boundaries for subsystem protection in addition to the traditional protection of user and privileged modes. Some work done by Windows on behalf of the application might appear in other subsystem processes in addition to the privileged time in the process.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentPrivilegedTime {
+            get {
+                if ((curObj["PercentPrivilegedTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentPrivilegedTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentPrivilegedUtilityNull {
+            get {
+                if ((curObj["PercentPrivilegedUtility"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"Privileged Utility is the amount of work a processor is completing while executing in privileged mode, as a percentage of the amount of work the processor could complete if it were running at its nominal performance and never idle. On some processors, Privileged Utility may exceed 100%.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentPrivilegedUtility {
+            get {
+                if ((curObj["PercentPrivilegedUtility"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentPrivilegedUtility"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentProcessorPerformanceNull {
+            get {
+                if ((curObj["PercentProcessorPerformance"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Processor Performance is the average performance of the processor while it is exe" +
+            "cuting instructions, as a percentage of the nominal performance of the processor" +
+            ". On some processors, Processor Performance may exceed 100%.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentProcessorPerformance {
+            get {
+                if ((curObj["PercentProcessorPerformance"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentProcessorPerformance"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentProcessorTimeNull {
+            get {
+                if ((curObj["PercentProcessorTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% Processor Time is the percentage of elapsed time that the processor spends to execute a non-Idle thread. It is calculated by measuring the percentage of time that the processor spends executing the idle thread and then subtracting that value from 100%. (Each processor has an idle thread to which time is accumulated when no other threads are ready to run). This counter is the primary indicator of processor activity, and displays the average percentage of busy time observed during the sample interval. It should be noted that the accounting calculation of whether the processor is idle is performed at an internal sampling interval of the system clock tick. On todays fast processors, % Processor Time can therefore underestimate the processor utilization as the processor may be spending a lot of time servicing threads between the system clock sampling interval. Workload based timer applications are one example  of applications  which are more likely to be measured
  inaccurately as timers are signaled just after the sample is taken.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentProcessorTime {
+            get {
+                if ((curObj["PercentProcessorTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentProcessorTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentProcessorUtilityNull {
+            get {
+                if ((curObj["PercentProcessorUtility"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Processor Utility is the amount of work a processor is completing, as a percentag" +
+            "e of the amount of work the processor could complete if it were running at its n" +
+            "ominal performance and never idle. On some processors, Processor Utility may exc" +
+            "eed 100%.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentProcessorUtility {
+            get {
+                if ((curObj["PercentProcessorUtility"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentProcessorUtility"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPercentUserTimeNull {
+            get {
+                if ((curObj["PercentUserTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description(@"% User Time is the percentage of elapsed time the processor spends in the user mode. User mode is a restricted processing mode designed for applications, environment subsystems, and integral subsystems.  The alternative, privileged mode, is designed for operating system components and allows direct access to hardware and all memory.  The operating system switches application threads to privileged mode to access operating system services. This counter displays the average busy time as a percentage of the sample time.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong PercentUserTime {
+            get {
+                if ((curObj["PercentUserTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["PercentUserTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsPerformanceLimitFlagsNull {
+            get {
+                if ((curObj["PerformanceLimitFlags"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Performance Limit Flags indicate reasons why the processor performance was limite" +
+            "d.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint PerformanceLimitFlags {
+            get {
+                if ((curObj["PerformanceLimitFlags"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["PerformanceLimitFlags"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsProcessorFrequencyNull {
+            get {
+                if ((curObj["ProcessorFrequency"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Processor Frequency is the frequency of the current processor in megahertz.")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint ProcessorFrequency {
+            get {
+                if ((curObj["ProcessorFrequency"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["ProcessorFrequency"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsProcessorStateFlagsNull {
+            get {
+                if ((curObj["ProcessorStateFlags"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [Description("Processor State Flags")]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public uint ProcessorStateFlags {
+            get {
+                if ((curObj["ProcessorStateFlags"] == null)) {
+                    return System.Convert.ToUInt32(0);
+                }
+                return ((uint)(curObj["ProcessorStateFlags"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimestamp_ObjectNull {
+            get {
+                if ((curObj["Timestamp_Object"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Timestamp_Object {
+            get {
+                if ((curObj["Timestamp_Object"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Timestamp_Object"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimestamp_PerfTimeNull {
+            get {
+                if ((curObj["Timestamp_PerfTime"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Timestamp_PerfTime {
+            get {
+                if ((curObj["Timestamp_PerfTime"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Timestamp_PerfTime"]));
+            }
+        }
+        
+        [Browsable(false)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        public bool IsTimestamp_Sys100NSNull {
+            get {
+                if ((curObj["Timestamp_Sys100NS"] == null)) {
+                    return true;
+                }
+                else {
+                    return false;
+                }
+            }
+        }
+        
+        [Browsable(true)]
+        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+        [TypeConverter(typeof(WMIValueTypeConverter))]
+        public ulong Timestamp_Sys100NS {
+            get {
+                if ((curObj["Timestamp_Sys100NS"] == null)) {
+                    return System.Convert.ToUInt64(0);
+                }
+                return ((ulong)(curObj["Timestamp_Sys100NS"]));
+            }
+        }
+        
+        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 ShouldSerializeAverageIdleTime() {
+            if ((this.IsAverageIdleTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeC1TransitionsPersec() {
+            if ((this.IsC1TransitionsPersecNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeC2TransitionsPersec() {
+            if ((this.IsC2TransitionsPersecNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeC3TransitionsPersec() {
+            if ((this.IsC3TransitionsPersecNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeClockInterruptsPersec() {
+            if ((this.IsClockInterruptsPersecNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDPCRate() {
+            if ((this.IsDPCRateNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeDPCsQueuedPersec() {
+            if ((this.IsDPCsQueuedPersecNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeFrequency_Object() {
+            if ((this.IsFrequency_ObjectNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeFrequency_PerfTime() {
+            if ((this.IsFrequency_PerfTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeFrequency_Sys100NS() {
+            if ((this.IsFrequency_Sys100NSNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeIdleBreakEventsPersec() {
+            if ((this.IsIdleBreakEventsPersecNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeInterruptsPersec() {
+            if ((this.IsInterruptsPersecNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeParkingStatus() {
+            if ((this.IsParkingStatusNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentC1Time() {
+            if ((this.IsPercentC1TimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentC2Time() {
+            if ((this.IsPercentC2TimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentC3Time() {
+            if ((this.IsPercentC3TimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentDPCTime() {
+            if ((this.IsPercentDPCTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentIdleTime() {
+            if ((this.IsPercentIdleTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentInterruptTime() {
+            if ((this.IsPercentInterruptTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentofMaximumFrequency() {
+            if ((this.IsPercentofMaximumFrequencyNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentPerformanceLimit() {
+            if ((this.IsPercentPerformanceLimitNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentPriorityTime() {
+            if ((this.IsPercentPriorityTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentPrivilegedTime() {
+            if ((this.IsPercentPrivilegedTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentPrivilegedUtility() {
+            if ((this.IsPercentPrivilegedUtilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentProcessorPerformance() {
+            if ((this.IsPercentProcessorPerformanceNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentProcessorTime() {
+            if ((this.IsPercentProcessorTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentProcessorUtility() {
+            if ((this.IsPercentProcessorUtilityNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePercentUserTime() {
+            if ((this.IsPercentUserTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializePerformanceLimitFlags() {
+            if ((this.IsPerformanceLimitFlagsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeProcessorFrequency() {
+            if ((this.IsProcessorFrequencyNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeProcessorStateFlags() {
+            if ((this.IsProcessorStateFlagsNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimestamp_Object() {
+            if ((this.IsTimestamp_ObjectNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimestamp_PerfTime() {
+            if ((this.IsTimestamp_PerfTimeNull == false)) {
+                return true;
+            }
+            return false;
+        }
+        
+        private bool ShouldSerializeTimestamp_Sys100NS() {
+            if ((this.IsTimestamp_Sys100NSNull == 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 keyName) {
+            string strPath = "root\\CIMV2:Win32_PerfFormattedData_Counters_ProcessorInformation";
+            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 PerfFormattedData_Counters_ProcessorInformationCollection GetInstances() {
+            return GetInstances(null, null, null);
+        }
+        
+        public static PerfFormattedData_Counters_ProcessorInformationCollection GetInstances(string condition) {
+            return GetInstances(null, condition, null);
+        }
+        
+        public static PerfFormattedData_Counters_ProcessorInformationCollection GetInstances(string[] selectedProperties) {
+            return GetInstances(null, null, selectedProperties);
+        }
+        
+        public static PerfFormattedData_Counters_ProcessorInformationCollection GetInstances(string condition, string[] selectedProperties) {
+            return GetInstances(null, condition, selectedProperties);
+        }
+        
+        public static PerfFormattedData_Counters_ProcessorInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\CIMV2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Win32_PerfFormattedData_Counters_ProcessorInformation";
+            pathObj.NamespacePath = "root\\CIMV2";
+            System.Management.ManagementClass clsObject = new System.Management.ManagementClass(mgmtScope, pathObj, null);
+            if ((enumOptions == null)) {
+                enumOptions = new System.Management.EnumerationOptions();
+                enumOptions.EnsureLocatable = true;
+            }
+            return new PerfFormattedData_Counters_ProcessorInformationCollection(clsObject.GetInstances(enumOptions));
+        }
+        
+        public static PerfFormattedData_Counters_ProcessorInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) {
+            return GetInstances(mgmtScope, condition, null);
+        }
+        
+        public static PerfFormattedData_Counters_ProcessorInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) {
+            return GetInstances(mgmtScope, null, selectedProperties);
+        }
+        
+        public static PerfFormattedData_Counters_ProcessorInformationCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) {
+            if ((mgmtScope == null)) {
+                if ((statMgmtScope == null)) {
+                    mgmtScope = new System.Management.ManagementScope();
+                    mgmtScope.Path.NamespacePath = "root\\CIMV2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementObjectSearcher ObjectSearcher = new System.Management.ManagementObjectSearcher(mgmtScope, new SelectQuery("Win32_PerfFormattedData_Counters_ProcessorInformation", condition, selectedProperties));
+            System.Management.EnumerationOptions enumOptions = new System.Management.EnumerationOptions();
+            enumOptions.EnsureLocatable = true;
+            ObjectSearcher.Options = enumOptions;
+            return new PerfFormattedData_Counters_ProcessorInformationCollection(ObjectSearcher.Get());
+        }
+        
+        [Browsable(true)]
+        public static PerfFormattedData_Counters_ProcessorInformation 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 PerfFormattedData_Counters_ProcessorInformation(tmpMgmtClass.CreateInstance());
+        }
+        
+        [Browsable(true)]
+        public void Delete() {
+            PrivateLateBoundObject.Delete();
+        }
+        
+        // Enumerator implementation for enumerating instances of the class.
+        public class PerfFormattedData_Counters_ProcessorInformationCollection : object, ICollection {
+            
+            private ManagementObjectCollection privColObj;
+            
+            public PerfFormattedData_Counters_ProcessorInformationCollection(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 PerfFormattedData_Counters_ProcessorInformation(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr);
+                }
+            }
+            
+            public virtual System.Collections.IEnumerator GetEnumerator() {
+                return new PerfFormattedData_Counters_ProcessorInformationEnumerator(privColObj.GetEnumerator());
+            }
+            
+            public class PerfFormattedData_Counters_ProcessorInformationEnumerator : object, System.Collections.IEnumerator {
+                
+                private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum;
+                
+                public PerfFormattedData_Counters_ProcessorInformationEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) {
+                    privObjEnum = objEnum;
+                }
+                
+                public virtual object Current {
+                    get {
+                        return new PerfFormattedData_Counters_ProcessorInformation(((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/1d0a931d/plugins/hypervisors/hyperv/buildagent.sh
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/buildagent.sh b/plugins/hypervisors/hyperv/buildagent.sh
new file mode 100644
index 0000000..f2a4921
--- /dev/null
+++ b/plugins/hypervisors/hyperv/buildagent.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#  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.
+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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/conf/agent.properties
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/conf/agent.properties b/plugins/hypervisors/hyperv/conf/agent.properties
new file mode 100644
index 0000000..4e61451
--- /dev/null
+++ b/plugins/hypervisors/hyperv/conf/agent.properties
@@ -0,0 +1,35 @@
+#Storage
+#Tue Feb 12 10:08:17 GMT 2013
+local.storage.path=E\:\\Disks\\Disks
+cpus=8
+resource=com.cloud.hypervisor.hyperv.resource.HypervResource
+type=Routing
+ipaddress=10.70.176.29
+private.mac.address=101F742C6B88
+# If localhost is used, mac address is blank.
+#private.ip.address=127.0.0.1
+#private.mac.address=
+local.storage.uuid=5fe2bad3-d785-394e-9949-89786b8a63d2
+capabilities=hvm
+cpuspeed=2130
+port=8250
+hyperv.python.module.script=cloudstackcmds.py
+memory=34359738368
+host=camldonall01.citrite.net
+pod=1
+gateway.ip.address=10.70.176.1
+guid=16f85622-4508-415e-b13a-49a39bb14e4d
+#guid=generate_from_private.ip.address
+cluster=2
+zone=1
+local.secondary.storage.path=c\:\\Secondary
+workers=5
+agent.executable=C\:\\cygwin\\home\\Administrator\\github\\cshv3\\plugins\\hypervisors\\hyperv\\DotNET\\ServerResource\\AgentShell\\bin\\Debug\\AgentShell.exe
+private.ip.netmask=255.255.240.0
+HypervResource.id=5
+hyperv.python.module.dir=C\:\\cygwin\\home\\Administrator\\github\\cshv3\\plugins\\hypervisors\\hyperv\\scripts\\hyperv\\
+DefaultVirtualDiskFolder=E\:\\Disks\\
+TestCoreCount=8
+TestCoreMhz=2133
+TestMemoryMb=34350288896
+TestDom0MinMemoryMb=2147483648

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/conf/developer.properties.template
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/conf/developer.properties.template b/plugins/hypervisors/hyperv/conf/developer.properties.template
new file mode 100644
index 0000000..a70a136
--- /dev/null
+++ b/plugins/hypervisors/hyperv/conf/developer.properties.template
@@ -0,0 +1,55 @@
+# 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.
+
+#instance=AH
+#private.macaddr.start=00:16:3e:77:01:01
+#private.ipaddr.start=192.168.166.128
+
+#instance=KM
+#private.macaddr.start=00:16:3e:77:02:01
+#private.ipaddr.start=192.168.167.128
+
+#instance=KY
+#private.macaddr.start=00:16:3e:77:03:01
+#private.ipaddr.start=192.168.168.128
+
+#instance=WC
+#private.macaddr.start=00:16:3e:77:04:01
+#private.ipaddr.start=192.168.169.128
+
+#instance=CV
+#private.macaddr.start=00:16:3e:77:05:01
+#private.ipaddr.start=192.168.170.128
+
+#instance=KS
+#private.macaddr.start=00:16:3e:77:06:01
+#private.ipaddr.start=192.168.171.128
+
+#instance=ES
+#private.macaddr.start=00:16:3e:77:07:01
+#private.ipaddr.start=192.168.172.128
+
+#instance=RC
+#private.macaddr.start=00:16:3e:77:08:01
+#private.ipaddr.start=192.168.173.128
+
+#instance=AX
+#private.macaddr.start=00:16:3e:77:09:01
+#private.ipaddr.start=192.168.174.128
+
+private.macaddr.start=@private.macaddr.start@
+private.ipaddr.start=@private.ipaddr.start@

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/conf/environment.properties.in
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/conf/environment.properties.in b/plugins/hypervisors/hyperv/conf/environment.properties.in
new file mode 100644
index 0000000..514161a
--- /dev/null
+++ b/plugins/hypervisors/hyperv/conf/environment.properties.in
@@ -0,0 +1,21 @@
+# 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.
+
+# management server compile-time environment parameters
+
+paths.pid=@PIDDIR@
+paths.script=@COMMONLIBDIR@

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/plugins/hypervisors/hyperv/conf/log4j-cloud.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/conf/log4j-cloud.xml b/plugins/hypervisors/hyperv/conf/log4j-cloud.xml
new file mode 100644
index 0000000..1e97ce9
--- /dev/null
+++ b/plugins/hypervisors/hyperv/conf/log4j-cloud.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+   <!-- ================================= -->
+   <!-- Preserve messages in a local file -->
+   <!-- ================================= -->
+
+   <!-- A time/date based rolling appender -->
+   <appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
+      <param name="Append" value="true"/>
+      <param name="Threshold" value="TRACE"/>
+      <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
+        <param name="FileNamePattern" value="log/@AGENTLOG@.%d{yyyy-MM-dd}.gz"/>
+        <param name="ActiveFileName" value="log/@AGENTLOG@"/>
+      </rollingPolicy>
+      <layout class="org.apache.log4j.EnhancedPatternLayout">
+         <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{3}] (%t:%x) %m%n"/>
+      </layout>
+   </appender>
+   
+   <!-- ============================== -->
+   <!-- Append messages to the console -->
+   <!-- ============================== -->
+
+   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <param name="Target" value="System.out"/>
+      <param name="Threshold" value="TRACE"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <param name="ConversionPattern" value="%d{ISO8601}{GMT} %-5p [%c{3}] (%t:%x) %m%n"/>
+      </layout>
+   </appender>
+
+   <!-- ================ -->
+   <!-- Limit categories -->
+   <!-- ================ -->
+
+   <category name="com.cloud">
+     <priority value="TRACE"/>
+   </category>
+   
+   <category name="com.cloud.agent.metrics">
+     <priority value="TRACE"/>
+   </category>
+   
+   <category name="com.cloud.agent.resource.computing.ComputingResource$StorageMonitorTask">
+     <priority value="TRACE"/>
+   </category>
+
+   <!-- Limit the org.apache category to TRACE as its DEBUG is verbose -->
+   <category name="org.apache">
+      <priority value="TRACE"/>
+   </category>
+
+   <category name="org">
+      <priority value="TRACE"/>
+   </category>
+   
+   <category name="net">
+     <priority value="TRACE"/>
+   </category>
+
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+      <level value="TRACE"/>
+      <appender-ref ref="CONSOLE"/>
+      <appender-ref ref="FILE"/>
+   </root>
+
+</log4j:configuration>


[41/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Acquire management/pod ip for control ip when VR deploys in HyperV


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

Branch: refs/heads/hyperv
Commit: 0d424d152e5736bc32b16cc81e7ef31dbbc48657
Parents: c2ddf83
Author: Rajesh Battala <ra...@citrix.com>
Authored: Thu Oct 10 23:46:56 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Oct 11 00:02:46 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/network/guru/ControlNetworkGuru.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0d424d15/server/src/com/cloud/network/guru/ControlNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/com/cloud/network/guru/ControlNetworkGuru.java
index 1943e16..a5b7c88 100755
--- a/server/src/com/cloud/network/guru/ControlNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ControlNetworkGuru.java
@@ -133,7 +133,9 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
     InsufficientAddressCapacityException {
         assert nic.getTrafficType() == TrafficType.Control;
 
-        if (dest.getHost().getHypervisorType() == HypervisorType.VMware && isRouterVm(vm)) {
+        // we have to get management/private ip for the control nic for vmware/hyperv due ssh issues.
+         HypervisorType hType = dest.getHost().getHypervisorType(); 
+        if ( ( (hType == HypervisorType.VMware) || (hType == HypervisorType.Hyperv) )&& isRouterVm(vm)) {
             if(dest.getDataCenter().getNetworkType() != NetworkType.Basic) {
                 super.reserve(nic, config, vm, dest, context);
 


[50/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Fixed hyperv localstorage path encode url issue. encode is converting space to '+'


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

Branch: refs/heads/hyperv
Commit: 1b5cd843dac6732e777641c142d91d43ab1a8347
Parents: 62098f7
Author: Rajesh Battala <ra...@citrix.com>
Authored: Tue Oct 22 15:51:32 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Tue Oct 22 15:51:32 2013 +0530

----------------------------------------------------------------------
 .../lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java          | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b5cd843/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
index 9a70124..64c2a5f 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
@@ -186,6 +186,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
         Object localStorage = dsInfos.get("localStorage");
         if (localStorage != null) {
             hostPath = hostPath.replaceFirst("/", "");
+            hostPath = hostPath.replace("+"," ");
         }
         String userInfo = uri.getUserInfo();
         int port = uri.getPort();


[48/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Implemented SetFirewallRulesCommand in HyperV Resource


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

Branch: refs/heads/hyperv
Commit: f74e9aac741ed0ba78310a99677d7adea25848b5
Parents: b24935f
Author: Rajesh Battala <ra...@citrix.com>
Authored: Fri Oct 18 17:40:36 2013 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Fri Oct 18 17:40:36 2013 +0530

----------------------------------------------------------------------
 .../resource/HypervDirectConnectResource.java   | 86 +++++++++++++++++++-
 1 file changed, 85 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f74e9aac/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 57a9dfd..9d46322 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
@@ -64,13 +64,17 @@ import com.cloud.agent.api.routing.IpAssocAnswer;
 import com.cloud.agent.api.routing.IpAssocCommand;
 import com.cloud.agent.api.routing.NetworkElementCommand;
 import com.cloud.agent.api.routing.SavePasswordCommand;
+import com.cloud.agent.api.routing.SetFirewallRulesAnswer;
+import com.cloud.agent.api.routing.SetFirewallRulesCommand;
 import com.cloud.agent.api.routing.VmDataCommand;
 import com.cloud.agent.api.to.DhcpTO;
+import com.cloud.agent.api.to.FirewallRuleTO;
 import com.cloud.agent.api.to.IpAddressTO;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor;
 import com.cloud.network.Networks.RouterPrivateIpStrategy;
+import com.cloud.network.rules.FirewallRule;
 import com.cloud.resource.ServerResource;
 import com.cloud.resource.ServerResourceBase;
 import com.cloud.serializer.GsonHelper;
@@ -363,7 +367,9 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
             answer = execute((VmDataCommand) cmd);
         } else if (clazz == SavePasswordCommand.class) {
             answer = execute((SavePasswordCommand) cmd);
-        }
+        } else  if (clazz == SetFirewallRulesCommand.class) {
+            answer = execute((SetFirewallRulesCommand)cmd);
+        } 
 
         else {
 
@@ -431,6 +437,84 @@ public class HypervDirectConnectResource extends ServerResourceBase implements
     }
 
 
+    protected SetFirewallRulesAnswer execute(SetFirewallRulesCommand cmd) {
+        String controlIp = getRouterSshControlIp(cmd);
+        String[] results = new String[cmd.getRules().length];
+        FirewallRuleTO[] allrules = cmd.getRules();
+        FirewallRule.TrafficType trafficType = allrules[0].getTrafficType();
+        String egressDefault = cmd.getAccessDetail(NetworkElementCommand.FIREWALL_EGRESS_DEFAULT);
+
+        String[][] rules = cmd.generateFwRules();
+        String args = "";
+        args += " -F ";
+        if (trafficType == FirewallRule.TrafficType.Egress){
+            args+= " -E ";
+            if (egressDefault.equals("true")) {
+                args+= " -P 1 ";
+            } else if (egressDefault.equals("System")) {
+                args+= " -P 2 ";
+            } else {
+                args+= " -P 0 ";
+            }
+        }
+
+        StringBuilder sb = new StringBuilder();
+        String[] fwRules = rules[0];
+        if (fwRules.length > 0) {
+            for (int i = 0; i < fwRules.length; i++) {
+                sb.append(fwRules[i]).append(',');
+            }
+            args += " -a " + sb.toString();
+        }
+
+        try {
+            Pair<Boolean, String> result = null;
+
+            if (trafficType == FirewallRule.TrafficType.Egress){
+                result = SshHelper.sshExecute(controlIp,
+                        DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(),
+                        null, "/root/firewallRule_egress.sh " + args);
+            } else {
+                result = SshHelper.sshExecute(controlIp,
+                        DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(),
+                        null, "/root/firewall_rule.sh " + args);
+            }
+
+            if (s_logger.isDebugEnabled()) {
+                if (trafficType == FirewallRule.TrafficType.Egress){
+                    s_logger.debug("Executing script on domain router " + controlIp
+                            + ": /root/firewallRule_egress.sh " + args);
+                } else {
+                    s_logger.debug("Executing script on domain router " + controlIp
+                            + ": /root/firewall_rule.sh " + args);
+                }
+            }
+
+
+            if (!result.first()) {
+                s_logger.error("SetFirewallRulesCommand failure on setting one rule. args: "
+                        + args);
+                //FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails
+                for (int i=0; i < results.length; i++) {
+                    results[i] = "Failed";
+                }
+
+                return new SetFirewallRulesAnswer(cmd, false, results);
+            }
+        } catch (Throwable e) {
+            s_logger.error("SetFirewallRulesCommand(args: " + args
+                    + ") failed on setting one rule due to "
+                     ,e);
+            //FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails
+            for (int i=0; i < results.length; i++) {
+                results[i] = "Failed";
+            }
+            return new SetFirewallRulesAnswer(cmd, false, results);
+        }
+
+        return new SetFirewallRulesAnswer(cmd, true, results);
+    }
+
 
     protected Answer execute(VmDataCommand cmd) {
         if (s_logger.isInfoEnabled()) {


[33/54] Add ability to pass kvp data via the key cloudstack-vm-userdata

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53fd4e8c/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
new file mode 100755
index 0000000..b5da7f6
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs
@@ -0,0 +1,1916 @@
+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_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\\v2";
+        
+        // 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\\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_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\\v2";
+                }
+                else {
+                    mgmtScope = statMgmtScope;
+                }
+            }
+            System.Management.ManagementPath pathObj = new System.Management.ManagementPath();
+            pathObj.ClassName = "Msvm_VirtualSystemManagementService";
+            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 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\\v2";
+                }
+                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 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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].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 AddFibreChannelChap(string[] FcPortSettings, byte SecretEncoding, byte[] SharedSecret) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("AddFibreChannelChap");
+                inParams["FcPortSettings"] = ((string[])(FcPortSettings));
+                inParams["SecretEncoding"] = ((byte)(SecretEncoding));
+                inParams["SharedSecret"] = ((byte[])(SharedSecret));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("AddFibreChannelChap", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+//                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    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 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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != 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 ExportSystemDefinition(System.Management.ManagementPath ComputerSystem, string ExportDirectory, string ExportSettingData, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ExportSystemDefinition");
+                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
+                inParams["ExportDirectory"] = ((string)(ExportDirectory));
+                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)
+                {
+                    //                    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 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 GenerateWwpn(uint NumberOfWwpns, out string[] GeneratedWwpn) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("GenerateWwpn");
+                inParams["NumberOfWwpns"] = ((uint)(NumberOfWwpns));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GenerateWwpn", inParams, null);
+                GeneratedWwpn = ((string[])(outParams.Properties["GeneratedWwpn"].Value));
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                GeneratedWwpn = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint GetCurrentWwpnFromGenerator(out string CurrentWwpn) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetCurrentWwpnFromGenerator", inParams, null);
+                CurrentWwpn = System.Convert.ToString(outParams.Properties["CurrentWwpn"].Value);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                CurrentWwpn = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint GetDefinitionFileSummaryInformation(string[] DefinitionFiles, out System.Management.ManagementBaseObject[] SummaryInformation) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("GetDefinitionFileSummaryInformation");
+                inParams["DefinitionFiles"] = ((string[])(DefinitionFiles));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetDefinitionFileSummaryInformation", 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 GetSizeOfSystemFiles(System.Management.ManagementPath Vssd, out ulong Size) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("GetSizeOfSystemFiles");
+                inParams["Vssd"] = ((System.Management.ManagementPath)(Vssd)).Path;
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("GetSizeOfSystemFiles", inParams, null);
+                Size = System.Convert.ToUInt64(outParams.Properties["Size"].Value);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                Size = System.Convert.ToUInt64(0);
+                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 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 ImportSnapshotDefinitions(System.Management.ManagementPath PlannedSystem, string SnapshotFolder, out System.Management.ManagementPath[] ImportedSnapshots, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ImportSnapshotDefinitions");
+                inParams["PlannedSystem"] = ((System.Management.ManagementPath)(PlannedSystem)).Path;
+                inParams["SnapshotFolder"] = ((string)(SnapshotFolder));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportSnapshotDefinitions", inParams, null);
+                ImportedSnapshots = null;
+                if ((outParams.Properties["ImportedSnapshots"] != 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)) {
+                        arrToRet[iCounter] = new System.Management.ManagementPath(((System.Array)(outParams.Properties["ImportedSnapshots"].Value)).GetValue(iCounter).ToString());
+                    }
+                    ImportedSnapshots = arrToRet;
+                }
+                Job = null;
+                //                if (outParams.Properties["Job"] != null)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                ImportedSnapshots = null;
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint ImportSystemDefinition(bool GenerateNewSystemIdentifier, string SnapshotFolder, string SystemDefinitionFile, out System.Management.ManagementPath ImportedSystem, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ImportSystemDefinition");
+                inParams["GenerateNewSystemIdentifier"] = ((bool)(GenerateNewSystemIdentifier));
+                inParams["SnapshotFolder"] = ((string)(SnapshotFolder));
+                inParams["SystemDefinitionFile"] = ((string)(SystemDefinitionFile));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("ImportSystemDefinition", inParams, null);
+                ImportedSystem = null;
+                if ((outParams.Properties["ImportedSystem"] != 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)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                }
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                ImportedSystem = null;
+                Job = null;
+                return System.Convert.ToUInt32(0);
+            }
+        }
+        
+        public uint ModifyDiskMergeSettings(string SettingData, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ModifyDiskMergeSettings");
+                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)
+                {
+                    //                    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 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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].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 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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != 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 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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].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 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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != 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 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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != 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 RealizePlannedSystem(System.Management.ManagementPath PlannedSystem, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RealizePlannedSystem");
+                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)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].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 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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != 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 RemoveFibreChannelChap(string[] FcPortSettings) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("RemoveFibreChannelChap");
+                inParams["FcPortSettings"] = ((string[])(FcPortSettings));
+                System.Management.ManagementBaseObject outParams = PrivateLateBoundObject.InvokeMethod("RemoveFibreChannelChap", inParams, null);
+                return System.Convert.ToUInt32(outParams.Properties["ReturnValue"].Value);
+            }
+            else {
+                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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    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)
+                if (outParams.Properties["Job"] != null || outParams.Properties["Job"].Value != null)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    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 SetGuestNetworkAdapterConfiguration(System.Management.ManagementPath ComputerSystem, string[] NetworkConfiguration, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("SetGuestNetworkAdapterConfiguration");
+                inParams["ComputerSystem"] = ((System.Management.ManagementPath)(ComputerSystem)).Path;
+                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)
+                {
+                    //                    Job = new System.Management.ManagementPath(outParams.Properties["Job"].ToString());
+                    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);
+            }
+        }
+        
+        public uint ValidatePlannedSystem(System.Management.ManagementPath PlannedSystem, out System.Management.ManagementPath Job) {
+            if ((isEmbedded == false)) {
+                System.Management.ManagementBaseObject inParams = null;
+                inParams = PrivateLateBoundObject.GetMethodParameters("ValidatePlannedSystem");
+                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)
+                {
+                    //                    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 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 vi

<TRUNCATED>

[53/54] 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.

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a27899aa/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/a27899aa/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..96b411c 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/ServerResource.Tests.csproj
@@ -53,6 +53,9 @@
     <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>
@@ -64,6 +67,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.ComponentModel.DataAnnotations" />
     <Reference Include="System.Configuration" />
@@ -83,8 +89,12 @@
     </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" />
   </ItemGroup>
@@ -121,4 +131,9 @@
   <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>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a27899aa/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/a27899aa/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 8de9b57..ad6245e 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/WmiWrappers.csproj
@@ -50,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" />
@@ -58,6 +73,9 @@
     <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">
@@ -172,4 +190,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
\ No newline at end of file
+</Project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a27899aa/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..93aec16
--- a/plugins/hypervisors/hyperv/buildagent.sh
+++ b/plugins/hypervisors/hyperv/buildagent.sh
@@ -19,4 +19,4 @@ 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
+xbuild /p:BuildWithMono="true" ./DotNet/ServerResource/ServerResource.sln

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a27899aa/plugins/hypervisors/hyperv/var/test/storagepool/TestCopiedLocalTemplate.vhdx
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/hyperv/var/test/storagepool/TestCopiedLocalTemplate.vhdx b/plugins/hypervisors/hyperv/var/test/storagepool/TestCopiedLocalTemplate.vhdx
new file mode 100644
index 0000000..bea65f3
--- /dev/null
+++ b/plugins/hypervisors/hyperv/var/test/storagepool/TestCopiedLocalTemplate.vhdx
@@ -0,0 +1 @@
+fake template file
\ No newline at end of file


[06/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..81016a2
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSystemManagementService.cs
@@ -0,0 +1,1731 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[40/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@apache.org.
Test failures are easier to deal with if test key is not deleted.


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

Branch: refs/heads/hyperv
Commit: c2ddf836bfa6289b6e19127699c9b912b3cffc26
Parents: 1edd300
Author: Donal Lafferty <do...@citrix.com>
Authored: Thu Oct 10 18:17:27 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Thu Oct 10 18:18:05 2013 +0530

----------------------------------------------------------------------
 .../ServerResource.Tests/HypervResourceControllerTest.cs           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2ddf836/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 7d7f627..8a86727 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs
@@ -816,7 +816,7 @@ namespace ServerResource.Tests
 
                 if (existingKey == key && existingValue == value)
                 {
-                    WmiCallsV2.DeleteHostKvpItem(vm, existingKey);
+//                    WmiCallsV2.DeleteHostKvpItem(vm, existingKey);
                     userDataInPlace = true;
                     break;
                 }


[52/54] git commit: updated refs/heads/hyperv to a27899a

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


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

Branch: refs/heads/hyperv
Commit: d0f764b55a5ef4a39e84c08df420bd10b0de8dc5
Parents: 15f9b82
Author: Devdeep Singh <de...@gmail.com>
Authored: Fri Oct 25 11:15:06 2013 -0700
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Oct 25 16:54:43 2013 +0530

----------------------------------------------------------------------
 .../ServerResource/AgentShell/AgentService.cs   |   1 +
 .../AgentShell/AgentSettings.Designer.cs        |  14 +-
 .../ServerResource/AgentShell/AgentShell.csproj |   3 -
 .../DotNet/ServerResource/AgentShell/App.config |   6 +-
 .../HypervResource/HypervResourceController.cs  |  32 +-
 .../ServerResource/HypervResource/WmiCalls.cs   |  26 +-
 .../ServerResource/HypervResource/WmiCallsV2.cs |  23 +
 ...VirtualSystemManagementServiceSettingData.cs | 791 +++++++++++++++++++
 .../WmiWrappers/WmiWrappers.csproj              |  12 +-
 9 files changed, 878 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0f764b5/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/d0f764b5/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..281f169 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs
@@ -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/d0f764b5/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..2a3c0db 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj
@@ -104,9 +104,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>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0f764b5/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/d0f764b5/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..2d61a6c 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>
@@ -111,6 +112,7 @@ namespace HypervResource
         public static HypervResourceControllerConfig config = new HypervResourceControllerConfig();
 
         private static ILog logger = LogManager.GetLogger(typeof(WmiCalls));
+        private static string systemVmIso;
 
         public static void Initialize()
         {
@@ -140,9 +142,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
                 };
@@ -803,7 +831,7 @@ namespace HypervResource
 
                 try
                 {
-                    WmiCalls.DeployVirtualMachine(cmd);
+                    WmiCalls.DeployVirtualMachine(cmd, systemVmIso);
                     result = true;
                 }
                 catch (Exception wmiEx)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0f764b5/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..65b726e 100644
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCalls.cs
@@ -158,7 +158,7 @@ namespace HypervResource
         /// <summary>
         /// Create new VM.  By default we start it. 
         /// </summary>
-        public static ComputerSystem DeployVirtualMachine(dynamic jsonObj)
+        public static ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso)
         {
             var vmInfo = jsonObj.vm;
             string vmName = vmInfo.name;
@@ -325,25 +325,12 @@ namespace HypervResource
                
                 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;
-
             }
+
             // call patch systemvm iso only for systemvms
             if (vmName.StartsWith("r-"))
             {
-                patchSystemVmIso(vmName);
+                patchSystemVmIso(vmName, systemVmIso);
             }
 
             logger.DebugFormat("Starting VM {0}", vmName);
@@ -354,9 +341,10 @@ namespace HypervResource
             {
                 System.Threading.Thread.Sleep(90000);
                 SetState(newVm, RequiredState.Reboot);
-               // wait for the second boot and then return with suces
+                // wait for the second boot and then return with sucess
                 System.Threading.Thread.Sleep(50000);
             }
+            
             logger.InfoFormat("Started VM {0}", vmName);
             return newVm;
        }
@@ -364,11 +352,11 @@ namespace HypervResource
         /// this method is to add a dvd drive and attach the systemvm iso.
         /// 
 
-        public static void patchSystemVmIso(String vmName)
+        public static void patchSystemVmIso(String vmName, String systemVmIso)
         {
             ComputerSystem vmObject = WmiCalls.GetComputerSystem(vmName);
             AddDiskDriveToVm(vmObject, "", "1", IDE_ISO_DRIVE);
-            WmiCalls.AttachIso(vmName, "c:\\systemvm.iso");
+            WmiCalls.AttachIso(vmName, systemVmIso);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0f764b5/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..f95c337 100755
--- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs
@@ -39,8 +39,18 @@ 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>
@@ -202,6 +212,19 @@ namespace HypervResource
             return result;
         }
 
+        public static 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 static VirtualSystemSettingData GetVmSettings(ComputerSystem vm)
         {
             // An ASSOCIATOR object provides the cross reference from the ComputerSettings and the 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0f764b5/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"]));
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0f764b5/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..8de9b57 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>
@@ -58,7 +60,6 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="ROOT.CIMV2.Win32_OperatingSystem.cs">
       <SubType>Component</SubType>
     </Compile>
@@ -149,6 +150,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 +160,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">
@@ -164,4 +172,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>
\ No newline at end of file


[09/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..4d56445
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_VirtualSwitch.cs
@@ -0,0 +1,1305 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[51/54] git commit: updated refs/heads/hyperv to a27899a

Posted by de...@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.


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

Branch: refs/heads/hyperv
Commit: 15f9b827350d8252b3c86c2a3f3d64d197a83234
Parents: 1b5cd84
Author: Devdeep Singh <de...@gmail.com>
Authored: Fri Oct 25 15:57:31 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Oct 25 15:57:31 2013 +0530

----------------------------------------------------------------------
 core/src/com/cloud/agent/api/SetupCommand.java  |  20 ++
 .../discoverer/HypervServerDiscoverer.java      | 231 ++++++++++++++++++-
 .../resource/HypervDirectConnectResource.java   | 105 +++------
 3 files changed, 285 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15f9b827/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/15f9b827/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/15f9b827/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..7069748 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();
 


[12/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..6edc7bd
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_SyntheticEthernetPortSettingData.cs
@@ -0,0 +1,1010 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[24/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..082db9d
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ComputerSystem.cs
@@ -0,0 +1,1298 @@
+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"]));
+                }
+            }
+        }
+    }
+}


[18/54] A plugin for Hyper-V control is available for CloudStack. The plugin implements basic VM control; however, its architecture allows additional functionality to be easily added. Incorporating the plugin in CloudStack will allow the community to

Posted by de...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1d0a931d/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
new file mode 100644
index 0000000..1b22931
--- /dev/null
+++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.Msvm_ProcessorSettingData.cs
@@ -0,0 +1,1190 @@
+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"]));
+                }
+            }
+        }
+    }
+}