diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml index df1b1a2825e..5e8d65905eb 100644 --- a/.github/linters/.markdown-lint.yml +++ b/.github/linters/.markdown-lint.yml @@ -27,27 +27,15 @@ MD004: false # MD007/ul-indent Unordered list indentation MD007: false -# MD009/no-trailing-spaces Trailing spaces -MD009: false - # MD010/no-hard-tabs Hard tabs MD010: false -# MD012/no-multiple-blanks Multiple consecutive blank lines -MD012: false - # MD013/line-length Line length MD013: false # MD014/commands-show-output Dollar signs used before commands without showing output MD014: false -# MD018/no-missing-space-atx No space after hash on atx style heading -MD018: false - -# MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading -MD019: false - # MD022/blanks-around-headings Headings should be surrounded by blank lines MD022: false diff --git a/.gitignore b/.gitignore index 648b93b0696..abaef83e455 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,9 @@ # 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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e8f3c6093a9..803f182f3b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: - id: check-merge-conflict - id: check-symlinks - id: check-vcs-permalinks - #- id: check-yaml + - id: check-yaml - id: destroyed-symlinks - id: detect-aws-credentials args: [--allow-missing-credentials] @@ -59,7 +59,7 @@ repos: - id: mixed-line-ending exclude: \.(cs|xml)$ - id: trailing-whitespace - files: \.(header|in|java|md|properties|py|rb|sh|sql|txt|vue|xml|yaml|yml)$ + files: \.(cs|bat|css|gitignore|header|in|install|java|md|properties|py|rb|sh|sql|txt|vue|xml|xsl|yaml|yml)$ args: [--markdown-linebreak-ext=md] exclude: ^services/console-proxy/rdpconsole/src/test/doc/freerdp-debug-log\.txt$ - repo: https://github.com/codespell-project/codespell @@ -87,7 +87,7 @@ repos: ^setup/bindir/cloud-setup-encryption\.in$| ^venv/.*$ - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.40.0 + rev: v0.43.0 hooks: - id: markdownlint name: run markdownlint diff --git a/CHANGES.md b/CHANGES.md index 9544fc014c7..8fea4f3a355 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -242,7 +242,6 @@ Bug ID | Description [CLOUDSTACK-7722](https://issues.apache.org/jira/browse/CLOUDSTACK-7722) | add.label: Add button for tags show the label not "Add" text... [CLOUDSTACK-7246](https://issues.apache.org/jira/browse/CLOUDSTACK-7246) | VM deployment failed due to wrong in script name createipalias.sh... - Version 4.4.1 ------------- @@ -276,7 +275,6 @@ Bug ID | Description [CLOUDSTACK-1632](https://issues.apache.org/jira/browse/CLOUDSTACK-1632) | Mistakes in authorizeSecurityGroup* API docs... [CLOUDSTACK-401](https://issues.apache.org/jira/browse/CLOUDSTACK-401) | Storage options missing from table... - Version 4.4.0 ------------- @@ -930,7 +928,6 @@ Security Fixes: * CVE-2012-4501: Apache CloudStack configuration vulnerability - Version 4.0.2 ------------------------ @@ -979,7 +976,6 @@ Issues fixed in this release: * CLOUDSTACK-2090: Upgrade from version 4.0.1 to version 4.0.2 triggers the 4.0.0 to 4.0.1. * CLOUDSTACK-2091: Error in API documentation for 4.0.x. - Version 4.0.1-incubating ------------------------ @@ -1023,7 +1019,6 @@ Bugs fixed in this release: * CLOUDSTACK-961: Installation docs don't detail dependencies for building RPMs * CLOUDSTACK-995: Not able to add the KVM host - Version 4.0.0-incubating ------------------------ @@ -1056,7 +1051,6 @@ Security Fixes: * CVE-2012-4501: Apache CloudStack configuration vulnerability - Updating this file ------------------ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bb84e4e91fb..a6d006938f3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,11 +51,9 @@ $ git fetch upstream $ git rebase upstream/main ``` - Making changes -------------- - It is important that you create a new branch to make changes on and that you do not change the `main` branch (other than to rebase in changes from `upstream/main`). In this example I will assume you will be making your changes to a branch called `feature_x`. This `feature_x` branch will be created on your local repository and will be pushed to your forked repository on GitHub. Once this branch is on your fork you will create a Pull Request for the changes to be added to the ACS project. It is best practice to create a new branch each time you want to contribute to the project and only track the changes for that pull request in this branch. @@ -70,7 +68,6 @@ $ git commit -a -m "descriptive commit message for your changes" > The `-b` specifies that you want to create a new branch called `feature_x`. You only specify `-b` the first time you checkout because you are creating a new branch. Once the `feature_x` branch exists, you can later switch to it with only `git checkout feature_x`. - Rebase `feature_x` to include updates from `upstream/main` ------------------------------------------------------------ @@ -92,7 +89,6 @@ $ git rebase main > Now your `feature_x` branch is up-to-date with all the code in `upstream/main`. - Make a GitHub Pull Request to contribute your changes ----------------------------------------------------- @@ -107,7 +103,7 @@ $ git push origin main $ git push origin feature_x ``` -Now that the `feature_x` branch has been pushed to your GitHub repository, you can initiate the pull request. +Now that the `feature_x` branch has been pushed to your GitHub repository, you can initiate the pull request. To initiate the pull request, do the following: @@ -118,7 +114,6 @@ To initiate the pull request, do the following: If you are requested to make modifications to your proposed changes, make the changes locally on your `feature_x` branch, re-push the `feature_x` branch to your fork. The existing pull request should automatically pick up the change and update accordingly. - Cleaning up after a successful pull request ------------------------------------------- diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 85c1ac9ec6a..4a48a4e7591 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -35,17 +35,14 @@ New line separated list of affected versions, commit ID for issues on main branc Information about the configuration if relevant, e.g. basic network, advanced networking, etc. N/A otherwise --> - ##### OS / ENVIRONMENT - ##### SUMMARY - ##### STEPS TO REPRODUCE @@ -53,5 +51,4 @@ This PR... - diff --git a/README.md b/README.md index f66a4dc6f97..cc71c848d5d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Apache CloudStack [![Build Status](https://github.com/apache/cloudstack/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/apache/cloudstack/actions/workflows/build.yml) [![UI Build](https://github.com/apache/cloudstack/actions/workflows/ui.yml/badge.svg)](https://github.com/apache/cloudstack/actions/workflows/ui.yml) [![License Check](https://github.com/apache/cloudstack/actions/workflows/rat.yml/badge.svg?branch=main)](https://github.com/apache/cloudstack/actions/workflows/rat.yml) [![Simulator CI](https://github.com/apache/cloudstack/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/apache/cloudstack/actions/workflows/ci.yml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=apache_cloudstack&metric=alert_status)](https://sonarcloud.io/dashboard?id=apache_cloudstack) [![codecov](https://codecov.io/gh/apache/cloudstack/branch/main/graph/badge.svg)](https://codecov.io/gh/apache/cloudstack) -[![Apache CloudStack](tools/logo/apache_cloudstack.png)](https://cloudstack.apache.org/) +[![Apache CloudStack](tools/logo/acsxmas.jpg)](https://cloudstack.apache.org/) Apache CloudStack is open source software designed to deploy and manage large networks of virtual machines, as a highly available, highly scalable diff --git a/agent/pom.xml b/agent/pom.xml index 9caa6d992c8..76c37cd87be 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT diff --git a/agent/src/main/java/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java b/agent/src/main/java/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java index ccd0d976e58..26f9d4b3d73 100644 --- a/agent/src/main/java/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java +++ b/agent/src/main/java/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java @@ -397,9 +397,8 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe } public String authenticateConsoleAccess(String host, String port, String vmId, String sid, String ticket, - Boolean isReauthentication, String sessionToken) { - - ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(host, port, vmId, sid, ticket, sessionToken); + Boolean isReauthentication, String sessionToken, String clientAddress) { + ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(host, port, vmId, sid, ticket, sessionToken, clientAddress); cmd.setReauthenticating(isReauthentication); ConsoleProxyAuthenticationResult result = new ConsoleProxyAuthenticationResult(); diff --git a/api/pom.xml b/api/pom.xml index 32897725e0c..ec68e24c7e5 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT diff --git a/api/src/main/java/com/cloud/agent/api/to/PortForwardingRuleTO.java b/api/src/main/java/com/cloud/agent/api/to/PortForwardingRuleTO.java index 76d6d952814..d43625c09a9 100644 --- a/api/src/main/java/com/cloud/agent/api/to/PortForwardingRuleTO.java +++ b/api/src/main/java/com/cloud/agent/api/to/PortForwardingRuleTO.java @@ -19,6 +19,9 @@ package com.cloud.agent.api.to; import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.PortForwardingRule; import com.cloud.utils.net.NetUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; /** * PortForwardingRuleTO specifies one port forwarding rule. @@ -29,6 +32,8 @@ public class PortForwardingRuleTO extends FirewallRuleTO { String dstIp; int[] dstPortRange; + List sourceCidrList; + protected PortForwardingRuleTO() { super(); } @@ -37,6 +42,7 @@ public class PortForwardingRuleTO extends FirewallRuleTO { super(rule, srcVlanTag, srcIp); this.dstIp = rule.getDestinationIpAddress().addr(); this.dstPortRange = new int[] {rule.getDestinationPortStart(), rule.getDestinationPortEnd()}; + this.sourceCidrList = rule.getSourceCidrList(); } public PortForwardingRuleTO(long id, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, @@ -58,4 +64,11 @@ public class PortForwardingRuleTO extends FirewallRuleTO { return NetUtils.portRangeToString(dstPortRange); } + public String getSourceCidrListAsString() { + if (sourceCidrList != null) { + return StringUtils.join(sourceCidrList, ","); + } + return null; + } + } diff --git a/api/src/main/java/com/cloud/bgp/BGPService.java b/api/src/main/java/com/cloud/bgp/BGPService.java index 935237092dd..61d149f2847 100644 --- a/api/src/main/java/com/cloud/bgp/BGPService.java +++ b/api/src/main/java/com/cloud/bgp/BGPService.java @@ -21,6 +21,7 @@ import com.cloud.network.Network; import com.cloud.network.vpc.Vpc; import com.cloud.utils.Pair; import org.apache.cloudstack.api.command.user.bgp.ListASNumbersCmd; +import org.apache.cloudstack.network.BgpPeer; import java.util.List; @@ -36,4 +37,8 @@ public interface BGPService { boolean applyBgpPeers(Network network, boolean continueOnError) throws ResourceUnavailableException; boolean applyBgpPeers(Vpc vpc, boolean continueOnError) throws ResourceUnavailableException; + + List getBgpPeersForNetwork(Network network); + + List getBgpPeersForVpc(Vpc vpc); } diff --git a/api/src/main/java/com/cloud/event/EventTypes.java b/api/src/main/java/com/cloud/event/EventTypes.java index 5e5309965c1..81ed185dae5 100644 --- a/api/src/main/java/com/cloud/event/EventTypes.java +++ b/api/src/main/java/com/cloud/event/EventTypes.java @@ -292,6 +292,7 @@ public class EventTypes { //register for user API and secret keys public static final String EVENT_REGISTER_FOR_SECRET_API_KEY = "REGISTER.USER.KEY"; + public static final String API_KEY_ACCESS_UPDATE = "API.KEY.ACCESS.UPDATE"; // Template Events public static final String EVENT_TEMPLATE_CREATE = "TEMPLATE.CREATE"; diff --git a/api/src/main/java/com/cloud/hypervisor/Hypervisor.java b/api/src/main/java/com/cloud/hypervisor/Hypervisor.java index e1108b34a83..27ffef1c370 100644 --- a/api/src/main/java/com/cloud/hypervisor/Hypervisor.java +++ b/api/src/main/java/com/cloud/hypervisor/Hypervisor.java @@ -20,37 +20,57 @@ import com.cloud.storage.Storage.ImageFormat; import org.apache.commons.lang3.StringUtils; import java.util.LinkedHashMap; +import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Set; +import java.util.EnumSet; +import java.util.stream.Collectors; + +import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.DirectDownloadTemplate; +import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.RootDiskSizeOverride; +import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.VmStorageMigration; public class Hypervisor { public static class HypervisorType { + public enum Functionality { + DirectDownloadTemplate, + RootDiskSizeOverride, + VmStorageMigration + } + private static final Map hypervisorTypeMap = new LinkedHashMap<>(); public static final HypervisorType None = new HypervisorType("None"); //for storage hosts - public static final HypervisorType XenServer = new HypervisorType("XenServer", ImageFormat.VHD); - public static final HypervisorType KVM = new HypervisorType("KVM", ImageFormat.QCOW2); - public static final HypervisorType VMware = new HypervisorType("VMware", ImageFormat.OVA); + public static final HypervisorType XenServer = new HypervisorType("XenServer", ImageFormat.VHD, EnumSet.of(RootDiskSizeOverride, VmStorageMigration)); + public static final HypervisorType KVM = new HypervisorType("KVM", ImageFormat.QCOW2, EnumSet.of(DirectDownloadTemplate, RootDiskSizeOverride, VmStorageMigration)); + public static final HypervisorType VMware = new HypervisorType("VMware", ImageFormat.OVA, EnumSet.of(RootDiskSizeOverride, VmStorageMigration)); public static final HypervisorType Hyperv = new HypervisorType("Hyperv"); public static final HypervisorType VirtualBox = new HypervisorType("VirtualBox"); public static final HypervisorType Parralels = new HypervisorType("Parralels"); public static final HypervisorType BareMetal = new HypervisorType("BareMetal"); - public static final HypervisorType Simulator = new HypervisorType("Simulator"); + public static final HypervisorType Simulator = new HypervisorType("Simulator", null, EnumSet.of(RootDiskSizeOverride, VmStorageMigration)); public static final HypervisorType Ovm = new HypervisorType("Ovm", ImageFormat.RAW); public static final HypervisorType Ovm3 = new HypervisorType("Ovm3", ImageFormat.RAW); public static final HypervisorType LXC = new HypervisorType("LXC"); - public static final HypervisorType Custom = new HypervisorType("Custom"); + public static final HypervisorType Custom = new HypervisorType("Custom", null, EnumSet.of(RootDiskSizeOverride)); public static final HypervisorType Any = new HypervisorType("Any"); /*If you don't care about the hypervisor type*/ private final String name; private final ImageFormat imageFormat; + private final Set supportedFunctionalities; public HypervisorType(String name) { - this(name, null); + this(name, null, EnumSet.noneOf(Functionality.class)); } public HypervisorType(String name, ImageFormat imageFormat) { + this(name, imageFormat, EnumSet.noneOf(Functionality.class)); + } + + public HypervisorType(String name, ImageFormat imageFormat, Set supportedFunctionalities) { this.name = name; this.imageFormat = imageFormat; + this.supportedFunctionalities = supportedFunctionalities; if (name.equals("Parralels")){ // typo in the original code hypervisorTypeMap.put("parallels", this); } else { @@ -81,6 +101,12 @@ public class Hypervisor { return hypervisorType; } + public static List getListOfHypervisorsSupportingFunctionality(Functionality functionality) { + return hypervisorTypeMap.values().stream() + .filter(hypervisor -> hypervisor.supportedFunctionalities.contains(functionality)) + .collect(Collectors.toList()); + } + /** * Returns the display name of a hypervisor type in case the custom hypervisor is used, * using the 'hypervisor.custom.display.name' setting. Otherwise, returns hypervisor name @@ -102,6 +128,15 @@ public class Hypervisor { return name; } + /** + * Make this method to be part of the properties of the hypervisor type itself. + * + * @return true if the hypervisor plugin support the specified functionality + */ + public boolean isFunctionalitySupported(Functionality functionality) { + return supportedFunctionalities.contains(functionality); + } + @Override public int hashCode() { return Objects.hash(name); diff --git a/api/src/main/java/com/cloud/network/rules/RulesService.java b/api/src/main/java/com/cloud/network/rules/RulesService.java index 0b4afeef945..547d4ab51e0 100644 --- a/api/src/main/java/com/cloud/network/rules/RulesService.java +++ b/api/src/main/java/com/cloud/network/rules/RulesService.java @@ -26,6 +26,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.utils.Pair; import com.cloud.utils.net.Ip; +import org.apache.cloudstack.api.command.user.firewall.UpdatePortForwardingRuleCmd; public interface RulesService { Pair, Integer> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, @@ -81,6 +82,8 @@ public interface RulesService { boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException; - PortForwardingRule updatePortForwardingRule(long id, Integer privatePort, Integer privateEndPort, Long virtualMachineId, Ip vmGuestIp, String customId, Boolean forDisplay); + PortForwardingRule updatePortForwardingRule(UpdatePortForwardingRuleCmd cmd); + + void validatePortForwardingSourceCidrList(List sourceCidrList); } diff --git a/api/src/main/java/com/cloud/server/ManagementServerHostStats.java b/api/src/main/java/com/cloud/server/ManagementServerHostStats.java index 1f201d7689f..1eea7addba3 100644 --- a/api/src/main/java/com/cloud/server/ManagementServerHostStats.java +++ b/api/src/main/java/com/cloud/server/ManagementServerHostStats.java @@ -32,6 +32,8 @@ public interface ManagementServerHostStats { String getManagementServerHostUuid(); + long getManagementServerRunId(); + long getSessions(); double getCpuUtilization(); diff --git a/api/src/main/java/com/cloud/user/Account.java b/api/src/main/java/com/cloud/user/Account.java index bb9838f137a..6be4d0a48f6 100644 --- a/api/src/main/java/com/cloud/user/Account.java +++ b/api/src/main/java/com/cloud/user/Account.java @@ -93,4 +93,8 @@ public interface Account extends ControlledEntity, InternalIdentity, Identity { boolean isDefault(); + public void setApiKeyAccess(Boolean apiKeyAccess); + + public Boolean getApiKeyAccess(); + } diff --git a/api/src/main/java/com/cloud/user/AccountService.java b/api/src/main/java/com/cloud/user/AccountService.java index 63f5455cfd0..e2c3bed0c29 100644 --- a/api/src/main/java/com/cloud/user/AccountService.java +++ b/api/src/main/java/com/cloud/user/AccountService.java @@ -19,6 +19,7 @@ package com.cloud.user; import java.util.List; import java.util.Map; +import com.cloud.utils.Pair; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.acl.SecurityChecker.AccessType; @@ -116,6 +117,8 @@ public interface AccountService { void checkAccess(Account account, AccessType accessType, boolean sameOwner, String apiName, ControlledEntity... entities) throws PermissionDeniedException; + void validateAccountHasAccessToResource(Account account, AccessType accessType, Object resource); + Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly); /** @@ -125,9 +128,9 @@ public interface AccountService { */ UserAccount getUserAccountById(Long userId); - public Map getKeys(GetUserKeysCmd cmd); + public Pair> getKeys(GetUserKeysCmd cmd); - public Map getKeys(Long userId); + public Pair> getKeys(Long userId); /** * Lists user two-factor authentication provider plugins diff --git a/api/src/main/java/com/cloud/user/User.java b/api/src/main/java/com/cloud/user/User.java index 422e264f10b..041b39ad272 100644 --- a/api/src/main/java/com/cloud/user/User.java +++ b/api/src/main/java/com/cloud/user/User.java @@ -94,4 +94,9 @@ public interface User extends OwnedBy, InternalIdentity { public boolean isUser2faEnabled(); public String getKeyFor2fa(); + + public void setApiKeyAccess(Boolean apiKeyAccess); + + public Boolean getApiKeyAccess(); + } diff --git a/api/src/main/java/com/cloud/vm/VmDetailConstants.java b/api/src/main/java/com/cloud/vm/VmDetailConstants.java index c21f6d23485..040f32ee322 100644 --- a/api/src/main/java/com/cloud/vm/VmDetailConstants.java +++ b/api/src/main/java/com/cloud/vm/VmDetailConstants.java @@ -74,6 +74,7 @@ public interface VmDetailConstants { String ENCRYPTED_PASSWORD = "Encrypted.Password"; String CONFIG_DRIVE_LOCATION = "configDriveLocation"; + String LAST_CONFIG_DRIVE_LOCATION = "lastConfigDriveLocation"; String SKIP_DRS = "skipFromDRS"; diff --git a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java index cf667063e38..77373aaf10b 100644 --- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java @@ -35,6 +35,7 @@ public class ApiConstants { public static final String ALLOW_USER_FORCE_STOP_VM = "allowuserforcestopvm"; public static final String ANNOTATION = "annotation"; public static final String API_KEY = "apikey"; + public static final String API_KEY_ACCESS = "apikeyaccess"; public static final String ARCHIVED = "archived"; public static final String ARCH = "arch"; public static final String AS_NUMBER = "asnumber"; @@ -244,6 +245,7 @@ public class ApiConstants { public static final String ICMP_TYPE = "icmptype"; public static final String ID = "id"; public static final String IDS = "ids"; + public static final String IMPORT_INSTANCE_HOST_ID = "importinstancehostid"; public static final String INDEX = "index"; public static final String INSTANCES_DISKS_STATS_RETENTION_ENABLED = "instancesdisksstatsretentionenabled"; public static final String INSTANCES_DISKS_STATS_RETENTION_TIME = "instancesdisksstatsretentiontime"; @@ -385,6 +387,14 @@ public class ApiConstants { public static final String PATH = "path"; public static final String PAYLOAD = "payload"; public static final String PAYLOAD_URL = "payloadurl"; + public static final String PEERS = "peers"; + public static final String PEER_ID = "peerid"; + public static final String PEER_NAME = "peername"; + public static final String PEER_MSID = "peermsid"; + public static final String PEER_RUNID = "peerrunid"; + public static final String PEER_SERVICE_IP = "peerserviceip"; + public static final String PEER_SERVICE_PORT = "peerserviceport"; + public static final String PEER_STATE = "peerstate"; public static final String POD_ID = "podid"; public static final String POD_NAME = "podname"; public static final String POD_IDS = "podids"; @@ -459,6 +469,7 @@ public class ApiConstants { public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid"; public static final String SNAPSHOT_TYPE = "snapshottype"; public static final String SNAPSHOT_QUIESCEVM = "quiescevm"; + public static final String SOURCE_CIDR_LIST = "sourcecidrlist"; public static final String SOURCE_ZONE_ID = "sourcezoneid"; public static final String SSL_VERIFICATION = "sslverification"; public static final String START_ASN = "startasn"; @@ -997,6 +1008,7 @@ public class ApiConstants { public static final String ACL_NAME = "aclname"; public static final String NUMBER = "number"; public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable"; + public static final String ROUTED_MODE_ENABLED = "routedmodeenabled"; public static final String ROUTING = "isrouting"; public static final String ROUTING_MODE = "routingmode"; public static final String MAX_CONNECTIONS = "maxconnections"; @@ -1255,4 +1267,30 @@ public class ApiConstants { public enum DomainDetails { all, resource, min; } + + public enum ApiKeyAccess { + DISABLED(false), + ENABLED(true), + INHERIT(null); + + Boolean apiKeyAccess; + + ApiKeyAccess(Boolean keyAccess) { + apiKeyAccess = keyAccess; + } + + public Boolean toBoolean() { + return apiKeyAccess; + } + + public static ApiKeyAccess fromBoolean(Boolean value) { + if (value == null) { + return INHERIT; + } else if (value) { + return ENABLED; + } else { + return DISABLED; + } + } + } } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java index 91cbb90e4da..3347a0d09f3 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java @@ -21,7 +21,9 @@ import java.util.Map; import javax.inject.Inject; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiCommandResourceType; +import org.apache.cloudstack.api.command.user.UserCmd; import org.apache.cloudstack.api.response.RoleResponse; import org.apache.cloudstack.acl.SecurityChecker.AccessType; @@ -40,8 +42,8 @@ import org.apache.cloudstack.region.RegionService; import com.cloud.user.Account; @APICommand(name = "updateAccount", description = "Updates account information for the authenticated user", responseObject = AccountResponse.class, entityType = {Account.class}, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) -public class UpdateAccountCmd extends BaseCmd { + responseView = ResponseView.Restricted, requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) +public class UpdateAccountCmd extends BaseCmd implements UserCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -70,6 +72,9 @@ public class UpdateAccountCmd extends BaseCmd { @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "Details for the account used to store specific parameters") private Map details; + @Parameter(name = ApiConstants.API_KEY_ACCESS, type = CommandType.STRING, description = "Determines if Api key access for this user is enabled, disabled or inherits the value from its parent, the domain level setting api.key.access", since = "4.20.1.0", authorized = {RoleType.Admin}) + private String apiKeyAccess; + @Inject RegionService _regionService; @@ -109,6 +114,10 @@ public class UpdateAccountCmd extends BaseCmd { return params; } + public String getApiKeyAccess() { + return apiKeyAccess; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -131,7 +140,7 @@ public class UpdateAccountCmd extends BaseCmd { public void execute() { Account result = _regionService.updateAccount(this); if (result != null){ - AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); + AccountResponse response = _responseGenerator.createAccountResponse(getResponseView(), result); response.setResponseName(getCommandName()); setResponseObject(response); } else { diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/management/ListMgmtsCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/management/ListMgmtsCmd.java index a68ed62857a..7b7eae1d0e9 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/management/ListMgmtsCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/management/ListMgmtsCmd.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.api.BaseListCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ManagementServerResponse; +import org.apache.commons.lang3.BooleanUtils; @APICommand(name = "listManagementServers", description = "Lists management servers.", responseObject = ManagementServerResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) @@ -39,6 +40,11 @@ public class ListMgmtsCmd extends BaseListCmd { @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the management server") private String hostName; + @Parameter(name = ApiConstants.PEERS, type = CommandType.BOOLEAN, + description = "Whether to return the management server peers or not. By default, the management server peers will not be returned.", + since = "4.20.1.0") + private Boolean peers; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -51,6 +57,10 @@ public class ListMgmtsCmd extends BaseListCmd { return hostName; } + public Boolean getPeers() { + return BooleanUtils.toBooleanDefaultIfNull(peers, false); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/user/GetUserKeysCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/user/GetUserKeysCmd.java index 3a3414d95d8..cdd239f72b5 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/user/GetUserKeysCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/user/GetUserKeysCmd.java @@ -20,6 +20,7 @@ package org.apache.cloudstack.api.command.admin.user; import com.cloud.user.Account; import com.cloud.user.User; +import com.cloud.utils.Pair; import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; @@ -54,11 +55,13 @@ public class GetUserKeysCmd extends BaseCmd{ else return Account.ACCOUNT_ID_SYSTEM; } public void execute(){ - Map keys = _accountService.getKeys(this); + Pair> keys = _accountService.getKeys(this); + RegisterResponse response = new RegisterResponse(); if(keys != null){ - response.setApiKey(keys.get("apikey")); - response.setSecretKey(keys.get("secretkey")); + response.setApiKeyAccess(keys.first()); + response.setApiKey(keys.second().get("apikey")); + response.setSecretKey(keys.second().get("secretkey")); } response.setObjectName("userkeys"); diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java index ef9e3fa2240..2f29b1ec1e4 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java @@ -16,23 +16,29 @@ // under the License. package org.apache.cloudstack.api.command.admin.user; +import com.cloud.exception.InvalidParameterValueException; import com.cloud.server.ResourceIcon; import com.cloud.server.ResourceTag; import com.cloud.user.Account; +import com.cloud.user.User; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.command.user.UserCmd; import org.apache.cloudstack.api.response.ResourceIconResponse; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListAccountResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.UserResponse; +import org.apache.commons.lang3.EnumUtils; import java.util.List; @APICommand(name = "listUsers", description = "Lists user accounts", responseObject = UserResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) -public class ListUsersCmd extends BaseListAccountResourcesCmd { + responseView = ResponseView.Restricted, requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) +public class ListUsersCmd extends BaseListAccountResourcesCmd implements UserCmd { ///////////////////////////////////////////////////// @@ -53,10 +59,17 @@ public class ListUsersCmd extends BaseListAccountResourcesCmd { @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, description = "List user by the username") private String username; + @Parameter(name = ApiConstants.API_KEY_ACCESS, type = CommandType.STRING, description = "List users by the Api key access value", since = "4.20.1.0", authorized = {RoleType.Admin}) + private String apiKeyAccess; + @Parameter(name = ApiConstants.SHOW_RESOURCE_ICON, type = CommandType.BOOLEAN, description = "flag to display the resource icon for users") private Boolean showIcon; + @Parameter(name = ApiConstants.USER_SOURCE, type = CommandType.STRING, since = "4.21.0.0", + description = "List users by their authentication source. Valid values are: native, ldap, saml2 and saml2disabled.") + private String userSource; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -77,17 +90,38 @@ public class ListUsersCmd extends BaseListAccountResourcesCmd { return username; } + public String getApiKeyAccess() { + return apiKeyAccess; + } + public Boolean getShowIcon() { return showIcon != null ? showIcon : false; } + public User.Source getUserSource() { + if (userSource == null) { + return null; + } + + User.Source source = EnumUtils.getEnumIgnoreCase(User.Source.class, userSource); + if (source == null || List.of(User.Source.OAUTH2, User.Source.UNKNOWN).contains(source)) { + throw new InvalidParameterValueException(String.format("Invalid user source: %s. Valid values are: native, ldap, saml2 and saml2disabled.", userSource)); + } + + if (source == User.Source.NATIVE) { + return User.Source.UNKNOWN; + } + + return source; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @Override public void execute() { - ListResponse response = _queryService.searchForUsers(this); + ListResponse response = _queryService.searchForUsers(getResponseView(), this); response.setResponseName(getCommandName()); this.setResponseObject(response); if (response != null && response.getCount() > 0 && getShowIcon()) { diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java index c9e1e934152..3d7f51ae220 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.user; import javax.inject.Inject; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandResourceType; import org.apache.cloudstack.api.ApiConstants; @@ -69,6 +70,9 @@ public class UpdateUserCmd extends BaseCmd { @Parameter(name = ApiConstants.USER_SECRET_KEY, type = CommandType.STRING, description = "The secret key for the user. Must be specified with userApiKey") private String secretKey; + @Parameter(name = ApiConstants.API_KEY_ACCESS, type = CommandType.STRING, description = "Determines if Api key access for this user is enabled, disabled or inherits the value from its parent, the owning account", since = "4.20.1.0", authorized = {RoleType.Admin}) + private String apiKeyAccess; + @Parameter(name = ApiConstants.TIMEZONE, type = CommandType.STRING, description = "Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.") @@ -120,6 +124,10 @@ public class UpdateUserCmd extends BaseCmd { return secretKey; } + public String getApiKeyAccess() { + return apiKeyAccess; + } + public String getTimezone() { return timezone; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java index 6f148ff0ee4..db43b53ab9a 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java @@ -144,15 +144,19 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd { private String clusterName; @Parameter(name = ApiConstants.CONVERT_INSTANCE_HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, - description = "(only for importing VMs from VMware to KVM) optional - the host to perform the virt-v2v migration from VMware to KVM.") + description = "(only for importing VMs from VMware to KVM) optional - the host to perform the virt-v2v conversion from VMware to KVM.") private Long convertInstanceHostId; + @Parameter(name = ApiConstants.IMPORT_INSTANCE_HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, since = "4.19.2", + description = "(only for importing VMs from VMware to KVM) optional - the host to import the converted instance from VMware to KVM.") + private Long importInstanceHostId; + @Parameter(name = ApiConstants.CONVERT_INSTANCE_STORAGE_POOL_ID, type = CommandType.UUID, entityType = StoragePoolResponse.class, description = "(only for importing VMs from VMware to KVM) optional - the temporary storage pool to perform the virt-v2v migration from VMware to KVM.") private Long convertStoragePoolId; @Parameter(name = ApiConstants.FORCE_MS_TO_IMPORT_VM_FILES, type = CommandType.BOOLEAN, - description = "(only for importing VMs from VMware to KVM) optional - if true, forces MS to import VM file(s) to temporary storage, else uses KVM Host if ovftool is available, falls back to MS if not.") + description = "(only for importing VMs from VMware to KVM) optional - if true, forces MS to export OVF from VMware to temporary storage, else uses KVM Host if ovftool is available, falls back to MS if not.") private Boolean forceMsToImportVmFiles; ///////////////////////////////////////////////////// @@ -199,6 +203,10 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd { return convertInstanceHostId; } + public Long getImportInstanceHostId() { + return importInstanceHostId; + } + public Long getConvertStoragePoolId() { return convertStoragePoolId; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java index 0a962b19e4f..9157188fdee 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.List; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandResourceType; import org.apache.cloudstack.api.ApiConstants; @@ -70,6 +71,9 @@ public class ListAccountsCmd extends BaseListDomainResourcesCmd implements UserC description = "comma separated list of account details requested, value can be a list of [ all, resource, min]") private List viewDetails; + @Parameter(name = ApiConstants.API_KEY_ACCESS, type = CommandType.STRING, description = "List accounts by the Api key access value", since = "4.20.1.0", authorized = {RoleType.Admin}) + private String apiKeyAccess; + @Parameter(name = ApiConstants.SHOW_RESOURCE_ICON, type = CommandType.BOOLEAN, description = "flag to display the resource icon for accounts") private Boolean showIcon; @@ -120,6 +124,10 @@ public class ListAccountsCmd extends BaseListDomainResourcesCmd implements UserC return dv; } + public String getApiKeyAccess() { + return apiKeyAccess; + } + public boolean getShowIcon() { return showIcon != null ? showIcon : false; } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/backup/ListBackupScheduleCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/backup/ListBackupScheduleCmd.java index a7610717435..fa6e3ea5d45 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/backup/ListBackupScheduleCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/backup/ListBackupScheduleCmd.java @@ -82,7 +82,7 @@ public class ListBackupScheduleCmd extends BaseCmd { List schedules = backupManager.listBackupSchedule(getVmId()); ListResponse response = new ListResponse<>(); List scheduleResponses = new ArrayList<>(); - if (CollectionUtils.isNullOrEmpty(schedules)) { + if (!CollectionUtils.isNullOrEmpty(schedules)) { for (BackupSchedule schedule : schedules) { scheduleResponses.add(_responseGenerator.createBackupScheduleResponse(schedule)); } diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java index 3545b3d21fb..9d1fe176019 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java @@ -105,8 +105,12 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P description = "the ID of the virtual machine for the port forwarding rule") private Long virtualMachineId; - @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from. Multiple entries must be separated by a single comma character (,). This parameter is deprecated. Do not use.") - private List cidrlist; + @Parameter(name = ApiConstants.CIDR_LIST, + type = CommandType.LIST, + collectionType = CommandType.STRING, + description = " the source CIDR list to allow traffic from; all other CIDRs will be blocked. " + + "Multiple entries must be separated by a single comma character (,). This param will be used only for VPC tiers. By default, all CIDRs are allowed.") + private List sourceCidrList; @Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for source/end public port is automatically created; " + "if false - firewall rule has to be created explicitly. If not specified 1) defaulted to false when PF" @@ -155,11 +159,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P @Override public List getSourceCidrList() { - if (cidrlist != null) { - throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall " - + "rule for the specific cidr, please refer to createFirewallRule command"); - } - return null; + return sourceCidrList; } public Boolean getOpenFirewall() { @@ -332,12 +332,6 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P @Override public void create() { - // cidr list parameter is deprecated - if (cidrlist != null) { - throw new InvalidParameterValueException( - "Parameter cidrList is deprecated; if you need to open firewall rule for the specific cidr, please refer to createFirewallRule command"); - } - Ip privateIp = getVmSecondaryIp(); if (privateIp != null) { if (!NetUtils.isValidIp4(privateIp.toString())) { @@ -345,6 +339,8 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P } } + _rulesService.validatePortForwardingSourceCidrList(sourceCidrList); + try { PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, getOpenFirewall(), isDisplay()); setEntityId(result.getId()); diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java index 3fb66bd861f..ee4bd18ad40 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java @@ -32,6 +32,8 @@ import com.cloud.network.rules.PortForwardingRule; import com.cloud.user.Account; import com.cloud.utils.net.Ip; +import java.util.List; + @APICommand(name = "updatePortForwardingRule", responseObject = FirewallRuleResponse.class, description = "Updates a port forwarding rule. Only the private port and the virtual machine can be updated.", entityType = {PortForwardingRule.class}, @@ -63,6 +65,13 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) private Boolean display; + @Parameter(name = ApiConstants.CIDR_LIST, + type = CommandType.LIST, + collectionType = CommandType.STRING, + description = " the source CIDR list to allow traffic from; all other CIDRs will be blocked. " + + "Multiple entries must be separated by a single comma character (,). This param will be used only for VPC tiers. By default, all CIDRs are allowed.") + private List sourceCidrList; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -94,6 +103,10 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { return display; } + public List getSourceCidrList() { + return sourceCidrList; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -130,7 +143,7 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { @Override public void execute() { - PortForwardingRule rule = _rulesService.updatePortForwardingRule(getId(), getPrivatePort(), getPrivateEndPort(), getVirtualMachineId(), getVmGuestIp(), getCustomId(), getDisplay()); + PortForwardingRule rule = _rulesService.updatePortForwardingRule(this); FirewallRuleResponse fwResponse = new FirewallRuleResponse(); if (rule != null) { fwResponse = _responseGenerator.createPortForwardingRuleResponse(rule); diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java index f86d1ae85da..34798c4efe1 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java @@ -104,7 +104,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "the domain ID associated with the load balancer") private Long domainId; - @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, since = "4.18.0.0", description = "the CIDR list to allow traffic, " + @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, since = "4.18.0.0", description = "the source CIDR list to allow traffic from; " + "all other CIDRs will be blocked. Multiple entries must be separated by a single comma character (,). By default, all CIDRs are allowed.") private List cidrlist; diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java index 6dc51272fad..b7c14a6d3c8 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java @@ -371,7 +371,9 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd { "Parameter zoneids cannot combine all zones (-1) option with other zones"); String customHypervisor = HypervisorGuru.HypervisorCustomDisplayName.value(); - if (isDirectDownload() && !(getHypervisor().equalsIgnoreCase(Hypervisor.HypervisorType.KVM.toString()) + if (isDirectDownload() && + !(Hypervisor.HypervisorType.getType(getHypervisor()) + .isFunctionalitySupported(Hypervisor.HypervisorType.Functionality.DirectDownloadTemplate) || getHypervisor().equalsIgnoreCase(customHypervisor))) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, String.format("Parameter directdownload " + "is only allowed for KVM or %s templates", customHypervisor)); diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java index 65a3d6a7063..eb89115cf46 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java @@ -73,6 +73,10 @@ public class ResizeVolumeCmd extends BaseAsyncCmd implements UserCmd { description = "new disk offering id") private Long newDiskOfferingId; + @Parameter(name = ApiConstants.AUTO_MIGRATE, type = CommandType.BOOLEAN, required = false, + description = "Flag to allow automatic migration of the volume to another suitable storage pool that accommodates the new size", since = "4.20.1") + private Boolean autoMigrate; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -129,6 +133,10 @@ public class ResizeVolumeCmd extends BaseAsyncCmd implements UserCmd { return newDiskOfferingId; } + public boolean getAutoMigrate() { + return autoMigrate == null ? false : autoMigrate; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java index 7a84e85a4a6..6fc098295f6 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/AccountResponse.java @@ -271,6 +271,10 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou @Param(description = "The tagged resource limit and count for the account", since = "4.20.0") List taggedResources; + @SerializedName(ApiConstants.API_KEY_ACCESS) + @Param(description = "whether api key access is Enabled, Disabled or set to Inherit (it inherits the value from the parent)", since = "4.20.1.0") + ApiConstants.ApiKeyAccess apiKeyAccess; + @Override public String getObjectId() { return id; @@ -554,4 +558,8 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou public void setTaggedResourceLimitsAndCounts(List taggedResourceLimitsAndCounts) { this.taggedResources = taggedResourceLimitsAndCounts; } + + public void setApiKeyAccess(Boolean apiKeyAccess) { + this.apiKeyAccess = ApiConstants.ApiKeyAccess.fromBoolean(apiKeyAccess); + } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/ManagementServerResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/ManagementServerResponse.java index a471045eb67..fc7d3b722ab 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/ManagementServerResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/ManagementServerResponse.java @@ -24,7 +24,9 @@ import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import org.apache.cloudstack.management.ManagementServerHost.State; +import java.util.ArrayList; import java.util.Date; +import java.util.List; @EntityReference(value = ManagementServerHost.class) public class ManagementServerResponse extends BaseResponse { @@ -76,6 +78,10 @@ public class ManagementServerResponse extends BaseResponse { @Param(description = "the IP Address for this Management Server") private String serviceIp; + @SerializedName(ApiConstants.PEERS) + @Param(description = "the Management Server Peers") + private List peers; + public String getId() { return this.id; } @@ -171,4 +177,19 @@ public class ManagementServerResponse extends BaseResponse { public String getKernelVersion() { return kernelVersion; } + + public List getPeers() { + return peers; + } + + public void setPeers(List peers) { + this.peers = peers; + } + + public void addPeer(PeerManagementServerNodeResponse peer) { + if (peers == null) { + peers = new ArrayList<>(); + } + peers.add(peer); + } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/PeerManagementServerNodeResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/PeerManagementServerNodeResponse.java new file mode 100644 index 00000000000..802294171fa --- /dev/null +++ b/api/src/main/java/org/apache/cloudstack/api/response/PeerManagementServerNodeResponse.java @@ -0,0 +1,100 @@ +// 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 org.apache.cloudstack.api.response; + +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseResponse; +import org.apache.cloudstack.management.ManagementServerHost.State; + +import java.util.Date; + +public class PeerManagementServerNodeResponse extends BaseResponse { + + @SerializedName(ApiConstants.STATE) + @Param(description = "the state of the management server peer") + private State state; + + @SerializedName(ApiConstants.LAST_UPDATED) + @Param(description = "the last updated time of the management server peer state") + private Date lastUpdated; + + @SerializedName(ApiConstants.PEER_ID) + @Param(description = "the ID of the peer management server") + private String peerId; + + @SerializedName(ApiConstants.PEER_NAME) + @Param(description = "the name of the peer management server") + private String peerName; + + @SerializedName(ApiConstants.PEER_MSID) + @Param(description = "the management ID of the peer management server") + private String peerMsId; + + @SerializedName(ApiConstants.PEER_RUNID) + @Param(description = "the run ID of the peer management server") + private String peerRunId; + + @SerializedName(ApiConstants.PEER_STATE) + @Param(description = "the state of the peer management server") + private String peerState; + + @SerializedName(ApiConstants.PEER_SERVICE_IP) + @Param(description = "the IP Address for the peer Management Server") + private String peerServiceIp; + + @SerializedName(ApiConstants.PEER_SERVICE_PORT) + @Param(description = "the service port for the peer Management Server") + private String peerServicePort; + + public void setState(State state) { + this.state = state; + } + + public void setLastUpdated(Date lastUpdated) { + this.lastUpdated = lastUpdated; + } + + public void setPeerId(String peerId) { + this.peerId = peerId; + } + + public void setPeerName(String peerName) { + this.peerName = peerName; + } + + public void setPeerMsId(String peerMsId) { + this.peerMsId = peerMsId; + } + + public void setPeerRunId(String peerRunId) { + this.peerRunId = peerRunId; + } + + public void setPeerState(String peerState) { + this.peerState = peerState; + } + + public void setPeerServiceIp(String peerServiceIp) { + this.peerServiceIp = peerServiceIp; + } + + public void setPeerServicePort(String peerServicePort) { + this.peerServicePort = peerServicePort; + } +} diff --git a/api/src/main/java/org/apache/cloudstack/api/response/RegisterResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/RegisterResponse.java index 5faedabfc16..dd17cc5cc8a 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/RegisterResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/RegisterResponse.java @@ -18,19 +18,24 @@ package org.apache.cloudstack.api.response; import com.google.gson.annotations.SerializedName; +import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import com.cloud.serializer.Param; public class RegisterResponse extends BaseResponse { - @SerializedName("apikey") + @SerializedName(ApiConstants.API_KEY) @Param(description = "the api key of the registered user", isSensitive = true) private String apiKey; - @SerializedName("secretkey") + @SerializedName(ApiConstants.SECRET_KEY) @Param(description = "the secret key of the registered user", isSensitive = true) private String secretKey; + @SerializedName(ApiConstants.API_KEY_ACCESS) + @Param(description = "whether api key access is allowed or not", isSensitive = true) + private Boolean apiKeyAccess; + public String getApiKey() { return apiKey; } @@ -46,4 +51,8 @@ public class RegisterResponse extends BaseResponse { public void setSecretKey(String secretKey) { this.secretKey = secretKey; } + + public void setApiKeyAccess(Boolean apiKeyAccess) { + this.apiKeyAccess = apiKeyAccess; + } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/UserResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/UserResponse.java index 1a17f3b8698..5e4e6e1f3c8 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/UserResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/UserResponse.java @@ -67,7 +67,7 @@ public class UserResponse extends BaseResponse implements SetResourceIconRespons @Param(description = "the account type of the user") private Integer accountType; - @SerializedName("usersource") + @SerializedName(ApiConstants.USER_SOURCE) @Param(description = "the source type of the user in lowercase, such as native, ldap, saml2") private String userSource; @@ -128,6 +128,10 @@ public class UserResponse extends BaseResponse implements SetResourceIconRespons @Param(description = "true if user has two factor authentication is mandated", since = "4.18.0.0") private Boolean is2FAmandated; + @SerializedName(ApiConstants.API_KEY_ACCESS) + @Param(description = "whether api key access is Enabled, Disabled or set to Inherit (it inherits the value from the parent)", since = "4.20.1.0") + ApiConstants.ApiKeyAccess apiKeyAccess; + @Override public String getObjectId() { return this.getId(); @@ -309,4 +313,8 @@ public class UserResponse extends BaseResponse implements SetResourceIconRespons public void set2FAmandated(Boolean is2FAmandated) { this.is2FAmandated = is2FAmandated; } + + public void setApiKeyAccess(Boolean apiKeyAccess) { + this.apiKeyAccess = ApiConstants.ApiKeyAccess.fromBoolean(apiKeyAccess); + } } diff --git a/api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java index 143dfad0eaf..4a5279753a1 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java @@ -157,6 +157,11 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso @Param(description = "AS Number Range") private String asnRange; + @SerializedName(ApiConstants.ROUTED_MODE_ENABLED) + @Param(description = "true, if routed network/vpc is enabled", since = "4.20.1") + private boolean routedModeEnabled = false; + + public ZoneResponse() { tags = new LinkedHashSet(); } @@ -412,4 +417,12 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso public String getAsnRange() { return asnRange; } + + public boolean isRoutedModeEnabled() { + return routedModeEnabled; + } + + public void setRoutedModeEnabled(boolean routedModeEnabled) { + this.routedModeEnabled = routedModeEnabled; + } } diff --git a/api/src/main/java/org/apache/cloudstack/consoleproxy/ConsoleAccessManager.java b/api/src/main/java/org/apache/cloudstack/consoleproxy/ConsoleAccessManager.java index 5bd9699b201..23b571e7fae 100644 --- a/api/src/main/java/org/apache/cloudstack/consoleproxy/ConsoleAccessManager.java +++ b/api/src/main/java/org/apache/cloudstack/consoleproxy/ConsoleAccessManager.java @@ -44,7 +44,7 @@ public interface ConsoleAccessManager extends Manager, Configurable { void removeSessions(String[] sessionUuids); - void acquireSession(String sessionUuid); + void acquireSession(String sessionUuid, String clientAddress); String genAccessTicket(String host, String port, String sid, String tag, String sessionUuid); String genAccessTicket(String host, String port, String sid, String tag, Date normalizedHashTime, String sessionUuid); diff --git a/api/src/main/java/org/apache/cloudstack/network/RoutedIpv4Manager.java b/api/src/main/java/org/apache/cloudstack/network/RoutedIpv4Manager.java index 2f704e9f47d..221a550ad63 100644 --- a/api/src/main/java/org/apache/cloudstack/network/RoutedIpv4Manager.java +++ b/api/src/main/java/org/apache/cloudstack/network/RoutedIpv4Manager.java @@ -57,6 +57,13 @@ import java.util.List; public interface RoutedIpv4Manager extends PluggableService, Configurable { + ConfigKey RoutedNetworkVpcEnabled = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Boolean.class, + "routed.network.vpc.enabled", + "true", + "If true, the Routed network and VPC are enabled in the zone.", + true, + ConfigKey.Scope.Zone); + ConfigKey RoutedNetworkIPv4MaxCidrSize = new ConfigKey<>(ConfigKey.CATEGORY_NETWORK, Integer.class, "routed.network.ipv4.max.cidr.size", "30", "The maximum value of the cidr size for isolated networks in ROUTED mode", true, ConfigKey.Scope.Account); @@ -196,4 +203,6 @@ public interface RoutedIpv4Manager extends PluggableService, Configurable { void removeBgpPeersByAccountId(long accountId); void removeBgpPeersByDomainId(long domainId); + + Boolean isRoutedNetworkVpcEnabled(long zoneId); } diff --git a/api/src/main/java/org/apache/cloudstack/query/QueryService.java b/api/src/main/java/org/apache/cloudstack/query/QueryService.java index c93e43d9f37..88081494320 100644 --- a/api/src/main/java/org/apache/cloudstack/query/QueryService.java +++ b/api/src/main/java/org/apache/cloudstack/query/QueryService.java @@ -19,6 +19,7 @@ package org.apache.cloudstack.query; import java.util.List; import org.apache.cloudstack.affinity.AffinityGroupResponse; +import org.apache.cloudstack.api.ResponseObject; import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd; import org.apache.cloudstack.api.command.admin.host.ListHostTagsCmd; import org.apache.cloudstack.api.command.admin.host.ListHostsCmd; @@ -130,7 +131,7 @@ public interface QueryService { ConfigKey ReturnVmStatsOnVmList = new ConfigKey<>("Advanced", Boolean.class, "list.vm.default.details.stats", "true", "Determines whether VM stats should be returned when details are not explicitly specified in listVirtualMachines API request. When false, details default to [group, nics, secgrp, tmpl, servoff, diskoff, backoff, iso, volume, min, affgrp]. When true, all details are returned including 'stats'.", true, ConfigKey.Scope.Global); - ListResponse searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException; + ListResponse searchForUsers(ResponseObject.ResponseView responseView, ListUsersCmd cmd) throws PermissionDeniedException; ListResponse searchForUsers(Long domainId, boolean recursive) throws PermissionDeniedException; diff --git a/client/pom.xml b/client/pom.xml index d89dbbbbe9d..2ef6c910509 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT diff --git a/core/pom.xml b/core/pom.xml index 83cdee8cf4f..25ac46518b3 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT diff --git a/core/src/main/java/com/cloud/agent/api/ConsoleAccessAuthenticationCommand.java b/core/src/main/java/com/cloud/agent/api/ConsoleAccessAuthenticationCommand.java index 683d4afd5b2..ac6f15ec4c3 100644 --- a/core/src/main/java/com/cloud/agent/api/ConsoleAccessAuthenticationCommand.java +++ b/core/src/main/java/com/cloud/agent/api/ConsoleAccessAuthenticationCommand.java @@ -27,6 +27,7 @@ public class ConsoleAccessAuthenticationCommand extends AgentControlCommand { private String _sid; private String _ticket; private String sessionUuid; + private String clientAddress; private boolean _isReauthenticating; @@ -35,13 +36,14 @@ public class ConsoleAccessAuthenticationCommand extends AgentControlCommand { } public ConsoleAccessAuthenticationCommand(String host, String port, String vmId, String sid, String ticket, - String sessiontkn) { + String sessiontkn, String clientAddress) { _host = host; _port = port; _vmId = vmId; _sid = sid; _ticket = ticket; sessionUuid = sessiontkn; + this.clientAddress = clientAddress; } public String getHost() { @@ -79,4 +81,12 @@ public class ConsoleAccessAuthenticationCommand extends AgentControlCommand { public void setSessionUuid(String sessionUuid) { this.sessionUuid = sessionUuid; } + + public String getClientAddress() { + return clientAddress; + } + + public void setClientAddress(String clientAddress) { + this.clientAddress = clientAddress; + } } diff --git a/core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java b/core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java index 829888570a6..174348f4f18 100644 --- a/core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java +++ b/core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java @@ -20,6 +20,8 @@ import org.apache.cloudstack.vm.UnmanagedInstanceTO; public class ConvertInstanceAnswer extends Answer { + private String temporaryConvertUuid; + public ConvertInstanceAnswer() { super(); } @@ -34,6 +36,15 @@ public class ConvertInstanceAnswer extends Answer { this.convertedInstance = convertedInstance; } + public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) { + super(command, true, ""); + this.temporaryConvertUuid = temporaryConvertUuid; + } + + public String getTemporaryConvertUuid() { + return temporaryConvertUuid; + } + public UnmanagedInstanceTO getConvertedInstance() { return convertedInstance; } diff --git a/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java b/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java new file mode 100644 index 00000000000..2a8f8704e3f --- /dev/null +++ b/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java @@ -0,0 +1,40 @@ +// 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.agent.api; + +import org.apache.cloudstack.vm.UnmanagedInstanceTO; + +public class ImportConvertedInstanceAnswer extends Answer { + + public ImportConvertedInstanceAnswer() { + super(); + } + private UnmanagedInstanceTO convertedInstance; + + public ImportConvertedInstanceAnswer(Command command, boolean success, String details) { + super(command, success, details); + } + + public ImportConvertedInstanceAnswer(Command command, UnmanagedInstanceTO convertedInstance) { + super(command, true, ""); + this.convertedInstance = convertedInstance; + } + + public UnmanagedInstanceTO getConvertedInstance() { + return convertedInstance; + } +} diff --git a/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java b/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java new file mode 100644 index 00000000000..9d50e852ced --- /dev/null +++ b/core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java @@ -0,0 +1,63 @@ +// 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.agent.api; + +import com.cloud.agent.api.to.DataStoreTO; +import com.cloud.agent.api.to.RemoteInstanceTO; + +import java.util.List; + +public class ImportConvertedInstanceCommand extends Command { + + private RemoteInstanceTO sourceInstance; + private List destinationStoragePools; + private DataStoreTO conversionTemporaryLocation; + private String temporaryConvertUuid; + + public ImportConvertedInstanceCommand() { + } + + public ImportConvertedInstanceCommand(RemoteInstanceTO sourceInstance, + List destinationStoragePools, + DataStoreTO conversionTemporaryLocation, String temporaryConvertUuid) { + this.sourceInstance = sourceInstance; + this.destinationStoragePools = destinationStoragePools; + this.conversionTemporaryLocation = conversionTemporaryLocation; + this.temporaryConvertUuid = temporaryConvertUuid; + } + + public RemoteInstanceTO getSourceInstance() { + return sourceInstance; + } + + public List getDestinationStoragePools() { + return destinationStoragePools; + } + + public DataStoreTO getConversionTemporaryLocation() { + return conversionTemporaryLocation; + } + + public String getTemporaryConvertUuid() { + return temporaryConvertUuid; + } + + @Override + public boolean executeInSequence() { + return false; + } +} diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetPortForwardingRulesConfigItem.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetPortForwardingRulesConfigItem.java index c9d0e74e2e4..4daef64ed8a 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetPortForwardingRulesConfigItem.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetPortForwardingRulesConfigItem.java @@ -41,7 +41,7 @@ public class SetPortForwardingRulesConfigItem extends AbstractConfigItemFacade { for (final PortForwardingRuleTO rule : command.getRules()) { final ForwardingRule fwdRule = new ForwardingRule(rule.revoked(), rule.getProtocol().toLowerCase(), rule.getSrcIp(), rule.getStringSrcPortRange(), rule.getDstIp(), - rule.getStringDstPortRange()); + rule.getStringDstPortRange(), rule.getSourceCidrListAsString()); rules.add(fwdRule); } diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/ForwardingRule.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/ForwardingRule.java index cf3e43d1c01..1dc1cc855c4 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/ForwardingRule.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/model/ForwardingRule.java @@ -26,18 +26,21 @@ public class ForwardingRule { private String sourcePortRange; private String destinationIpAddress; private String destinationPortRange; + private String sourceCidrList; public ForwardingRule() { // Empty constructor for (de)serialization } - public ForwardingRule(boolean revoke, String protocol, String sourceIpAddress, String sourcePortRange, String destinationIpAddress, String destinationPortRange) { + public ForwardingRule(boolean revoke, String protocol, String sourceIpAddress, String sourcePortRange, String destinationIpAddress, String destinationPortRange, + String sourceCidrList) { this.revoke = revoke; this.protocol = protocol; this.sourceIpAddress = sourceIpAddress; this.sourcePortRange = sourcePortRange; this.destinationIpAddress = destinationIpAddress; this.destinationPortRange = destinationPortRange; + this.sourceCidrList = sourceCidrList; } public boolean isRevoke() { @@ -88,4 +91,8 @@ public class ForwardingRule { this.destinationPortRange = destinationPortRange; } + public String getSourceCidrList() { + return sourceCidrList; + } + } diff --git a/debian/changelog b/debian/changelog index cbc4fcfdb2d..d17676ef268 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,12 @@ -cloudstack (4.20.0.0-SNAPSHOT) unstable; urgency=low +cloudstack (4.21.0.0-SNAPSHOT) unstable; urgency=low - * Update the version to 4.20.0.0-SNAPSHOT + * Update the version to 4.21.0.0-SNAPSHOT + + -- the Apache CloudStack project Tue, 19 Nov 2024 08:54:07 -0300 + +cloudstack (4.21.0.0-SNAPSHOT-SNAPSHOT) unstable; urgency=low + + * Update the version to 4.21.0.0-SNAPSHOT-SNAPSHOT -- the Apache CloudStack project Mon, 29 Jan 2024 10:21:52 +0530 diff --git a/debian/cloudstack-cli.install b/debian/cloudstack-cli.install index 978b68af62a..13a83393a91 100644 --- a/debian/cloudstack-cli.install +++ b/debian/cloudstack-cli.install @@ -5,9 +5,9 @@ # 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 diff --git a/debian/cloudstack-docs.install b/debian/cloudstack-docs.install index 978b68af62a..13a83393a91 100644 --- a/debian/cloudstack-docs.install +++ b/debian/cloudstack-docs.install @@ -5,9 +5,9 @@ # 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 diff --git a/debian/control b/debian/control index ed4f95d8e49..c0cb95af035 100644 --- a/debian/control +++ b/debian/control @@ -24,7 +24,7 @@ Description: CloudStack server library Package: cloudstack-agent Architecture: all -Depends: ${python:Depends}, ${python3:Depends}, openjdk-17-jre-headless | java17-runtime-headless | java17-runtime | zulu-17, cloudstack-common (= ${source:Version}), lsb-base (>= 9), openssh-client, qemu-kvm (>= 2.5) | qemu-system-x86 (>= 5.2), libvirt-bin (>= 1.3) | libvirt-daemon-system (>= 3.0), iproute2, ebtables, vlan, ipset, python3-libvirt, ethtool, iptables, cryptsetup, rng-tools, rsync, lsb-release, ufw, apparmor, cpu-checker +Depends: ${python:Depends}, ${python3:Depends}, openjdk-17-jre-headless | java17-runtime-headless | java17-runtime | zulu-17, cloudstack-common (= ${source:Version}), lsb-base (>= 9), openssh-client, qemu-kvm (>= 2.5) | qemu-system-x86 (>= 5.2), libvirt-bin (>= 1.3) | libvirt-daemon-system (>= 3.0), iproute2, ebtables, vlan, ipset, python3-libvirt, ethtool, iptables, cryptsetup, rng-tools, rsync, lsb-release, ufw, apparmor, cpu-checker, libvirt-daemon-driver-storage-rbd Recommends: init-system-helpers Conflicts: cloud-agent, cloud-agent-libs, cloud-agent-deps, cloud-agent-scripts Description: CloudStack agent diff --git a/developer/pom.xml b/developer/pom.xml index b44446ec0a5..c573c03d008 100644 --- a/developer/pom.xml +++ b/developer/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT diff --git a/engine/api/pom.xml b/engine/api/pom.xml index 1112e6eff8b..25aaa1365df 100644 --- a/engine/api/pom.xml +++ b/engine/api/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/engine/components-api/pom.xml b/engine/components-api/pom.xml index b06b644d67f..0b30decffda 100644 --- a/engine/components-api/pom.xml +++ b/engine/components-api/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/engine/components-api/src/main/java/com/cloud/capacity/CapacityManager.java b/engine/components-api/src/main/java/com/cloud/capacity/CapacityManager.java index 1c3edad886b..e1bb10f5d26 100644 --- a/engine/components-api/src/main/java/com/cloud/capacity/CapacityManager.java +++ b/engine/components-api/src/main/java/com/cloud/capacity/CapacityManager.java @@ -40,6 +40,7 @@ public interface CapacityManager { static final String StorageCapacityDisableThresholdCK = "pool.storage.capacity.disablethreshold"; static final String StorageOverprovisioningFactorCK = "storage.overprovisioning.factor"; static final String StorageAllocatedCapacityDisableThresholdCK = "pool.storage.allocated.capacity.disablethreshold"; + static final String StorageAllocatedCapacityDisableThresholdForVolumeResizeCK = "pool.storage.allocated.resize.capacity.disablethreshold"; static final ConfigKey CpuOverprovisioningFactor = new ConfigKey<>( @@ -118,6 +119,17 @@ public interface CapacityManager { "Percentage (as a value between 0 and 1) of secondary storage capacity threshold.", true); + static final ConfigKey StorageAllocatedCapacityDisableThresholdForVolumeSize = + new ConfigKey<>( + ConfigKey.CATEGORY_ALERT, + Double.class, + StorageAllocatedCapacityDisableThresholdForVolumeResizeCK, + "0.90", + "Percentage (as a value between 0 and 1) of allocated storage utilization above which allocators will disable using the pool for volume resize. " + + "This is applicable only when volume.resize.allowed.beyond.allocation is set to true.", + true, + ConfigKey.Scope.Zone); + public boolean releaseVmCapacity(VirtualMachine vm, boolean moveFromReserved, boolean moveToReservered, Long hostId); void allocateVmCapacity(VirtualMachine vm, boolean fromLastHost); diff --git a/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java b/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java index ae47b1d76ed..728f5a2b180 100644 --- a/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java +++ b/engine/components-api/src/main/java/com/cloud/ha/HighAvailabilityManager.java @@ -32,7 +32,7 @@ import java.util.List; */ public interface HighAvailabilityManager extends Manager { - public ConfigKey ForceHA = new ConfigKey<>("Advanced", Boolean.class, "force.ha", "false", + ConfigKey ForceHA = new ConfigKey<>("Advanced", Boolean.class, "force.ha", "false", "Force High-Availability to happen even if the VM says no.", true, Cluster); ConfigKey HAWorkers = new ConfigKey<>("Advanced", Integer.class, "ha.workers", "5", @@ -112,7 +112,7 @@ public interface HighAvailabilityManager extends Manager { void cancelDestroy(VMInstanceVO vm, Long hostId); - void scheduleDestroy(VMInstanceVO vm, long hostId); + boolean scheduleDestroy(VMInstanceVO vm, long hostId); /** * Schedule restarts for all vms running on the host. @@ -143,7 +143,7 @@ public interface HighAvailabilityManager extends Manager { * @param host host the virtual machine is on. * @param type which type of stop is requested. */ - void scheduleStop(VMInstanceVO vm, long hostId, WorkType type); + boolean scheduleStop(VMInstanceVO vm, long hostId, WorkType type); void cancelScheduledMigrations(HostVO host); diff --git a/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java b/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java index a340f49c13f..e7f02e62045 100644 --- a/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java +++ b/engine/components-api/src/main/java/com/cloud/network/vpc/VpcManager.java @@ -37,8 +37,26 @@ import com.cloud.network.PhysicalNetwork; import com.cloud.network.addr.PublicIp; import com.cloud.offering.NetworkOffering; import com.cloud.user.Account; +import org.apache.cloudstack.framework.config.ConfigKey; public interface VpcManager { + ConfigKey VpcTierNamePrepend = new ConfigKey<>(Boolean.class, + "vpc.tier.name.prepend", + ConfigKey.CATEGORY_NETWORK, + "false", + "Whether to prepend the VPC name to the VPC tier network name", + true, + ConfigKey.Scope.Global, + null); + ConfigKey VpcTierNamePrependDelimiter = new ConfigKey<>(String.class, + "vpc.tier.name.prepend.delimiter", + ConfigKey.CATEGORY_NETWORK, + " ", + "Delimiter string to use between the VPC and the VPC tier name", + true, + ConfigKey.Scope.Global, + null); + /** * Returns all the Guest networks that are part of VPC * diff --git a/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java b/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java index c3909bc56b0..b5153668899 100644 --- a/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java +++ b/engine/components-api/src/main/java/com/cloud/storage/StorageManager.java @@ -209,6 +209,11 @@ public interface StorageManager extends StorageService { ConfigKey HEURISTICS_SCRIPT_TIMEOUT = new ConfigKey<>("Advanced", Long.class, "heuristics.script.timeout", "3000", "The maximum runtime, in milliseconds, to execute the heuristic rule; if it is reached, a timeout will happen.", true); + ConfigKey AllowVolumeReSizeBeyondAllocation = new ConfigKey("Advanced", Boolean.class, "volume.resize.allowed.beyond.allocation", "false", + "Determines whether volume size can exceed the pool capacity allocation disable threshold (pool.storage.allocated.capacity.disablethreshold) " + + "when resize a volume upto resize capacity disable threshold (pool.storage.allocated.resize.capacity.disablethreshold)", + true, ConfigKey.Scope.Zone); + /** * should we execute in sequence not involving any storages? * @return tru if commands should execute in sequence diff --git a/engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java b/engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java index 82456004cc3..a01d4ee5cae 100644 --- a/engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java +++ b/engine/components-api/src/main/java/com/cloud/vm/snapshot/VMSnapshotManager.java @@ -31,7 +31,7 @@ public interface VMSnapshotManager extends VMSnapshotService, Manager { static final ConfigKey VMSnapshotExpireInterval = new ConfigKey("Advanced", Integer.class, "vmsnapshot.expire.interval", "-1", "VM Snapshot expire interval in hours", true, ConfigKey.Scope.Account); - public static final int VMSNAPSHOTMAX = 10; + ConfigKey VMSnapshotMax = new ConfigKey("Advanced", Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a single vm", true, ConfigKey.Scope.Global); /** * Delete all VM snapshots belonging to one VM diff --git a/engine/orchestration/pom.xml b/engine/orchestration/pom.xml index e4953fc0cbe..bf8ab14c952 100755 --- a/engine/orchestration/pom.xml +++ b/engine/orchestration/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentAttache.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentAttache.java index 173fd9fc704..c0f7586aee0 100644 --- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentAttache.java +++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentAttache.java @@ -47,6 +47,7 @@ import com.cloud.agent.api.CleanupNetworkRulesCmd; import com.cloud.agent.api.Command; import com.cloud.agent.api.CreateStoragePoolCommand; import com.cloud.agent.api.DeleteStoragePoolCommand; +import com.cloud.agent.api.HandleConfigDriveIsoCommand; import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.ModifySshKeysCommand; @@ -122,11 +123,10 @@ public abstract class AgentAttache { public final static String[] s_commandsAllowedInMaintenanceMode = new String[] { MaintainCommand.class.toString(), MigrateCommand.class.toString(), StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(), - ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), - CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString(), - ModifyTargetsCommand.class.toString(), ModifySshKeysCommand.class.toString(), - CreateStoragePoolCommand.class.toString(), DeleteStoragePoolCommand.class.toString(), ModifyStoragePoolCommand.class.toString(), - SetupMSListCommand.class.toString(), RollingMaintenanceCommand.class.toString(), CleanupPersistentNetworkResourceCommand.class.toString()}; + ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), CleanupNetworkRulesCmd.class.toString(), + CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString(), ModifyTargetsCommand.class.toString(), + ModifySshKeysCommand.class.toString(), CreateStoragePoolCommand.class.toString(), DeleteStoragePoolCommand.class.toString(), ModifyStoragePoolCommand.class.toString(), + SetupMSListCommand.class.toString(), RollingMaintenanceCommand.class.toString(), CleanupPersistentNetworkResourceCommand.class.toString(), HandleConfigDriveIsoCommand.class.toString()}; protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] { StartCommand.class.toString(), CreateCommand.class.toString() }; static { Arrays.sort(s_commandsAllowedInMaintenanceMode); diff --git a/engine/pom.xml b/engine/pom.xml index 5e52544aeca..1df7d84284f 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/engine/schema/pom.xml b/engine/schema/pom.xml index 82120ae70cc..8238da84835 100644 --- a/engine/schema/pom.xml +++ b/engine/schema/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDao.java b/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDao.java index 55c454860ef..df5b6b5d647 100644 --- a/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDao.java +++ b/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDao.java @@ -29,4 +29,6 @@ public interface FirewallRulesCidrsDao extends GenericDao listByFirewallRuleId(long firewallRuleId); + + void updateSourceCidrsForRule(Long firewallRuleId, List sourceCidrList); } diff --git a/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java b/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java index fdd1e0ec43a..6279289bdfe 100644 --- a/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Component; import com.cloud.utils.db.DB; @@ -45,7 +46,7 @@ public class FirewallRulesCidrsDaoImpl extends GenericDaoBase results = search(sc, null); - List cidrs = new ArrayList(results.size()); + List cidrs = new ArrayList<>(results.size()); for (FirewallRulesCidrsVO result : results) { cidrs.add(result.getCidr()); } @@ -63,9 +64,27 @@ public class FirewallRulesCidrsDaoImpl extends GenericDaoBase sourceCidrList) { + TransactionLegacy txn = TransactionLegacy.currentTxn(); + txn.start(); + + SearchCriteria sc = CidrsSearch.create(); + sc.setParameters("firewallRuleId", firewallRuleId); + remove(sc); + + persist(firewallRuleId, sourceCidrList); + + txn.commit(); + } + @Override @DB public void persist(long firewallRuleId, List sourceCidrs) { + if (CollectionUtils.isEmpty(sourceCidrs)) { + return; + } + TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); diff --git a/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesDaoImpl.java b/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesDaoImpl.java index 5eaa44ca012..feed641df77 100644 --- a/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesDaoImpl.java @@ -258,9 +258,6 @@ public class FirewallRulesDaoImpl extends GenericDaoBase i } public void saveSourceCidrs(FirewallRuleVO firewallRule, List cidrList) { - if (cidrList == null) { - return; - } _firewallRulesCidrsDao.persist(firewallRule.getId(), cidrList); } diff --git a/engine/schema/src/main/java/com/cloud/network/rules/PortForwardingRuleVO.java b/engine/schema/src/main/java/com/cloud/network/rules/PortForwardingRuleVO.java index e1a698881f3..576e2f8172e 100644 --- a/engine/schema/src/main/java/com/cloud/network/rules/PortForwardingRuleVO.java +++ b/engine/schema/src/main/java/com/cloud/network/rules/PortForwardingRuleVO.java @@ -25,6 +25,7 @@ import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; +import javax.persistence.Transient; import com.cloud.utils.net.Ip; @@ -47,21 +48,30 @@ public class PortForwardingRuleVO extends FirewallRuleVO implements PortForwardi @Column(name = "instance_id") private long virtualMachineId; + @Transient + List sourceCidrs; + public PortForwardingRuleVO() { } public PortForwardingRuleVO(String xId, long srcIpId, int srcPortStart, int srcPortEnd, Ip dstIp, int dstPortStart, int dstPortEnd, String protocol, long networkId, - long accountId, long domainId, long instanceId) { - super(xId, srcIpId, srcPortStart, srcPortEnd, protocol, networkId, accountId, domainId, Purpose.PortForwarding, null, null, null, null, null); + long accountId, long domainId, long instanceId, List sourceCidrs) { + super(xId, srcIpId, srcPortStart, srcPortEnd, protocol, networkId, accountId, domainId, Purpose.PortForwarding, sourceCidrs, null, null, null, null); this.destinationIpAddress = dstIp; this.virtualMachineId = instanceId; this.destinationPortStart = dstPortStart; this.destinationPortEnd = dstPortEnd; + this.sourceCidrs = sourceCidrs; } - public PortForwardingRuleVO(String xId, long srcIpId, int srcPort, Ip dstIp, int dstPort, String protocol, List sourceCidrs, long networkId, long accountId, - long domainId, long instanceId) { - this(xId, srcIpId, srcPort, srcPort, dstIp, dstPort, dstPort, protocol.toLowerCase(), networkId, accountId, domainId, instanceId); + public PortForwardingRuleVO(String xId, long srcIpId, int srcPortStart, int srcPortEnd, Ip dstIp, int dstPortStart, int dstPortEnd, String protocol, long networkId, + long accountId, long domainId, long instanceId) { + this(xId, srcIpId, srcPortStart, srcPortEnd, dstIp, dstPortStart, dstPortEnd, protocol.toLowerCase(), networkId, accountId, domainId, instanceId, null); + } + + public PortForwardingRuleVO(String xId, long srcIpId, int srcPort, Ip dstIp, int dstPort, String protocol, long networkId, long accountId, + long domainId, long instanceId) { + this(xId, srcIpId, srcPort, srcPort, dstIp, dstPort, dstPort, protocol.toLowerCase(), networkId, accountId, domainId, instanceId, null); } @Override @@ -106,4 +116,13 @@ public class PortForwardingRuleVO extends FirewallRuleVO implements PortForwardi return null; } + public void setSourceCidrList(List sourceCidrs) { + this.sourceCidrs = sourceCidrs; + } + + @Override + public List getSourceCidrList() { + return sourceCidrs; + } + } diff --git a/engine/schema/src/main/java/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java b/engine/schema/src/main/java/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java index aa46015acff..637f47731b4 100644 --- a/engine/schema/src/main/java/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java @@ -31,6 +31,9 @@ import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.SearchCriteria.Op; +import com.cloud.utils.db.Transaction; +import com.cloud.utils.db.TransactionCallback; +import com.cloud.utils.db.TransactionLegacy; @Component public class PortForwardingRulesDaoImpl extends GenericDaoBase implements PortForwardingRulesDao { @@ -42,7 +45,7 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase ActiveRulesSearchByAccount; @Inject - protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao; + protected FirewallRulesCidrsDao portForwardingRulesCidrsDao; protected PortForwardingRulesDaoImpl() { super(); @@ -194,4 +197,43 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase) transactionStatus -> { + PortForwardingRuleVO dbPfRule = super.persist(portForwardingRule); + + portForwardingRulesCidrsDao.persist(portForwardingRule.getId(), portForwardingRule.getSourceCidrList()); + List cidrList = portForwardingRulesCidrsDao.getSourceCidrs(portForwardingRule.getId()); + portForwardingRule.setSourceCidrList(cidrList); + + return dbPfRule; + }); + + } + + @Override + public boolean update(Long id, PortForwardingRuleVO entity) { + TransactionLegacy txn = TransactionLegacy.currentTxn(); + txn.start(); + + boolean success = super.update(id, entity); + if (!success) { + return false; + } + + portForwardingRulesCidrsDao.updateSourceCidrsForRule(entity.getId(), entity.getSourceCidrList()); + txn.commit(); + + return true; + } + + @Override + public PortForwardingRuleVO findById(Long id) { + PortForwardingRuleVO rule = super.findById(id); + + List sourceCidrList = portForwardingRulesCidrsDao.getSourceCidrs(id); + rule.setSourceCidrList(sourceCidrList); + + return rule; + } } diff --git a/engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDao.java b/engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDao.java index 730182a1cb5..f4b2f646002 100644 --- a/engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDao.java +++ b/engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDao.java @@ -47,6 +47,8 @@ public interface ProjectAccountDao extends GenericDao { void removeAccountFromProjects(long accountId); + void removeUserFromProjects(long userId); + boolean canUserModifyProject(long projectId, long accountId, long userId); List listUsersOrAccountsByRole(long id); diff --git a/engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDaoImpl.java b/engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDaoImpl.java index 8947cc600b3..b6eb6d44cea 100644 --- a/engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/projects/dao/ProjectAccountDaoImpl.java @@ -192,6 +192,17 @@ public class ProjectAccountDaoImpl extends GenericDaoBase sc = AllFieldsSearch.create(); + sc.setParameters("userId", userId); + + int removedCount = remove(sc); + if (removedCount > 0) { + logger.debug(String.format("Removed user [%s] from %s project(s).", userId, removedCount)); + } + } + @Override public boolean canUserModifyProject(long projectId, long accountId, long userId) { SearchCriteria sc = AllFieldsSearch.create(); diff --git a/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java b/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java index c105acf40b8..ea57ef91237 100644 --- a/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java +++ b/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java @@ -48,31 +48,34 @@ public class VolumeVO implements Volume { @TableGenerator(name = "volume_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "volume_seq", allocationSize = 1) @GeneratedValue(strategy = GenerationType.TABLE) @Column(name = "id") - long id; + private long id; + + @Column(name = "last_id") + private long lastId; @Column(name = "name") - String name; + private String name; @Column(name = "pool_id") - Long poolId; + private Long poolId; @Column(name = "last_pool_id") - Long lastPoolId; + private Long lastPoolId; @Column(name = "account_id") - long accountId; + private long accountId; @Column(name = "domain_id") - long domainId; + private long domainId; @Column(name = "instance_id") - Long instanceId = null; + private Long instanceId = null; @Column(name = "device_id") - Long deviceId = null; + private Long deviceId = null; @Column(name = "size") - Long size; + private Long size; @Column(name = "min_iops") private Long minIops; @@ -81,50 +84,50 @@ public class VolumeVO implements Volume { private Long maxIops; @Column(name = "folder") - String folder; + private String folder; @Column(name = "path") - String path; + private String path; @Column(name = "pod_id") - Long podId; + private Long podId; @Column(name = "created") - Date created; + private Date created; @Column(name = "attached") @Temporal(value = TemporalType.TIMESTAMP) - Date attached; + private Date attached; @Column(name = "data_center_id") - long dataCenterId; + private long dataCenterId; @Column(name = "host_ip") - String hostip; + private String hostIp; @Column(name = "disk_offering_id") - long diskOfferingId; + private long diskOfferingId; @Column(name = "template_id") - Long templateId; + private Long templateId; @Column(name = "first_snapshot_backup_uuid") - String firstSnapshotBackupUuid; + private String firstSnapshotBackupUuid; @Column(name = "volume_type") @Enumerated(EnumType.STRING) - Type volumeType = Volume.Type.UNKNOWN; + private Type volumeType = Volume.Type.UNKNOWN; @Column(name = "pool_type") @Convert(converter = StoragePoolTypeConverter.class) - StoragePoolType poolType; + private StoragePoolType poolType; @Column(name = GenericDao.REMOVED_COLUMN) - Date removed; + private Date removed; @Column(name = "updated") @Temporal(value = TemporalType.TIMESTAMP) - Date updated; + private Date updated; @Column(name = "update_count", updatable = true, nullable = false) protected long updatedCount; // This field should be updated everytime the @@ -133,17 +136,17 @@ public class VolumeVO implements Volume { // dao code. @Column(name = "recreatable") - boolean recreatable; + private boolean recreatable; @Column(name = "state") @Enumerated(value = EnumType.STRING) private State state; @Column(name = "chain_info", length = 65535) - String chainInfo; + private String chainInfo; @Column(name = "uuid") - String uuid; + private String uuid; @Column(name = "format") private Storage.ImageFormat format; @@ -168,7 +171,7 @@ public class VolumeVO implements Volume { @Transient // @Column(name="reservation") - String reservationId; + private String reservationId; @Column(name = "hv_ss_reserve") private Integer hypervisorSnapshotReserve; @@ -428,11 +431,11 @@ public class VolumeVO implements Volume { } public String getHostIp() { - return hostip; + return hostIp; } public void setHostIp(String hostip) { - this.hostip = hostip; + this.hostIp = hostip; } public void setPodId(Long podId) { @@ -690,4 +693,12 @@ public class VolumeVO implements Volume { public void setDeleteProtection(boolean deleteProtection) { this.deleteProtection = deleteProtection; } + + public long getLastId() { + return lastId; + } + + public void setLastId(long lastId) { + this.lastId = lastId; + } } diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/VolumeStatsDaoImpl.java b/engine/schema/src/main/java/com/cloud/storage/dao/VolumeStatsDaoImpl.java index d1149e47408..e4c19fd1666 100644 --- a/engine/schema/src/main/java/com/cloud/storage/dao/VolumeStatsDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/storage/dao/VolumeStatsDaoImpl.java @@ -126,14 +126,7 @@ public class VolumeStatsDaoImpl extends GenericDaoBase impl logger.debug(String.format("Starting to remove all volume_stats rows older than [%s].", limitDate)); - long totalRemoved = 0; - long removed; - - do { - removed = expunge(sc, limitPerQuery); - totalRemoved += removed; - logger.trace(String.format("Removed [%s] volume_stats rows on the last update and a sum of [%s] volume_stats rows older than [%s] until now.", removed, totalRemoved, limitDate)); - } while (limitPerQuery > 0 && removed >= limitPerQuery); + long totalRemoved = batchExpunge(sc, limitPerQuery); logger.info(String.format("Removed a total of [%s] volume_stats rows older than [%s].", totalRemoved, limitDate)); } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java index cb219007325..1e3b3a7e5ec 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -88,6 +88,8 @@ import com.cloud.upgrade.dao.Upgrade41800to41810; import com.cloud.upgrade.dao.Upgrade41810to41900; import com.cloud.upgrade.dao.Upgrade41900to41910; import com.cloud.upgrade.dao.Upgrade41910to42000; +import com.cloud.upgrade.dao.Upgrade42000to42010; +import com.cloud.upgrade.dao.Upgrade42010to42100; import com.cloud.upgrade.dao.Upgrade420to421; import com.cloud.upgrade.dao.Upgrade421to430; import com.cloud.upgrade.dao.Upgrade430to440; @@ -230,6 +232,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { .next("4.18.1.0", new Upgrade41810to41900()) .next("4.19.0.0", new Upgrade41900to41910()) .next("4.19.1.0", new Upgrade41910to42000()) + .next("4.20.0.0", new Upgrade42000to42010()) + .next("4.20.1.0", new Upgrade42010to42100()) .build(); } diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41910to41920.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41910to41920.java new file mode 100644 index 00000000000..6215021473e --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41910to41920.java @@ -0,0 +1,66 @@ +// 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.upgrade.dao; + +import com.cloud.utils.exception.CloudRuntimeException; + +import java.io.InputStream; +import java.sql.Connection; + +public class Upgrade41910to41920 implements DbUpgrade { + + @Override + public String[] getUpgradableVersionRange() { + return new String[]{"4.19.1.0", "4.19.2.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.19.2.0"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } + + @Override + public InputStream[] getPrepareScripts() { + final String scriptFile = "META-INF/db/schema-41910to41920.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[]{script}; + } + + @Override + public void performDataMigration(Connection conn) { + } + + @Override + public InputStream[] getCleanupScripts() { + final String scriptFile = "META-INF/db/schema-41910to41920-cleanup.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[]{script}; + } +} diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42000to42010.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42000to42010.java new file mode 100644 index 00000000000..197ca1cb34c --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42000to42010.java @@ -0,0 +1,83 @@ +// 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.upgrade.dao; + +import java.io.InputStream; +import java.sql.Connection; + +import com.cloud.upgrade.SystemVmTemplateRegistration; +import com.cloud.utils.exception.CloudRuntimeException; + +public class Upgrade42000to42010 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate { + private SystemVmTemplateRegistration systemVmTemplateRegistration; + + @Override + public String[] getUpgradableVersionRange() { + return new String[] {"4.20.0.0", "4.20.1.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.20.1.0"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } + + @Override + public InputStream[] getPrepareScripts() { + final String scriptFile = "META-INF/db/schema-42000to42010.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[] {script}; + } + + @Override + public void performDataMigration(Connection conn) { + } + + @Override + public InputStream[] getCleanupScripts() { + final String scriptFile = "META-INF/db/schema-42000to42010-cleanup.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[] {script}; + } + + private void initSystemVmTemplateRegistration() { + systemVmTemplateRegistration = new SystemVmTemplateRegistration(""); + } + + @Override + public void updateSystemVmTemplates(Connection conn) { + logger.debug("Updating System Vm template IDs"); + initSystemVmTemplateRegistration(); + try { + systemVmTemplateRegistration.updateSystemVmTemplates(conn); + } catch (Exception e) { + throw new CloudRuntimeException("Failed to find / register SystemVM template(s)"); + } + } +} diff --git a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42010to42100.java b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42010to42100.java new file mode 100644 index 00000000000..06a68ec3d8b --- /dev/null +++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42010to42100.java @@ -0,0 +1,83 @@ +// 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.upgrade.dao; + +import com.cloud.upgrade.SystemVmTemplateRegistration; +import com.cloud.utils.exception.CloudRuntimeException; + +import java.io.InputStream; +import java.sql.Connection; + +public class Upgrade42010to42100 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate { + private SystemVmTemplateRegistration systemVmTemplateRegistration; + + @Override + public String[] getUpgradableVersionRange() { + return new String[] {"4.20.1.0", "4.21.0.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.21.0.0"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } + + @Override + public InputStream[] getPrepareScripts() { + final String scriptFile = "META-INF/db/schema-42010to42100.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[] {script}; + } + + @Override + public void performDataMigration(Connection conn) { + } + + @Override + public InputStream[] getCleanupScripts() { + final String scriptFile = "META-INF/db/schema-42010to42100-cleanup.sql"; + final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile); + if (script == null) { + throw new CloudRuntimeException("Unable to find " + scriptFile); + } + + return new InputStream[] {script}; + } + + private void initSystemVmTemplateRegistration() { + systemVmTemplateRegistration = new SystemVmTemplateRegistration(""); + } + + @Override + public void updateSystemVmTemplates(Connection conn) { + logger.debug("Updating System Vm template IDs"); + initSystemVmTemplateRegistration(); + try { + systemVmTemplateRegistration.updateSystemVmTemplates(conn); + } catch (Exception e) { + throw new CloudRuntimeException("Failed to find / register SystemVM template(s)"); + } + } +} diff --git a/engine/schema/src/main/java/com/cloud/user/AccountVO.java b/engine/schema/src/main/java/com/cloud/user/AccountVO.java index f04b2bafbde..74a538565d7 100644 --- a/engine/schema/src/main/java/com/cloud/user/AccountVO.java +++ b/engine/schema/src/main/java/com/cloud/user/AccountVO.java @@ -77,6 +77,9 @@ public class AccountVO implements Account { @Column(name = "default") boolean isDefault; + @Column(name = "api_key_access") + private Boolean apiKeyAccess; + public AccountVO() { uuid = UUID.randomUUID().toString(); } @@ -229,4 +232,14 @@ public class AccountVO implements Account { public String reflectionToString() { return ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "id", "uuid", "accountName", "domainId"); } + + @Override + public void setApiKeyAccess(Boolean apiKeyAccess) { + this.apiKeyAccess = apiKeyAccess; + } + + @Override + public Boolean getApiKeyAccess() { + return apiKeyAccess; + } } diff --git a/engine/schema/src/main/java/com/cloud/user/UserVO.java b/engine/schema/src/main/java/com/cloud/user/UserVO.java index 69970bf2d2c..7dac26429ac 100644 --- a/engine/schema/src/main/java/com/cloud/user/UserVO.java +++ b/engine/schema/src/main/java/com/cloud/user/UserVO.java @@ -115,6 +115,9 @@ public class UserVO implements User, Identity, InternalIdentity { @Column(name = "key_for_2fa") private String keyFor2fa; + @Column(name = "api_key_access") + private Boolean apiKeyAccess; + public UserVO() { this.uuid = UUID.randomUUID().toString(); } @@ -350,4 +353,13 @@ public class UserVO implements User, Identity, InternalIdentity { this.user2faProvider = user2faProvider; } + @Override + public void setApiKeyAccess(Boolean apiKeyAccess) { + this.apiKeyAccess = apiKeyAccess; + } + + @Override + public Boolean getApiKeyAccess() { + return apiKeyAccess; + } } diff --git a/engine/schema/src/main/java/com/cloud/user/dao/AccountDaoImpl.java b/engine/schema/src/main/java/com/cloud/user/dao/AccountDaoImpl.java index eed5572a0b2..f9ef5c40eba 100644 --- a/engine/schema/src/main/java/com/cloud/user/dao/AccountDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/user/dao/AccountDaoImpl.java @@ -41,8 +41,8 @@ import java.util.List; @Component public class AccountDaoImpl extends GenericDaoBase implements AccountDao { - private static final String FIND_USER_ACCOUNT_BY_API_KEY = "SELECT u.id, u.username, u.account_id, u.secret_key, u.state, " - + "a.id, a.account_name, a.type, a.role_id, a.domain_id, a.state " + "FROM `cloud`.`user` u, `cloud`.`account` a " + private static final String FIND_USER_ACCOUNT_BY_API_KEY = "SELECT u.id, u.username, u.account_id, u.secret_key, u.state, u.api_key_access, " + + "a.id, a.account_name, a.type, a.role_id, a.domain_id, a.state, a.api_key_access " + "FROM `cloud`.`user` u, `cloud`.`account` a " + "WHERE u.account_id = a.id AND u.api_key = ? and u.removed IS NULL"; protected final SearchBuilder AllFieldsSearch; @@ -148,13 +148,25 @@ public class AccountDaoImpl extends GenericDaoBase implements A u.setAccountId(rs.getLong(3)); u.setSecretKey(DBEncryptionUtil.decrypt(rs.getString(4))); u.setState(State.getValueOf(rs.getString(5))); + boolean apiKeyAccess = rs.getBoolean(6); + if (rs.wasNull()) { + u.setApiKeyAccess(null); + } else { + u.setApiKeyAccess(apiKeyAccess); + } - AccountVO a = new AccountVO(rs.getLong(6)); - a.setAccountName(rs.getString(7)); - a.setType(Account.Type.getFromValue(rs.getInt(8))); - a.setRoleId(rs.getLong(9)); - a.setDomainId(rs.getLong(10)); - a.setState(State.getValueOf(rs.getString(11))); + AccountVO a = new AccountVO(rs.getLong(7)); + a.setAccountName(rs.getString(8)); + a.setType(Account.Type.getFromValue(rs.getInt(9))); + a.setRoleId(rs.getLong(10)); + a.setDomainId(rs.getLong(11)); + a.setState(State.getValueOf(rs.getString(12))); + apiKeyAccess = rs.getBoolean(13); + if (rs.wasNull()) { + a.setApiKeyAccess(null); + } else { + a.setApiKeyAccess(apiKeyAccess); + } userAcctPair = new Pair(u, a); } diff --git a/engine/schema/src/main/java/com/cloud/vm/ConsoleSessionVO.java b/engine/schema/src/main/java/com/cloud/vm/ConsoleSessionVO.java index 81a11241e4b..ef777be2de9 100644 --- a/engine/schema/src/main/java/com/cloud/vm/ConsoleSessionVO.java +++ b/engine/schema/src/main/java/com/cloud/vm/ConsoleSessionVO.java @@ -64,6 +64,12 @@ public class ConsoleSessionVO { @Column(name = "removed") private Date removed; + @Column(name = "console_endpoint_creator_address") + private String consoleEndpointCreatorAddress; + + @Column(name = "client_address") + private String clientAddress; + public long getId() { return id; } @@ -135,4 +141,20 @@ public class ConsoleSessionVO { public void setAcquired(Date acquired) { this.acquired = acquired; } + + public String getConsoleEndpointCreatorAddress() { + return consoleEndpointCreatorAddress; + } + + public void setConsoleEndpointCreatorAddress(String consoleEndpointCreatorAddress) { + this.consoleEndpointCreatorAddress = consoleEndpointCreatorAddress; + } + + public String getClientAddress() { + return clientAddress; + } + + public void setClientAddress(String clientAddress) { + this.clientAddress = clientAddress; + } } diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDao.java b/engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDao.java index 79158dd13b2..95ced889b3d 100644 --- a/engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDao.java +++ b/engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDao.java @@ -33,7 +33,7 @@ public interface ConsoleSessionDao extends GenericDao { int expungeSessionsOlderThanDate(Date date); - void acquireSession(String sessionUuid); + void acquireSession(String sessionUuid, String clientAddress); int expungeByVmList(List vmIds, Long batchSize); } diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDaoImpl.java b/engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDaoImpl.java index 48709674451..3d117894670 100644 --- a/engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDaoImpl.java @@ -62,9 +62,10 @@ public class ConsoleSessionDaoImpl extends GenericDaoBase implements V logger.debug(String.format("Starting to remove all vm_stats rows older than [%s].", limitDate)); - long totalRemoved = 0; - long removed; - - do { - removed = expunge(sc, limitPerQuery); - totalRemoved += removed; - logger.trace(String.format("Removed [%s] vm_stats rows on the last update and a sum of [%s] vm_stats rows older than [%s] until now.", removed, totalRemoved, limitDate)); - } while (limitPerQuery > 0 && removed >= limitPerQuery); + long totalRemoved = batchExpunge(sc, limitPerQuery); logger.info(String.format("Removed a total of [%s] vm_stats rows older than [%s].", totalRemoved, limitDate)); } diff --git a/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml b/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml index 171685ce413..4f22234d7bf 100644 --- a/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml +++ b/engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml @@ -117,6 +117,7 @@ + diff --git a/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_add_foreign_key.sql b/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_add_foreign_key.sql new file mode 100644 index 00000000000..754c02acb93 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/procedures/cloud.idempotent_add_foreign_key.sql @@ -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. + +DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY`; + +CREATE PROCEDURE `cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY` ( + IN in_table_name VARCHAR(200) + , IN in_key_name VARCHAR(200) + , IN in_foreign_key VARCHAR(200) + , IN in_references VARCHAR(1000) +) +BEGIN + + DECLARE CONTINUE HANDLER FOR 1061 BEGIN END; SET @ddl = CONCAT_WS(' ', 'ALTER TABLE ', in_table_name, ' ADD CONSTRAINT ', in_key_name, ' FOREIGN KEY ', in_foreign_key, ' REFERENCES ', in_references, ' ON DELETE CASCADE'); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41910to41920-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41910to41920-cleanup.sql new file mode 100644 index 00000000000..cb317c69b79 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41910to41920-cleanup.sql @@ -0,0 +1,23 @@ +-- 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. + +--; +-- Schema upgrade cleanup from 4.19.1.0 to 4.19.2.0 +--; + +-- Delete `project_account` entries for users that were removed +DELETE FROM `cloud`.`project_account` WHERE `user_id` IN (SELECT `id` FROM `cloud`.`user` WHERE `removed`); diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41910to41920.sql b/engine/schema/src/main/resources/META-INF/db/schema-41910to41920.sql new file mode 100644 index 00000000000..2ce8ea99bd1 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-41910to41920.sql @@ -0,0 +1,23 @@ +-- 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. + +--; +-- Schema upgrade from 4.19.1.0 to 4.19.2.0 +--; + +-- Add last_id to the volumes table +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.volumes', 'last_id', 'bigint(20) unsigned DEFAULT NULL'); diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42000to42010-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-42000to42010-cleanup.sql new file mode 100644 index 00000000000..d187b6fa043 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-42000to42010-cleanup.sql @@ -0,0 +1,20 @@ +-- 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. + +--; +-- Schema upgrade cleanup from 4.20.0.0 to 4.20.1.0 +--; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42000to42010.sql b/engine/schema/src/main/resources/META-INF/db/schema-42000to42010.sql new file mode 100644 index 00000000000..aef99dd0c7f --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-42000to42010.sql @@ -0,0 +1,34 @@ +-- 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. + +--; +-- Schema upgrade from 4.20.0.0 to 4.20.1.0 +--; + +-- Add column api_key_access to user and account tables +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.user', 'api_key_access', 'boolean DEFAULT NULL COMMENT "is api key access allowed for the user" AFTER `secret_key`'); +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.account', 'api_key_access', 'boolean DEFAULT NULL COMMENT "is api key access allowed for the account" '); + +-- Modify index for mshost_peer +DELETE FROM `cloud`.`mshost_peer`; +CALL `cloud`.`IDEMPOTENT_DROP_FOREIGN_KEY`('cloud.mshost_peer','fk_mshost_peer__owner_mshost'); +CALL `cloud`.`IDEMPOTENT_DROP_INDEX`('i_mshost_peer__owner_peer_runid','mshost_peer'); +CALL `cloud`.`IDEMPOTENT_ADD_UNIQUE_KEY`('cloud.mshost_peer', 'i_mshost_peer__owner_peer', '(owner_mshost, peer_mshost)'); +CALL `cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY`('cloud.mshost_peer', 'fk_mshost_peer__owner_mshost', '(owner_mshost)', '`mshost`(`id`)'); + +-- Add last_id to the volumes table +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.volumes', 'last_id', 'bigint(20) unsigned DEFAULT NULL'); diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42010to42100-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-42010to42100-cleanup.sql new file mode 100644 index 00000000000..5f257f2965b --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-42010to42100-cleanup.sql @@ -0,0 +1,20 @@ +-- 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. + +--; +-- Schema upgrade cleanup from 4.20.1.0 to 4.21.0.0 +--; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql b/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql new file mode 100644 index 00000000000..91223bab798 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql @@ -0,0 +1,26 @@ +-- 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. + +--; +-- Schema upgrade from 4.20.1.0 to 4.21.0.0 +--; + +-- Add console_endpoint_creator_address column to cloud.console_session table +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.console_session', 'console_endpoint_creator_address', 'VARCHAR(45)'); + +-- Add client_address column to cloud.console_session table +CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.console_session', 'client_address', 'VARCHAR(45)'); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql index 87546a9d118..dc64380fb57 100644 --- a/engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql @@ -31,6 +31,7 @@ select `account`.`cleanup_needed` AS `cleanup_needed`, `account`.`network_domain` AS `network_domain` , `account`.`default` AS `default`, + `account`.`api_key_access` AS `api_key_access`, `domain`.`id` AS `domain_id`, `domain`.`uuid` AS `domain_uuid`, `domain`.`name` AS `domain_name`, diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.mshost_peer_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.mshost_peer_view.sql new file mode 100644 index 00000000000..5f741449d85 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.mshost_peer_view.sql @@ -0,0 +1,44 @@ +-- 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. + + +DROP VIEW IF EXISTS `cloud`.`mshost_peer_view`; + +CREATE VIEW `cloud`.`mshost_peer_view` AS +SELECT + `mshost_peer`.`id` AS `id`, + `mshost_peer`.`peer_state` AS `peer_state`, + `mshost_peer`.`last_update` AS `last_update`, + `owner_mshost`.`id` AS `owner_mshost_id`, + `owner_mshost`.`msid` AS `owner_mshost_msid`, + `owner_mshost`.`runid` AS `owner_mshost_runid`, + `owner_mshost`.`name` AS `owner_mshost_name`, + `owner_mshost`.`uuid` AS `owner_mshost_uuid`, + `owner_mshost`.`state` AS `owner_mshost_state`, + `owner_mshost`.`service_ip` AS `owner_mshost_service_ip`, + `owner_mshost`.`service_port` AS `owner_mshost_service_port`, + `peer_mshost`.`id` AS `peer_mshost_id`, + `peer_mshost`.`msid` AS `peer_mshost_msid`, + `peer_mshost`.`runid` AS `peer_mshost_runid`, + `peer_mshost`.`name` AS `peer_mshost_name`, + `peer_mshost`.`uuid` AS `peer_mshost_uuid`, + `peer_mshost`.`state` AS `peer_mshost_state`, + `peer_mshost`.`service_ip` AS `peer_mshost_service_ip`, + `peer_mshost`.`service_port` AS `peer_mshost_service_port` +FROM `cloud`.`mshost_peer` +LEFT JOIN `cloud`.`mshost` AS owner_mshost on `mshost_peer`.`owner_mshost` = `owner_mshost`.`id` +LEFT JOIN `cloud`.`mshost` AS peer_mshost on `mshost_peer`.`peer_mshost` = `peer_mshost`.`id`; diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.user_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.user_view.sql index 7eedc03712b..340cfa9055f 100644 --- a/engine/schema/src/main/resources/META-INF/db/views/cloud.user_view.sql +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.user_view.sql @@ -39,6 +39,7 @@ select user.incorrect_login_attempts, user.source, user.default, + user.api_key_access, account.id account_id, account.uuid account_uuid, account.account_name account_name, diff --git a/engine/service/pom.xml b/engine/service/pom.xml index 34221e1001d..83179d2db65 100644 --- a/engine/service/pom.xml +++ b/engine/service/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT cloud-engine-service war diff --git a/engine/storage/cache/pom.xml b/engine/storage/cache/pom.xml index a1b7aff7afd..60822f761bc 100644 --- a/engine/storage/cache/pom.xml +++ b/engine/storage/cache/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/configdrive/pom.xml b/engine/storage/configdrive/pom.xml index b14acf10138..e66f38cd6c3 100644 --- a/engine/storage/configdrive/pom.xml +++ b/engine/storage/configdrive/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/datamotion/pom.xml b/engine/storage/datamotion/pom.xml index 5620ca8ef70..ff1859a99d8 100644 --- a/engine/storage/datamotion/pom.xml +++ b/engine/storage/datamotion/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java index 07b53842640..3456731ef1c 100644 --- a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java +++ b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java @@ -1958,25 +1958,26 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { * - Full clones (no backing file): Take snapshot of the VM prior disk creation * Return this information */ - protected void setVolumeMigrationOptions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo, - VirtualMachineTO vmTO, Host srcHost, StoragePoolVO destStoragePool) { - if (!destStoragePool.isManaged()) { - String srcVolumeBackingFile = getVolumeBackingFile(srcVolumeInfo); - - String srcPoolUuid = srcVolumeInfo.getDataStore().getUuid(); - StoragePoolVO srcPool = _storagePoolDao.findById(srcVolumeInfo.getPoolId()); - Storage.StoragePoolType srcPoolType = srcPool.getPoolType(); - - MigrationOptions migrationOptions; - if (StringUtils.isNotBlank(srcVolumeBackingFile)) { - migrationOptions = createLinkedCloneMigrationOptions(srcVolumeInfo, destVolumeInfo, - srcVolumeBackingFile, srcPoolUuid, srcPoolType); - } else { - migrationOptions = createFullCloneMigrationOptions(srcVolumeInfo, vmTO, srcHost, srcPoolUuid, srcPoolType); - } - migrationOptions.setTimeout(StorageManager.KvmStorageOnlineMigrationWait.value()); - destVolumeInfo.setMigrationOptions(migrationOptions); + protected void setVolumeMigrationOptions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo, VirtualMachineTO vmTO, Host srcHost, StoragePoolVO destStoragePool, + MigrationOptions.Type migrationType) { + if (destStoragePool.isManaged()) { + return; } + + String srcVolumeBackingFile = getVolumeBackingFile(srcVolumeInfo); + + String srcPoolUuid = srcVolumeInfo.getDataStore().getUuid(); + StoragePoolVO srcPool = _storagePoolDao.findById(srcVolumeInfo.getPoolId()); + Storage.StoragePoolType srcPoolType = srcPool.getPoolType(); + + MigrationOptions migrationOptions; + if (MigrationOptions.Type.LinkedClone.equals(migrationType)) { + migrationOptions = createLinkedCloneMigrationOptions(srcVolumeInfo, destVolumeInfo, srcVolumeBackingFile, srcPoolUuid, srcPoolType); + } else { + migrationOptions = createFullCloneMigrationOptions(srcVolumeInfo, vmTO, srcHost, srcPoolUuid, srcPoolType); + } + migrationOptions.setTimeout(StorageManager.KvmStorageOnlineMigrationWait.value()); + destVolumeInfo.setMigrationOptions(migrationOptions); } /** @@ -2007,6 +2008,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { Map srcVolumeInfoToDestVolumeInfo = new HashMap<>(); boolean managedStorageDestination = false; + boolean migrateNonSharedInc = false; for (Map.Entry entry : volumeDataStoreMap.entrySet()) { VolumeInfo srcVolumeInfo = entry.getKey(); DataStore destDataStore = entry.getValue(); @@ -2024,15 +2026,8 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { continue; } - VMTemplateVO vmTemplate = _vmTemplateDao.findById(vmInstance.getTemplateId()); - if (srcVolumeInfo.getTemplateId() != null && - Objects.nonNull(vmTemplate) && - !Arrays.asList(KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME, VM_IMPORT_DEFAULT_TEMPLATE_NAME).contains(vmTemplate.getName())) { - logger.debug(String.format("Copying template [%s] of volume [%s] from source storage pool [%s] to target storage pool [%s].", srcVolumeInfo.getTemplateId(), srcVolumeInfo.getId(), sourceStoragePool.getId(), destStoragePool.getId())); - copyTemplateToTargetFilesystemStorageIfNeeded(srcVolumeInfo, sourceStoragePool, destDataStore, destStoragePool, destHost); - } else { - logger.debug(String.format("Skipping copy template from source storage pool [%s] to target storage pool [%s] before migration due to volume [%s] does not have a template.", sourceStoragePool.getId(), destStoragePool.getId(), srcVolumeInfo.getId())); - } + MigrationOptions.Type migrationType = decideMigrationTypeAndCopyTemplateIfNeeded(destHost, vmInstance, srcVolumeInfo, sourceStoragePool, destStoragePool, destDataStore); + migrateNonSharedInc = migrateNonSharedInc || MigrationOptions.Type.LinkedClone.equals(migrationType); VolumeVO destVolume = duplicateVolumeOnAnotherStorage(srcVolume, destStoragePool); VolumeInfo destVolumeInfo = _volumeDataFactory.getVolume(destVolume.getId(), destDataStore); @@ -2044,7 +2039,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { // move the volume from Ready to Migrating destVolumeInfo.processEvent(Event.MigrationRequested); - setVolumeMigrationOptions(srcVolumeInfo, destVolumeInfo, vmTO, srcHost, destStoragePool); + setVolumeMigrationOptions(srcVolumeInfo, destVolumeInfo, vmTO, srcHost, destStoragePool, migrationType); // create a volume on the destination storage destDataStore.getDriver().createAsync(destDataStore, destVolumeInfo, null); @@ -2059,7 +2054,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { _volumeDao.update(destVolume.getId(), destVolume); - postVolumeCreationActions(srcVolumeInfo, destVolumeInfo, vmTO, srcHost); + postVolumeCreationActions(srcVolumeInfo, destVolumeInfo); destVolumeInfo = _volumeDataFactory.getVolume(destVolume.getId(), destDataStore); @@ -2083,8 +2078,8 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { migrateDiskInfo = configureMigrateDiskInfo(srcVolumeInfo, destPath, backingPath); migrateDiskInfo.setSourceDiskOnStorageFileSystem(isStoragePoolTypeOfFile(sourceStoragePool)); migrateDiskInfoList.add(migrateDiskInfo); - prepareDiskWithSecretConsumerDetail(vmTO, srcVolumeInfo, destVolumeInfo.getPath()); } + prepareDiskWithSecretConsumerDetail(vmTO, srcVolumeInfo, destVolumeInfo.getPath()); migrateStorage.put(srcVolumeInfo.getPath(), migrateDiskInfo); @@ -2110,8 +2105,6 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { VMInstanceVO vm = _vmDao.findById(vmTO.getId()); boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows"); - boolean migrateNonSharedInc = isSourceAndDestinationPoolTypeOfNfs(volumeDataStoreMap); - MigrateCommand migrateCommand = new MigrateCommand(vmTO.getName(), destHost.getPrivateIpAddress(), isWindows, vmTO, true); migrateCommand.setWait(StorageManager.KvmStorageOnlineMigrationWait.value()); migrateCommand.setMigrateStorage(migrateStorage); @@ -2161,6 +2154,22 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { } } + private MigrationOptions.Type decideMigrationTypeAndCopyTemplateIfNeeded(Host destHost, VMInstanceVO vmInstance, VolumeInfo srcVolumeInfo, StoragePoolVO sourceStoragePool, StoragePoolVO destStoragePool, DataStore destDataStore) { + VMTemplateVO vmTemplate = _vmTemplateDao.findById(vmInstance.getTemplateId()); + String srcVolumeBackingFile = getVolumeBackingFile(srcVolumeInfo); + if (StringUtils.isNotBlank(srcVolumeBackingFile) && supportStoragePoolType(destStoragePool.getPoolType(), StoragePoolType.Filesystem) && + srcVolumeInfo.getTemplateId() != null && + Objects.nonNull(vmTemplate) && + !Arrays.asList(KVM_VM_IMPORT_DEFAULT_TEMPLATE_NAME, VM_IMPORT_DEFAULT_TEMPLATE_NAME).contains(vmTemplate.getName())) { + logger.debug(String.format("Copying template [%s] of volume [%s] from source storage pool [%s] to target storage pool [%s].", srcVolumeInfo.getTemplateId(), srcVolumeInfo.getId(), sourceStoragePool.getId(), destStoragePool.getId())); + copyTemplateToTargetFilesystemStorageIfNeeded(srcVolumeInfo, sourceStoragePool, destDataStore, destStoragePool, destHost); + return MigrationOptions.Type.LinkedClone; + } + logger.debug(String.format("Skipping copy template from source storage pool [%s] to target storage pool [%s] before migration due to volume [%s] does not have a " + + "template or we are doing full clone migration.", sourceStoragePool.getId(), destStoragePool.getId(), srcVolumeInfo.getId())); + return MigrationOptions.Type.FullClone; + } + protected String formatMigrationElementsAsJsonToDisplayOnLog(String objectName, Object object, Object from, Object to){ return String.format("{%s: \"%s\", from: \"%s\", to:\"%s\"}", objectName, object, from, to); } @@ -2284,6 +2293,8 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { if (success) { VolumeVO volumeVO = _volumeDao.findById(destVolumeInfo.getId()); volumeVO.setFormat(ImageFormat.QCOW2); + volumeVO.setLastId(srcVolumeInfo.getId()); + _volumeDao.update(volumeVO.getId(), volumeVO); _volumeService.copyPoliciesBetweenVolumesAndDestroySourceVolumeAfterMigration(Event.OperationSuccessed, null, srcVolumeInfo, destVolumeInfo, false); @@ -2422,7 +2433,7 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { /** * Handle post destination volume creation actions depending on the migrating volume type: full clone or linked clone */ - protected void postVolumeCreationActions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo, VirtualMachineTO vmTO, Host srcHost) { + protected void postVolumeCreationActions(VolumeInfo srcVolumeInfo, VolumeInfo destVolumeInfo) { MigrationOptions migrationOptions = destVolumeInfo.getMigrationOptions(); if (migrationOptions != null) { if (migrationOptions.getType() == MigrationOptions.Type.LinkedClone && migrationOptions.isCopySrcTemplate()) { @@ -2470,7 +2481,8 @@ public class StorageSystemDataMotionStrategy implements DataMotionStrategy { throw new CloudRuntimeException("Destination storage pool with ID " + dataStore.getId() + " was not located."); } - if (srcStoragePoolVO.isManaged() && srcStoragePoolVO.getId() != destStoragePoolVO.getId()) { + boolean isSrcAndDestPoolPowerFlexStorage = srcStoragePoolVO.getPoolType().equals(Storage.StoragePoolType.PowerFlex) && destStoragePoolVO.getPoolType().equals(Storage.StoragePoolType.PowerFlex); + if (srcStoragePoolVO.isManaged() && !isSrcAndDestPoolPowerFlexStorage && srcStoragePoolVO.getId() != destStoragePoolVO.getId()) { throw new CloudRuntimeException("Migrating a volume online with KVM from managed storage is not currently supported."); } diff --git a/engine/storage/image/pom.xml b/engine/storage/image/pom.xml index 278b3672b2f..c5023e24534 100644 --- a/engine/storage/image/pom.xml +++ b/engine/storage/image/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java index 5e21f37f4d5..abc955c2e49 100644 --- a/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java +++ b/engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/TemplateServiceImpl.java @@ -533,6 +533,11 @@ public class TemplateServiceImpl implements TemplateService { logger.info("Skip downloading template " + tmplt.getUniqueName() + " since no url is specified."); continue; } + // if this is private template, skip sync to a new image store + if (isSkipTemplateStoreDownload(tmplt, zoneId)) { + logger.info("Skip sync downloading private template " + tmplt.getUniqueName() + " to a new image store"); + continue; + } // if this is a region store, and there is already an DOWNLOADED entry there without install_path information, which // means that this is a duplicate entry from migration of previous NFS to staging. diff --git a/engine/storage/integration-test/pom.xml b/engine/storage/integration-test/pom.xml index a5bc225f4f6..ff0b64f5eaf 100644 --- a/engine/storage/integration-test/pom.xml +++ b/engine/storage/integration-test/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/object/pom.xml b/engine/storage/object/pom.xml index 7159a646fbb..97859ec68db 100644 --- a/engine/storage/object/pom.xml +++ b/engine/storage/object/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/pom.xml b/engine/storage/pom.xml index e16e88e235d..7588b61eb39 100644 --- a/engine/storage/pom.xml +++ b/engine/storage/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/engine/storage/snapshot/pom.xml b/engine/storage/snapshot/pom.xml index f29b43d8de0..db70d53647a 100644 --- a/engine/storage/snapshot/pom.xml +++ b/engine/storage/snapshot/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java index 1d3788a0301..09f569e6f19 100644 --- a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java +++ b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java @@ -419,7 +419,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot if (answer != null && answer.getDetails() != null) errMsg = errMsg + " due to " + answer.getDetails(); logger.error(errMsg); - throw new CloudRuntimeException(errMsg); + throw new CloudRuntimeException(String.format("Unable to revert VM %s to snapshot %s.", userVm.getInstanceName(), vmSnapshotVO.getName())); } } catch (OperationTimedoutException e) { logger.debug("Failed to revert vm snapshot", e); diff --git a/engine/storage/volume/pom.xml b/engine/storage/volume/pom.xml index a00c3314126..7709a7c2c5b 100644 --- a/engine/storage/volume/pom.xml +++ b/engine/storage/volume/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 9a3319f79a3..3ca1d9201db 100644 --- a/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -1720,6 +1720,7 @@ public class VolumeServiceImpl implements VolumeService { newVol.setPassphraseId(volume.getPassphraseId()); newVol.setEncryptFormat(volume.getEncryptFormat()); } + newVol.setLastId(volume.getId()); return volDao.persist(newVol); } diff --git a/engine/userdata/cloud-init/pom.xml b/engine/userdata/cloud-init/pom.xml index d4396ba382a..70e2d70f94b 100644 --- a/engine/userdata/cloud-init/pom.xml +++ b/engine/userdata/cloud-init/pom.xml @@ -23,7 +23,7 @@ cloud-engine org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/engine/userdata/pom.xml b/engine/userdata/pom.xml index 038aa18f290..a97a308c1ab 100644 --- a/engine/userdata/pom.xml +++ b/engine/userdata/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/agent-lb/pom.xml b/framework/agent-lb/pom.xml index 50e0bd47b90..14b692d6a45 100644 --- a/framework/agent-lb/pom.xml +++ b/framework/agent-lb/pom.xml @@ -24,7 +24,7 @@ cloudstack-framework org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/ca/pom.xml b/framework/ca/pom.xml index d82389cd008..691e9e3a9da 100644 --- a/framework/ca/pom.xml +++ b/framework/ca/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/cluster/pom.xml b/framework/cluster/pom.xml index ef511584ae6..b2e89704c89 100644 --- a/framework/cluster/pom.xml +++ b/framework/cluster/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/cluster/src/main/java/com/cloud/cluster/ClusterManager.java b/framework/cluster/src/main/java/com/cloud/cluster/ClusterManager.java index 54f575830e4..7fdaa6f7f77 100644 --- a/framework/cluster/src/main/java/com/cloud/cluster/ClusterManager.java +++ b/framework/cluster/src/main/java/com/cloud/cluster/ClusterManager.java @@ -27,9 +27,9 @@ import com.cloud.utils.component.Manager; public interface ClusterManager extends Manager { static final String ALERT_SUBJECT = "cluster-alert"; final ConfigKey HeartbeatInterval = new ConfigKey(Integer.class, "cluster.heartbeat.interval", "management-server", "1500", - "Interval to check for the heart beat between management server nodes", false); + "Interval (in milliseconds) to check for the heart beat between management server nodes", false); final ConfigKey HeartbeatThreshold = new ConfigKey(Integer.class, "cluster.heartbeat.threshold", "management-server", "150000", - "Threshold before self-fence the management server", true); + "Threshold (in milliseconds) before self-fence the management server. The threshold should be larger than management.server.stats.interval", true); /** * Adds a new packet to the incoming queue. diff --git a/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java b/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java index 32fdf782696..0ec566a4194 100644 --- a/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java +++ b/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java @@ -758,21 +758,16 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C } switch (msg.getMessageType()) { - case nodeAdded: { - final List l = msg.getNodes(); - if (l != null && l.size() > 0) { - for (final ManagementServerHostVO mshost : l) { - _mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Up); - } - } - } + case nodeAdded: break; case nodeRemoved: { final List l = msg.getNodes(); if (l != null && l.size() > 0) { for (final ManagementServerHostVO mshost : l) { - _mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Down); + if (mshost.getId() != _mshostId) { + _mshostPeerDao.updatePeerInfo(_mshostId, mshost.getId(), mshost.getRunid(), ManagementServerHost.State.Down); + } } } } @@ -823,8 +818,9 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C final List downHostList = new ArrayList(); for (final ManagementServerHostVO host : inactiveList) { - if (!pingManagementNode(host)) { - logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and also not pingable"); + // Check if peer state is Up in the period + if (!_mshostPeerDao.isPeerUpState(_mshostId, host.getId(), new Date(cutTime.getTime() - HeartbeatThreshold.value()))) { + logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and did not send node status to this node"); downHostList.add(host); } } @@ -898,6 +894,44 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C final Profiler profilerInvalidatedNodeList = new Profiler(); profilerInvalidatedNodeList.start(); + processInvalidatedNodes(invalidatedNodeList); + profilerInvalidatedNodeList.stop(); + + final Profiler profilerRemovedList = new Profiler(); + profilerRemovedList.start(); + processRemovedNodes(cutTime, removedNodeList); + profilerRemovedList.stop(); + + final Profiler profilerNewList = new Profiler(); + profilerNewList.start(); + processNewNodes(cutTime, currentList); + profilerNewList.stop(); + + final Profiler profilerInactiveList = new Profiler(); + profilerInactiveList.start(); + processInactiveNodes(cutTime); + profilerInactiveList.stop(); + + profiler.stop(); + + logger.debug(String.format("Peer scan is finished. profiler: %s , profilerQueryActiveList: %s, " + + ", profilerSyncClusterInfo: %s, profilerInvalidatedNodeList: %s, profilerRemovedList: %s," + + ", profilerNewList: %s, profilerInactiveList: %s", + profiler, profilerQueryActiveList, profilerSyncClusterInfo, profilerInvalidatedNodeList, profilerRemovedList, + profilerNewList, profilerInactiveList)); + + if (profiler.getDurationInMillis() >= HeartbeatInterval.value()) { + if (logger.isDebugEnabled()) { + logger.debug(String.format("Peer scan takes too long to finish. profiler: %s , profilerQueryActiveList: %s, " + + ", profilerSyncClusterInfo: %s, profilerInvalidatedNodeList: %s, profilerRemovedList: %s," + + ", profilerNewList: %s, profilerInactiveList: %s", + profiler, profilerQueryActiveList, profilerSyncClusterInfo, profilerInvalidatedNodeList, profilerRemovedList, + profilerNewList, profilerInactiveList)); + } + } + } + + private void processInvalidatedNodes(List invalidatedNodeList) { // process invalidated node list if (invalidatedNodeList.size() > 0) { for (final ManagementServerHostVO mshost : invalidatedNodeList) { @@ -911,16 +945,16 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeRemoved, invalidatedNodeList)); } - profilerInvalidatedNodeList.stop(); + } - final Profiler profilerRemovedList = new Profiler(); - profilerRemovedList.start(); + private void processRemovedNodes(Date cutTime, List removedNodeList) { // process removed node list final Iterator it = removedNodeList.iterator(); while (it.hasNext()) { final ManagementServerHostVO mshost = it.next(); - if (!pingManagementNode(mshost)) { - logger.warn("Management node " + mshost.getId() + " is detected inactive by timestamp and also not pingable"); + // Check if peer state is Up in the period + if (!_mshostPeerDao.isPeerUpState(_mshostId, mshost.getId(), new Date(cutTime.getTime() - HeartbeatThreshold.value()))) { + logger.warn("Management node " + mshost.getId() + " is detected inactive by timestamp and did not send node status to this node"); _activePeers.remove(mshost.getId()); try { JmxUtil.unregisterMBean("ClusterManager", "Node " + mshost.getId()); @@ -928,7 +962,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C logger.warn("Unable to deregiester cluster node from JMX monitoring due to exception " + e.toString()); } } else { - logger.info("Management node " + mshost.getId() + " is detected inactive by timestamp but is pingable"); + logger.info("Management node " + mshost.getId() + " is detected inactive by timestamp but sent node status to this node"); it.remove(); } } @@ -936,8 +970,9 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C if (removedNodeList.size() > 0) { queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeRemoved, removedNodeList)); } - profilerRemovedList.stop(); + } + private void processNewNodes(Date cutTime, List currentList) { final List newNodeList = new ArrayList(); for (final ManagementServerHostVO mshost : currentList) { if (!_activePeers.containsKey(mshost.getId())) { @@ -959,18 +994,31 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C if (newNodeList.size() > 0) { queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeAdded, newNodeList)); } + } - profiler.stop(); - - if (profiler.getDurationInMillis() >= HeartbeatInterval.value()) { - if (logger.isDebugEnabled()) { - logger.debug("Peer scan takes too long to finish. profiler: " + profiler.toString() + ", profilerQueryActiveList: " + - profilerQueryActiveList.toString() + ", profilerSyncClusterInfo: " + profilerSyncClusterInfo.toString() + ", profilerInvalidatedNodeList: " + - profilerInvalidatedNodeList.toString() + ", profilerRemovedList: " + profilerRemovedList.toString()); + private void processInactiveNodes(Date cutTime) { + final List inactiveList = _mshostDao.getInactiveList(new Date(cutTime.getTime() - HeartbeatThreshold.value())); + if (inactiveList.size() > 0) { + if (logger.isInfoEnabled()) { + logger.info(String.format("Found %s inactive management server node based on timestamp", inactiveList.size())); } + for (final ManagementServerHostVO host : inactiveList) { + logger.info(String.format("management server node msid: %s, name: %s, service ip: %s, version: %s", + host.getMsid(), host.getName(), host.getServiceIP(), host.getVersion())); + // Check if any peer state is Up in the period + if (ManagementServerHost.State.Up.equals(host.getState()) && + !_mshostPeerDao.isPeerUpState(host.getId(), new Date(cutTime.getTime() - HeartbeatThreshold.value()))) { + logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and did not send node status to all other nodes"); + host.setState(ManagementServerHost.State.Down); + _mshostDao.update(host.getId(), host); + } + } + } else { + logger.info("No inactive management server node found"); } } + private static ManagementServerHostVO getInListById(final Long id, final List l) { for (final ManagementServerHostVO mshost : l) { if (mshost.getId() == id) { diff --git a/framework/cluster/src/main/java/com/cloud/cluster/ManagementServerHostPeerJoinVO.java b/framework/cluster/src/main/java/com/cloud/cluster/ManagementServerHostPeerJoinVO.java new file mode 100644 index 00000000000..673db160b3c --- /dev/null +++ b/framework/cluster/src/main/java/com/cloud/cluster/ManagementServerHostPeerJoinVO.java @@ -0,0 +1,177 @@ +// 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.cluster; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.cloudstack.management.ManagementServerHost; + +@Entity +@Table(name = "mshost_peer_view") +public class ManagementServerHostPeerJoinVO { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "peer_state") + @Enumerated(value = EnumType.STRING) + private ManagementServerHost.State peerState; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "last_update") + private Date lastUpdateTime; + + @Column(name = "owner_mshost_id") + private long ownerMshostId; + + @Column(name = "owner_mshost_msid") + private long ownerMshostMsId; + + @Column(name = "owner_mshost_runid") + private long ownerMshostRunId; + + @Column(name = "owner_mshost_name") + private String ownerMshostName; + + @Column(name = "owner_mshost_uuid") + private String ownerMshostUuid; + + @Column(name = "owner_mshost_state") + private String ownerMshostState; + + @Column(name = "owner_mshost_service_ip") + private String ownerMshostServiceIp; + + @Column(name = "owner_mshost_service_port") + private Integer ownerMshostServicePort; + + @Column(name = "peer_mshost_id") + private long peerMshostId; + + @Column(name = "peer_mshost_msid") + private long peerMshostMsId; + + @Column(name = "peer_mshost_runid") + private long peerMshostRunId; + + @Column(name = "peer_mshost_name") + private String peerMshostName; + + @Column(name = "peer_mshost_uuid") + private String peerMshostUuid; + + @Column(name = "peer_mshost_state") + private String peerMshostState; + + @Column(name = "peer_mshost_service_ip") + private String peerMshostServiceIp; + + @Column(name = "peer_mshost_service_port") + private Integer peerMshostServicePort; + + public ManagementServerHostPeerJoinVO() { + } + + public long getId() { + return id; + } + + public ManagementServerHost.State getPeerState() { + return peerState; + } + + public Date getLastUpdateTime() { + return lastUpdateTime; + } + + public long getOwnerMshostId() { + return ownerMshostId; + } + + public long getOwnerMshostMsId() { + return ownerMshostMsId; + } + + public long getOwnerMshostRunId() { + return ownerMshostRunId; + } + + public String getOwnerMshostName() { + return ownerMshostName; + } + + public String getOwnerMshostUuid() { + return ownerMshostUuid; + } + + public String getOwnerMshostState() { + return ownerMshostState; + } + + public String getOwnerMshostServiceIp() { + return ownerMshostServiceIp; + } + + public Integer getOwnerMshostServicePort() { + return ownerMshostServicePort; + } + + public long getPeerMshostId() { + return peerMshostId; + } + + public long getPeerMshostMsId() { + return peerMshostMsId; + } + + public long getPeerMshostRunId() { + return peerMshostRunId; + } + + public String getPeerMshostName() { + return peerMshostName; + } + + public String getPeerMshostUuid() { + return peerMshostUuid; + } + + public String getPeerMshostState() { + return peerMshostState; + } + + public String getPeerMshostServiceIp() { + return peerMshostServiceIp; + } + + public Integer getPeerMshostServicePort() { + return peerMshostServicePort; + } +} diff --git a/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java b/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java index 7b69889c853..27b6d52f61b 100644 --- a/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java +++ b/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostDaoImpl.java @@ -130,7 +130,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase { void clearPeerInfo(long ownerMshost); void updatePeerInfo(long ownerMshost, long peerMshost, long peerRunid, ManagementServerHost.State peerState); - int countStateSeenInPeers(long mshost, long runid, ManagementServerHost.State state); + int countStateSeenInPeers(long peerMshost, long runid, ManagementServerHost.State state); + + boolean isPeerUpState(long peerMshost, Date cutTime); + + boolean isPeerUpState(long ownerMshost, long peerMshost, Date cutTime); + } diff --git a/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerDaoImpl.java b/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerDaoImpl.java index 827be4fe299..ec69f5817ac 100644 --- a/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerDaoImpl.java +++ b/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerDaoImpl.java @@ -16,10 +16,10 @@ // under the License. package com.cloud.cluster.dao; +import java.util.Date; import java.util.List; - import org.apache.cloudstack.management.ManagementServerHost; import com.cloud.cluster.ManagementServerHostPeerVO; import com.cloud.utils.db.DB; @@ -33,10 +33,12 @@ public class ManagementServerHostPeerDaoImpl extends GenericDaoBase ClearPeerSearch; private final SearchBuilder FindForUpdateSearch; private final SearchBuilder CountSearch; + private final SearchBuilder ActiveSearch; public ManagementServerHostPeerDaoImpl() { ClearPeerSearch = createSearchBuilder(); ClearPeerSearch.and("ownerMshost", ClearPeerSearch.entity().getOwnerMshost(), SearchCriteria.Op.EQ); + ClearPeerSearch.or("peerMshost", ClearPeerSearch.entity().getPeerMshost(), SearchCriteria.Op.EQ); ClearPeerSearch.done(); FindForUpdateSearch = createSearchBuilder(); @@ -50,6 +52,13 @@ public class ManagementServerHostPeerDaoImpl extends GenericDaoBase sc = ClearPeerSearch.create(); sc.setParameters("ownerMshost", ownerMshost); + sc.setParameters("peerMshost", ownerMshost); expunge(sc); } @@ -71,11 +81,12 @@ public class ManagementServerHostPeerDaoImpl extends GenericDaoBase sc = FindForUpdateSearch.create(); sc.setParameters("ownerMshost", ownerMshost); sc.setParameters("peerMshost", peerMshost); - sc.setParameters("peerRunid", peerRunid); List l = listBy(sc); if (l.size() == 1) { ManagementServerHostPeerVO peer = l.get(0); + peer.setPeerRunid(peerRunid); peer.setPeerState(peerState); + peer.setLastUpdateTime(new Date()); update(peer.getId(), peer); } else { ManagementServerHostPeerVO peer = new ManagementServerHostPeerVO(ownerMshost, peerMshost, peerRunid, peerState); @@ -90,13 +101,36 @@ public class ManagementServerHostPeerDaoImpl extends GenericDaoBase sc = CountSearch.create(); - sc.setParameters("peerMshost", mshost); + sc.setParameters("peerMshost", peerMshost); sc.setParameters("peerRunid", runid); sc.setParameters("peerState", state); List l = listBy(sc); return l.size(); } + + @Override + @DB + public boolean isPeerUpState(long peerMshost, Date cutTime) { + SearchCriteria sc = ActiveSearch.create(); + sc.setParameters("peerMshost", peerMshost); + sc.setParameters("peerState", ManagementServerHost.State.Up); + sc.setParameters("lastUpdateTime", cutTime); + + return listBy(sc).size() > 0; + } + + @Override + @DB + public boolean isPeerUpState(long ownerMshost, long peerMshost, Date cutTime) { + SearchCriteria sc = ActiveSearch.create(); + sc.setParameters("ownerMshost", ownerMshost); + sc.setParameters("peerMshost", peerMshost); + sc.setParameters("peerState", ManagementServerHost.State.Up); + sc.setParameters("lastUpdateTime", cutTime); + + return listBy(sc).size() > 0; + } } diff --git a/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerJoinDao.java b/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerJoinDao.java new file mode 100644 index 00000000000..46f87b6484c --- /dev/null +++ b/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerJoinDao.java @@ -0,0 +1,27 @@ +// 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.cluster.dao; + +import com.cloud.cluster.ManagementServerHostPeerJoinVO; +import com.cloud.utils.db.GenericDao; + +import java.util.List; + +public interface ManagementServerHostPeerJoinDao extends GenericDao { + + List listByOwnerMshostId(long ownerMshostId); +} diff --git a/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerJoinDaoImpl.java b/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerJoinDaoImpl.java new file mode 100644 index 00000000000..16a17863d04 --- /dev/null +++ b/framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerHostPeerJoinDaoImpl.java @@ -0,0 +1,42 @@ +// 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.cluster.dao; + +import java.util.List; + +import com.cloud.cluster.ManagementServerHostPeerJoinVO; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; + +public class ManagementServerHostPeerJoinDaoImpl extends GenericDaoBase implements ManagementServerHostPeerJoinDao { + + private final SearchBuilder AllFieldSearch; + + public ManagementServerHostPeerJoinDaoImpl() { + AllFieldSearch = createSearchBuilder(); + AllFieldSearch.and("ownerMshostId", AllFieldSearch.entity().getOwnerMshostId(), SearchCriteria.Op.EQ); + AllFieldSearch.done(); + } + + @Override + public List listByOwnerMshostId(long ownerMshostId) { + SearchCriteria sc = AllFieldSearch.create(); + sc.setParameters("ownerMshostId", ownerMshostId); + return listBy(sc); + } +} diff --git a/framework/config/pom.xml b/framework/config/pom.xml index fc3b14642f1..403429380b6 100644 --- a/framework/config/pom.xml +++ b/framework/config/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/config/src/main/java/org/apache/cloudstack/framework/config/ConfigKey.java b/framework/config/src/main/java/org/apache/cloudstack/framework/config/ConfigKey.java index 36a8050754c..00cf56345c8 100644 --- a/framework/config/src/main/java/org/apache/cloudstack/framework/config/ConfigKey.java +++ b/framework/config/src/main/java/org/apache/cloudstack/framework/config/ConfigKey.java @@ -34,6 +34,7 @@ public class ConfigKey { public static final String CATEGORY_ADVANCED = "Advanced"; public static final String CATEGORY_ALERT = "Alert"; public static final String CATEGORY_NETWORK = "Network"; + public static final String CATEGORY_SYSTEM = "System"; public enum Scope { Global, Zone, Cluster, StoragePool, Account, ManagementServer, ImageStore, Domain diff --git a/framework/db/pom.xml b/framework/db/pom.xml index 586d72f34f3..db6421a4717 100644 --- a/framework/db/pom.xml +++ b/framework/db/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/db/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java b/framework/db/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java index 961c537d0da..e96b0a00894 100644 --- a/framework/db/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java +++ b/framework/db/src/main/java/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java @@ -656,7 +656,7 @@ public class EncryptionSecretKeyChanger { String sqlTemplateDeployAsIsDetails = "SELECT template_deploy_as_is_details.value " + "FROM template_deploy_as_is_details JOIN vm_instance " + "WHERE template_deploy_as_is_details.template_id = vm_instance.vm_template_id " + - "vm_instance.id = %s AND template_deploy_as_is_details.name = '%s' LIMIT 1"; + "AND vm_instance.id = %s AND template_deploy_as_is_details.name = '%s' LIMIT 1"; try (PreparedStatement selectPstmt = conn.prepareStatement("SELECT id, vm_id, name, value FROM user_vm_deploy_as_is_details"); ResultSet rs = selectPstmt.executeQuery(); PreparedStatement updatePstmt = conn.prepareStatement("UPDATE user_vm_deploy_as_is_details SET value=? WHERE id=?") diff --git a/framework/db/src/main/java/com/cloud/utils/db/GenericDao.java b/framework/db/src/main/java/com/cloud/utils/db/GenericDao.java index 84750c2068c..de8838b0999 100644 --- a/framework/db/src/main/java/com/cloud/utils/db/GenericDao.java +++ b/framework/db/src/main/java/com/cloud/utils/db/GenericDao.java @@ -247,14 +247,6 @@ public interface GenericDao { int expungeList(List ids); - /** - * Delete the entity beans specified by the search criteria with a given limit - * @param sc Search criteria - * @param limit Maximum number of rows that will be affected - * @return Number of rows deleted - */ - int expunge(SearchCriteria sc, long limit); - /** * expunge the removed rows. */ diff --git a/framework/db/src/main/java/com/cloud/utils/db/GenericDaoBase.java b/framework/db/src/main/java/com/cloud/utils/db/GenericDaoBase.java index 52a6b204ee8..82fea9749ff 100644 --- a/framework/db/src/main/java/com/cloud/utils/db/GenericDaoBase.java +++ b/framework/db/src/main/java/com/cloud/utils/db/GenericDaoBase.java @@ -1244,13 +1244,6 @@ public abstract class GenericDaoBase extends Compone } } - // FIXME: Does not work for joins. - @Override - public int expunge(final SearchCriteria sc, long limit) { - Filter filter = new Filter(limit); - return expunge(sc, filter); - } - @Override public int expunge(final SearchCriteria sc, final Filter filter) { if (sc == null) { @@ -1400,22 +1393,39 @@ public abstract class GenericDaoBase extends Compone onClause.append("?"); joinAttrList.add(join.getFirstAttributes()[i]); } else { - onClause.append(joinedTableNames.getOrDefault(join.getFirstAttributes()[i].table, join.getFirstAttributes()[i].table)) - .append(".") - .append(join.getFirstAttributes()[i].columnName); - } - onClause.append("="); - if (join.getSecondAttribute()[i].getValue() != null) { - onClause.append("?"); - joinAttrList.add(join.getSecondAttribute()[i]); - } else { - if(!joinTableAlias.equals(joinTableName)) { - onClause.append(joinTableAlias); + if ((join.getFirstAttributes()[i].table == null && join.getFirstAttributes()[i].value == null) || + (join.getSecondAttribute()[i].table == null && join.getSecondAttribute()[i].value == null)) { + onClause.append(joinedTableNames.getOrDefault(join.getSecondAttribute()[i].table, join.getFirstAttributes()[i].table)) + .append("."); + if (join.getFirstAttributes()[i].table == null && join.getFirstAttributes()[i].value == null) { + onClause.append(join.getSecondAttribute()[i].columnName); + } else { + onClause.append(join.getFirstAttributes()[i].columnName); + } + } else { - onClause.append(joinTableName); + onClause.append(joinedTableNames.getOrDefault(join.getFirstAttributes()[i].table, join.getFirstAttributes()[i].table)) + .append(".") + .append(join.getFirstAttributes()[i].columnName); + } + } + if ((join.getFirstAttributes()[i].table == null && join.getFirstAttributes()[i].value == null) || + (join.getSecondAttribute()[i].table == null && join.getSecondAttribute()[i].value == null)) { + onClause.append(" IS NULL"); + } else { + onClause.append("="); + if (join.getSecondAttribute()[i].getValue() != null) { + onClause.append("?"); + joinAttrList.add(join.getSecondAttribute()[i]); + } else { + if (!joinTableAlias.equals(joinTableName)) { + onClause.append(joinTableAlias); + } else { + onClause.append(joinTableName); + } + onClause.append(".") + .append(join.getSecondAttribute()[i].columnName); } - onClause.append(".") - .append(join.getSecondAttribute()[i].columnName); } } onClause.append(" "); diff --git a/framework/direct-download/pom.xml b/framework/direct-download/pom.xml index 1915377f222..eeb6049285a 100644 --- a/framework/direct-download/pom.xml +++ b/framework/direct-download/pom.xml @@ -32,7 +32,7 @@ cloudstack-framework org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/events/pom.xml b/framework/events/pom.xml index 3f457920cc9..20e2a02fd45 100644 --- a/framework/events/pom.xml +++ b/framework/events/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/ipc/pom.xml b/framework/ipc/pom.xml index 3c03ed04e28..66812b1051c 100644 --- a/framework/ipc/pom.xml +++ b/framework/ipc/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/jobs/pom.xml b/framework/jobs/pom.xml index a82f514635f..a7c8699d0c7 100644 --- a/framework/jobs/pom.xml +++ b/framework/jobs/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/managed-context/pom.xml b/framework/managed-context/pom.xml index bc7fa17940b..32c07bc701d 100644 --- a/framework/managed-context/pom.xml +++ b/framework/managed-context/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/framework/pom.xml b/framework/pom.xml index 79b1036eae7..77a2710c335 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT diff --git a/framework/quota/pom.xml b/framework/quota/pom.xml index 2e608d7a248..a44ac18f2f9 100644 --- a/framework/quota/pom.xml +++ b/framework/quota/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java b/framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java index 226a47bb7df..c9254814f46 100644 --- a/framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java +++ b/framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java @@ -157,7 +157,7 @@ public class QuotaManagerImpl extends ManagerBase implements QuotaManager { .map(quotaUsageVO -> new Pair<>(quotaUsageVO.getStartDate(), quotaUsageVO.getEndDate())) .collect(Collectors.toCollection(LinkedHashSet::new)); - logger.info(String.format("Processing quota balance for account[{}] between [{}] and [{}].", accountToString, startDate, lastQuotaUsageEndDate)); + logger.info("Processing quota balance for account [{}] between [{}] and [{}].", accountToString, startDate, lastQuotaUsageEndDate); long accountId = accountVo.getAccountId(); long domainId = accountVo.getDomainId(); diff --git a/framework/quota/src/main/java/org/apache/cloudstack/quota/activationrule/presetvariables/PresetVariables.java b/framework/quota/src/main/java/org/apache/cloudstack/quota/activationrule/presetvariables/PresetVariables.java index b27bf589c16..6dab6604e91 100644 --- a/framework/quota/src/main/java/org/apache/cloudstack/quota/activationrule/presetvariables/PresetVariables.java +++ b/framework/quota/src/main/java/org/apache/cloudstack/quota/activationrule/presetvariables/PresetVariables.java @@ -17,6 +17,8 @@ package org.apache.cloudstack.quota.activationrule.presetvariables; +import java.util.List; + public class PresetVariables { @PresetVariableDefinition(description = "Account owner of the resource.") @@ -37,6 +39,9 @@ public class PresetVariables { @PresetVariableDefinition(description = "Zone where the resource is.") private GenericPresetVariable zone; + @PresetVariableDefinition(description = "A list containing the tariffs ordered by the field 'position'.") + private List lastTariffs; + public Account getAccount() { return account; } @@ -84,4 +89,12 @@ public class PresetVariables { public void setZone(GenericPresetVariable zone) { this.zone = zone; } + + public List getLastTariffs() { + return lastTariffs; + } + + public void setLastTariffs(List lastTariffs) { + this.lastTariffs = lastTariffs; + } } diff --git a/framework/quota/src/main/java/org/apache/cloudstack/quota/constant/QuotaTypes.java b/framework/quota/src/main/java/org/apache/cloudstack/quota/constant/QuotaTypes.java index 947183577a8..0da0d6e53f7 100644 --- a/framework/quota/src/main/java/org/apache/cloudstack/quota/constant/QuotaTypes.java +++ b/framework/quota/src/main/java/org/apache/cloudstack/quota/constant/QuotaTypes.java @@ -20,9 +20,11 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import com.cloud.utils.exception.CloudRuntimeException; import org.apache.cloudstack.usage.UsageTypes; import org.apache.cloudstack.usage.UsageUnitTypes; import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils; +import org.apache.commons.lang3.StringUtils; public class QuotaTypes extends UsageTypes { private final Integer quotaType; @@ -106,6 +108,20 @@ public class QuotaTypes extends UsageTypes { return quotaTypeMap.get(quotaType); } + static public QuotaTypes getQuotaTypeByName(String name) { + if (StringUtils.isBlank(name)) { + throw new CloudRuntimeException("Could not retrieve Quota type by name because the value passed as parameter is null, empty, or blank."); + } + + for (QuotaTypes type : quotaTypeMap.values()) { + if (type.getQuotaName().equals(name)) { + return type; + } + } + + throw new CloudRuntimeException(String.format("Could not find Quota type with name [%s].", name)); + } + @Override public String toString() { return ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "quotaType", "quotaName"); diff --git a/framework/rest/pom.xml b/framework/rest/pom.xml index d1ffff3c7bd..37a9791bd38 100644 --- a/framework/rest/pom.xml +++ b/framework/rest/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml cloud-framework-rest diff --git a/framework/security/pom.xml b/framework/security/pom.xml index f41d5460bb7..05a108b4d45 100644 --- a/framework/security/pom.xml +++ b/framework/security/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-framework - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/framework/spring/lifecycle/pom.xml b/framework/spring/lifecycle/pom.xml index fbdb2e60dc6..7c648d225cf 100644 --- a/framework/spring/lifecycle/pom.xml +++ b/framework/spring/lifecycle/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../../pom.xml diff --git a/framework/spring/module/pom.xml b/framework/spring/module/pom.xml index ea39e3a6141..0a2280bff44 100644 --- a/framework/spring/module/pom.xml +++ b/framework/spring/module/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../../pom.xml diff --git a/packaging/el8/cloud.spec b/packaging/el8/cloud.spec index a88d4b1cbbf..eb03cfe0df4 100644 --- a/packaging/el8/cloud.spec +++ b/packaging/el8/cloud.spec @@ -102,6 +102,7 @@ Requires: java-17-openjdk Requires: tzdata-java Requires: %{name}-common = %{_ver} Requires: libvirt +Requires: libvirt-daemon-driver-storage-rbd Requires: ebtables Requires: iptables Requires: ethtool @@ -244,6 +245,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/lib mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management +mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/systemd/system/%{name}-management.service.d mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/run mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup/wheel @@ -293,6 +295,7 @@ install -D utils/target/cloud-utils-%{_maventag}-bundled.jar ${RPM_BUILD_ROOT}%{ install -D packaging/el8/cloud-ipallocator.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-ipallocator install -D packaging/el8/cloud.limits ${RPM_BUILD_ROOT}%{_sysconfdir}/security/limits.d/cloud +install -D packaging/el8/filelimit.conf ${RPM_BUILD_ROOT}%{_sysconfdir}/systemd/system/%{name}-management.service.d install -D packaging/systemd/cloudstack-management.service ${RPM_BUILD_ROOT}%{_unitdir}/%{name}-management.service install -D packaging/systemd/cloudstack-management.default ${RPM_BUILD_ROOT}%{_sysconfdir}/default/%{name}-management install -D server/target/conf/cloudstack-sudoers ${RPM_BUILD_ROOT}%{_sysconfdir}/sudoers.d/%{name}-management @@ -574,6 +577,7 @@ pip3 install --upgrade /usr/share/cloudstack-marvin/Marvin-*.tar.gz %config(noreplace) %{_sysconfdir}/default/%{name}-management %config(noreplace) %{_sysconfdir}/sudoers.d/%{name}-management %config(noreplace) %{_sysconfdir}/security/limits.d/cloud +%config(noreplace) %{_sysconfdir}/systemd/system/%{name}-management.service.d %config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/db.properties %config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/server.properties %config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/config.json diff --git a/packaging/el8/filelimit.conf b/packaging/el8/filelimit.conf new file mode 100644 index 00000000000..7a8a835e3fe --- /dev/null +++ b/packaging/el8/filelimit.conf @@ -0,0 +1,20 @@ +# 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. + +# should go in /etc/systemd/system/cloudstack-management.service.d/ +[Service] +LimitNPROC=infinity diff --git a/plugins/acl/dynamic-role-based/pom.xml b/plugins/acl/dynamic-role-based/pom.xml index b1972a54ba5..15150a26288 100644 --- a/plugins/acl/dynamic-role-based/pom.xml +++ b/plugins/acl/dynamic-role-based/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/acl/project-role-based/pom.xml b/plugins/acl/project-role-based/pom.xml index 3f5d64d29a7..4745936fc8b 100644 --- a/plugins/acl/project-role-based/pom.xml +++ b/plugins/acl/project-role-based/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/acl/static-role-based/pom.xml b/plugins/acl/static-role-based/pom.xml index 62fb60395e0..158add1395b 100644 --- a/plugins/acl/static-role-based/pom.xml +++ b/plugins/acl/static-role-based/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/affinity-group-processors/explicit-dedication/pom.xml b/plugins/affinity-group-processors/explicit-dedication/pom.xml index d6827ee13b6..d7535ba5925 100644 --- a/plugins/affinity-group-processors/explicit-dedication/pom.xml +++ b/plugins/affinity-group-processors/explicit-dedication/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/affinity-group-processors/host-affinity/pom.xml b/plugins/affinity-group-processors/host-affinity/pom.xml index bd999288717..68c66c41f39 100644 --- a/plugins/affinity-group-processors/host-affinity/pom.xml +++ b/plugins/affinity-group-processors/host-affinity/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/affinity-group-processors/host-anti-affinity/pom.xml b/plugins/affinity-group-processors/host-anti-affinity/pom.xml index b224bbaf34a..ba0dde5949d 100644 --- a/plugins/affinity-group-processors/host-anti-affinity/pom.xml +++ b/plugins/affinity-group-processors/host-anti-affinity/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/affinity-group-processors/non-strict-host-affinity/pom.xml b/plugins/affinity-group-processors/non-strict-host-affinity/pom.xml index bf751ca4141..352cf299dd7 100644 --- a/plugins/affinity-group-processors/non-strict-host-affinity/pom.xml +++ b/plugins/affinity-group-processors/non-strict-host-affinity/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/affinity-group-processors/non-strict-host-anti-affinity/pom.xml b/plugins/affinity-group-processors/non-strict-host-anti-affinity/pom.xml index 445acfc11d6..8896eba19e7 100644 --- a/plugins/affinity-group-processors/non-strict-host-anti-affinity/pom.xml +++ b/plugins/affinity-group-processors/non-strict-host-anti-affinity/pom.xml @@ -32,7 +32,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/alert-handlers/snmp-alerts/pom.xml b/plugins/alert-handlers/snmp-alerts/pom.xml index fad47d426f2..a64fc56ecbf 100644 --- a/plugins/alert-handlers/snmp-alerts/pom.xml +++ b/plugins/alert-handlers/snmp-alerts/pom.xml @@ -24,7 +24,7 @@ cloudstack-plugins org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/alert-handlers/syslog-alerts/pom.xml b/plugins/alert-handlers/syslog-alerts/pom.xml index 54641bd8a8a..957d99fd522 100644 --- a/plugins/alert-handlers/syslog-alerts/pom.xml +++ b/plugins/alert-handlers/syslog-alerts/pom.xml @@ -24,7 +24,7 @@ cloudstack-plugins org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/discovery/pom.xml b/plugins/api/discovery/pom.xml index 6426dcd70a5..e947834c3fa 100644 --- a/plugins/api/discovery/pom.xml +++ b/plugins/api/discovery/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/rate-limit/pom.xml b/plugins/api/rate-limit/pom.xml index 2449a23f2d0..2daba3ff488 100644 --- a/plugins/api/rate-limit/pom.xml +++ b/plugins/api/rate-limit/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/solidfire-intg-test/pom.xml b/plugins/api/solidfire-intg-test/pom.xml index 907c5f2968d..c2385a705c6 100644 --- a/plugins/api/solidfire-intg-test/pom.xml +++ b/plugins/api/solidfire-intg-test/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/vmware-sioc/pom.xml b/plugins/api/vmware-sioc/pom.xml index b3c04e603cb..858e7ea69a0 100644 --- a/plugins/api/vmware-sioc/pom.xml +++ b/plugins/api/vmware-sioc/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/dummy/pom.xml b/plugins/backup/dummy/pom.xml index 52fbd085eb2..3a3749e50a8 100644 --- a/plugins/backup/dummy/pom.xml +++ b/plugins/backup/dummy/pom.xml @@ -23,7 +23,7 @@ cloudstack-plugins org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/nas/pom.xml b/plugins/backup/nas/pom.xml index 096bf45c67e..8160826e573 100644 --- a/plugins/backup/nas/pom.xml +++ b/plugins/backup/nas/pom.xml @@ -25,7 +25,7 @@ cloudstack-plugins org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/networker/pom.xml b/plugins/backup/networker/pom.xml index 1124d281d2e..fd1247ee58e 100644 --- a/plugins/backup/networker/pom.xml +++ b/plugins/backup/networker/pom.xml @@ -25,7 +25,7 @@ cloudstack-plugins org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/backup/veeam/pom.xml b/plugins/backup/veeam/pom.xml index a317f90388a..0e8f8c708a6 100644 --- a/plugins/backup/veeam/pom.xml +++ b/plugins/backup/veeam/pom.xml @@ -23,7 +23,7 @@ cloudstack-plugins org.apache.cloudstack - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/ca/root-ca/pom.xml b/plugins/ca/root-ca/pom.xml index fe1fb006302..da42fd9083c 100644 --- a/plugins/ca/root-ca/pom.xml +++ b/plugins/ca/root-ca/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/database/mysql-ha/pom.xml b/plugins/database/mysql-ha/pom.xml index 37a07784341..b23719df14f 100644 --- a/plugins/database/mysql-ha/pom.xml +++ b/plugins/database/mysql-ha/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/database/quota/pom.xml b/plugins/database/quota/pom.xml index b574b263020..3439f2f855c 100644 --- a/plugins/database/quota/pom.xml +++ b/plugins/database/quota/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaBalanceCmd.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaBalanceCmd.java index 218e3c2b2f9..628eca56c2d 100644 --- a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaBalanceCmd.java +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaBalanceCmd.java @@ -21,6 +21,9 @@ import java.util.List; import javax.inject.Inject; +import com.cloud.user.Account; + +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd; @@ -40,6 +43,7 @@ public class QuotaBalanceCmd extends BaseCmd { @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "Account Id for which statement needs to be generated") private String accountName; + @ACL @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class, description = "If domain Id is given and the caller is domain admin then the statement is generated for domain.") private Long domainId; @@ -51,6 +55,7 @@ public class QuotaBalanceCmd extends BaseCmd { ApiConstants.PARAMETER_DESCRIPTION_START_DATE_POSSIBLE_FORMATS) private Date startDate; + @ACL @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "List usage records for the specified account") private Long accountId; @@ -104,7 +109,14 @@ public class QuotaBalanceCmd extends BaseCmd { @Override public long getEntityOwnerId() { - return _accountService.getActiveAccountByName(accountName, domainId).getAccountId(); + if (accountId != null) { + return accountId; + } + Account account = _accountService.getActiveAccountByName(accountName, domainId); + if (account != null) { + return account.getAccountId(); + } + return Account.ACCOUNT_ID_SYSTEM; } @Override diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaCreditsCmd.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaCreditsCmd.java index 8ca29f275dd..cfa391291c8 100644 --- a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaCreditsCmd.java +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaCreditsCmd.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command; import com.cloud.user.Account; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -46,6 +47,7 @@ public class QuotaCreditsCmd extends BaseCmd { @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "Account Id for which quota credits need to be added") private String accountName; + @ACL @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class, description = "Domain for which quota credits need to be added") private Long domainId; @@ -130,6 +132,10 @@ public class QuotaCreditsCmd extends BaseCmd { @Override public long getEntityOwnerId() { + Account account = _accountService.getActiveAccountByName(accountName, domainId); + if (account != null) { + return account.getAccountId(); + } return Account.ACCOUNT_ID_SYSTEM; } diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaStatementCmd.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaStatementCmd.java index 4fb33f79672..78fa0f7df84 100644 --- a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaStatementCmd.java +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaStatementCmd.java @@ -21,6 +21,7 @@ import java.util.List; import javax.inject.Inject; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd; @@ -42,6 +43,7 @@ public class QuotaStatementCmd extends BaseCmd { @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "Optional, Account Id for which statement needs to be generated") private String accountName; + @ACL @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = true, entityType = DomainResponse.class, description = "Optional, If domain Id is given and the caller is domain admin then the statement is generated for domain.") private Long domainId; @@ -56,6 +58,7 @@ public class QuotaStatementCmd extends BaseCmd { @Parameter(name = ApiConstants.TYPE, type = CommandType.INTEGER, description = "List quota usage records for the specified usage type") private Integer usageType; + @ACL @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "List usage records for the specified account") private Long accountId; @@ -112,6 +115,9 @@ public class QuotaStatementCmd extends BaseCmd { @Override public long getEntityOwnerId() { + if (accountId != null) { + return accountId; + } Account activeAccountByName = _accountService.getActiveAccountByName(accountName, domainId); if (activeAccountByName != null) { return activeAccountByName.getAccountId(); diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaValidateActivationRuleCmd.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaValidateActivationRuleCmd.java new file mode 100644 index 00000000000..a9dc7ea63eb --- /dev/null +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaValidateActivationRuleCmd.java @@ -0,0 +1,70 @@ +//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 org.apache.cloudstack.api.command; + +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.user.Account; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.QuotaResponseBuilder; +import org.apache.cloudstack.api.response.QuotaValidateActivationRuleResponse; +import org.apache.cloudstack.quota.constant.QuotaTypes; + +import javax.inject.Inject; + +@APICommand(name = "quotaValidateActivationRule", responseObject = QuotaValidateActivationRuleResponse.class, description = "Validates if the given activation rule is valid for the informed usage type.", since = "4.20.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaValidateActivationRuleCmd extends BaseCmd { + + @Inject + QuotaResponseBuilder responseBuilder; + + @Parameter(name = ApiConstants.ACTIVATION_RULE, type = CommandType.STRING, required = true, description = "Quota tariff's activation rule to validate. The activation rule is valid if it has no syntax errors and all " + + "variables are compatible with the given usage type.", length = 65535) + private String activationRule; + + @Parameter(name = ApiConstants.USAGE_TYPE, type = CommandType.INTEGER, required = true, description = "The Quota usage type used to validate the activation rule.") + private Integer quotaType; + + @Override + public void execute() { + QuotaValidateActivationRuleResponse response = responseBuilder.validateActivationRule(this); + + response.setResponseName(getCommandName()); + setResponseObject(response); + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + public String getActivationRule() { + return activationRule; + } + + public QuotaTypes getQuotaType() { + QuotaTypes quotaTypes = QuotaTypes.getQuotaType(quotaType); + + if (quotaTypes == null) { + throw new InvalidParameterValueException(String.format("Usage type not found for value [%s].", quotaType)); + } + + return quotaTypes; + } +} diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilder.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilder.java index c635551aeb5..56935a1360c 100644 --- a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilder.java +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilder.java @@ -26,6 +26,7 @@ import org.apache.cloudstack.api.command.QuotaStatementCmd; import org.apache.cloudstack.api.command.QuotaTariffCreateCmd; import org.apache.cloudstack.api.command.QuotaTariffListCmd; import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd; +import org.apache.cloudstack.api.command.QuotaValidateActivationRuleCmd; import org.apache.cloudstack.quota.vo.QuotaBalanceVO; import org.apache.cloudstack.quota.vo.QuotaEmailConfigurationVO; import org.apache.cloudstack.quota.vo.QuotaTariffVO; @@ -88,4 +89,6 @@ public interface QuotaResponseBuilder { QuotaConfigureEmailResponse createQuotaConfigureEmailResponse(QuotaEmailConfigurationVO quotaEmailConfigurationVO, Double minBalance, long accountId); List listEmailConfiguration(long accountId); + + QuotaValidateActivationRuleResponse validateActivationRule(QuotaValidateActivationRuleCmd cmd); } diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java index 1c486759e43..733f7792356 100644 --- a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java @@ -16,6 +16,7 @@ //under the License. package org.apache.cloudstack.api.response; +import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; @@ -34,12 +35,15 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.Map; +import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; import javax.inject.Inject; import com.cloud.utils.DateUtil; +import com.cloud.utils.exception.CloudRuntimeException; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.command.QuotaBalanceCmd; @@ -51,8 +55,10 @@ import org.apache.cloudstack.api.command.QuotaStatementCmd; import org.apache.cloudstack.api.command.QuotaTariffCreateCmd; import org.apache.cloudstack.api.command.QuotaTariffListCmd; import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd; +import org.apache.cloudstack.api.command.QuotaValidateActivationRuleCmd; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.discovery.ApiDiscoveryService; +import org.apache.cloudstack.jsinterpreter.JsInterpreterHelper; import org.apache.cloudstack.quota.QuotaManager; import org.apache.cloudstack.quota.QuotaManagerImpl; import org.apache.cloudstack.quota.QuotaService; @@ -78,6 +84,7 @@ import org.apache.cloudstack.quota.vo.QuotaEmailConfigurationVO; import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO; import org.apache.cloudstack.quota.vo.QuotaTariffVO; import org.apache.cloudstack.quota.vo.QuotaUsageVO; +import org.apache.cloudstack.utils.jsinterpreter.JsInterpreter; import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.FieldUtils; @@ -133,11 +140,13 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder { private QuotaManager _quotaManager; @Inject private QuotaEmailConfigurationDao quotaEmailConfigurationDao; + @Inject + private JsInterpreterHelper jsInterpreterHelper; + @Inject + private ApiDiscoveryService apiDiscoveryService; private final Class[] assignableClasses = {GenericPresetVariable.class, ComputingResources.class}; - @Inject - private ApiDiscoveryService apiDiscoveryService; @Override public QuotaTariffResponse createQuotaTariffResponse(QuotaTariffVO tariff, boolean returnActivationRule) { @@ -789,7 +798,7 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder { */ public void filterSupportedTypes(List> variables, QuotaTypes quotaType, PresetVariableDefinition presetVariableDefinitionAnnotation, Class fieldClass, String presetVariableName) { - if (Arrays.stream(presetVariableDefinitionAnnotation.supportedTypes()).noneMatch(supportedType -> + if (quotaType != null && Arrays.stream(presetVariableDefinitionAnnotation.supportedTypes()).noneMatch(supportedType -> supportedType == quotaType.getQuotaType() || supportedType == 0)) { return; } @@ -928,4 +937,82 @@ public class QuotaResponseBuilderImpl implements QuotaResponseBuilder { return quotaConfigureEmailResponse; } + + @Override + public QuotaValidateActivationRuleResponse validateActivationRule(QuotaValidateActivationRuleCmd cmd) { + String message; + String activationRule = cmd.getActivationRule(); + QuotaTypes quotaType = cmd.getQuotaType(); + String quotaName = quotaType.getQuotaName(); + List> usageTypeVariablesAndDescriptions = new ArrayList<>(); + + addAllPresetVariables(PresetVariables.class, quotaType, usageTypeVariablesAndDescriptions, null); + List usageTypeVariables = usageTypeVariablesAndDescriptions.stream().map(Pair::first).collect(Collectors.toList()); + + try (JsInterpreter jsInterpreter = new JsInterpreter(QuotaConfig.QuotaActivationRuleTimeout.value())) { + Map newVariables = injectUsageTypeVariables(jsInterpreter, usageTypeVariables); + String scriptToExecute = jsInterpreterHelper.replaceScriptVariables(activationRule, newVariables); + jsInterpreter.executeScript(String.format("new Function(\"%s\")", scriptToExecute.replaceAll("\n", ""))); + } catch (IOException | CloudRuntimeException e) { + logger.error("Unable to execute activation rule due to: [{}].", e.getMessage(), e); + message = "Error while executing activation rule. Check if there are no syntax errors and all variables are compatible with the given usage type."; + return createValidateActivationRuleResponse(activationRule, quotaName, false, message); + } + + Set scriptVariables = jsInterpreterHelper.getScriptVariables(activationRule); + if (isScriptVariablesValid(scriptVariables, usageTypeVariables)) { + message = "The script has no syntax errors and all variables are compatible with the given usage type."; + return createValidateActivationRuleResponse(activationRule, quotaName, true, message); + } + + message = "Found variables that are not compatible with the given usage type."; + return createValidateActivationRuleResponse(activationRule, quotaName, false, message); + } + + /** + * Checks whether script variables are compatible with the usage type. First, we remove all script variables that correspond to the script's usage type variables. + * Then, returns true if none of the remaining script variables match any usage types variables, and false otherwise. + * + * @param scriptVariables Script variables. + * @param scriptUsageTypeVariables Script usage type variables. + * @return True if the script variables are valid, false otherwise. + */ + protected boolean isScriptVariablesValid(Set scriptVariables, List scriptUsageTypeVariables) { + List> allUsageTypeVariablesAndDescriptions = new ArrayList<>(); + addAllPresetVariables(PresetVariables.class, null, allUsageTypeVariablesAndDescriptions, null); + List allUsageTypesVariables = allUsageTypeVariablesAndDescriptions.stream().map(Pair::first).collect(Collectors.toList()); + + List matchVariables = scriptVariables.stream().filter(scriptUsageTypeVariables::contains).collect(Collectors.toList()); + matchVariables.forEach(scriptVariables::remove); + + return scriptVariables.stream().noneMatch(allUsageTypesVariables::contains); + } + + /** + * Injects variables into JavaScript interpreter. It's necessary to remove all dots from the given variables, as the interpreter + * does not interpret the variables as attributes of objects. + * + * @param jsInterpreter the {@link JsInterpreter} which the variables will be injected. + * @param variables the {@link List} with variables to format and inject the formatted variables into interpreter. + * @return A {@link Map} which has the key as the given variable and the value as the given variable formatted (without dots). + */ + protected Map injectUsageTypeVariables(JsInterpreter jsInterpreter, List variables) { + Map formattedVariables = new HashMap<>(); + for (String variable : variables) { + String formattedVariable = variable.replace(".", ""); + formattedVariables.put(variable, formattedVariable); + jsInterpreter.injectVariable(formattedVariable, "false"); + } + + return formattedVariables; + } + + public QuotaValidateActivationRuleResponse createValidateActivationRuleResponse(String activationRule, String quotaType, Boolean isValid, String message) { + QuotaValidateActivationRuleResponse response = new QuotaValidateActivationRuleResponse(); + response.setActivationRule(activationRule); + response.setQuotaType(quotaType); + response.setValid(isValid); + response.setMessage(message); + return response; + } } diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaValidateActivationRuleResponse.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaValidateActivationRuleResponse.java new file mode 100644 index 00000000000..0726764568f --- /dev/null +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaValidateActivationRuleResponse.java @@ -0,0 +1,76 @@ +//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 org.apache.cloudstack.api.response; + +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; +import org.apache.cloudstack.api.BaseResponse; + +public class QuotaValidateActivationRuleResponse extends BaseResponse { + + @SerializedName("activationrule") + @Param(description = "The validated activation rule.") + private String activationRule; + + @SerializedName("quotatype") + @Param(description = "The Quota usage type used to validate the activation rule.") + private String quotaType; + + @SerializedName("isvalid") + @Param(description = "Whether the activation rule is valid.") + private Boolean isValid; + + @SerializedName("message") + @Param(description = "The reason whether the activation rule is valid or not.") + private String message; + + public QuotaValidateActivationRuleResponse() { + super("validactivationrule"); + } + + public String getActivationRule() { + return activationRule; + } + + public void setActivationRule(String activationRule) { + this.activationRule = activationRule; + } + + public Boolean isValid() { + return isValid; + } + + public void setValid(Boolean valid) { + isValid = valid; + } + + public String getQuotaType() { + return quotaType; + } + + public void setQuotaType(String quotaType) { + this.quotaType = quotaType; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java b/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java index 17fa7bd8425..97d77b8aa22 100644 --- a/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java +++ b/plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java @@ -41,6 +41,7 @@ import org.apache.cloudstack.api.command.QuotaTariffDeleteCmd; import org.apache.cloudstack.api.command.QuotaTariffListCmd; import org.apache.cloudstack.api.command.QuotaTariffUpdateCmd; import org.apache.cloudstack.api.command.QuotaUpdateCmd; +import org.apache.cloudstack.api.command.QuotaValidateActivationRuleCmd; import org.apache.cloudstack.api.response.QuotaResponseBuilder; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.framework.config.ConfigKey; @@ -121,6 +122,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi cmdList.add(QuotaConfigureEmailCmd.class); cmdList.add(QuotaListEmailConfigurationCmd.class); cmdList.add(QuotaPresetVariablesListCmd.class); + cmdList.add(QuotaValidateActivationRuleCmd.class); return cmdList; } diff --git a/plugins/database/quota/src/test/java/org/apache/cloudstack/api/command/QuotaValidateActivationRuleCmdTest.java b/plugins/database/quota/src/test/java/org/apache/cloudstack/api/command/QuotaValidateActivationRuleCmdTest.java new file mode 100644 index 00000000000..1d0c0cf7ff6 --- /dev/null +++ b/plugins/database/quota/src/test/java/org/apache/cloudstack/api/command/QuotaValidateActivationRuleCmdTest.java @@ -0,0 +1,41 @@ +// 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 org.apache.cloudstack.api.command; + +import org.apache.cloudstack.api.response.QuotaResponseBuilder; +import org.apache.cloudstack.api.response.QuotaValidateActivationRuleResponse; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class QuotaValidateActivationRuleCmdTest { + @Mock + QuotaResponseBuilder responseBuilderMock; + + @Test + public void executeTestVerifyCalls() { + QuotaValidateActivationRuleCmd cmd = new QuotaValidateActivationRuleCmd(); + cmd.responseBuilder = responseBuilderMock; + Mockito.doReturn(new QuotaValidateActivationRuleResponse()).when(responseBuilderMock).validateActivationRule(cmd); + cmd.execute(); + + Mockito.verify(responseBuilderMock).validateActivationRule(cmd); + } +} diff --git a/plugins/database/quota/src/test/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImplTest.java b/plugins/database/quota/src/test/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImplTest.java index fd359525893..a26e6c0476d 100644 --- a/plugins/database/quota/src/test/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImplTest.java +++ b/plugins/database/quota/src/test/java/org/apache/cloudstack/api/response/QuotaResponseBuilderImplTest.java @@ -25,6 +25,9 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.HashSet; import java.util.function.Consumer; import com.cloud.domain.DomainVO; @@ -34,7 +37,10 @@ import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.command.QuotaConfigureEmailCmd; import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd; import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd; +import org.apache.cloudstack.api.command.QuotaValidateActivationRuleCmd; +import org.apache.cloudstack.discovery.ApiDiscoveryService; import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.jsinterpreter.JsInterpreterHelper; import org.apache.cloudstack.quota.QuotaService; import org.apache.cloudstack.quota.QuotaStatement; import org.apache.cloudstack.quota.activationrule.presetvariables.PresetVariableDefinition; @@ -55,7 +61,7 @@ import org.apache.cloudstack.quota.vo.QuotaCreditsVO; import org.apache.cloudstack.quota.vo.QuotaEmailConfigurationVO; import org.apache.cloudstack.quota.vo.QuotaEmailTemplatesVO; import org.apache.cloudstack.quota.vo.QuotaTariffVO; -import org.apache.cloudstack.discovery.ApiDiscoveryService; +import org.apache.cloudstack.utils.jsinterpreter.JsInterpreter; import org.apache.commons.lang3.time.DateUtils; @@ -160,6 +166,12 @@ public class QuotaResponseBuilderImplTest extends TestCase { return new Calendar[] {calendar, calendar}; } + @Mock + QuotaValidateActivationRuleCmd quotaValidateActivationRuleCmdMock = Mockito.mock(QuotaValidateActivationRuleCmd.class); + + @Mock + JsInterpreterHelper jsInterpreterHelperMock = Mockito.mock(JsInterpreterHelper.class); + private QuotaTariffVO makeTariffTestData() { QuotaTariffVO tariffVO = new QuotaTariffVO(); tariffVO.setUsageType(QuotaTypes.IP_ADDRESS); @@ -645,4 +657,78 @@ public class QuotaResponseBuilderImplTest extends TestCase { assertFalse(quotaResponseBuilderSpy.isUserAllowedToSeeActivationRules(userMock)); } + + @Test + public void validateActivationRuleTestValidateActivationRuleReturnValidScriptResponse() { + Mockito.doReturn("if (account.name == 'test') { true } else { false }").when(quotaValidateActivationRuleCmdMock).getActivationRule(); + Mockito.doReturn(QuotaTypes.getQuotaType(30)).when(quotaValidateActivationRuleCmdMock).getQuotaType(); + Mockito.doReturn(quotaValidateActivationRuleCmdMock.getActivationRule()).when(jsInterpreterHelperMock).replaceScriptVariables(Mockito.anyString(), Mockito.any()); + + QuotaValidateActivationRuleResponse response = quotaResponseBuilderSpy.validateActivationRule(quotaValidateActivationRuleCmdMock); + + Assert.assertTrue(response.isValid()); + } + + @Test + public void validateActivationRuleTestUsageTypeIncompatibleVariableReturnInvalidScriptResponse() { + Mockito.doReturn("if (value.osName == 'test') { true } else { false }").when(quotaValidateActivationRuleCmdMock).getActivationRule(); + Mockito.doReturn(QuotaTypes.getQuotaType(30)).when(quotaValidateActivationRuleCmdMock).getQuotaType(); + Mockito.doReturn(quotaValidateActivationRuleCmdMock.getActivationRule()).when(jsInterpreterHelperMock).replaceScriptVariables(Mockito.anyString(), Mockito.any()); + Mockito.when(jsInterpreterHelperMock.getScriptVariables(quotaValidateActivationRuleCmdMock.getActivationRule())).thenReturn(Set.of("value.osName")); + + QuotaValidateActivationRuleResponse response = quotaResponseBuilderSpy.validateActivationRule(quotaValidateActivationRuleCmdMock); + + Assert.assertFalse(response.isValid()); + } + + @Test + public void validateActivationRuleTestActivationRuleWithSyntaxErrorsReturnInvalidScriptResponse() { + Mockito.doReturn("{ if (account.name == 'test') { true } else { false } }}").when(quotaValidateActivationRuleCmdMock).getActivationRule(); + Mockito.doReturn(QuotaTypes.getQuotaType(1)).when(quotaValidateActivationRuleCmdMock).getQuotaType(); + Mockito.doReturn(quotaValidateActivationRuleCmdMock.getActivationRule()).when(jsInterpreterHelperMock).replaceScriptVariables(Mockito.anyString(), Mockito.any()); + + QuotaValidateActivationRuleResponse response = quotaResponseBuilderSpy.validateActivationRule(quotaValidateActivationRuleCmdMock); + + Assert.assertFalse(response.isValid()); + } + + @Test + public void isScriptVariablesValidTestUnsupportedUsageTypeVariablesReturnFalse() { + Set scriptVariables = new HashSet<>(List.of("value.computingResources.cpuNumber", "account.name", "zone.id")); + List usageTypeVariables = List.of("value.virtualSize", "account.name", "zone.id"); + + boolean isScriptVariablesValid = quotaResponseBuilderSpy.isScriptVariablesValid(scriptVariables, usageTypeVariables); + + Assert.assertFalse(isScriptVariablesValid); + } + + @Test + public void isScriptVariablesValidTestSupportedUsageTypeVariablesReturnTrue() { + Set scriptVariables = new HashSet<>(List.of("value.computingResources.cpuNumber", "account.name", "zone.id")); + List usageTypeVariables = List.of("value.computingResources.cpuNumber", "account.name", "zone.id"); + + boolean isScriptVariablesValid = quotaResponseBuilderSpy.isScriptVariablesValid(scriptVariables, usageTypeVariables); + + Assert.assertTrue(isScriptVariablesValid); + } + + @Test + public void isScriptVariablesValidTestVariablesUnrelatedToUsageTypeReturnTrue() { + Set scriptVariables = new HashSet<>(List.of("variable1.valid", "variable2.valid.", "variable3.valid")); + List usageTypeVariables = List.of("project.name", "account.id", "domain.path"); + + boolean isScriptVariablesValid = quotaResponseBuilderSpy.isScriptVariablesValid(scriptVariables, usageTypeVariables); + + Assert.assertTrue(isScriptVariablesValid); + } + + @Test + public void injectUsageTypeVariablesTestReturnInjectedVariables() { + JsInterpreter interpreter = Mockito.mock(JsInterpreter.class); + + Map formattedVariables = quotaResponseBuilderSpy.injectUsageTypeVariables(interpreter, List.of("account.name", "zone.name")); + + Assert.assertTrue(formattedVariables.containsValue("accountname")); + Assert.assertTrue(formattedVariables.containsValue("zonename")); + } } diff --git a/plugins/dedicated-resources/pom.xml b/plugins/dedicated-resources/pom.xml index 5aeecec818d..cffeddec7a7 100644 --- a/plugins/dedicated-resources/pom.xml +++ b/plugins/dedicated-resources/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../pom.xml diff --git a/plugins/deployment-planners/implicit-dedication/pom.xml b/plugins/deployment-planners/implicit-dedication/pom.xml index b9f8be5d08a..12454d37270 100644 --- a/plugins/deployment-planners/implicit-dedication/pom.xml +++ b/plugins/deployment-planners/implicit-dedication/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/deployment-planners/user-concentrated-pod/pom.xml b/plugins/deployment-planners/user-concentrated-pod/pom.xml index 0dcbe3506c6..ad3ac14a5b5 100644 --- a/plugins/deployment-planners/user-concentrated-pod/pom.xml +++ b/plugins/deployment-planners/user-concentrated-pod/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/deployment-planners/user-dispersing/pom.xml b/plugins/deployment-planners/user-dispersing/pom.xml index bbd74bf1a7a..a05577ed04b 100644 --- a/plugins/deployment-planners/user-dispersing/pom.xml +++ b/plugins/deployment-planners/user-dispersing/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/drs/cluster/balanced/pom.xml b/plugins/drs/cluster/balanced/pom.xml index 743a5f2bc98..4db1bd796f8 100644 --- a/plugins/drs/cluster/balanced/pom.xml +++ b/plugins/drs/cluster/balanced/pom.xml @@ -27,7 +27,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/drs/cluster/condensed/pom.xml b/plugins/drs/cluster/condensed/pom.xml index 60b472bccb5..29a8ae2081d 100644 --- a/plugins/drs/cluster/condensed/pom.xml +++ b/plugins/drs/cluster/condensed/pom.xml @@ -27,7 +27,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../../pom.xml diff --git a/plugins/event-bus/inmemory/pom.xml b/plugins/event-bus/inmemory/pom.xml index be85e8afd8d..d3b389d9b3f 100644 --- a/plugins/event-bus/inmemory/pom.xml +++ b/plugins/event-bus/inmemory/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/kafka/pom.xml b/plugins/event-bus/kafka/pom.xml index 44014847548..95667c5cc79 100644 --- a/plugins/event-bus/kafka/pom.xml +++ b/plugins/event-bus/kafka/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/rabbitmq/pom.xml b/plugins/event-bus/rabbitmq/pom.xml index 1e04caf026f..5ccc2a813ed 100644 --- a/plugins/event-bus/rabbitmq/pom.xml +++ b/plugins/event-bus/rabbitmq/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/webhook/pom.xml b/plugins/event-bus/webhook/pom.xml index 278f4dc0ec5..e9dc24804f5 100644 --- a/plugins/event-bus/webhook/pom.xml +++ b/plugins/event-bus/webhook/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/ha-planners/skip-heurestics/pom.xml b/plugins/ha-planners/skip-heurestics/pom.xml index 3dc3989da2c..4f47bf7ee75 100644 --- a/plugins/ha-planners/skip-heurestics/pom.xml +++ b/plugins/ha-planners/skip-heurestics/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/host-allocators/random/pom.xml b/plugins/host-allocators/random/pom.xml index f01494914ce..8f04ec9b63b 100644 --- a/plugins/host-allocators/random/pom.xml +++ b/plugins/host-allocators/random/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/baremetal/pom.xml b/plugins/hypervisors/baremetal/pom.xml index d866c9b47e2..f75cb4a4b6c 100755 --- a/plugins/hypervisors/baremetal/pom.xml +++ b/plugins/hypervisors/baremetal/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml cloud-plugin-hypervisor-baremetal diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.Designer.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.Designer.cs index 4bf424fa4b9..4b4d8bd121c 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.Designer.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.Designer.cs @@ -18,7 +18,7 @@ namespace CloudStack.Plugin.AgentShell { partial class AgentService { - /// + /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; @@ -38,8 +38,8 @@ namespace CloudStack.Plugin.AgentShell #region Component Designer generated code - /// - /// Required method for Designer support - do not modify + /// + /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs index 94b640edd1b..e2fecd52e47 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentService.cs @@ -67,7 +67,7 @@ namespace CloudStack.Plugin.AgentShell 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 + // 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. diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs index fc3b69af3e8..5e89a18fb2d 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentSettings.Designer.cs @@ -16,20 +16,20 @@ // under the License. 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")] @@ -38,7 +38,7 @@ namespace CloudStack.Plugin.AgentShell { return ((int)(this["cpus"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("Routing")] @@ -47,7 +47,7 @@ namespace CloudStack.Plugin.AgentShell { return ((string)(this["type"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("5fe2bad3-d785-394e-9949-89786b8a63d2")] @@ -56,7 +56,7 @@ namespace CloudStack.Plugin.AgentShell { return ((global::System.Guid)(this["local_storage_uuid"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("hvm")] @@ -65,7 +65,7 @@ namespace CloudStack.Plugin.AgentShell { return ((string)(this["capabilities"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("2130")] @@ -74,7 +74,7 @@ namespace CloudStack.Plugin.AgentShell { return ((int)(this["Settingcpuspeed"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("8250")] @@ -83,7 +83,7 @@ namespace CloudStack.Plugin.AgentShell { return ((int)(this["port"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("34359738368")] @@ -92,7 +92,7 @@ namespace CloudStack.Plugin.AgentShell { return ((long)(this["memory"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("camldonall01.citrite.net")] @@ -101,7 +101,7 @@ namespace CloudStack.Plugin.AgentShell { return ((string)(this["host"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("1")] @@ -110,7 +110,7 @@ namespace CloudStack.Plugin.AgentShell { return ((int)(this["pod"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("10.1.1.1")] @@ -119,7 +119,7 @@ namespace CloudStack.Plugin.AgentShell { return ((string)(this["gateway_ip_address"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public global::System.Guid guid { @@ -127,7 +127,7 @@ namespace CloudStack.Plugin.AgentShell { return ((global::System.Guid)(this["guid"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("2")] @@ -136,7 +136,7 @@ namespace CloudStack.Plugin.AgentShell { return ((int)(this["cluster"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("1")] @@ -145,7 +145,7 @@ namespace CloudStack.Plugin.AgentShell { return ((int)(this["zone"])); } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("c:\\Secondary")] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.AgentShell { this["local_secondary_storage_path"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("E:\\Disks\\Disks")] @@ -169,7 +169,7 @@ namespace CloudStack.Plugin.AgentShell { this["local_storage_path"] = value; } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("5")] @@ -178,7 +178,7 @@ namespace CloudStack.Plugin.AgentShell { return ((int)(this["workers"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("255.255.240.0")] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.AgentShell { return ((string)(this["private_ip_netmask"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("4294967296")] @@ -196,7 +196,7 @@ namespace CloudStack.Plugin.AgentShell { return ((long)(this["RootDeviceReservedSpaceBytes"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("../../../../../")] @@ -205,7 +205,7 @@ namespace CloudStack.Plugin.AgentShell { return ((string)(this["hyperv_plugin_root"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("e:\\")] @@ -214,7 +214,7 @@ namespace CloudStack.Plugin.AgentShell { return ((string)(this["RootDeviceName"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("101F742C6B88")] @@ -247,7 +247,7 @@ namespace CloudStack.Plugin.AgentShell { this["testLocalStorePath"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("testS3Bucket")] @@ -259,7 +259,7 @@ namespace CloudStack.Plugin.AgentShell { this["testS3Bucket"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("testS3Endpoint")] @@ -271,7 +271,7 @@ namespace CloudStack.Plugin.AgentShell { this["testS3Endpoint"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("testS3AccessKey")] @@ -283,7 +283,7 @@ namespace CloudStack.Plugin.AgentShell { this["testS3AccessKey"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("testS3SecretKey")] @@ -295,7 +295,7 @@ namespace CloudStack.Plugin.AgentShell { this["testS3SecretKey"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("206-2-73592258-559a-3b38-8f66-b667aab143eb")] @@ -307,7 +307,7 @@ namespace CloudStack.Plugin.AgentShell { this["testS3TemplateName"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("5fe2bad3-d785-394e-9949-89786b8a63d2")] @@ -319,7 +319,7 @@ namespace CloudStack.Plugin.AgentShell { this["testLocalStoreUUID"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("acton-systemvm-02062012.vhd.bz2")] @@ -331,7 +331,7 @@ namespace CloudStack.Plugin.AgentShell { this["testSystemVMTemplateName"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("acton-systemvm-02062012")] @@ -343,7 +343,7 @@ namespace CloudStack.Plugin.AgentShell { this["testSystemVMTemplateNameNoExt"] = value; } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("2048")] @@ -352,7 +352,7 @@ namespace CloudStack.Plugin.AgentShell { return ((ulong)(this["dom0MinMemory"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("10.1.1.1")] @@ -361,7 +361,7 @@ namespace CloudStack.Plugin.AgentShell { 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" + @@ -374,7 +374,7 @@ namespace CloudStack.Plugin.AgentShell { 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")] diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/ProjectInstaller.Designer.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/ProjectInstaller.Designer.cs index 2c6ffe24462..3668a592732 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/ProjectInstaller.Designer.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/ProjectInstaller.Designer.cs @@ -23,7 +23,7 @@ namespace CloudStack.Plugin.AgentShell /// private System.ComponentModel.IContainer components = null; - /// + /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Properties/AssemblyInfo.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Properties/AssemblyInfo.cs index bd188bb0ef2..1216f9b1fcb 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Properties/AssemblyInfo.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/Properties/AssemblyInfo.cs @@ -19,7 +19,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// 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")] @@ -31,8 +31,8 @@ using System.Runtime.InteropServices; [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 +// 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)] @@ -42,11 +42,11 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// 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")] diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs index 306bc96f8c9..2e3de19939d 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/CloudStackTypes.cs @@ -26,7 +26,7 @@ using System.Threading.Tasks; // C# versions of certain CloudStack types to simplify JSON serialisation. // Limit to the number of types, because they are written and maintained manually. // JsonProperty used to identify property name when serialised, which allows -// later adoption of C# naming conventions if requried. +// later adoption of C# naming conventions if requried. namespace HypervResource { public class PrimaryDataStoreTO @@ -474,15 +474,15 @@ namespace HypervResource /// Filesystem, /// - /// NFS or CIFS + /// NFS or CIFS /// NetworkFilesystem, /// - /// shared LUN, with a clusterfs overlay + /// shared LUN, with a clusterfs overlay /// IscsiLUN, /// - /// for e.g., ZFS Comstar + /// for e.g., ZFS Comstar /// Iscsi, /// @@ -494,31 +494,31 @@ namespace HypervResource /// LVM, /// - /// + /// /// CLVM, /// - /// + /// /// RBD, /// - /// + /// /// SharedMountPoint, /// - /// VMware VMFS storage + /// VMware VMFS storage /// VMFS, /// - /// for XenServer, Storage Pool is set up by customers. + /// for XenServer, Storage Pool is set up by customers. /// PreSetup, /// - /// XenServer local EXT SR + /// XenServer local EXT SR /// EXT, /// - /// + /// /// OCFS2, /// @@ -662,7 +662,7 @@ namespace HypervResource } /// - /// Fully qualified named for a number of types used in CloudStack. Used to specify the intended type for JSON serialised objects. + /// Fully qualified named for a number of types used in CloudStack. Used to specify the intended type for JSON serialised objects. /// public class CloudStackTypes { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs index 59397e8fba8..7e31ced3e38 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/HypervResourceController.cs @@ -129,7 +129,7 @@ namespace HypervResource /// /// /// 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 + /// 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 @@ -141,7 +141,7 @@ namespace HypervResource /// 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 + /// NB: global alternatives discussed at /// http://weblogs.asp.net/fredriknormen/archive/2012/06/11/asp-net-web-api-exception-handling.aspx /// /// @@ -174,7 +174,7 @@ namespace HypervResource } /// - /// NOP - placeholder for future setup, e.g. delete existing VMs or Network ports + /// NOP - placeholder for future setup, e.g. delete existing VMs or Network ports /// POST api/HypervResource/SetupCommand /// /// @@ -486,7 +486,7 @@ namespace HypervResource } } - + private static JArray ReturnCloudStackTypedJArray(object ansContent, string ansType) { JObject ansObj = Utils.CreateCloudStackObject(ansType, ansContent); @@ -705,7 +705,7 @@ namespace HypervResource /// +-System.UnauthorizedAccessException /// +-System.IO.IOException /// +-System.IO.PathTooLongException - /// + /// /// Exceptions related to HTTP URIs /// System.SystemException /// +-System.InvalidOperationException diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Properties/AssemblyInfo.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Properties/AssemblyInfo.cs index 7bbc9b55adb..6a05afa8f7f 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Properties/AssemblyInfo.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/Properties/AssemblyInfo.cs @@ -19,7 +19,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// 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")] @@ -31,8 +31,8 @@ using System.Runtime.InteropServices; [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 +// 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)] @@ -42,11 +42,11 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// 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")] diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs index d385a8e67ab..6f0327845a0 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/HypervResource/WmiCallsV2.cs @@ -111,7 +111,7 @@ namespace HypervResource return vm; } - + /// /// Returns ComputerSystem lacking any NICs and VOLUMEs /// @@ -164,7 +164,7 @@ namespace HypervResource // Obtain controller for Hyper-V networking subsystem var vmNetMgmtSvc = GetVirtualSwitchManagementService(); - // Create NIC resource by cloning the default NIC + // Create NIC resource by cloning the default NIC var synthNICsSettings = SyntheticEthernetPortSettingData.GetInstances(vmNetMgmtSvc.Scope, "InstanceID LIKE \"%Default\""); // Assert @@ -217,7 +217,7 @@ namespace HypervResource public const string HARDDISK_DISK = "Microsoft:Hyper-V:Virtual Hard Disk"; // For IDE_HARDDISK_DRIVE /// - /// Create new VM. By default we start it. + /// Create new VM. By default we start it. /// public ComputerSystem DeployVirtualMachine(dynamic jsonObj, string systemVmIso) { @@ -351,9 +351,9 @@ namespace HypervResource break; case "DATADISK": break; - default: + default: // TODO: double check exception type - errMsg = string.Format("Unknown disk type {0} for disk {1}, vm named {2}", + 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); @@ -452,9 +452,9 @@ namespace HypervResource SetBandWidthLimit((ulong)networkRateMbps, portSettings); } - logger.DebugFormat("Created adapter {0} on port {1}, {2}", + logger.DebugFormat("Created adapter {0} on port {1}, {2}", newAdapter.Path, portSettings.Path, (vlan == null ? "No VLAN" : "VLAN " + vlan)); - // logger.DebugFormat("Created adapter {0} on port {1}, {2}", + // logger.DebugFormat("Created adapter {0} on port {1}, {2}", // newAdapter.Path, portSettings.Path, (vlan == null ? "No VLAN" : "VLAN " + vlan)); } } @@ -468,7 +468,7 @@ namespace HypervResource var vm = GetComputerSystem(vmName); if (bootArgs != null && !String.IsNullOrEmpty((string)bootArgs)) { - + String bootargs = bootArgs; AddUserData(vm, bootargs); } @@ -576,7 +576,7 @@ namespace HypervResource } /// this method is to add a dvd drive and attach the systemvm iso. - /// + /// public void patchSystemVmIso(String vmName, String systemVmIso) { ComputerSystem vmObject = GetComputerSystem(vmName); @@ -611,7 +611,7 @@ namespace HypervResource /// IDE_HARDDISK_DRIVE or IDE_ISO_DRIVE public ManagementPath AddDiskDriveToIdeController(ComputerSystem vm, string vhdfile, string cntrllerAddr, string driveResourceType) { - logger.DebugFormat("Creating DISK for VM {0} (GUID {1}) by attaching {2}", + logger.DebugFormat("Creating DISK for VM {0} (GUID {1}) by attaching {2}", vm.ElementName, vm.Name, vhdfile); @@ -622,13 +622,13 @@ namespace HypervResource case HARDDISK_DRIVE: diskResourceSubType = HARDDISK_DISK; break; - case ISO_DRIVE: + case ISO_DRIVE: diskResourceSubType = ISO_DISK; break; default: var errMsg = string.Format( "Unrecognised disk drive type {0} for VM {1} (GUID {2})", - string.IsNullOrEmpty(driveResourceType) ? "NULL": driveResourceType, + string.IsNullOrEmpty(driveResourceType) ? "NULL": driveResourceType, vm.ElementName, vm.Name); var ex = new WmiException(errMsg); @@ -886,7 +886,7 @@ namespace HypervResource } /// - /// Create Msvm_StorageAllocationSettingData corresponding to the ISO image, and + /// Create Msvm_StorageAllocationSettingData corresponding to the ISO image, and /// associate this with the VM's DVD drive. /// private void AttachIso(ComputerSystem vm, string isoPath) @@ -1191,7 +1191,7 @@ namespace HypervResource string vmToDestroy = jsonObj.vmName; DestroyVm(vmToDestroy); } - + /// /// Remove all VMs and all SwitchPorts with the displayName. VHD gets deleted elsewhere. /// @@ -1461,7 +1461,7 @@ namespace HypervResource /// /// Path that uniquely identifies the resource. /// VM to which the disk image will be attached. - // Add new + // Add new private void RemoveNetworkResource(ManagementPath resourcePath) { var virtSwitchMgmtSvc = GetVirtualSwitchManagementService(); @@ -1523,9 +1523,9 @@ namespace HypervResource public void SetState(ComputerSystem vm, ushort requiredState) { logger.InfoFormat( - "Changing state of {0} (GUID {1}) to {2}", - vm.ElementName, - vm.Name, + "Changing state of {0} (GUID {1}) to {2}", + vm.ElementName, + vm.Name, RequiredState.ToString(requiredState)); ManagementPath jobPath; @@ -1555,9 +1555,9 @@ namespace HypervResource } logger.InfoFormat( - "Successfully changed vm state of {0} (GUID {1} to requested state {2}", - vm.ElementName, - vm.Name, + "Successfully changed vm state of {0} (GUID {1} to requested state {2}", + vm.ElementName, + vm.Name, requiredState); } @@ -1589,9 +1589,9 @@ namespace HypervResource public SyntheticEthernetPortSettingData GetSyntheticEthernetPortSettings(EthernetSwitchPort port) { - // An ASSOCIATOR object provides the cross reference from the EthernetSwitchPort and the + // An ASSOCIATOR object provides the cross reference from the EthernetSwitchPort and the // SyntheticEthernetPortSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method. - // Instead, we use the System.Management to code the equivalant of + // Instead, we use the System.Management to code the equivalant of // string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vm.path, resultclassName); // var wmiObjQuery = new RelatedObjectQuery(port.Path.Path, SyntheticEthernetPortSettingData.CreatedClassName); @@ -1620,7 +1620,7 @@ namespace HypervResource /// Msvm_StorageAllocationSettings with HostResource configured with image /// file and Parent set to a controller associated with the ComputerSystem /// VM to which the disk image will be attached. - // Add new + // Add new private ManagementPath[] AddStorageResource(string[] storageSettings, ComputerSystem vm) { return AddVirtualResource(storageSettings, vm); @@ -1697,7 +1697,7 @@ namespace HypervResource var vmVirtMgmtSvc = GetVirtualisationSystemManagementService(); EthernetSwitchPortVlanSettingData.GetInstances(); - // Create NIC resource by cloning the default NIC + // Create NIC resource by cloning the default NIC var vlanSettings = EthernetSwitchPortVlanSettingData.GetInstances(vmVirtMgmtSvc.Scope, "InstanceID LIKE \"%Default\""); // Assert @@ -1783,7 +1783,7 @@ namespace HypervResource /// /// With V1 API, external ethernet port was attached to the land endpoint, which was attached to the switch. /// e.g. Msvm_ExternalEthernetPort -> SwitchLANEndpoint -> SwitchPort -> VirtualSwitch - /// + /// /// With V2 API, there are two kinds of lan endpoint: one on the computer system and one on the switch /// e.g. Msvm_ExternalEthernetPort -> LANEndpoint -> LANEdnpoint -> EthernetSwitchPort -> VirtualEthernetSwitch /// @@ -1800,7 +1800,7 @@ namespace HypervResource logger.Error(errMsg, ex); throw ex; } - foreach(ExternalEthernetPort externNIC in externNICs.OfType()) { + foreach(ExternalEthernetPort externNIC in externNICs.OfType()) { // 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 @@ -1822,7 +1822,7 @@ namespace HypervResource var switchEndpointQuery = new RelatedObjectQuery(adapterEndPoint.Path.Path, LANEndpoint.CreatedClassName); var switchEndpointSearch = new ManagementObjectSearcher(externNIC.Scope, switchEndpointQuery); var switchEndpointCollection = new LANEndpoint.LANEndpointCollection(switchEndpointSearch.Get()); - + // assert if (endpointCollection.Count < 1) { @@ -1831,12 +1831,12 @@ namespace HypervResource logger.Error(errMsg, ex); throw ex; } - + LANEndpoint switchEndPoint = switchEndpointCollection.OfType().First(); var switchPortQuery = new RelatedObjectQuery(switchEndPoint.Path.Path, EthernetSwitchPort.CreatedClassName); var switchPortSearch = new ManagementObjectSearcher(switchEndPoint.Scope, switchPortQuery); var switchPortCollection = new EthernetSwitchPort.EthernetSwitchPortCollection(switchPortSearch.Get()); - + // assert if (switchPortCollection.Count < 1 ) { @@ -1845,7 +1845,7 @@ namespace HypervResource logger.Error(errMsg, ex); throw ex; } - + EthernetSwitchPort switchPort = switchPortCollection.OfType().First(); var vSwitchQuery = new RelatedObjectQuery(switchPort.Path.Path, VirtualEthernetSwitch.CreatedClassName); var vSwitchSearch = new ManagementObjectSearcher(externNIC.Scope, vSwitchQuery); @@ -2001,7 +2001,7 @@ namespace HypervResource private static ComputerSystem CreateDefaultVm(VirtualSystemManagementService vmMgmtSvc, string name) { - // Tweak default settings by basing new VM on default global setting object + // Tweak default settings by basing new VM on default global setting object // with designed display name. UInt16 startupAction = 2; // Do nothing. UInt16 stopAction = 4; // Shutdown. @@ -2142,7 +2142,7 @@ namespace HypervResource { // 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) { @@ -2192,8 +2192,8 @@ namespace HypervResource if (jobObj.JobState != JobState.Completed) { var errMsg = string.Format( - "Hyper-V Job failed, Error Code:{0}, Description: {1}", - jobObj.ErrorCode, + "Hyper-V Job failed, Error Code:{0}, Description: {1}", + jobObj.ErrorCode, jobObj.ErrorDescription); var ex = new WmiException(errMsg); logger.Error(errMsg, ex); @@ -2269,18 +2269,18 @@ namespace HypervResource sockets++; } } - + public void GetProcessorUsageInfo(out double cpuUtilization) { - PerfFormattedData_Counters_ProcessorInformation.PerfFormattedData_Counters_ProcessorInformationCollection coll = + 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 + // Idle during a given internal // See http://library.wmifun.net/cimv2/win32_perfformatteddata_counters_processorinformation.html - cpuUtilization = 100.0 - (double)procInfo.PercentIdleTime; + cpuUtilization = 100.0 - (double)procInfo.PercentIdleTime; } } @@ -2308,7 +2308,7 @@ namespace HypervResource logger.Error(errMsg); return null; } - + return defaultVirtualHardDiskPath; } @@ -2376,9 +2376,9 @@ namespace HypervResource public ProcessorSettingData GetProcSettings(VirtualSystemSettingData vmSettings) { - // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the + // 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 + // 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); @@ -2401,9 +2401,9 @@ namespace HypervResource public MemorySettingData GetMemSettings(VirtualSystemSettingData vmSettings) { - // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the + // 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 + // 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); @@ -2431,7 +2431,7 @@ namespace HypervResource foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection) { - // DVD drive is '16', see http://msdn.microsoft.com/en-us/library/hh850200(v=vs.85).aspx + // DVD drive is '16', see http://msdn.microsoft.com/en-us/library/hh850200(v=vs.85).aspx if (wmiObj.ResourceType == 16) { return wmiObj; @@ -2459,8 +2459,8 @@ namespace HypervResource } var errMsg = string.Format( - "Cannot find the Microsoft Emulated IDE Controlle at address {0} in VirtualSystemSettingData {1}", - cntrllerAddr, + "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); @@ -2488,8 +2488,8 @@ namespace HypervResource } /// - /// 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 + /// 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 /// @@ -2497,9 +2497,9 @@ namespace HypervResource /// public ResourceAllocationSettingData.ResourceAllocationSettingDataCollection GetResourceAllocationSettings(VirtualSystemSettingData vmSettings) { - // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the + // 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 + // 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); @@ -2525,9 +2525,9 @@ namespace HypervResource // ComputerSystem -> VirtualSystemSettingData -> EthernetPortAllocationSettingData VirtualSystemSettingData vmSettings = GetVmSettings(vm); - // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the + // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the // EthernetPortAllocationSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method. - // Instead, we use the System.Management to code the equivalant of + // Instead, we use the System.Management to code the equivalant of // string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName); // var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, EthernetPortAllocationSettingData.CreatedClassName); @@ -2568,9 +2568,9 @@ namespace HypervResource public EthernetSwitchPortVlanSettingData GetVlanSettings(EthernetPortAllocationSettingData ethernetConnection) { - // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the + // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the // EthernetPortAllocationSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method. - // Instead, we use the System.Management to code the equivalant of + // Instead, we use the System.Management to code the equivalant of // string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName); // var wmiObjQuery = new RelatedObjectQuery(ethernetConnection.Path.Path, EthernetSwitchPortVlanSettingData.CreatedClassName); @@ -2596,14 +2596,14 @@ namespace HypervResource return wmiObjCollection.OfType().First(); } - + public SyntheticEthernetPortSettingData[] GetEthernetPortSettings(ComputerSystem vm) { - // An ASSOCIATOR object provides the cross reference from the ComputerSettings and the + // 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 + // Instead, we use the System.Management to code the equivalant of // // string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vm.path, resultclassName); // @@ -2640,9 +2640,9 @@ namespace HypervResource public VirtualSystemSettingData GetVmSettings(ComputerSystem vm) { - // An ASSOCIATOR object provides the cross reference from the ComputerSettings and the + // 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 + // 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); @@ -2671,9 +2671,9 @@ namespace HypervResource public KvpExchangeComponentSettingData GetKvpSettings(VirtualSystemSettingData vmSettings) { - // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the + // 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 + // 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); @@ -2700,7 +2700,7 @@ namespace HypervResource { return; } - // Process info available from WMI, + // Process info available from WMI, // See http://msdn.microsoft.com/en-us/library/hh850062(v=vs.85).aspx uint[] requestedInfo = new uint[] { // TODO: correct? 0, // Name @@ -2887,7 +2887,7 @@ namespace HypervResource /// 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 + /// The previous V1 API is described by /// http://msdn.microsoft.com/en-us/library/cc136822%28v=vs.85%29.aspx /// public class EnabledState @@ -2914,27 +2914,27 @@ namespace HypervResource public const UInt16 Suspended = 32769; /// /// The VM is starting. This is a transitional state between 3 (Disabled) - /// or 32769 (Suspended) and 2 (Enabled) initiated by a call to the + /// or 32769 (Suspended) and 2 (Enabled) initiated by a call to the /// RequestStateChange method with a RequestedState parameter of 2 (Enabled). /// public const UInt16 Starting = 32770; /// - /// 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), + /// 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). /// public const UInt16 Snapshotting = 32771; /// /// 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 + /// and 32769 (Suspended) initiated by a call to the RequestStateChange method /// with a RequestedState parameter of 32769 (Suspended). /// public const UInt16 Saving = 32773; /// - /// 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 + /// 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. /// public const UInt16 Stopping = 32774; @@ -2980,7 +2980,7 @@ namespace HypervResource case Saving: result = "Saving"; break; case Stopping: result = "Stopping"; break; case Pausing: result = "Unknown"; break; - case Resuming: result = "Starting"; break; + case Resuming: result = "Starting"; break; } return result; } diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs index 91d41e63b9b..91194a1424d 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceController1Test.cs @@ -66,7 +66,7 @@ namespace ServerResource.Tests /// /// 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. @@ -117,10 +117,10 @@ namespace ServerResource.Tests // 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); - + // Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName); + testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID); - s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage."); + s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage."); // Capture other JSON encoded paths @@ -150,7 +150,7 @@ namespace ServerResource.Tests return JsonConvert.SerializeObject(newFileInfo.FullName); } - + [Fact] public void TestCreateCommand() { @@ -267,7 +267,7 @@ namespace ServerResource.Tests 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); + Assert.Null((string)startAns[0][CloudStackTypes.StartAnswer].details); } [Fact] @@ -323,7 +323,7 @@ namespace ServerResource.Tests "\"volumeId\":10," + // "\"vmName\":\"i-3-5-VM\"," + // TODO: do we have to fill in the vmName? "\"accountId\":3,\"id\":10}" + - "}"; // end of destTO + "}"; // end of destTO return sampleVolumeObjectTO; } @@ -345,6 +345,6 @@ namespace ServerResource.Tests "\"broadcastUri\":\"vlan://261\",\"isolationUri\":\"vlan://261\",\"isSecurityGroupEnabled\":false}" + "]},\"contextMap\":{},\"wait\":0}"; return sample; - } + } } } diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs index 7f03e151253..f8761867b18 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/HypervResourceControllerTest.cs @@ -64,7 +64,7 @@ namespace ServerResource.Tests /// /// 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. @@ -326,7 +326,7 @@ namespace ServerResource.Tests "\"volumeId\":10," + // "\"vmName\":\"i-3-5-VM\"," + // TODO: do we have to fill in the vmName? "\"accountId\":3,\"id\":10}" + - "}"; // end of destTO + "}"; // end of destTO return sampleVolumeObjectTO; } @@ -443,7 +443,7 @@ namespace ServerResource.Tests "\"vmName\":\"i-3-5-VM\"," + "\"accountId\":3," + "\"id\":10 }" + - "}," + // end of destTO + "}," + // 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} @@ -562,7 +562,7 @@ namespace ServerResource.Tests "\"vmName\":\"i-3-5-VM\"," + "\"accountId\":1," + "\"id\":10}" + - "}," + // end of destTO + "}," + // end of destTO "\"wait\":0}"; // end of Copy Command #endregion @@ -1117,7 +1117,7 @@ namespace ServerResource.Tests string strippedExpectedMac = expectedMac.Replace(":", string.Empty); Assert.Equal(nicSettingsViaVm[0].Address.ToLower(), strippedExpectedMac.ToLower()); - // Assert switchport has correct VLAN + // Assert switchport has correct VLAN var ethernetConnections = wmiCallsV2.GetEthernetConnections(vm); var vlanSettings = wmiCallsV2.GetVlanSettings(ethernetConnections[0]); string isolationUri = (string)jsonStartCmd.vm.nics[0].isolationUri; diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/Properties/AssemblyInfo.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/Properties/AssemblyInfo.cs index c8820467b3c..1929739e8f5 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/Properties/AssemblyInfo.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/ServerResource.Tests/Properties/AssemblyInfo.cs @@ -19,7 +19,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// 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")] @@ -31,8 +31,8 @@ using System.Runtime.InteropServices; [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 +// 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)] @@ -42,11 +42,11 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Revision and Build Numbers +// 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")] diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Properties/AssemblyInfo.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Properties/AssemblyInfo.cs index 8d12d056411..e3ec242149f 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Properties/AssemblyInfo.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/Properties/AssemblyInfo.cs @@ -19,7 +19,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// 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")] @@ -31,8 +31,8 @@ using System.Runtime.InteropServices; [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 +// 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)] @@ -42,11 +42,11 @@ using System.Runtime.InteropServices; // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// 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")] 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 index ce1e22ffe9c..a29ede0f0a0 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_OperatingSystem.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_OperatingSystem.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,58 +32,58 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { // 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)) { @@ -95,7 +95,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { throw new System.ArgumentException("Class name does not match."); } } - + public OperatingSystem0(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -108,7 +108,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -117,7 +117,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return "ROOT\\CIMV2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -126,7 +126,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -135,7 +135,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -144,7 +144,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -153,7 +153,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -172,7 +172,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + // 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)] @@ -184,7 +184,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -205,7 +205,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -217,7 +217,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The BootDevice property indicates the name of the disk drive from which the Win32" + @@ -227,7 +227,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((string)(curObj["BootDevice"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The BuildNumber property indicates the build number of the operating system. It " + @@ -238,7 +238,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((string)(curObj["BuildNumber"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The BuildType property indicates the type of build used for the operating system." + @@ -248,7 +248,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((string)(curObj["BuildType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Caption property is a short textual description (one-line string) of the obje" + @@ -258,7 +258,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { 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. @@ -268,7 +268,7 @@ Example: 1255.")] 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. @@ -278,7 +278,7 @@ Example: 1 for the United States)")] return ((string)(curObj["CountryCode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("CreationClassName indicates the name of the class or the subclass used in the cre" + @@ -290,7 +290,7 @@ Example: 1 for the United States)")] return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("CSCreationClassName contains the scoping computer system\'s creation class name.")] @@ -299,7 +299,7 @@ Example: 1 for the United States)")] 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. @@ -309,7 +309,7 @@ Example: Service Pack 3.")] return ((string)(curObj["CSDVersion"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("CSName contains the scoping computer system\'s name.")] @@ -318,7 +318,7 @@ Example: Service Pack 3.")] return ((string)(curObj["CSName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCurrentTimeZoneNull { @@ -331,7 +331,7 @@ Example: Service Pack 3.")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("CurrentTimeZone indicates the number of minutes the operating system is offset fr" + @@ -345,7 +345,7 @@ Example: Service Pack 3.")] return ((short)(curObj["CurrentTimeZone"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDataExecutionPrevention_32BitApplicationsNull { @@ -358,7 +358,7 @@ Example: Service Pack 3.")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("If true, indicates that 32-bit applications are running with Data Execution Preve" + @@ -372,7 +372,7 @@ Example: Service Pack 3.")] return ((bool)(curObj["DataExecutionPrevention_32BitApplications"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDataExecutionPrevention_AvailableNull { @@ -385,7 +385,7 @@ Example: Service Pack 3.")] } } } - + [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 ")] @@ -398,7 +398,7 @@ Example: Service Pack 3.")] return ((bool)(curObj["DataExecutionPrevention_Available"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDataExecutionPrevention_DriversNull { @@ -411,7 +411,7 @@ Example: Service Pack 3.")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("If true, indicates that drivers are running with Data Execution Prevention (DEP) " + @@ -425,7 +425,7 @@ Example: Service Pack 3.")] return ((bool)(curObj["DataExecutionPrevention_Drivers"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDataExecutionPrevention_SupportPolicyNull { @@ -438,7 +438,7 @@ Example: Service Pack 3.")] } } } - + [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 turned off for all 32-bit applications on the machine. ")] @@ -451,7 +451,7 @@ Example: Service Pack 3.")] return ((DataExecutionPrevention_SupportPolicyValues)(System.Convert.ToInt32(curObj["DataExecutionPrevention_SupportPolicy"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDebugNull { @@ -464,7 +464,7 @@ Example: Service Pack 3.")] } } } - + [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. @@ -478,7 +478,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((bool)(curObj["Debug"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Description property provides a description of the Windows operating system. " + @@ -490,13 +490,13 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } set { curObj["Description"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDistributedNull { @@ -509,7 +509,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Boolean indicating whether the operating system is distributed across several com" + @@ -523,7 +523,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((bool)(curObj["Distributed"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEncryptionLevelNull { @@ -536,7 +536,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The EncryptionLevel property specifies if the encryption level for secure transac" + @@ -550,7 +550,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((EncryptionLevelValues)(System.Convert.ToInt32(curObj["EncryptionLevel"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsForegroundApplicationBoostNull { @@ -563,7 +563,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [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.")] @@ -582,13 +582,13 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e else { curObj["ForegroundApplicationBoost"] = value; } - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFreePhysicalMemoryNull { @@ -601,7 +601,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Number of kilobytes of physical memory currently unused and available")] @@ -614,7 +614,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((ulong)(curObj["FreePhysicalMemory"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFreeSpaceInPagingFilesNull { @@ -627,7 +627,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The total number of KBytes that can be mapped into the OperatingSystem\'s paging f" + @@ -642,7 +642,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((ulong)(curObj["FreeSpaceInPagingFiles"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFreeVirtualMemoryNull { @@ -655,7 +655,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Number of kilobytes of virtual memory currently unused and available. For example" + @@ -671,7 +671,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((ulong)(curObj["FreeVirtualMemory"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -684,7 +684,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The InstallDate property is datetime value indicating when the object was install" + @@ -700,7 +700,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLargeSystemCacheNull { @@ -713,7 +713,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The LargeSystemCache property indicates whether to optimize memory for applicatio" + @@ -727,7 +727,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((LargeSystemCacheValues)(System.Convert.ToInt32(curObj["LargeSystemCache"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastBootUpTimeNull { @@ -740,7 +740,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Time when the operating system was last booted")] @@ -755,7 +755,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLocalDateTimeNull { @@ -768,7 +768,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Operating system\'s notion of the local date and time of day.")] @@ -783,7 +783,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [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.")] @@ -792,7 +792,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string)(curObj["Locale"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Manufacturer property indicates the name of the operating system manufacturer" + @@ -802,7 +802,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string)(curObj["Manufacturer"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxNumberOfProcessesNull { @@ -815,7 +815,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [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.")] @@ -828,7 +828,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((uint)(curObj["MaxNumberOfProcesses"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxProcessMemorySizeNull { @@ -841,7 +841,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [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.")] @@ -854,7 +854,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((ulong)(curObj["MaxProcessMemorySize"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The MUILanguages property indicates the MUI Languages installed in the system. \n " + @@ -864,7 +864,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string[])(curObj["MUILanguages"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Name of the operating system instance within a computer system.")] @@ -873,7 +873,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNumberOfLicensedUsersNull { @@ -886,7 +886,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Number of user licenses for the operating system. If unlimited, enter 0. If unkno" + @@ -900,7 +900,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((uint)(curObj["NumberOfLicensedUsers"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNumberOfProcessesNull { @@ -913,7 +913,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Number of process contexts currently loaded or running on the operating system.")] @@ -926,7 +926,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((uint)(curObj["NumberOfProcesses"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNumberOfUsersNull { @@ -939,7 +939,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Number of user sessions for which the operating system is currently storing state" + @@ -953,7 +953,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((uint)(curObj["NumberOfUsers"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingSystemSKUNull { @@ -966,7 +966,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The OperatingSystemSKU property identifies the SKU of the operating system.")] @@ -979,7 +979,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((uint)(curObj["OperatingSystemSKU"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Organization property indicates the registered user\'s (of the operating syste" + @@ -989,7 +989,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string)(curObj["Organization"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The OSArchitecture property indicates the Architecture of the operating system.Ex" + @@ -999,7 +999,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string)(curObj["OSArchitecture"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOSLanguageNull { @@ -1012,7 +1012,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The OSLanguage property indicates which language version of the operating system " + @@ -1026,7 +1026,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((uint)(curObj["OSLanguage"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOSProductSuiteNull { @@ -1039,7 +1039,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The OSProductSuite property identifies installed and licensed system product addi" + @@ -1053,7 +1053,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((OSProductSuiteValues)(System.Convert.ToInt32(curObj["OSProductSuite"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOSTypeNull { @@ -1066,7 +1066,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("A integer indicating the type of operating system.")] @@ -1079,7 +1079,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e 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.")] @@ -1088,7 +1088,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string)(curObj["OtherTypeDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPAEEnabledNull { @@ -1101,7 +1101,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1113,7 +1113,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((bool)(curObj["PAEEnabled"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The PlusProductID property contains the product identification number for the Win" + @@ -1123,7 +1123,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string)(curObj["PlusProductID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The PlusVersionNumber property contains the version number of the Windows Plus! o" + @@ -1133,7 +1133,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e return ((string)(curObj["PlusVersionNumber"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPortableOperatingSystemNull { @@ -1146,7 +1146,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the debugging version of User.e } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"The PortableOperatingSystem property indicates if theOperating System is booting from a supported locally connected storagedevice. @@ -1161,7 +1161,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((bool)(curObj["PortableOperatingSystem"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryNull { @@ -1174,7 +1174,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Primary property determines whether this is the primary operating system.\nVal" + @@ -1189,7 +1189,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((bool)(curObj["Primary"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsProductTypeNull { @@ -1202,7 +1202,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The ProductType property indicates additional information about the system. This " + @@ -1217,7 +1217,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted 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" + @@ -1227,7 +1227,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((string)(curObj["RegisteredUser"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The SerialNumber property indicates the operating system product serial identific" + @@ -1237,7 +1237,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((string)(curObj["SerialNumber"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsServicePackMajorVersionNull { @@ -1250,7 +1250,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [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).")] @@ -1263,7 +1263,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((ushort)(curObj["ServicePackMajorVersion"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsServicePackMinorVersionNull { @@ -1276,7 +1276,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [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).")] @@ -1289,7 +1289,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((ushort)(curObj["ServicePackMinorVersion"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSizeStoredInPagingFilesNull { @@ -1302,7 +1302,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The total number of kilobytes that can be stored in the operating system\'s paging" + @@ -1317,7 +1317,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted 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.")] @@ -1326,7 +1326,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((string)(curObj["Status"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSuiteMaskNull { @@ -1339,20 +1339,20 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [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 + [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 { @@ -1363,7 +1363,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((SuiteMaskValues)(System.Convert.ToInt32(curObj["SuiteMask"]))); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The SystemDevice property indicates the physical disk partition the operating sys" + @@ -1373,7 +1373,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((string)(curObj["SystemDevice"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The SystemDirectory property indicates the system directory of the operating syst" + @@ -1383,7 +1383,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((string)(curObj["SystemDirectory"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The SystemDrive property contains the letter of the disk drive that the operating" + @@ -1393,7 +1393,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((string)(curObj["SystemDrive"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTotalSwapSpaceSizeNull { @@ -1406,7 +1406,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [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.")] @@ -1419,7 +1419,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((ulong)(curObj["TotalSwapSpaceSize"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTotalVirtualMemorySizeNull { @@ -1432,7 +1432,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Number of kilobytes of virtual memory. For example, this may be calculated by add" + @@ -1448,7 +1448,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((ulong)(curObj["TotalVirtualMemorySize"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTotalVisibleMemorySizeNull { @@ -1461,7 +1461,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The total amount of physical memory (in Kbytes) available to the OperatingSystem." + @@ -1476,7 +1476,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((ulong)(curObj["TotalVisibleMemorySize"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Version property indicates the version number of the operating system.\nExampl" + @@ -1486,7 +1486,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((string)(curObj["Version"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The WindowsDirectory property indicates the Windows directory of the operating sy" + @@ -1496,9 +1496,9 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return ((string)(curObj["WindowsDirectory"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1506,9 +1506,9 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1525,107 +1525,107 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } 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) + 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) + 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; @@ -1677,13 +1677,13 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1711,7 +1711,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1738,8 +1738,8 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1749,198 +1749,198 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted 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)) { @@ -1952,7 +1952,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + [Browsable(true)] public static OperatingSystem0 CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1967,12 +1967,12 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted 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; @@ -1986,7 +1986,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return System.Convert.ToUInt32(0); } } - + public uint SetDateTime(System.DateTime LocalDateTime) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -2002,7 +2002,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return System.Convert.ToUInt32(0); } } - + public uint Shutdown() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -2016,7 +2016,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return System.Convert.ToUInt32(0); } } - + public uint Win32Shutdown(int Flags, int Reserved) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -2033,7 +2033,7 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return System.Convert.ToUInt32(0); } } - + public uint Win32ShutdownTracker(string Comment, int Flags, uint ReasonCode, uint Timeout) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -2052,395 +2052,395 @@ Values: TRUE or FALSE, A value of TRUE indicates the OperatingSystem was booted return System.Convert.ToUInt32(0); } } - + public enum DataExecutionPrevention_SupportPolicyValues { - + Always_Off = 0, - + Always_On = 1, - + Opt_In = 2, - + Opt_Out = 3, - + NULL_ENUM_VALUE = 4, } - + public enum EncryptionLevelValues { - + Val_40_bit = 0, - + Val_128_bit = 1, - + N_bit = 2, - + NULL_ENUM_VALUE = 3, } - + public enum ForegroundApplicationBoostValues { - + None = 0, - + Minimum = 1, - + Maximum = 2, - + NULL_ENUM_VALUE = 3, } - + public enum LargeSystemCacheValues { - + Optimize_for_Applications = 0, - + Optimize_for_System_Performance = 1, - + NULL_ENUM_VALUE = 2, } - + public enum OSProductSuiteValues { - + Small_Business = 1, - + Enterprise = 2, - + BackOffice = 4, - + Communication_Server = 8, - + Terminal_Server = 16, - + Small_Business_Restricted_ = 32, - + Embedded_NT = 64, - + Data_Center = 128, - + NULL_ENUM_VALUE = 256, } - + public enum OSTypeValues { - + Unknown0 = 0, - + Other0 = 1, - + MACOS = 2, - + ATTUNIX = 3, - + DGUX = 4, - + DECNT = 5, - + Digital_Unix = 6, - + OpenVMS = 7, - + HPUX = 8, - + AIX = 9, - + MVS = 10, - + OS400 = 11, - + OS_2 = 12, - + JavaVM = 13, - + MSDOS = 14, - + WIN3x = 15, - + WIN95 = 16, - + WIN98 = 17, - + WINNT = 18, - + WINCE = 19, - + NCR3000 = 20, - + NetWare = 21, - + OSF = 22, - + DC_OS = 23, - + Reliant_UNIX = 24, - + SCO_UnixWare = 25, - + SCO_OpenServer = 26, - + Sequent = 27, - + IRIX = 28, - + Solaris = 29, - + SunOS = 30, - + U6000 = 31, - + ASERIES = 32, - + TandemNSK = 33, - + TandemNT = 34, - + BS2000 = 35, - + LINUX = 36, - + Lynx = 37, - + XENIX = 38, - + VM_ESA = 39, - + Interactive_UNIX = 40, - + BSDUNIX = 41, - + FreeBSD = 42, - + NetBSD = 43, - + GNU_Hurd = 44, - + OS9 = 45, - + MACH_Kernel = 46, - + Inferno = 47, - + QNX = 48, - + EPOC = 49, - + IxWorks = 50, - + VxWorks = 51, - + MiNT = 52, - + BeOS = 53, - + HP_MPE = 54, - + NextStep = 55, - + PalmPilot = 56, - + Rhapsody = 57, - + Windows_2000 = 58, - + Dedicated = 59, - + OS_390 = 60, - + VSE = 61, - + TPF = 62, - + NULL_ENUM_VALUE = 63, } - + public enum ProductTypeValues { - + Work_Station = 1, - + Domain_Controller = 2, - + Server = 3, - + NULL_ENUM_VALUE = 0, } - + public enum SuiteMaskValues { - + Windows_Server_2003_Small_Business_Edition = 0, - + Windows_Server_2003_Enterprise_Edition = 1, - + Windows_Server_2003_Backoffice_Edition = 2, - + Windows_Server_2003_Communications_Edition = 3, - + Microsoft_Terminal_Services = 4, - + Windows_Server_2003_Small_Business_Edition_Restricted = 5, - + Windows_XP_Embedded = 6, - + Windows_Server_2003_Datacenter_Edition = 7, - + Single_User = 8, - + Windows_XP_Home_Edition = 9, - + Windows_Server_2003_Web_Edition = 10, - + NULL_ENUM_VALUE = 20, } - + // 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { 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 index 09ef22b4288..48e7ecec50a 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_Processor.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.CIMV2.Win32_Processor.cs @@ -24,8 +24,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -33,62 +33,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 // 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)) { @@ -100,7 +100,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 throw new System.ArgumentException("Class name does not match."); } } - + public Processor(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -113,7 +113,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -122,7 +122,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return "ROOT\\CIMV2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -131,7 +131,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -140,7 +140,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -149,7 +149,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -158,7 +158,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -177,7 +177,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + // 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)] @@ -189,7 +189,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -210,7 +210,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -222,7 +222,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAddressWidthNull { @@ -235,7 +235,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Processor address width in bits.")] @@ -248,7 +248,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return ((ushort)(curObj["AddressWidth"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsArchitectureNull { @@ -261,7 +261,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Architecture property specifies the processor architecture used by this platf" + @@ -276,7 +276,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return ((ArchitectureValues)(System.Convert.ToInt32(curObj["Architecture"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAvailabilityNull { @@ -289,7 +289,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + [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.")] @@ -302,7 +302,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 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" + @@ -312,7 +312,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConfigManagerErrorCodeNull { @@ -325,7 +325,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates the Win32 Configuration Manager error code. The following values may b" + @@ -367,7 +367,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return ((ConfigManagerErrorCodeValues)(System.Convert.ToInt32(curObj["ConfigManagerErrorCode"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConfigManagerUserConfigNull { @@ -380,7 +380,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates whether the device is using a user-defined configuration.")] @@ -393,7 +393,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return ((bool)(curObj["ConfigManagerUserConfig"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCpuStatusNull { @@ -406,7 +406,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The CpuStatus property specifies the current status of the processor. Changes in " + @@ -420,7 +420,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 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" + @@ -432,7 +432,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return ((string)(curObj["CreationClassName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCurrentClockSpeedNull { @@ -445,7 +445,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The current speed (in MHz) of this processor.")] @@ -458,7 +458,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 return ((uint)(curObj["CurrentClockSpeed"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCurrentVoltageNull { @@ -471,7 +471,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 } } } - + [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. @@ -485,7 +485,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((ushort)(curObj["CurrentVoltage"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDataWidthNull { @@ -498,7 +498,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Processor data width in bits.")] @@ -511,7 +511,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((ushort)(curObj["DataWidth"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Description property provides a textual description of the object. ")] @@ -520,7 +520,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The DeviceID property contains a string uniquely identifying the processor with o" + @@ -530,7 +530,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["DeviceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsErrorClearedNull { @@ -543,7 +543,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("ErrorCleared is a boolean property indicating that the error reported in LastErro" + @@ -557,7 +557,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((bool)(curObj["ErrorCleared"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("ErrorDescription is a free-form string supplying more information about the error" + @@ -568,7 +568,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["ErrorDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsExtClockNull { @@ -581,7 +581,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The ExtClock property specifies the external clock frequency. If the frequency is" + @@ -595,7 +595,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["ExtClock"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFamilyNull { @@ -608,7 +608,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The processor family type. For example, values include \"Pentium(R) processor with" + @@ -622,7 +622,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((FamilyValues)(System.Convert.ToInt32(curObj["Family"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -635,7 +635,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The InstallDate property is datetime value indicating when the object was install" + @@ -651,7 +651,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsL2CacheSizeNull { @@ -664,7 +664,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The L2CacheSize property specifies the size of the processor\'s Level 2 cache. A L" + @@ -679,7 +679,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["L2CacheSize"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsL2CacheSpeedNull { @@ -692,7 +692,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The L2CacheSpeed property specifies the clockspeed of the processor\'s Level 2 cac" + @@ -707,7 +707,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["L2CacheSpeed"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsL3CacheSizeNull { @@ -720,7 +720,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The L3CacheSize property specifies the size of the processor\'s Level 3 cache. A L" + @@ -735,7 +735,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["L3CacheSize"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsL3CacheSpeedNull { @@ -748,7 +748,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The L3CacheSpeed property specifies the clockspeed of the processor\'s Level 3 cac" + @@ -763,7 +763,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["L3CacheSpeed"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastErrorCodeNull { @@ -776,7 +776,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("LastErrorCode captures the last error code reported by the logical device.")] @@ -789,7 +789,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["LastErrorCode"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLevelNull { @@ -802,7 +802,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Level property further defines the processor type. The value depends on the " + @@ -816,7 +816,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((ushort)(curObj["Level"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLoadPercentageNull { @@ -829,7 +829,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The LoadPercentage property specifies each processor\'s load capacity averaged ove" + @@ -844,7 +844,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((ushort)(curObj["LoadPercentage"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Manufacturer property specifies the name of the processor\'s manufacturer.\nExa" + @@ -854,7 +854,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["Manufacturer"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxClockSpeedNull { @@ -867,7 +867,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum speed (in MHz) of this processor.")] @@ -880,7 +880,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["MaxClockSpeed"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Name property defines the label by which the object is known. When subclassed" + @@ -890,7 +890,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNumberOfCoresNull { @@ -903,7 +903,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The NumberOfCores property contains a Processor\'s total number of cores. e.g dual" + @@ -917,7 +917,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["NumberOfCores"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNumberOfLogicalProcessorsNull { @@ -930,7 +930,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The NumberOfLogicalProcessors property specifies the total number of logical proc" + @@ -944,7 +944,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((uint)(curObj["NumberOfLogicalProcessors"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("A string describing the processor family type - used when the family property is " + @@ -955,7 +955,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["OtherFamilyDescription"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates the Win32 Plug and Play device ID of the logical device. Example: *PNP" + @@ -965,7 +965,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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.")] @@ -980,7 +980,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return enumToRet; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerManagementSupportedNull { @@ -993,7 +993,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [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.")] @@ -1006,7 +1006,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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.")] @@ -1015,7 +1015,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["ProcessorId"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsProcessorTypeNull { @@ -1028,7 +1028,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The ProcessorType property specifies the processor\'s primary function.")] @@ -1041,7 +1041,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((ProcessorTypeValues)(System.Convert.ToInt32(curObj["ProcessorType"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRevisionNull { @@ -1054,7 +1054,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Revision property specifies the system\'s architecture-dependent revision leve" + @@ -1069,7 +1069,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((ushort)(curObj["Revision"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("A free form string describing the role of the processor - for example, \"Central P" + @@ -1079,7 +1079,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["Role"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSecondLevelAddressTranslationExtensionsNull { @@ -1092,7 +1092,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The SecondLevelAddressTranslationExtensions property determines whether the proce" + @@ -1106,7 +1106,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((bool)(curObj["SecondLevelAddressTranslationExtensions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The SocketDesignation property contains the type of chip socket used on the circu" + @@ -1116,7 +1116,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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.")] @@ -1125,7 +1125,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["Status"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStatusInfoNull { @@ -1138,7 +1138,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("StatusInfo is a string indicating whether the logical device is in an enabled (va" + @@ -1154,7 +1154,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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" + @@ -1164,7 +1164,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["Stepping"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The scoping System\'s CreationClassName.")] @@ -1173,7 +1173,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The scoping System\'s Name.")] @@ -1182,7 +1182,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["SystemName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("A globally unique identifier for the processor. This identifier may only be uniq" + @@ -1192,7 +1192,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["UniqueId"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsUpgradeMethodNull { @@ -1205,7 +1205,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("CPU socket information including data on how this Processor can be upgraded (if u" + @@ -1219,7 +1219,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((UpgradeMethodValues)(System.Convert.ToInt32(curObj["UpgradeMethod"]))); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The Version property specifies an architecture-dependent processor revision numbe" + @@ -1229,7 +1229,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((string)(curObj["Version"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualizationFirmwareEnabledNull { @@ -1242,7 +1242,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The VirtualizationFirmwareEnabled property determines whether the Firmware has en" + @@ -1256,7 +1256,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((bool)(curObj["VirtualizationFirmwareEnabled"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVMMonitorModeExtensionsNull { @@ -1269,7 +1269,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The VMMonitorModeExtensions property determines whether the processor supports In" + @@ -1283,7 +1283,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return ((bool)(curObj["VMMonitorModeExtensions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVoltageCapsNull { @@ -1296,7 +1296,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } } } - + [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.")] @@ -1309,9 +1309,9 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1319,9 +1319,9 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1338,91 +1338,91 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } 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; @@ -1474,13 +1474,13 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1508,7 +1508,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1535,8 +1535,8 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1546,172 +1546,172 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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)) { @@ -1723,24 +1723,24 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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)) { @@ -1761,15 +1761,15 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( } 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)) { @@ -1786,7 +1786,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( ObjectSearcher.Options = enumOptions; return new ProcessorCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static Processor CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1801,12 +1801,12 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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; @@ -1817,7 +1817,7 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( return System.Convert.ToUInt32(0); } } - + public uint SetPowerState(ushort PowerState, System.DateTime Time) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1831,514 +1831,514 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( 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, - + G5 = 202, - + G6 = 203, - + Z_Architecture_base = 204, - + I860 = 250, - + I960 = 251, - + SH_3 = 260, - + SH_4 = 261, - + ARM = 280, - + StrongARM = 281, - + Val_6x86 = 300, - + MediaGX = 301, - + MII = 302, - + WinChip = 320, - + DSP = 350, - + Video_Processor = 500, - + NULL_ENUM_VALUE = 0, } - + public enum PowerManagementCapabilitiesValues { - + Unknown0 = 0, - + Not_Supported = 1, - + Disabled = 2, - + Enabled = 3, - + Power_Saving_Modes_Entered_Automatically = 4, - + Power_State_Settable = 5, - + Power_Cycling_Supported = 6, - + Timed_Power_On_Supported = 7, - + NULL_ENUM_VALUE = 8, } - + public enum ProcessorTypeValues { - + Other0 = 1, - + Unknown0 = 2, - + Central_Processor = 3, - + Math_Processor = 4, - + DSP_Processor = 5, - + Video_Processor = 6, - + NULL_ENUM_VALUE = 0, } - + public enum StatusInfoValues { - + Other0 = 1, - + Unknown0 = 2, - + Enabled = 3, - + Disabled = 4, - + Not_Applicable = 5, - + NULL_ENUM_VALUE = 0, } - + public enum UpgradeMethodValues { - + Other0 = 1, - + Unknown0 = 2, - + Daughter_Board = 3, - + ZIF_Socket = 4, - + Replacement_Piggy_Back = 5, - + None = 6, - + LIF_Socket = 7, - + Slot_1 = 8, - + Slot_2 = 9, - + Val_370_Pin_Socket = 10, - + Slot_A = 11, - + Slot_M = 12, - + Socket_423 = 13, - + Socket_A_Socket_462_ = 14, - + Socket_478 = 15, - + Socket_754 = 16, - + Socket_940 = 17, - + Socket_939 = 18, - + NULL_ENUM_VALUE = 0, } - + public enum VoltageCapsValues { - + Val_5 = 1, - + Val_3_3 = 2, - + Val_2_9 = 4, - + NULL_ENUM_VALUE = 8, } - + // Enumerator implementation for enumerating instances of the class. public class ProcessorCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public ProcessorCollection(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; @@ -2346,189 +2346,189 @@ Example: field value for a processor voltage of 1.8 volts would be 92h = 80h + ( array.SetValue(new Processor(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new ProcessorEnumerator(privColObj.GetEnumerator()); } - + public class ProcessorEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public ProcessorEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new Processor(((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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ComputerSystem.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ComputerSystem.cs index 76057138f71..012b33bc67f 100644 --- 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 @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // 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)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public ComputerSystem(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -237,7 +237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -250,7 +250,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -262,7 +262,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] Dedicated { @@ -278,7 +278,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["Dedicated"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -286,7 +286,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -299,7 +299,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -311,7 +311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -319,7 +319,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -332,7 +332,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -344,7 +344,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -357,7 +357,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -369,7 +369,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFailedOverReplicationTypeNull { @@ -382,7 +382,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Type of failover that was performed for the virtual machine.")] @@ -395,7 +395,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((FailedOverReplicationTypeValues)(System.Convert.ToInt32(curObj["FailedOverReplicationType"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -408,7 +408,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -420,7 +420,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] IdentifyingDescriptions { @@ -428,7 +428,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["IdentifyingDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -441,7 +441,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -455,7 +455,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -463,7 +463,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastApplicationConsistentReplicationTimeNull { @@ -476,7 +476,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The time at which the last application consistent replication is received on reco" + @@ -492,7 +492,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastReplicationTimeNull { @@ -505,7 +505,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The time at which the last replication is received on recovery for the virtual ma" + @@ -521,7 +521,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastReplicationTypeNull { @@ -534,7 +534,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Type of the last replication that was received for the virtual machine.")] @@ -547,7 +547,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((LastReplicationTypeValues)(System.Convert.ToInt32(curObj["LastReplicationType"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastSuccessfulBackupTimeNull { @@ -560,7 +560,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The time at which the last successful backup has completed for the virtual machin" + @@ -576,7 +576,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -584,7 +584,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string NameFormat { @@ -592,7 +592,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["NameFormat"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNumberOfNumaNodesNull { @@ -605,7 +605,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [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).")] @@ -618,7 +618,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["NumberOfNumaNodes"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOnTimeInMillisecondsNull { @@ -631,7 +631,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [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.")] @@ -644,7 +644,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["OnTimeInMilliseconds"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -657,7 +657,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -669,7 +669,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -677,7 +677,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherDedicatedDescriptions { @@ -685,7 +685,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherDedicatedDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -693,7 +693,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherIdentifyingInfo { @@ -701,7 +701,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherIdentifyingInfo"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] PowerManagementCapabilities { @@ -709,7 +709,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["PowerManagementCapabilities"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerContact { @@ -717,7 +717,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerContact"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerName { @@ -725,7 +725,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -738,7 +738,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -750,7 +750,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsProcessIDNull { @@ -763,7 +763,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The identifier of the process under which this virtual machine is running. This v" + @@ -778,7 +778,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["ProcessID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReplicationHealthNull { @@ -791,7 +791,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Replication health for the virtual machine.")] @@ -804,7 +804,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ReplicationHealthValues)(System.Convert.ToInt32(curObj["ReplicationHealth"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReplicationModeNull { @@ -817,7 +817,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Identifies replication type for the virtual machine.")] @@ -830,7 +830,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ReplicationModeValues)(System.Convert.ToInt32(curObj["ReplicationMode"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReplicationStateNull { @@ -843,7 +843,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Replication state for the virtual machine.")] @@ -856,7 +856,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ReplicationStateValues)(System.Convert.ToInt32(curObj["ReplicationState"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -869,7 +869,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -881,7 +881,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResetCapabilityNull { @@ -894,7 +894,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -906,7 +906,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ResetCapability"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Roles { @@ -914,7 +914,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["Roles"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -922,7 +922,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -930,7 +930,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastConfigurationChangeNull { @@ -943,7 +943,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The date and time when the virtual machine configuration file was last modified. " + @@ -961,7 +961,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -974,7 +974,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -988,7 +988,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -1001,7 +1001,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1013,9 +1013,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1023,9 +1023,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1042,49 +1042,49 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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; @@ -1136,13 +1136,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1170,7 +1170,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1197,8 +1197,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1208,159 +1208,159 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1372,24 +1372,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1410,15 +1410,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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)) { @@ -1435,7 +1435,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new ComputerSystemCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static ComputerSystem CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1450,12 +1450,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1474,7 +1474,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1494,7 +1494,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SetPowerState(uint PowerState, System.DateTime Time) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1508,115 +1508,115 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1624,189 +1624,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { 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 index 823e41482bc..931d7a648eb 100644 --- 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 @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -33,62 +33,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // 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)) { @@ -100,7 +100,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public ConcreteJob(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -113,7 +113,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -122,7 +122,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -131,7 +131,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -140,7 +140,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -149,7 +149,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -158,7 +158,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -177,7 +177,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -189,7 +189,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -210,7 +210,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -222,7 +222,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCancellableNull { @@ -235,7 +235,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates whether the job can be cancelled. The value of this property does not g" + @@ -249,7 +249,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["Cancellable"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -257,7 +257,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -282,7 +282,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDeleteOnCompletionNull { @@ -295,7 +295,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -307,7 +307,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["DeleteOnCompletion"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -315,7 +315,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -328,7 +328,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -340,7 +340,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsElapsedTimeNull { @@ -353,7 +353,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -367,7 +367,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -375,7 +375,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsErrorCodeNull { @@ -388,7 +388,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -400,7 +400,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ErrorCode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorDescription { @@ -408,7 +408,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorDescription"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorSummaryDescription { @@ -416,7 +416,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorSummaryDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -429,7 +429,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -441,7 +441,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -454,7 +454,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -468,7 +468,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -476,7 +476,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobRunTimesNull { @@ -489,7 +489,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -501,7 +501,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["JobRunTimes"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobStateNull { @@ -514,7 +514,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -526,7 +526,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["JobState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string JobStatus { @@ -534,7 +534,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["JobStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobTypeNull { @@ -547,7 +547,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates the type of Job being tracked by this object.")] @@ -560,7 +560,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["JobType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLocalOrUtcTimeNull { @@ -573,7 +573,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -585,7 +585,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["LocalOrUtcTime"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -593,7 +593,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Notify { @@ -601,7 +601,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Notify"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -614,7 +614,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -626,7 +626,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -634,7 +634,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherRecoveryAction { @@ -642,7 +642,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherRecoveryAction"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Owner { @@ -650,7 +650,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Owner"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentCompleteNull { @@ -663,7 +663,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -675,7 +675,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PercentComplete"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -688,7 +688,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -700,7 +700,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPriorityNull { @@ -713,7 +713,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -725,7 +725,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["Priority"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRecoveryActionNull { @@ -738,7 +738,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -750,7 +750,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RecoveryAction"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunDayNull { @@ -763,7 +763,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -775,7 +775,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((sbyte)(curObj["RunDay"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunDayOfWeekNull { @@ -788,7 +788,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -800,7 +800,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((sbyte)(curObj["RunDayOfWeek"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunMonthNull { @@ -813,7 +813,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -825,7 +825,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((byte)(curObj["RunMonth"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunStartIntervalNull { @@ -838,7 +838,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -852,7 +852,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsScheduledStartTimeNull { @@ -865,7 +865,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -879,7 +879,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStartTimeNull { @@ -892,7 +892,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -906,7 +906,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -914,7 +914,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -922,7 +922,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeBeforeRemovalNull { @@ -935,7 +935,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -949,7 +949,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -962,7 +962,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -976,7 +976,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeSubmittedNull { @@ -989,7 +989,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1003,7 +1003,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsUntilTimeNull { @@ -1016,7 +1016,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1030,9 +1030,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1040,9 +1040,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1059,21 +1059,21 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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; @@ -1114,7 +1114,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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'); @@ -1131,8 +1131,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((timespan.Ticks - tsTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicroSec = ((long)(microsec)).ToString(); if ((strMicroSec.Length > 6)) { @@ -1142,21 +1142,21 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1208,13 +1208,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1242,7 +1242,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1269,8 +1269,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1280,193 +1280,193 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1478,24 +1478,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1516,15 +1516,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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)) { @@ -1541,7 +1541,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new ConcreteJobCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static ConcreteJob CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1556,12 +1556,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1574,7 +1574,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint GetErrorEx(out string[] Errors) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1587,7 +1587,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint KillJob(bool DeleteOnKill) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1600,7 +1600,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint RequestStateChange(ushort RequestedState, System.TimeSpan TimeoutPeriod) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1614,34 +1614,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1649,189 +1649,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs index f281def4b10..680a57f53c3 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetPortAllocationSettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // An Early Bound class generated for the WMI class.Msvm_EthernetPortAllocationSettingData public class EthernetPortAllocationSettingData : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_EthernetPortAllocationSettingData"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public EthernetPortAllocationSettingData() { this.InitializeObject(null, null, null); } - + public EthernetPortAllocationSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(EthernetPortAllocationSettingData.ConstructPath(keyInstanceID)), null); } - + public EthernetPortAllocationSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetPortAllocationSettingData.ConstructPath(keyInstanceID)), null); } - + public EthernetPortAllocationSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public EthernetPortAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public EthernetPortAllocationSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public EthernetPortAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public EthernetPortAllocationSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public EthernetPortAllocationSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Address { @@ -228,7 +228,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Address"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AddressOnParent { @@ -236,7 +236,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AddressOnParent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AllocationUnits { @@ -244,7 +244,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AllocationUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticAllocationNull { @@ -257,7 +257,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -269,7 +269,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticAllocation"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticDeallocationNull { @@ -282,7 +282,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -294,7 +294,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticDeallocation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -302,7 +302,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Connection { @@ -310,7 +310,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["Connection"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConsumerVisibilityNull { @@ -323,7 +323,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -335,7 +335,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ConsumerVisibility"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -343,7 +343,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDesiredVLANEndpointModeNull { @@ -356,7 +356,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -368,7 +368,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DesiredVLANEndpointMode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -376,7 +376,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -389,7 +389,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"EnabledState is an integer enumeration that indicates whether the allocation request is enabled or disabled. When an allocation request is marked as Disabled (3), then the allocation is not processed. The EnabledState for an active configuration is always marked as Enabled (2).")] @@ -402,7 +402,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((EnabledStateValues)(System.Convert.ToInt32(curObj["EnabledState"]))); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] HostResource { @@ -410,7 +410,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["HostResource"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -418,7 +418,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitNull { @@ -431,7 +431,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -443,7 +443,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Limit"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMappingBehaviorNull { @@ -456,7 +456,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -468,7 +468,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["MappingBehavior"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEndpointMode { @@ -476,7 +476,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEndpointMode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherResourceType { @@ -484,7 +484,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherResourceType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Parent { @@ -492,7 +492,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Parent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PoolID { @@ -500,7 +500,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PoolID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The list of friendly names corresponding to each entry in the RequiredFeatures.")] @@ -509,7 +509,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["RequiredFeatureHints"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The list of feature identifers representing all the features that are required fo" + @@ -520,13 +520,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["RequiredFeatures"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReservationNull { @@ -539,7 +539,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -551,7 +551,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Reservation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ResourceSubType { @@ -559,7 +559,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ResourceSubType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResourceTypeNull { @@ -572,7 +572,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -584,7 +584,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ResourceType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("This property specifies the network resource pool from which a connection will be" + @@ -595,13 +595,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["TestReplicaPoolID"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("This property specifies the friendly name of the virtual network switch to which " + @@ -612,13 +612,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["TestReplicaSwitchName"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualQuantityNull { @@ -631,7 +631,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -643,7 +643,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["VirtualQuantity"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string VirtualQuantityUnits { @@ -651,7 +651,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["VirtualQuantityUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsWeightNull { @@ -664,7 +664,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -676,9 +676,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["Weight"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -686,9 +686,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -705,133 +705,133 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeAutomaticAllocation() { if ((this.IsAutomaticAllocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutomaticDeallocation() { if ((this.IsAutomaticDeallocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeConsumerVisibility() { if ((this.IsConsumerVisibilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeDesiredVLANEndpointMode() { if ((this.IsDesiredVLANEndpointModeNull == false)) { return true; } return false; } - + private bool ShouldSerializeEnabledState() { if ((this.IsEnabledStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeLimit() { if ((this.IsLimitNull == false)) { return true; } return false; } - + private bool ShouldSerializeMappingBehavior() { if ((this.IsMappingBehaviorNull == false)) { return true; } return false; } - + private void ResetRequiredFeatures() { curObj["RequiredFeatures"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeReservation() { if ((this.IsReservationNull == false)) { return true; } return false; } - + private bool ShouldSerializeResourceType() { if ((this.IsResourceTypeNull == false)) { return true; } return false; } - + private void ResetTestReplicaPoolID() { curObj["TestReplicaPoolID"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetTestReplicaSwitchName() { curObj["TestReplicaSwitchName"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeVirtualQuantity() { if ((this.IsVirtualQuantityNull == false)) { return true; } return false; } - + private bool ShouldSerializeWeight() { if ((this.IsWeightNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyInstanceID) { string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetPortAllocationSettingData"; strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -843,24 +843,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static EthernetPortAllocationSettingDataCollection GetInstances() { return GetInstances(null, null, null); } - + public static EthernetPortAllocationSettingDataCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static EthernetPortAllocationSettingDataCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static EthernetPortAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -881,15 +881,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new EthernetPortAllocationSettingDataCollection(clsObject.GetInstances(enumOptions)); } - + public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static EthernetPortAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -906,7 +906,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new EthernetPortAllocationSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static EthernetPortAllocationSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -921,48 +921,48 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new EthernetPortAllocationSettingData(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public enum EnabledStateValues { - + Enabled = 2, - + Disabled = 3, - + NULL_ENUM_VALUE = 0, } - + // Enumerator implementation for enumerating instances of the class. public class EthernetPortAllocationSettingDataCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public EthernetPortAllocationSettingDataCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -970,189 +970,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new EthernetPortAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new EthernetPortAllocationSettingDataEnumerator(privColObj.GetEnumerator()); } - + public class EthernetPortAllocationSettingDataEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public EthernetPortAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new EthernetPortAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); } } - + public virtual bool MoveNext() { return privObjEnum.MoveNext(); } - + public virtual void Reset() { privObjEnum.Reset(); } } } - + // TypeConverter to handle null values for ValueType properties public class WMIValueTypeConverter : TypeConverter { - + private TypeConverter baseConverter; - + private System.Type baseType; - + public WMIValueTypeConverter(System.Type inBaseType) { baseConverter = TypeDescriptor.GetConverter(inBaseType); baseType = inBaseType; } - + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { return baseConverter.CanConvertFrom(context, srcType); } - + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return baseConverter.CanConvertTo(context, destinationType); } - + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return baseConverter.ConvertFrom(context, culture, value); } - + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { return baseConverter.CreateInstance(context, dictionary); } - + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetCreateInstanceSupported(context); } - + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { return baseConverter.GetProperties(context, value, attributeVar); } - + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetPropertiesSupported(context); } - + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValues(context); } - + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesExclusive(context); } - + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesSupported(context); } - + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((baseType.BaseType == typeof(System.Enum))) { if ((value.GetType() == destinationType)) { return value; } - if ((((value == null) - && (context != null)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs index 5bc97f864bb..b33b3a5890a 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPort.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. // An Early Bound class generated for the WMI class.Msvm_EthernetSwitchPort public class EthernetSwitchPort : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_EthernetSwitchPort"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public EthernetSwitchPort() { this.InitializeObject(null, null, null); } - + public EthernetSwitchPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(null, new System.Management.ManagementPath(EthernetSwitchPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); } - + public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetSwitchPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); } - + public EthernetSwitchPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public EthernetSwitchPort(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public EthernetSwitchPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public EthernetSwitchPort(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public EthernetSwitchPort(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsActiveMaximumTransmissionUnitNull { @@ -234,7 +234,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -246,7 +246,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["ActiveMaximumTransmissionUnit"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AdditionalAvailability { @@ -254,7 +254,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AdditionalAvailability"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutoSenseNull { @@ -267,7 +267,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -279,7 +279,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutoSense"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAvailabilityNull { @@ -292,7 +292,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -304,7 +304,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["Availability"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -312,7 +312,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] Capabilities { @@ -320,7 +320,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["Capabilities"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] CapabilityDescriptions { @@ -328,7 +328,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["CapabilityDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -336,7 +336,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -349,7 +349,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -361,7 +361,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -369,7 +369,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -377,7 +377,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -390,7 +390,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -402,7 +402,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string DeviceID { @@ -410,7 +410,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["DeviceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -418,7 +418,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] EnabledCapabilities { @@ -426,7 +426,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["EnabledCapabilities"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -439,7 +439,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -451,7 +451,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -464,7 +464,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -476,7 +476,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsErrorClearedNull { @@ -489,7 +489,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -501,7 +501,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["ErrorCleared"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorDescription { @@ -509,7 +509,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFullDuplexNull { @@ -522,7 +522,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -534,7 +534,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["FullDuplex"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -547,7 +547,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -559,7 +559,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] IdentifyingDescriptions { @@ -567,7 +567,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["IdentifyingDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -580,7 +580,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -594,7 +594,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -602,7 +602,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsIOVOffloadUsageNull { @@ -615,7 +615,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The current I/O virtualization (IOV) offload usage on this port. The usage is the" + @@ -629,7 +629,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["IOVOffloadUsage"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastErrorCodeNull { @@ -642,7 +642,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -654,7 +654,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["LastErrorCode"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLinkTechnologyNull { @@ -667,7 +667,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -679,7 +679,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["LinkTechnology"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxDataSizeNull { @@ -692,7 +692,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -704,7 +704,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["MaxDataSize"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxQuiesceTimeNull { @@ -717,7 +717,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -729,7 +729,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MaxQuiesceTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxSpeedNull { @@ -742,7 +742,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -754,7 +754,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MaxSpeed"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -762,7 +762,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] NetworkAddresses { @@ -770,7 +770,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["NetworkAddresses"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -783,7 +783,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -795,7 +795,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -803,7 +803,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherEnabledCapabilities { @@ -811,7 +811,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherEnabledCapabilities"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -819,7 +819,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherIdentifyingInfo { @@ -827,7 +827,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherIdentifyingInfo"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherLinkTechnology { @@ -835,7 +835,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherLinkTechnology"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherNetworkPortType { @@ -843,7 +843,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherNetworkPortType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherPortType { @@ -851,7 +851,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherPortType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PermanentAddress { @@ -859,7 +859,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PermanentAddress"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPortNumberNull { @@ -872,7 +872,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -884,7 +884,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PortNumber"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPortTypeNull { @@ -897,7 +897,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -909,7 +909,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PortType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] PowerManagementCapabilities { @@ -917,7 +917,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["PowerManagementCapabilities"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerManagementSupportedNull { @@ -930,7 +930,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -942,7 +942,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["PowerManagementSupported"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerOnHoursNull { @@ -955,7 +955,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -967,7 +967,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["PowerOnHours"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -980,7 +980,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -992,7 +992,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedSpeedNull { @@ -1005,7 +1005,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1017,7 +1017,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["RequestedSpeed"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -1030,7 +1030,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1042,7 +1042,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSpeedNull { @@ -1055,7 +1055,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1067,7 +1067,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Speed"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -1075,7 +1075,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -1083,7 +1083,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStatusInfoNull { @@ -1096,7 +1096,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1108,7 +1108,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["StatusInfo"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSupportedMaximumTransmissionUnitNull { @@ -1121,7 +1121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1133,7 +1133,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["SupportedMaximumTransmissionUnit"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -1141,7 +1141,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -1149,7 +1149,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -1162,7 +1162,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1176,7 +1176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTotalPowerOnHoursNull { @@ -1189,7 +1189,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1201,7 +1201,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["TotalPowerOnHours"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -1214,7 +1214,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1226,7 +1226,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsUsageRestrictionNull { @@ -1239,7 +1239,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1251,7 +1251,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["UsageRestriction"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVMQOffloadUsageNull { @@ -1264,7 +1264,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The current VMQ offloading usage on this port. The usage is the amount of VMQ res" + @@ -1278,9 +1278,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["VMQOffloadUsage"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1288,9 +1288,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1307,77 +1307,77 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeActiveMaximumTransmissionUnit() { if ((this.IsActiveMaximumTransmissionUnitNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutoSense() { if ((this.IsAutoSenseNull == false)) { return true; } return false; } - + private bool ShouldSerializeAvailability() { if ((this.IsAvailabilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeCommunicationStatus() { if ((this.IsCommunicationStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeDetailedStatus() { if ((this.IsDetailedStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeEnabledDefault() { if ((this.IsEnabledDefaultNull == false)) { return true; } return false; } - + private bool ShouldSerializeEnabledState() { if ((this.IsEnabledStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeErrorCleared() { if ((this.IsErrorClearedNull == false)) { return true; } return false; } - + private bool ShouldSerializeFullDuplex() { if ((this.IsFullDuplexNull == false)) { return true; } return false; } - + private bool ShouldSerializeHealthState() { if ((this.IsHealthStateNull == false)) { return true; } return false; } - + // Converts a given datetime in DMTF format to System.DateTime object. static System.DateTime ToDateTime(string dmtfDate) { System.DateTime initializer = System.DateTime.MinValue; @@ -1429,13 +1429,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1463,7 +1463,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1490,8 +1490,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1501,187 +1501,187 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { dmtfDateTime = string.Concat(dmtfDateTime, utcString); return dmtfDateTime; } - + private bool ShouldSerializeInstallDate() { if ((this.IsInstallDateNull == false)) { return true; } return false; } - + private bool ShouldSerializeIOVOffloadUsage() { if ((this.IsIOVOffloadUsageNull == false)) { return true; } return false; } - + private bool ShouldSerializeLastErrorCode() { if ((this.IsLastErrorCodeNull == false)) { return true; } return false; } - + private bool ShouldSerializeLinkTechnology() { if ((this.IsLinkTechnologyNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxDataSize() { if ((this.IsMaxDataSizeNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxQuiesceTime() { if ((this.IsMaxQuiesceTimeNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxSpeed() { if ((this.IsMaxSpeedNull == false)) { return true; } return false; } - + private bool ShouldSerializeOperatingStatus() { if ((this.IsOperatingStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializePortNumber() { if ((this.IsPortNumberNull == false)) { return true; } return false; } - + private bool ShouldSerializePortType() { if ((this.IsPortTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializePowerManagementSupported() { if ((this.IsPowerManagementSupportedNull == false)) { return true; } return false; } - + private bool ShouldSerializePowerOnHours() { if ((this.IsPowerOnHoursNull == false)) { return true; } return false; } - + private bool ShouldSerializePrimaryStatus() { if ((this.IsPrimaryStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeRequestedSpeed() { if ((this.IsRequestedSpeedNull == false)) { return true; } return false; } - + private bool ShouldSerializeRequestedState() { if ((this.IsRequestedStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeSpeed() { if ((this.IsSpeedNull == false)) { return true; } return false; } - + private bool ShouldSerializeStatusInfo() { if ((this.IsStatusInfoNull == false)) { return true; } return false; } - + private bool ShouldSerializeSupportedMaximumTransmissionUnit() { if ((this.IsSupportedMaximumTransmissionUnitNull == false)) { return true; } return false; } - + private bool ShouldSerializeTimeOfLastStateChange() { if ((this.IsTimeOfLastStateChangeNull == false)) { return true; } return false; } - + private bool ShouldSerializeTotalPowerOnHours() { if ((this.IsTotalPowerOnHoursNull == false)) { return true; } return false; } - + private bool ShouldSerializeTransitioningToState() { if ((this.IsTransitioningToStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeUsageRestriction() { if ((this.IsUsageRestrictionNull == false)) { return true; } return false; } - + private bool ShouldSerializeVMQOffloadUsage() { if ((this.IsVMQOffloadUsageNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetSwitchPort"; strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); @@ -1690,7 +1690,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1702,24 +1702,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static EthernetSwitchPortCollection GetInstances() { return GetInstances(null, null, null); } - + public static EthernetSwitchPortCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static EthernetSwitchPortCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static EthernetSwitchPortCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1740,15 +1740,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new EthernetSwitchPortCollection(clsObject.GetInstances(enumOptions)); } - + public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static EthernetSwitchPortCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1765,7 +1765,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new EthernetSwitchPortCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static EthernetSwitchPort CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1780,12 +1780,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new EthernetSwitchPort(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint EnableDevice(bool Enabled) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1798,7 +1798,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint OnlineDevice(bool Online) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1811,7 +1811,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint QuiesceDevice(bool Quiesce) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1824,7 +1824,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1843,7 +1843,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint Reset() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1854,7 +1854,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint RestoreProperties() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1865,7 +1865,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SaveProperties() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1876,7 +1876,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SetPowerState(ushort PowerState, System.DateTime Time) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1890,34 +1890,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + // Enumerator implementation for enumerating instances of the class. public class EthernetSwitchPortCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public EthernetSwitchPortCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -1925,189 +1925,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new EthernetSwitchPort(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new EthernetSwitchPortEnumerator(privColObj.GetEnumerator()); } - + public class EthernetSwitchPortEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public EthernetSwitchPortEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new EthernetSwitchPort(((System.Management.ManagementObject)(privObjEnum.Current))); } } - + public virtual bool MoveNext() { return privObjEnum.MoveNext(); } - + public virtual void Reset() { privObjEnum.Reset(); } } } - + // TypeConverter to handle null values for ValueType properties public class WMIValueTypeConverter : TypeConverter { - + private TypeConverter baseConverter; - + private System.Type baseType; - + public WMIValueTypeConverter(System.Type inBaseType) { baseConverter = TypeDescriptor.GetConverter(inBaseType); baseType = inBaseType; } - + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { return baseConverter.CanConvertFrom(context, srcType); } - + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return baseConverter.CanConvertTo(context, destinationType); } - + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return baseConverter.ConvertFrom(context, culture, value); } - + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { return baseConverter.CreateInstance(context, dictionary); } - + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetCreateInstanceSupported(context); } - + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { return baseConverter.GetProperties(context, value, attributeVar); } - + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetPropertiesSupported(context); } - + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValues(context); } - + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesExclusive(context); } - + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesSupported(context); } - + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((baseType.BaseType == typeof(System.Enum))) { if ((value.GetType() == destinationType)) { return value; } - if ((((value == null) - && (context != null)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortBandwidthSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortBandwidthSettingData.cs index 482c4d2fa86..6085ac5aecc 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortBandwidthSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortBandwidthSettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset 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_EthernetSwitchPortBandwidthSettingData public class EthernetSwitchPortBandwidthSettingData : 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_EthernetSwitchPortBandwidthSettingData"; - + // 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 EthernetSwitchPortBandwidthSettingData() { this.InitializeObject(null, null, null); } - + public EthernetSwitchPortBandwidthSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(EthernetSwitchPortBandwidthSettingData.ConstructPath(keyInstanceID)), null); } - + public EthernetSwitchPortBandwidthSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetSwitchPortBandwidthSettingData.ConstructPath(keyInstanceID)), null); } - + public EthernetSwitchPortBandwidthSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public EthernetSwitchPortBandwidthSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public EthernetSwitchPortBandwidthSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public EthernetSwitchPortBandwidthSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public EthernetSwitchPortBandwidthSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public EthernetSwitchPortBandwidthSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsBurstLimitNull { @@ -233,7 +233,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The peak bandwidth allowed from the port during bursts.")] @@ -247,13 +247,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["BurstLimit"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsBurstSizeNull { @@ -266,7 +266,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum burst size allowed.")] @@ -280,13 +280,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["BurstSize"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -294,7 +294,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -302,7 +302,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -310,7 +310,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -318,7 +318,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitNull { @@ -331,7 +331,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The bandwidth limit allowed for the port.")] @@ -345,13 +345,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["Limit"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReservationNull { @@ -364,7 +364,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The minimum absolute bandwidth guaranteed for the port.")] @@ -378,13 +378,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["Reservation"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsWeightNull { @@ -397,7 +397,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The minimum bandwidth in weight guaranteed for the port.")] @@ -411,15 +411,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["Weight"] = value; - if (((isEmbedded == false) + 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) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -427,9 +427,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -446,107 +446,107 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeBurstLimit() { if ((this.IsBurstLimitNull == false)) { return true; } return false; } - + private void ResetBurstLimit() { curObj["BurstLimit"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeBurstSize() { if ((this.IsBurstSizeNull == false)) { return true; } return false; } - + private void ResetBurstSize() { curObj["BurstSize"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeLimit() { if ((this.IsLimitNull == false)) { return true; } return false; } - + private void ResetLimit() { curObj["Limit"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeReservation() { if ((this.IsReservationNull == false)) { return true; } return false; } - + private void ResetReservation() { curObj["Reservation"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeWeight() { if ((this.IsWeightNull == false)) { return true; } return false; } - + private void ResetWeight() { curObj["Weight"] = null; - if (((isEmbedded == false) + 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_EthernetSwitchPortBandwidthSettingData"; 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)) { @@ -558,24 +558,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static EthernetSwitchPortBandwidthSettingDataCollection GetInstances() { return GetInstances(null, null, null); } - + public static EthernetSwitchPortBandwidthSettingDataCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static EthernetSwitchPortBandwidthSettingDataCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static EthernetSwitchPortBandwidthSettingDataCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static EthernetSwitchPortBandwidthSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -596,15 +596,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new EthernetSwitchPortBandwidthSettingDataCollection(clsObject.GetInstances(enumOptions)); } - + public static EthernetSwitchPortBandwidthSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static EthernetSwitchPortBandwidthSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static EthernetSwitchPortBandwidthSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -621,7 +621,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new EthernetSwitchPortBandwidthSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static EthernetSwitchPortBandwidthSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -636,39 +636,39 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new EthernetSwitchPortBandwidthSettingData(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + // Enumerator implementation for enumerating instances of the class. public class EthernetSwitchPortBandwidthSettingDataCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public EthernetSwitchPortBandwidthSettingDataCollection(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; @@ -676,189 +676,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new EthernetSwitchPortBandwidthSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new EthernetSwitchPortBandwidthSettingDataEnumerator(privColObj.GetEnumerator()); } - + public class EthernetSwitchPortBandwidthSettingDataEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public EthernetSwitchPortBandwidthSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new EthernetSwitchPortBandwidthSettingData(((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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs index f95567cf954..e936f9e00dd 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_EthernetSwitchPortVlanSettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // An Early Bound class generated for the WMI class.Msvm_EthernetSwitchPortVlanSettingData public class EthernetSwitchPortVlanSettingData : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_EthernetSwitchPortVlanSettingData"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public EthernetSwitchPortVlanSettingData() { this.InitializeObject(null, null, null); } - + public EthernetSwitchPortVlanSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(EthernetSwitchPortVlanSettingData.ConstructPath(keyInstanceID)), null); } - + public EthernetSwitchPortVlanSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(EthernetSwitchPortVlanSettingData.ConstructPath(keyInstanceID)), null); } - + public EthernetSwitchPortVlanSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public EthernetSwitchPortVlanSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public EthernetSwitchPortVlanSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public EthernetSwitchPortVlanSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public EthernetSwitchPortVlanSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public EthernetSwitchPortVlanSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAccessVlanIdNull { @@ -233,7 +233,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The vlan ID in access mode.")] @@ -247,13 +247,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["AccessVlanId"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -261,7 +261,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -269,7 +269,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -277,7 +277,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -285,7 +285,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNativeVlanIdNull { @@ -298,7 +298,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The vlan ID in trunk mode.")] @@ -312,13 +312,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["NativeVlanId"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperationModeNull { @@ -331,7 +331,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The vlan operation modes.")] @@ -350,13 +350,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { else { curObj["OperationMode"] = value; } - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryVlanIdNull { @@ -369,7 +369,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The primary vlan ID in private mode.")] @@ -383,13 +383,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["PrimaryVlanId"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The prune vlan ID bitmap in trunk mode.")] @@ -399,13 +399,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["PruneVlanIdArray"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPvlanModeNull { @@ -418,7 +418,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The private vlan modes.")] @@ -437,13 +437,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { else { curObj["PvlanMode"] = value; } - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSecondaryVlanIdNull { @@ -456,7 +456,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The secondary vlan ID in private mode.")] @@ -470,13 +470,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["SecondaryVlanId"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The secondary vlan ID bitmap in private mode.")] @@ -486,13 +486,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["SecondaryVlanIdArray"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The trunk vlan ID bitmap in trunk mode.")] @@ -502,15 +502,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["TrunkVlanIdArray"] = value; - if (((isEmbedded == false) + 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) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -518,9 +518,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -537,146 +537,146 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeAccessVlanId() { if ((this.IsAccessVlanIdNull == false)) { return true; } return false; } - + private void ResetAccessVlanId() { curObj["AccessVlanId"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeNativeVlanId() { if ((this.IsNativeVlanIdNull == false)) { return true; } return false; } - + private void ResetNativeVlanId() { curObj["NativeVlanId"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeOperationMode() { if ((this.IsOperationModeNull == false)) { return true; } return false; } - + private void ResetOperationMode() { curObj["OperationMode"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializePrimaryVlanId() { if ((this.IsPrimaryVlanIdNull == false)) { return true; } return false; } - + private void ResetPrimaryVlanId() { curObj["PrimaryVlanId"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetPruneVlanIdArray() { curObj["PruneVlanIdArray"] = null; - if (((isEmbedded == false) + 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) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeSecondaryVlanId() { if ((this.IsSecondaryVlanIdNull == false)) { return true; } return false; } - + private void ResetSecondaryVlanId() { curObj["SecondaryVlanId"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetSecondaryVlanIdArray() { curObj["SecondaryVlanIdArray"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetTrunkVlanIdArray() { curObj["TrunkVlanIdArray"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyInstanceID) { string strPath = "ROOT\\virtualization\\v2:Msvm_EthernetSwitchPortVlanSettingData"; strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -688,24 +688,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static EthernetSwitchPortVlanSettingDataCollection GetInstances() { return GetInstances(null, null, null); } - + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -726,15 +726,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new EthernetSwitchPortVlanSettingDataCollection(clsObject.GetInstances(enumOptions)); } - + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static EthernetSwitchPortVlanSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -751,7 +751,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new EthernetSwitchPortVlanSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static EthernetSwitchPortVlanSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -766,61 +766,61 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new EthernetSwitchPortVlanSettingData(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public enum OperationModeValues { - + Access = 1, - + Trunk = 2, - + Private = 3, - + NULL_ENUM_VALUE = 0, } - + public enum PvlanModeValues { - + Isolated = 1, - + Community = 2, - + Promiscuous = 3, - + NULL_ENUM_VALUE = 0, } - + // Enumerator implementation for enumerating instances of the class. public class EthernetSwitchPortVlanSettingDataCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public EthernetSwitchPortVlanSettingDataCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -828,189 +828,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new EthernetSwitchPortVlanSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new EthernetSwitchPortVlanSettingDataEnumerator(privColObj.GetEnumerator()); } - + public class EthernetSwitchPortVlanSettingDataEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public EthernetSwitchPortVlanSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new EthernetSwitchPortVlanSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); } } - + public virtual bool MoveNext() { return privObjEnum.MoveNext(); } - + public virtual void Reset() { privObjEnum.Reset(); } } } - + // TypeConverter to handle null values for ValueType properties public class WMIValueTypeConverter : TypeConverter { - + private TypeConverter baseConverter; - + private System.Type baseType; - + public WMIValueTypeConverter(System.Type inBaseType) { baseConverter = TypeDescriptor.GetConverter(inBaseType); baseType = inBaseType; } - + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { return baseConverter.CanConvertFrom(context, srcType); } - + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return baseConverter.CanConvertTo(context, destinationType); } - + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return baseConverter.ConvertFrom(context, culture, value); } - + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { return baseConverter.CreateInstance(context, dictionary); } - + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetCreateInstanceSupported(context); } - + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { return baseConverter.GetProperties(context, value, attributeVar); } - + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetPropertiesSupported(context); } - + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValues(context); } - + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesExclusive(context); } - + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesSupported(context); } - + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((baseType.BaseType == typeof(System.Enum))) { if ((value.GetType() == destinationType)) { return value; } - if ((((value == null) - && (context != null)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs index 1b6828621d0..e4b2fda9d48 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ExternalEthernetPort.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. // An Early Bound class generated for the WMI class.Msvm_ExternalEthernetPort public class ExternalEthernetPort : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. private static string CreatedClassName = "Msvm_ExternalEthernetPort"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public ExternalEthernetPort() { this.InitializeObject(null, null, null); } - + public ExternalEthernetPort(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(null, new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); } - + public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ExternalEthernetPort.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); } - + public ExternalEthernetPort(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public ExternalEthernetPort(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public ExternalEthernetPort(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public ExternalEthernetPort(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public ExternalEthernetPort(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsActiveMaximumTransmissionUnitNull { @@ -234,7 +234,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -246,7 +246,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["ActiveMaximumTransmissionUnit"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AdditionalAvailability { @@ -254,7 +254,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AdditionalAvailability"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutoSenseNull { @@ -267,7 +267,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -279,7 +279,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutoSense"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAvailabilityNull { @@ -292,7 +292,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -304,7 +304,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["Availability"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -312,7 +312,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] Capabilities { @@ -320,7 +320,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["Capabilities"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] CapabilityDescriptions { @@ -328,7 +328,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["CapabilityDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -336,7 +336,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -349,7 +349,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -361,7 +361,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -369,7 +369,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -377,7 +377,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -390,7 +390,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -402,7 +402,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string DeviceID { @@ -410,7 +410,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["DeviceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -418,7 +418,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] EnabledCapabilities { @@ -426,7 +426,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["EnabledCapabilities"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -439,7 +439,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -451,7 +451,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -464,7 +464,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -476,7 +476,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsErrorClearedNull { @@ -489,7 +489,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -501,7 +501,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["ErrorCleared"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorDescription { @@ -509,7 +509,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFullDuplexNull { @@ -522,7 +522,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -534,7 +534,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["FullDuplex"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -547,7 +547,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -559,7 +559,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] IdentifyingDescriptions { @@ -567,7 +567,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["IdentifyingDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -580,7 +580,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -594,7 +594,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -602,7 +602,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsIsBoundNull { @@ -615,7 +615,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("If this property is true, then this Ethernet port can be connected to the switche" + @@ -631,7 +631,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["IsBound"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastErrorCodeNull { @@ -644,7 +644,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -656,7 +656,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["LastErrorCode"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLinkTechnologyNull { @@ -669,7 +669,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -681,7 +681,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["LinkTechnology"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxDataSizeNull { @@ -694,7 +694,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -706,7 +706,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["MaxDataSize"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxQuiesceTimeNull { @@ -719,7 +719,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -731,7 +731,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MaxQuiesceTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxSpeedNull { @@ -744,7 +744,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -756,7 +756,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MaxSpeed"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -764,7 +764,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] NetworkAddresses { @@ -772,7 +772,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["NetworkAddresses"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -785,7 +785,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -797,7 +797,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -805,7 +805,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherEnabledCapabilities { @@ -813,7 +813,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherEnabledCapabilities"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -821,7 +821,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherIdentifyingInfo { @@ -829,7 +829,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherIdentifyingInfo"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherLinkTechnology { @@ -837,7 +837,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherLinkTechnology"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherNetworkPortType { @@ -845,7 +845,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherNetworkPortType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherPortType { @@ -853,7 +853,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherPortType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PermanentAddress { @@ -861,7 +861,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PermanentAddress"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPortNumberNull { @@ -874,7 +874,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -886,7 +886,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PortNumber"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPortTypeNull { @@ -899,7 +899,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -911,7 +911,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PortType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] PowerManagementCapabilities { @@ -919,7 +919,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["PowerManagementCapabilities"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerManagementSupportedNull { @@ -932,7 +932,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -944,7 +944,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["PowerManagementSupported"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerOnHoursNull { @@ -957,7 +957,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -969,7 +969,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["PowerOnHours"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -982,7 +982,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -994,7 +994,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedSpeedNull { @@ -1007,7 +1007,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1019,7 +1019,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["RequestedSpeed"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -1032,7 +1032,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1044,7 +1044,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSpeedNull { @@ -1057,7 +1057,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1069,7 +1069,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Speed"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -1077,7 +1077,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -1085,7 +1085,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStatusInfoNull { @@ -1098,7 +1098,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1110,7 +1110,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["StatusInfo"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSupportedMaximumTransmissionUnitNull { @@ -1123,7 +1123,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1135,7 +1135,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["SupportedMaximumTransmissionUnit"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -1143,7 +1143,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -1151,7 +1151,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -1164,7 +1164,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1178,7 +1178,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTotalPowerOnHoursNull { @@ -1191,7 +1191,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1203,7 +1203,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["TotalPowerOnHours"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -1216,7 +1216,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1228,7 +1228,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsUsageRestrictionNull { @@ -1241,7 +1241,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1253,9 +1253,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["UsageRestriction"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1263,9 +1263,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1282,77 +1282,77 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeActiveMaximumTransmissionUnit() { if ((this.IsActiveMaximumTransmissionUnitNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutoSense() { if ((this.IsAutoSenseNull == false)) { return true; } return false; } - + private bool ShouldSerializeAvailability() { if ((this.IsAvailabilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeCommunicationStatus() { if ((this.IsCommunicationStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeDetailedStatus() { if ((this.IsDetailedStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeEnabledDefault() { if ((this.IsEnabledDefaultNull == false)) { return true; } return false; } - + private bool ShouldSerializeEnabledState() { if ((this.IsEnabledStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeErrorCleared() { if ((this.IsErrorClearedNull == false)) { return true; } return false; } - + private bool ShouldSerializeFullDuplex() { if ((this.IsFullDuplexNull == false)) { return true; } return false; } - + private bool ShouldSerializeHealthState() { if ((this.IsHealthStateNull == false)) { return true; } return false; } - + // Converts a given datetime in DMTF format to System.DateTime object. static System.DateTime ToDateTime(string dmtfDate) { System.DateTime initializer = System.DateTime.MinValue; @@ -1404,13 +1404,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1438,7 +1438,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1465,8 +1465,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1476,180 +1476,180 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { dmtfDateTime = string.Concat(dmtfDateTime, utcString); return dmtfDateTime; } - + private bool ShouldSerializeInstallDate() { if ((this.IsInstallDateNull == false)) { return true; } return false; } - + private bool ShouldSerializeIsBound() { if ((this.IsIsBoundNull == false)) { return true; } return false; } - + private bool ShouldSerializeLastErrorCode() { if ((this.IsLastErrorCodeNull == false)) { return true; } return false; } - + private bool ShouldSerializeLinkTechnology() { if ((this.IsLinkTechnologyNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxDataSize() { if ((this.IsMaxDataSizeNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxQuiesceTime() { if ((this.IsMaxQuiesceTimeNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxSpeed() { if ((this.IsMaxSpeedNull == false)) { return true; } return false; } - + private bool ShouldSerializeOperatingStatus() { if ((this.IsOperatingStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializePortNumber() { if ((this.IsPortNumberNull == false)) { return true; } return false; } - + private bool ShouldSerializePortType() { if ((this.IsPortTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializePowerManagementSupported() { if ((this.IsPowerManagementSupportedNull == false)) { return true; } return false; } - + private bool ShouldSerializePowerOnHours() { if ((this.IsPowerOnHoursNull == false)) { return true; } return false; } - + private bool ShouldSerializePrimaryStatus() { if ((this.IsPrimaryStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeRequestedSpeed() { if ((this.IsRequestedSpeedNull == false)) { return true; } return false; } - + private bool ShouldSerializeRequestedState() { if ((this.IsRequestedStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeSpeed() { if ((this.IsSpeedNull == false)) { return true; } return false; } - + private bool ShouldSerializeStatusInfo() { if ((this.IsStatusInfoNull == false)) { return true; } return false; } - + private bool ShouldSerializeSupportedMaximumTransmissionUnit() { if ((this.IsSupportedMaximumTransmissionUnitNull == false)) { return true; } return false; } - + private bool ShouldSerializeTimeOfLastStateChange() { if ((this.IsTimeOfLastStateChangeNull == false)) { return true; } return false; } - + private bool ShouldSerializeTotalPowerOnHours() { if ((this.IsTotalPowerOnHoursNull == false)) { return true; } return false; } - + private bool ShouldSerializeTransitioningToState() { if ((this.IsTransitioningToStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeUsageRestriction() { if ((this.IsUsageRestrictionNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { string strPath = "ROOT\\virtualization\\v2:Msvm_ExternalEthernetPort"; strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); @@ -1658,7 +1658,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1670,24 +1670,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1708,15 +1708,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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)) { @@ -1733,7 +1733,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new ExternalEthernetPortCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static ExternalEthernetPort CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1748,12 +1748,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1766,7 +1766,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint OnlineDevice(bool Online) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1779,7 +1779,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint QuiesceDevice(bool Quiesce) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1792,7 +1792,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1811,7 +1811,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint Reset() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1822,7 +1822,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint RestoreProperties() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1833,7 +1833,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SaveProperties() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1844,7 +1844,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SetPowerState(ushort PowerState, System.DateTime Time) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1858,34 +1858,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1893,189 +1893,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ImageManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ImageManagementService.cs index 1ebbeb00f91..5b3b781748b 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ImageManagementService.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ImageManagementService.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. // An Early Bound class generated for the WMI class.Msvm_ImageManagementService public class ImageManagementService : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. private static string CreatedClassName = "Msvm_ImageManagementService"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public ImageManagementService() { this.InitializeObject(null, null, null); } - + public ImageManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(null, new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); } - + public ImageManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ImageManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); } - + public ImageManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public ImageManagementService(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public ImageManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public ImageManagementService(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public ImageManagementService(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -237,7 +237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -250,7 +250,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -262,7 +262,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -278,7 +278,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -291,7 +291,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -303,7 +303,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -311,7 +311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -324,7 +324,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -336,7 +336,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -349,7 +349,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -361,7 +361,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -374,7 +374,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -386,7 +386,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -399,7 +399,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -413,7 +413,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -421,7 +421,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -429,7 +429,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -442,7 +442,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -454,7 +454,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -462,7 +462,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -470,7 +470,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerContact { @@ -478,7 +478,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerContact"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerName { @@ -486,7 +486,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -499,7 +499,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -511,7 +511,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -524,7 +524,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -536,7 +536,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStartedNull { @@ -549,7 +549,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -561,7 +561,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["Started"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string StartMode { @@ -569,7 +569,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["StartMode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -577,7 +577,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -585,7 +585,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -593,7 +593,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -601,7 +601,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -614,7 +614,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -628,7 +628,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -641,7 +641,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -653,9 +653,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -663,9 +663,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -682,42 +682,42 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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; @@ -769,13 +769,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -803,7 +803,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -830,8 +830,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -841,75 +841,75 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { dmtfDateTime = string.Concat(dmtfDateTime, utcString); return dmtfDateTime; } - + private bool ShouldSerializeInstallDate() { if ((this.IsInstallDateNull == false)) { return true; } return false; } - + private bool ShouldSerializeOperatingStatus() { if ((this.IsOperatingStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializePrimaryStatus() { if ((this.IsPrimaryStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeRequestedState() { if ((this.IsRequestedStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeStarted() { if ((this.IsStartedNull == false)) { return true; } return false; } - + private bool ShouldSerializeTimeOfLastStateChange() { if ((this.IsTimeOfLastStateChangeNull == false)) { return true; } return false; } - + private bool ShouldSerializeTransitioningToState() { if ((this.IsTransitioningToStateNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { string strPath = "ROOT\\virtualization\\v2:Msvm_ImageManagementService"; strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); @@ -918,7 +918,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -930,24 +930,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -968,15 +968,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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)) { @@ -993,7 +993,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new ImageManagementServiceCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static ImageManagementService CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1008,12 +1008,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new ImageManagementService(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint AttachVirtualHardDisk(bool AssignDriveLetter, string Path, bool ReadOnly, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1034,7 +1034,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint CompactVirtualHardDisk(ushort Mode, string Path, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1054,7 +1054,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint ConvertVirtualHardDisk(string SourcePath, string VirtualDiskSettingData, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1074,7 +1074,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint CreateVirtualFloppyDisk(string Path, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1093,7 +1093,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint CreateVirtualHardDisk(string VirtualDiskSettingData, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1112,7 +1112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint GetVirtualHardDiskSettingData(string Path, out System.Management.ManagementPath Job, out string SettingData) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1133,7 +1133,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint GetVirtualHardDiskState(string Path, out System.Management.ManagementPath Job, out string State) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1154,7 +1154,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1174,7 +1174,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1194,7 +1194,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint ResizeVirtualHardDisk(ulong MaxInternalSize, string Path, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1214,7 +1214,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SetParentVirtualHardDisk(string ChildPath, bool IgnoreIDMismatch, string LeafPath, string ParentPath, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1236,7 +1236,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SetVirtualHardDiskSettingData(string VirtualDiskSettingData, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1255,7 +1255,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint StartService() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1266,7 +1266,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint StopService() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1277,7 +1277,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint ValidateVirtualHardDisk(string Path, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1296,34 +1296,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1331,189 +1331,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_KvpExchangeComponent.cs index 976da28136f..016ad188574 100644 --- 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 @@ -24,8 +24,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -33,62 +33,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 // 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)) { @@ -100,7 +100,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + public KvpExchangeComponent(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -113,7 +113,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -122,7 +122,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -131,7 +131,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -140,7 +140,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -149,7 +149,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -158,7 +158,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -177,7 +177,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // 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)] @@ -189,7 +189,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -210,7 +210,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -222,7 +222,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AdditionalAvailability { @@ -230,7 +230,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort[])(curObj["AdditionalAvailability"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAvailabilityNull { @@ -243,7 +243,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -255,7 +255,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["Availability"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -263,7 +263,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -271,7 +271,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -284,7 +284,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -296,7 +296,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -304,7 +304,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -312,7 +312,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -325,7 +325,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -337,7 +337,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string DeviceID { @@ -345,7 +345,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["DeviceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -353,7 +353,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -366,7 +366,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -378,7 +378,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -391,7 +391,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -403,7 +403,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsErrorClearedNull { @@ -416,7 +416,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -428,7 +428,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((bool)(curObj["ErrorCleared"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorDescription { @@ -436,7 +436,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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.")] @@ -445,7 +445,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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.")] @@ -454,7 +454,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string[])(curObj["GuestIntrinsicExchangeItems"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -467,7 +467,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -479,7 +479,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["HealthState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] IdentifyingDescriptions { @@ -487,7 +487,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string[])(curObj["IdentifyingDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -500,7 +500,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -514,7 +514,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -522,7 +522,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastErrorCodeNull { @@ -535,7 +535,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -547,7 +547,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((uint)(curObj["LastErrorCode"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxQuiesceTimeNull { @@ -560,7 +560,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -572,7 +572,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ulong)(curObj["MaxQuiesceTime"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -580,7 +580,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -593,7 +593,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -605,7 +605,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -613,7 +613,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -621,7 +621,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherIdentifyingInfo { @@ -629,7 +629,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string[])(curObj["OtherIdentifyingInfo"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] PowerManagementCapabilities { @@ -637,7 +637,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort[])(curObj["PowerManagementCapabilities"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerManagementSupportedNull { @@ -650,7 +650,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -662,7 +662,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((bool)(curObj["PowerManagementSupported"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerOnHoursNull { @@ -675,7 +675,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -687,7 +687,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ulong)(curObj["PowerOnHours"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -700,7 +700,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -712,7 +712,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -725,7 +725,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -737,7 +737,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -745,7 +745,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -753,7 +753,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStatusInfoNull { @@ -766,7 +766,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -778,7 +778,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["StatusInfo"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -786,7 +786,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -794,7 +794,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -807,7 +807,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -821,7 +821,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTotalPowerOnHoursNull { @@ -834,7 +834,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -846,7 +846,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ulong)(curObj["TotalPowerOnHours"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -859,7 +859,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -871,9 +871,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -881,9 +881,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -900,56 +900,56 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } 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; @@ -1001,13 +1001,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1035,7 +1035,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1062,8 +1062,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1073,110 +1073,110 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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, "\"")))); @@ -1185,7 +1185,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) { @@ -1197,24 +1197,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) { @@ -1235,15 +1235,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } 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)) { @@ -1260,7 +1260,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 ObjectSearcher.Options = enumOptions; return new KvpExchangeComponentCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static KvpExchangeComponent CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1275,12 +1275,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1293,7 +1293,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint OnlineDevice(bool Online) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1306,7 +1306,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint QuiesceDevice(bool Quiesce) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1319,7 +1319,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1339,7 +1339,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint Reset() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1350,7 +1350,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint RestoreProperties() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1361,7 +1361,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint SaveProperties() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1372,7 +1372,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint SetPowerState(ushort PowerState, System.DateTime Time) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1386,34 +1386,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1421,189 +1421,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { 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 index 4e704e02354..81c562bd173 100644 --- 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 @@ -24,70 +24,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset 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)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + public KvpExchangeComponentSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Address { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Address"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AddressOnParent { @@ -237,7 +237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["AddressOnParent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AllocationUnits { @@ -245,7 +245,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["AllocationUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticAllocationNull { @@ -258,7 +258,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((bool)(curObj["AutomaticAllocation"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticDeallocationNull { @@ -283,7 +283,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -295,7 +295,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((bool)(curObj["AutomaticDeallocation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -303,7 +303,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Connection { @@ -311,7 +311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string[])(curObj["Connection"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConsumerVisibilityNull { @@ -324,7 +324,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -336,7 +336,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["ConsumerVisibility"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -344,7 +344,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -352,7 +352,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -365,7 +365,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"The enabled and disabled states of an element. @@ -380,7 +380,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("An array of Msvm_KvpExchangeDataItem instances.\nThis is a read-only property, but" + @@ -391,7 +391,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste 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.")] @@ -400,7 +400,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string[])(curObj["HostOnlyItems"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] HostResource { @@ -408,7 +408,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string[])(curObj["HostResource"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -416,7 +416,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitNull { @@ -429,7 +429,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -441,7 +441,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((ulong)(curObj["Limit"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMappingBehaviorNull { @@ -454,7 +454,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -466,7 +466,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((ushort)(curObj["MappingBehavior"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherResourceType { @@ -474,7 +474,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["OtherResourceType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Parent { @@ -482,7 +482,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["Parent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PoolID { @@ -490,7 +490,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["PoolID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReservationNull { @@ -503,7 +503,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -515,7 +515,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((ulong)(curObj["Reservation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ResourceSubType { @@ -523,7 +523,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["ResourceSubType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResourceTypeNull { @@ -536,7 +536,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -548,7 +548,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((ushort)(curObj["ResourceType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualQuantityNull { @@ -561,7 +561,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -573,7 +573,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((ulong)(curObj["VirtualQuantity"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string VirtualQuantityUnits { @@ -581,7 +581,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["VirtualQuantityUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsWeightNull { @@ -594,7 +594,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -606,9 +606,9 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((uint)(curObj["Weight"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -616,9 +616,9 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -635,102 +635,102 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } 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)) { @@ -742,24 +742,24 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste 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)) { @@ -780,15 +780,15 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } 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)) { @@ -805,7 +805,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste ObjectSearcher.Options = enumOptions; return new KvpExchangeComponentSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static KvpExchangeComponentSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -820,39 +820,39 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste 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; @@ -860,189 +860,189 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { 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 index f076f790277..58f3dff6816 100644 --- 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 @@ -24,62 +24,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset 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)) { @@ -91,7 +91,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + public KvpExchangeDataItem(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -104,7 +104,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -113,7 +113,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -122,7 +122,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -131,7 +131,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -140,7 +140,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -149,7 +149,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -168,7 +168,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // 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)] @@ -180,7 +180,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -201,7 +201,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -213,7 +213,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Data { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Data"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -237,7 +237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -245,7 +245,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -253,7 +253,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["InstanceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -261,7 +261,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSourceNull { @@ -274,7 +274,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -286,9 +286,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["Source"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -296,9 +296,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -315,38 +315,38 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } 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)) { @@ -358,24 +358,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) { @@ -396,15 +396,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } 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)) { @@ -421,7 +421,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 ObjectSearcher.Options = enumOptions; return new KvpExchangeDataItemCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static KvpExchangeDataItem CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -436,39 +436,39 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -476,189 +476,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_LANEndpoint.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_LANEndpoint.cs index 9f09a069498..7fc0495fa04 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_LANEndpoint.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_LANEndpoint.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. // An Early Bound class generated for the WMI class.Msvm_LANEndpoint public class LANEndpoint : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_LANEndpoint"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public LANEndpoint() { this.InitializeObject(null, null, null); } - + public LANEndpoint(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(null, new System.Management.ManagementPath(LANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); } - + public LANEndpoint(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(LANEndpoint.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); } - + public LANEndpoint(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public LANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public LANEndpoint(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public LANEndpoint(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public LANEndpoint(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public LANEndpoint(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] AliasAddresses { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["AliasAddresses"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -237,7 +237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -245,7 +245,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -258,7 +258,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConnectedNull { @@ -283,7 +283,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("This property is set to TRUE if the LAN endpoint is connected to a switch port.")] @@ -296,7 +296,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["Connected"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -304,7 +304,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -312,7 +312,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -325,7 +325,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -337,7 +337,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -345,7 +345,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -358,7 +358,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -370,7 +370,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -383,7 +383,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -395,7 +395,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] GroupAddresses { @@ -403,7 +403,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["GroupAddresses"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -416,7 +416,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -428,7 +428,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -441,7 +441,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -455,7 +455,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -463,7 +463,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string LANID { @@ -471,7 +471,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["LANID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLANTypeNull { @@ -484,7 +484,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -496,7 +496,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["LANType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string MACAddress { @@ -504,7 +504,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["MACAddress"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxDataSizeNull { @@ -517,7 +517,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -529,7 +529,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["MaxDataSize"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -537,7 +537,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string NameFormat { @@ -545,7 +545,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["NameFormat"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -558,7 +558,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -570,7 +570,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -578,7 +578,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -586,7 +586,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherLANType { @@ -594,7 +594,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherLANType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherTypeDescription { @@ -602,7 +602,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherTypeDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -615,7 +615,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -627,7 +627,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsProtocolIFTypeNull { @@ -640,7 +640,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -652,7 +652,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ProtocolIFType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsProtocolTypeNull { @@ -665,7 +665,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -677,7 +677,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ProtocolType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -690,7 +690,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -702,7 +702,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -710,7 +710,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -718,7 +718,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -726,7 +726,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -734,7 +734,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -747,7 +747,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -761,7 +761,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -774,7 +774,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -786,9 +786,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -796,9 +796,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -815,49 +815,49 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeCommunicationStatus() { if ((this.IsCommunicationStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeConnected() { if ((this.IsConnectedNull == false)) { return true; } return false; } - + private bool ShouldSerializeDetailedStatus() { if ((this.IsDetailedStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeEnabledDefault() { if ((this.IsEnabledDefaultNull == false)) { return true; } return false; } - + private bool ShouldSerializeEnabledState() { if ((this.IsEnabledStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeHealthState() { if ((this.IsHealthStateNull == false)) { return true; } return false; } - + // Converts a given datetime in DMTF format to System.DateTime object. static System.DateTime ToDateTime(string dmtfDate) { System.DateTime initializer = System.DateTime.MinValue; @@ -909,13 +909,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -943,7 +943,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -970,8 +970,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -981,96 +981,96 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { dmtfDateTime = string.Concat(dmtfDateTime, utcString); return dmtfDateTime; } - + private bool ShouldSerializeInstallDate() { if ((this.IsInstallDateNull == false)) { return true; } return false; } - + private bool ShouldSerializeLANType() { if ((this.IsLANTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxDataSize() { if ((this.IsMaxDataSizeNull == false)) { return true; } return false; } - + private bool ShouldSerializeOperatingStatus() { if ((this.IsOperatingStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializePrimaryStatus() { if ((this.IsPrimaryStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeProtocolIFType() { if ((this.IsProtocolIFTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializeProtocolType() { if ((this.IsProtocolTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializeRequestedState() { if ((this.IsRequestedStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeTimeOfLastStateChange() { if ((this.IsTimeOfLastStateChangeNull == false)) { return true; } return false; } - + private bool ShouldSerializeTransitioningToState() { if ((this.IsTransitioningToStateNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { string strPath = "ROOT\\virtualization\\v2:Msvm_LANEndpoint"; strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); @@ -1079,7 +1079,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1091,24 +1091,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static LANEndpointCollection GetInstances() { return GetInstances(null, null, null); } - + public static LANEndpointCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static LANEndpointCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static LANEndpointCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1129,15 +1129,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new LANEndpointCollection(clsObject.GetInstances(enumOptions)); } - + public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static LANEndpointCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1154,7 +1154,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new LANEndpointCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static LANEndpoint CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1169,12 +1169,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new LANEndpoint(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1193,34 +1193,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + // Enumerator implementation for enumerating instances of the class. public class LANEndpointCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public LANEndpointCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -1228,189 +1228,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new LANEndpoint(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new LANEndpointEnumerator(privColObj.GetEnumerator()); } - + public class LANEndpointEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public LANEndpointEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new LANEndpoint(((System.Management.ManagementObject)(privObjEnum.Current))); } } - + public virtual bool MoveNext() { return privObjEnum.MoveNext(); } - + public virtual void Reset() { privObjEnum.Reset(); } } } - + // TypeConverter to handle null values for ValueType properties public class WMIValueTypeConverter : TypeConverter { - + private TypeConverter baseConverter; - + private System.Type baseType; - + public WMIValueTypeConverter(System.Type inBaseType) { baseConverter = TypeDescriptor.GetConverter(inBaseType); baseType = inBaseType; } - + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { return baseConverter.CanConvertFrom(context, srcType); } - + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return baseConverter.CanConvertTo(context, destinationType); } - + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return baseConverter.ConvertFrom(context, culture, value); } - + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { return baseConverter.CreateInstance(context, dictionary); } - + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetCreateInstanceSupported(context); } - + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { return baseConverter.GetProperties(context, value, attributeVar); } - + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetPropertiesSupported(context); } - + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValues(context); } - + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesExclusive(context); } - + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesSupported(context); } - + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((baseType.BaseType == typeof(System.Enum))) { if ((value.GetType() == destinationType)) { return value; } - if ((((value == null) - && (context != null)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MemorySettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MemorySettingData.cs index 99200dd1b21..1276fe92891 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MemorySettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MemorySettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // An Early Bound class generated for the WMI class.Msvm_MemorySettingData public class MemorySettingData : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_MemorySettingData"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public MemorySettingData() { this.InitializeObject(null, null, null); } - + public MemorySettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(MemorySettingData.ConstructPath(keyInstanceID)), null); } - + public MemorySettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(MemorySettingData.ConstructPath(keyInstanceID)), null); } - + public MemorySettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public MemorySettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public MemorySettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public MemorySettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public MemorySettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public MemorySettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Address { @@ -228,7 +228,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Address"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AddressOnParent { @@ -236,7 +236,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AddressOnParent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AllocationUnits { @@ -244,7 +244,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AllocationUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticAllocationNull { @@ -257,7 +257,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -269,7 +269,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticAllocation"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticDeallocationNull { @@ -282,7 +282,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -294,7 +294,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticDeallocation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -302,7 +302,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Connection { @@ -310,7 +310,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["Connection"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConsumerVisibilityNull { @@ -323,7 +323,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -335,7 +335,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ConsumerVisibility"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -343,7 +343,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDynamicMemoryEnabledNull { @@ -356,7 +356,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates if dynamic memory is enabled.")] @@ -369,7 +369,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["DynamicMemoryEnabled"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -377,7 +377,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] HostResource { @@ -385,7 +385,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["HostResource"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -393,7 +393,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsIsVirtualizedNull { @@ -406,7 +406,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [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.")] @@ -419,7 +419,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["IsVirtualized"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitNull { @@ -432,7 +432,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -444,7 +444,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Limit"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMappingBehaviorNull { @@ -457,7 +457,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -469,7 +469,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["MappingBehavior"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxMemoryBlocksPerNumaNodeNull { @@ -482,7 +482,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum amount of memory that can be observed within the VM as belonging to a" + @@ -496,7 +496,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MaxMemoryBlocksPerNumaNode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherResourceType { @@ -504,7 +504,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherResourceType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Parent { @@ -512,7 +512,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Parent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PoolID { @@ -520,7 +520,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PoolID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReservationNull { @@ -533,7 +533,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -545,7 +545,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Reservation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ResourceSubType { @@ -553,7 +553,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ResourceSubType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResourceTypeNull { @@ -566,7 +566,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -578,7 +578,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ResourceType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSwapFilesInUseNull { @@ -591,7 +591,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates if smart paging is active.")] @@ -604,7 +604,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["SwapFilesInUse"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTargetMemoryBufferNull { @@ -617,7 +617,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -629,7 +629,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["TargetMemoryBuffer"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualQuantityNull { @@ -642,7 +642,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -654,7 +654,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["VirtualQuantity"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string VirtualQuantityUnits { @@ -662,7 +662,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["VirtualQuantityUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsWeightNull { @@ -675,7 +675,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -687,9 +687,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["Weight"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -697,9 +697,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -716,130 +716,130 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeAutomaticAllocation() { if ((this.IsAutomaticAllocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutomaticDeallocation() { if ((this.IsAutomaticDeallocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeConsumerVisibility() { if ((this.IsConsumerVisibilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeDynamicMemoryEnabled() { if ((this.IsDynamicMemoryEnabledNull == false)) { return true; } return false; } - + private bool ShouldSerializeIsVirtualized() { if ((this.IsIsVirtualizedNull == false)) { return true; } return false; } - + private bool ShouldSerializeLimit() { if ((this.IsLimitNull == false)) { return true; } return false; } - + private bool ShouldSerializeMappingBehavior() { if ((this.IsMappingBehaviorNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxMemoryBlocksPerNumaNode() { if ((this.IsMaxMemoryBlocksPerNumaNodeNull == false)) { return true; } return false; } - + private bool ShouldSerializeReservation() { if ((this.IsReservationNull == false)) { return true; } return false; } - + private bool ShouldSerializeResourceType() { if ((this.IsResourceTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializeSwapFilesInUse() { if ((this.IsSwapFilesInUseNull == false)) { return true; } return false; } - + private bool ShouldSerializeTargetMemoryBuffer() { if ((this.IsTargetMemoryBufferNull == false)) { return true; } return false; } - + private bool ShouldSerializeVirtualQuantity() { if ((this.IsVirtualQuantityNull == false)) { return true; } return false; } - + private bool ShouldSerializeWeight() { if ((this.IsWeightNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyInstanceID) { string strPath = "ROOT\\virtualization\\v2:Msvm_MemorySettingData"; strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -851,24 +851,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -889,15 +889,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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)) { @@ -914,7 +914,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new MemorySettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static MemorySettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -929,39 +929,39 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -969,189 +969,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MigrationJob.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MigrationJob.cs index 7b7e5f1d088..d58e282b4a0 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MigrationJob.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_MigrationJob.cs @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // 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_MigrationJob public class MigrationJob : 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_MigrationJob"; - + // 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 MigrationJob() { this.InitializeObject(null, null, null); } - + public MigrationJob(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(MigrationJob.ConstructPath(keyInstanceID)), null); } - + public MigrationJob(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(MigrationJob.ConstructPath(keyInstanceID)), null); } - + public MigrationJob(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public MigrationJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public MigrationJob(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public MigrationJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public MigrationJob(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public MigrationJob(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCancellableNull { @@ -234,7 +234,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates whether the job can be cancelled. The value of this property does not g" + @@ -248,7 +248,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["Cancellable"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -256,7 +256,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -269,7 +269,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -281,7 +281,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDeleteOnCompletionNull { @@ -294,7 +294,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -306,7 +306,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["DeleteOnCompletion"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -314,7 +314,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Hostname the destination virtualization platform where the virtual system is migr" + @@ -324,7 +324,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["DestinationHost"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -337,7 +337,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -349,7 +349,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsElapsedTimeNull { @@ -362,7 +362,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -376,7 +376,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -384,7 +384,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsErrorCodeNull { @@ -397,7 +397,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -409,7 +409,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ErrorCode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorDescription { @@ -417,7 +417,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorDescription"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorSummaryDescription { @@ -425,7 +425,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorSummaryDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -438,7 +438,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -450,7 +450,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -463,7 +463,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -477,7 +477,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -485,7 +485,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobRunTimesNull { @@ -498,7 +498,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -510,7 +510,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["JobRunTimes"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobStateNull { @@ -523,7 +523,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -535,7 +535,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["JobState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string JobStatus { @@ -543,7 +543,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["JobStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobTypeNull { @@ -556,7 +556,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates the type of Job being tracked by this object.")] @@ -569,7 +569,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((JobTypeValues)(System.Convert.ToInt32(curObj["JobType"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLocalOrUtcTimeNull { @@ -582,7 +582,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -594,7 +594,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["LocalOrUtcTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMigrationTypeNull { @@ -607,7 +607,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The migration type as defined in Msvm_VirtualSystemMigrationSettingData.Migration" + @@ -621,7 +621,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["MigrationType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -629,7 +629,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"For Live Migration this must be set to NULL. For Storage Migration, it will specify the virtual machine's virtual hard drives which moved and where they moved. If not NULL, NewResourceSettingData will contain an array of embedded instances of resource allocation setting data (RASD) which represent VHDs. Destination location will be provided using Connection property of RASD.")] @@ -638,7 +638,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["NewResourceSettingData"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"For Live Migration this will be set to NULL. For Storage Migration, it will indicate the new path for virtual machine data (ExternalDataRoot, SnapshotDataRoot and SwapFileDataRoot). This being NULL indicates that virtual machine's data roots are not moving. Otherwise NewSystemSettingData will be instance of Msvm_VirtualSystemGlobalSettingData containing properties ExternalDataRoot, SnapshotDataRoot and SwapFileDataRoot. If not NULL, ExternalDataRoot property will specify new location of virtual machine's current configuration and saved state. If not NULL, SnapshotDataRoot property will specify new location for snapshots data. If not NULL, SwapFileDataRoot property will specify new location of virtual machine's smart paging files ")] @@ -647,7 +647,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["NewSystemSettingData"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Notify { @@ -655,7 +655,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Notify"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -668,7 +668,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -680,7 +680,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -688,7 +688,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherRecoveryAction { @@ -696,7 +696,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherRecoveryAction"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Owner { @@ -704,7 +704,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Owner"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentCompleteNull { @@ -717,7 +717,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -729,7 +729,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PercentComplete"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -742,7 +742,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -754,7 +754,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPriorityNull { @@ -767,7 +767,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -779,7 +779,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["Priority"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRecoveryActionNull { @@ -792,7 +792,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -804,7 +804,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RecoveryAction"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunDayNull { @@ -817,7 +817,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -829,7 +829,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((sbyte)(curObj["RunDay"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunDayOfWeekNull { @@ -842,7 +842,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -854,7 +854,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((sbyte)(curObj["RunDayOfWeek"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunMonthNull { @@ -867,7 +867,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -879,7 +879,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((byte)(curObj["RunMonth"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunStartIntervalNull { @@ -892,7 +892,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -906,7 +906,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsScheduledStartTimeNull { @@ -919,7 +919,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -933,7 +933,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStartTimeNull { @@ -946,7 +946,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -960,7 +960,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -968,7 +968,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -976,7 +976,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeBeforeRemovalNull { @@ -989,7 +989,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1003,7 +1003,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -1016,7 +1016,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1030,7 +1030,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeSubmittedNull { @@ -1043,7 +1043,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1057,7 +1057,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsUntilTimeNull { @@ -1070,7 +1070,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1084,7 +1084,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("GUID of the affected virtual system.")] @@ -1093,9 +1093,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["VirtualSystemName"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1103,9 +1103,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1122,35 +1122,35 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeCancellable() { if ((this.IsCancellableNull == false)) { return true; } return false; } - + private bool ShouldSerializeCommunicationStatus() { if ((this.IsCommunicationStatusNull == false)) { return true; } return false; } - + 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; @@ -1202,13 +1202,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1236,7 +1236,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1263,8 +1263,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1274,200 +1274,200 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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 ShouldSerializeMigrationType() { if ((this.IsMigrationTypeNull == 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_MigrationJob"; 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)) { @@ -1479,24 +1479,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static MigrationJobCollection GetInstances() { return GetInstances(null, null, null); } - + public static MigrationJobCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static MigrationJobCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static MigrationJobCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static MigrationJobCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1517,15 +1517,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new MigrationJobCollection(clsObject.GetInstances(enumOptions)); } - + public static MigrationJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static MigrationJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static MigrationJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1542,7 +1542,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new MigrationJobCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static MigrationJob CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1557,12 +1557,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new MigrationJob(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint GetError(out string Error) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1575,7 +1575,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint GetErrorEx(out string[] Errors) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1588,7 +1588,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint KillJob(bool DeleteOnKill) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1601,7 +1601,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1615,57 +1615,57 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public enum JobTypeValues { - + Unknown0 = 0, - + Creating_Remote_Virtual_Machine = 300, - + Checking_Virtual_Machine_Compatibility = 301, - + Checking_Virtual_Machine_and_Storage_Compatibility = 302, - + Checking_Storage_Compatibility = 303, - + Checking_Storage_Migration = 304, - + Moving_Virtual_Machine = 305, - + Moving_Virtual_Machine_and_Storage = 306, - + Moving_Storage = 307, - + NULL_ENUM_VALUE = 308, } - + // Enumerator implementation for enumerating instances of the class. public class MigrationJobCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public MigrationJobCollection(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; @@ -1673,189 +1673,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new MigrationJob(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new MigrationJobEnumerator(privColObj.GetEnumerator()); } - + public class MigrationJobEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public MigrationJobEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new MigrationJob(((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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs index c21c71cc6d4..f8e0a73f2ed 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ProcessorSettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // An Early Bound class generated for the WMI class.Msvm_ProcessorSettingData public class ProcessorSettingData : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_ProcessorSettingData"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public ProcessorSettingData() { this.InitializeObject(null, null, null); } - + public ProcessorSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(ProcessorSettingData.ConstructPath(keyInstanceID)), null); } - + public ProcessorSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ProcessorSettingData.ConstructPath(keyInstanceID)), null); } - + public ProcessorSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public ProcessorSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public ProcessorSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public ProcessorSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public ProcessorSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public ProcessorSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Address { @@ -228,7 +228,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Address"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AddressOnParent { @@ -236,7 +236,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AddressOnParent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AllocationUnits { @@ -244,7 +244,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AllocationUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticAllocationNull { @@ -257,7 +257,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -269,7 +269,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticAllocation"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticDeallocationNull { @@ -282,7 +282,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -294,7 +294,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticDeallocation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -302,7 +302,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Connection { @@ -310,7 +310,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["Connection"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConsumerVisibilityNull { @@ -323,7 +323,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -335,7 +335,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ConsumerVisibility"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -343,7 +343,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -351,7 +351,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] HostResource { @@ -359,7 +359,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["HostResource"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -367,7 +367,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitNull { @@ -380,7 +380,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -392,7 +392,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Limit"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitCPUIDNull { @@ -405,7 +405,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates whether the virtual machine should lower the CPU identifier. Some older" + @@ -420,7 +420,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["LimitCPUID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitProcessorFeaturesNull { @@ -433,7 +433,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [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.")] @@ -446,7 +446,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["LimitProcessorFeatures"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMappingBehaviorNull { @@ -459,7 +459,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -471,7 +471,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["MappingBehavior"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxNumaNodesPerSocketNull { @@ -484,7 +484,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum number of NUMA nodes that can be observed within the VM as belonging " + @@ -498,7 +498,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MaxNumaNodesPerSocket"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxProcessorsPerNumaNodeNull { @@ -511,7 +511,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum number of virtual processors that can be observed within the VM as be" + @@ -525,7 +525,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MaxProcessorsPerNumaNode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherResourceType { @@ -533,7 +533,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherResourceType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Parent { @@ -541,7 +541,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Parent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PoolID { @@ -549,7 +549,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PoolID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReservationNull { @@ -562,7 +562,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -574,7 +574,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Reservation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ResourceSubType { @@ -582,7 +582,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ResourceSubType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResourceTypeNull { @@ -595,7 +595,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -607,7 +607,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ResourceType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualQuantityNull { @@ -620,7 +620,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -632,7 +632,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["VirtualQuantity"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string VirtualQuantityUnits { @@ -640,7 +640,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["VirtualQuantityUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsWeightNull { @@ -653,7 +653,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -665,9 +665,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["Weight"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -675,9 +675,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -694,123 +694,123 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeAutomaticAllocation() { if ((this.IsAutomaticAllocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutomaticDeallocation() { if ((this.IsAutomaticDeallocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeConsumerVisibility() { if ((this.IsConsumerVisibilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeLimit() { if ((this.IsLimitNull == false)) { return true; } return false; } - + private bool ShouldSerializeLimitCPUID() { if ((this.IsLimitCPUIDNull == false)) { return true; } return false; } - + private bool ShouldSerializeLimitProcessorFeatures() { if ((this.IsLimitProcessorFeaturesNull == false)) { return true; } return false; } - + private bool ShouldSerializeMappingBehavior() { if ((this.IsMappingBehaviorNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxNumaNodesPerSocket() { if ((this.IsMaxNumaNodesPerSocketNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxProcessorsPerNumaNode() { if ((this.IsMaxProcessorsPerNumaNodeNull == false)) { return true; } return false; } - + private bool ShouldSerializeReservation() { if ((this.IsReservationNull == false)) { return true; } return false; } - + private bool ShouldSerializeResourceType() { if ((this.IsResourceTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializeVirtualQuantity() { if ((this.IsVirtualQuantityNull == false)) { return true; } return false; } - + private bool ShouldSerializeWeight() { if ((this.IsWeightNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyInstanceID) { string strPath = "ROOT\\virtualization\\v2:Msvm_ProcessorSettingData"; strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -822,24 +822,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -860,15 +860,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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)) { @@ -885,7 +885,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new ProcessorSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static ProcessorSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -900,39 +900,39 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -940,189 +940,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs index a75837e15ec..dc097e1852a 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ResourceAllocationSettingData.cs @@ -24,70 +24,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // An Early Bound class generated for the WMI class.Msvm_ResourceAllocationSettingData public class ResourceAllocationSettingData : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_ResourceAllocationSettingData"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public ResourceAllocationSettingData() { this.InitializeObject(null, null, null); } - + public ResourceAllocationSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(ResourceAllocationSettingData.ConstructPath(keyInstanceID)), null); } - + public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ResourceAllocationSettingData.ConstructPath(keyInstanceID)), null); } - + public ResourceAllocationSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public ResourceAllocationSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public ResourceAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public ResourceAllocationSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + public ResourceAllocationSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Address { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Address"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AddressOnParent { @@ -237,7 +237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["AddressOnParent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AllocationUnits { @@ -245,7 +245,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["AllocationUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticAllocationNull { @@ -258,7 +258,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((bool)(curObj["AutomaticAllocation"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticDeallocationNull { @@ -283,7 +283,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -295,7 +295,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((bool)(curObj["AutomaticDeallocation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -303,7 +303,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Connection { @@ -311,7 +311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string[])(curObj["Connection"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConsumerVisibilityNull { @@ -324,7 +324,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -336,7 +336,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["ConsumerVisibility"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -344,7 +344,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -352,7 +352,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] HostResource { @@ -360,7 +360,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string[])(curObj["HostResource"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -368,7 +368,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitNull { @@ -381,7 +381,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -393,7 +393,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ulong)(curObj["Limit"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMappingBehaviorNull { @@ -406,7 +406,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -418,7 +418,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["MappingBehavior"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherResourceType { @@ -426,7 +426,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["OtherResourceType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Parent { @@ -434,7 +434,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Parent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PoolID { @@ -442,7 +442,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["PoolID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReservationNull { @@ -455,7 +455,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -467,7 +467,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ulong)(curObj["Reservation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ResourceSubType { @@ -475,7 +475,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["ResourceSubType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResourceTypeNull { @@ -488,7 +488,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -500,7 +500,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["ResourceType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualQuantityNull { @@ -513,7 +513,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -525,7 +525,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ulong)(curObj["VirtualQuantity"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string VirtualQuantityUnits { @@ -533,7 +533,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["VirtualQuantityUnits"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. These values are only used if the ResourceType property is set to 6 (Parallel SCSI HBA) and the ResourceSubType property is set to ""Microsoft Synthetic SCSI Controller"". This property is set to ""GUID"". @@ -544,7 +544,7 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt return ((string[])(curObj["VirtualSystemIdentifiers"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsWeightNull { @@ -557,7 +557,7 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -569,9 +569,9 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt return ((uint)(curObj["Weight"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -579,9 +579,9 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -598,95 +598,95 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt } return false; } - + private bool ShouldSerializeAutomaticAllocation() { if ((this.IsAutomaticAllocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutomaticDeallocation() { if ((this.IsAutomaticDeallocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeConsumerVisibility() { if ((this.IsConsumerVisibilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeLimit() { if ((this.IsLimitNull == false)) { return true; } return false; } - + private bool ShouldSerializeMappingBehavior() { if ((this.IsMappingBehaviorNull == false)) { return true; } return false; } - + private bool ShouldSerializeReservation() { if ((this.IsReservationNull == false)) { return true; } return false; } - + private bool ShouldSerializeResourceType() { if ((this.IsResourceTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializeVirtualQuantity() { if ((this.IsVirtualQuantityNull == false)) { return true; } return false; } - + private bool ShouldSerializeWeight() { if ((this.IsWeightNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyInstanceID) { string strPath = "ROOT\\virtualization\\v2:Msvm_ResourceAllocationSettingData"; strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -698,24 +698,24 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt 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)) { @@ -736,15 +736,15 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt } 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)) { @@ -761,7 +761,7 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt ObjectSearcher.Options = enumOptions; return new ResourceAllocationSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static ResourceAllocationSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -776,39 +776,39 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt 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; @@ -816,189 +816,189 @@ Windows Server 2008: The VirtualSystemIdentifiers property is not supported unt 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ShutdownComponent.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ShutdownComponent.cs index 81613ea88f4..678f80b0bf6 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ShutdownComponent.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_ShutdownComponent.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // 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_ShutdownComponent public class ShutdownComponent : 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_ShutdownComponent"; - + // 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 ShutdownComponent() { this.InitializeObject(null, null, null); } - + public ShutdownComponent(string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(null, new System.Management.ManagementPath(ShutdownComponent.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); } - + public ShutdownComponent(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyDeviceID, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(ShutdownComponent.ConstructPath(keyCreationClassName, keyDeviceID, keySystemCreationClassName, keySystemName)), null); } - + public ShutdownComponent(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public ShutdownComponent(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public ShutdownComponent(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public ShutdownComponent(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public ShutdownComponent(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public ShutdownComponent(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AdditionalAvailability { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AdditionalAvailability"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAvailabilityNull { @@ -242,7 +242,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -254,7 +254,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["Availability"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -262,7 +262,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -283,7 +283,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -295,7 +295,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -303,7 +303,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -311,7 +311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -324,7 +324,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -336,7 +336,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string DeviceID { @@ -344,7 +344,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["DeviceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -352,7 +352,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -365,7 +365,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -377,7 +377,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -390,7 +390,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -402,7 +402,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsErrorClearedNull { @@ -415,7 +415,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -427,7 +427,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["ErrorCleared"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorDescription { @@ -435,7 +435,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -448,7 +448,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -460,7 +460,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] IdentifyingDescriptions { @@ -468,7 +468,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["IdentifyingDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -481,7 +481,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -495,7 +495,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -503,7 +503,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLastErrorCodeNull { @@ -516,7 +516,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -528,7 +528,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["LastErrorCode"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxQuiesceTimeNull { @@ -541,7 +541,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -553,7 +553,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MaxQuiesceTime"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -561,7 +561,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -574,7 +574,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -586,7 +586,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -594,7 +594,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -602,7 +602,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherIdentifyingInfo { @@ -610,7 +610,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherIdentifyingInfo"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] PowerManagementCapabilities { @@ -618,7 +618,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["PowerManagementCapabilities"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerManagementSupportedNull { @@ -631,7 +631,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -643,7 +643,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["PowerManagementSupported"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPowerOnHoursNull { @@ -656,7 +656,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -668,7 +668,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["PowerOnHours"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -681,7 +681,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -693,7 +693,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -706,7 +706,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -718,7 +718,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -726,7 +726,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -734,7 +734,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStatusInfoNull { @@ -747,7 +747,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -759,7 +759,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["StatusInfo"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -767,7 +767,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -775,7 +775,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -788,7 +788,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -802,7 +802,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTotalPowerOnHoursNull { @@ -815,7 +815,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -827,7 +827,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["TotalPowerOnHours"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -840,7 +840,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -852,9 +852,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -862,9 +862,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -881,56 +881,56 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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; @@ -982,13 +982,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1016,7 +1016,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1043,8 +1043,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1054,110 +1054,110 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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_ShutdownComponent"; strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); @@ -1166,7 +1166,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1178,24 +1178,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static ShutdownComponentCollection GetInstances() { return GetInstances(null, null, null); } - + public static ShutdownComponentCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static ShutdownComponentCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static ShutdownComponentCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static ShutdownComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1216,15 +1216,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new ShutdownComponentCollection(clsObject.GetInstances(enumOptions)); } - + public static ShutdownComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static ShutdownComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static ShutdownComponentCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1241,7 +1241,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new ShutdownComponentCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static ShutdownComponent CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1256,12 +1256,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new ShutdownComponent(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint EnableDevice(bool Enabled) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1274,7 +1274,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint InitiateShutdown(bool Force, string Reason) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1288,7 +1288,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint OnlineDevice(bool Online) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1301,7 +1301,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint QuiesceDevice(bool Quiesce) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1314,7 +1314,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1333,7 +1333,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint Reset() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1344,7 +1344,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint RestoreProperties() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1355,7 +1355,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SaveProperties() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1366,7 +1366,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SetPowerState(ushort PowerState, System.DateTime Time) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1380,34 +1380,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + // Enumerator implementation for enumerating instances of the class. public class ShutdownComponentCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public ShutdownComponentCollection(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; @@ -1415,189 +1415,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new ShutdownComponent(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new ShutdownComponentEnumerator(privColObj.GetEnumerator()); } - + public class ShutdownComponentEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public ShutdownComponentEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new ShutdownComponent(((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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs index 602347f90dc..b9b58816539 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageAllocationSettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // An Early Bound class generated for the WMI class.Msvm_StorageAllocationSettingData public class StorageAllocationSettingData : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_StorageAllocationSettingData"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public StorageAllocationSettingData() { this.InitializeObject(null, null, null); } - + public StorageAllocationSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(StorageAllocationSettingData.ConstructPath(keyInstanceID)), null); } - + public StorageAllocationSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(StorageAllocationSettingData.ConstructPath(keyInstanceID)), null); } - + public StorageAllocationSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public StorageAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public StorageAllocationSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public StorageAllocationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public StorageAllocationSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public StorageAllocationSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAccessNull { @@ -233,7 +233,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -245,7 +245,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["Access"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Address { @@ -253,7 +253,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Address"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AddressOnParent { @@ -261,7 +261,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AddressOnParent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AllocationUnits { @@ -269,7 +269,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AllocationUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticAllocationNull { @@ -282,7 +282,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -294,7 +294,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticAllocation"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticDeallocationNull { @@ -307,7 +307,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -319,7 +319,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticDeallocation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -327,7 +327,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Connection { @@ -335,7 +335,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["Connection"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConsumerVisibilityNull { @@ -348,7 +348,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -360,7 +360,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ConsumerVisibility"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -368,7 +368,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -376,7 +376,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string HostExtentName { @@ -384,7 +384,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["HostExtentName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHostExtentNameFormatNull { @@ -397,7 +397,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -409,7 +409,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HostExtentNameFormat"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHostExtentNameNamespaceNull { @@ -422,7 +422,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -434,7 +434,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HostExtentNameNamespace"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHostExtentStartingAddressNull { @@ -447,7 +447,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -459,7 +459,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["HostExtentStartingAddress"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] HostResource { @@ -467,7 +467,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["HostResource"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHostResourceBlockSizeNull { @@ -480,7 +480,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -492,7 +492,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["HostResourceBlockSize"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -500,7 +500,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitNull { @@ -513,7 +513,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -525,7 +525,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Limit"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMappingBehaviorNull { @@ -538,7 +538,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -550,7 +550,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["MappingBehavior"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherHostExtentNameFormat { @@ -558,7 +558,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherHostExtentNameFormat"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherHostExtentNameNamespace { @@ -566,7 +566,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherHostExtentNameNamespace"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherResourceType { @@ -574,7 +574,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherResourceType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Parent { @@ -582,7 +582,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Parent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PoolID { @@ -590,7 +590,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PoolID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReservationNull { @@ -603,7 +603,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -615,7 +615,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Reservation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ResourceSubType { @@ -623,7 +623,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ResourceSubType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResourceTypeNull { @@ -636,7 +636,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -648,7 +648,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ResourceType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualQuantityNull { @@ -661,7 +661,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -673,7 +673,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["VirtualQuantity"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string VirtualQuantityUnits { @@ -681,7 +681,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["VirtualQuantityUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualResourceBlockSizeNull { @@ -694,7 +694,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -706,7 +706,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["VirtualResourceBlockSize"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsWeightNull { @@ -719,7 +719,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -731,9 +731,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["Weight"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -741,9 +741,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -760,137 +760,137 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeAccess() { if ((this.IsAccessNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutomaticAllocation() { if ((this.IsAutomaticAllocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutomaticDeallocation() { if ((this.IsAutomaticDeallocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeConsumerVisibility() { if ((this.IsConsumerVisibilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeHostExtentNameFormat() { if ((this.IsHostExtentNameFormatNull == false)) { return true; } return false; } - + private bool ShouldSerializeHostExtentNameNamespace() { if ((this.IsHostExtentNameNamespaceNull == false)) { return true; } return false; } - + private bool ShouldSerializeHostExtentStartingAddress() { if ((this.IsHostExtentStartingAddressNull == false)) { return true; } return false; } - + private bool ShouldSerializeHostResourceBlockSize() { if ((this.IsHostResourceBlockSizeNull == false)) { return true; } return false; } - + private bool ShouldSerializeLimit() { if ((this.IsLimitNull == false)) { return true; } return false; } - + private bool ShouldSerializeMappingBehavior() { if ((this.IsMappingBehaviorNull == false)) { return true; } return false; } - + private bool ShouldSerializeReservation() { if ((this.IsReservationNull == false)) { return true; } return false; } - + private bool ShouldSerializeResourceType() { if ((this.IsResourceTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializeVirtualQuantity() { if ((this.IsVirtualQuantityNull == false)) { return true; } return false; } - + private bool ShouldSerializeVirtualResourceBlockSize() { if ((this.IsVirtualResourceBlockSizeNull == false)) { return true; } return false; } - + private bool ShouldSerializeWeight() { if ((this.IsWeightNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyInstanceID) { string strPath = "ROOT\\virtualization\\v2:Msvm_StorageAllocationSettingData"; strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -902,24 +902,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static StorageAllocationSettingDataCollection GetInstances() { return GetInstances(null, null, null); } - + public static StorageAllocationSettingDataCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static StorageAllocationSettingDataCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static StorageAllocationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -940,15 +940,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new StorageAllocationSettingDataCollection(clsObject.GetInstances(enumOptions)); } - + public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static StorageAllocationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -965,7 +965,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new StorageAllocationSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static StorageAllocationSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -980,39 +980,39 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new StorageAllocationSettingData(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + // Enumerator implementation for enumerating instances of the class. public class StorageAllocationSettingDataCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public StorageAllocationSettingDataCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -1020,189 +1020,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new StorageAllocationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new StorageAllocationSettingDataEnumerator(privColObj.GetEnumerator()); } - + public class StorageAllocationSettingDataEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public StorageAllocationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new StorageAllocationSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); } } - + public virtual bool MoveNext() { return privObjEnum.MoveNext(); } - + public virtual void Reset() { privObjEnum.Reset(); } } } - + // TypeConverter to handle null values for ValueType properties public class WMIValueTypeConverter : TypeConverter { - + private TypeConverter baseConverter; - + private System.Type baseType; - + public WMIValueTypeConverter(System.Type inBaseType) { baseConverter = TypeDescriptor.GetConverter(inBaseType); baseType = inBaseType; } - + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { return baseConverter.CanConvertFrom(context, srcType); } - + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return baseConverter.CanConvertTo(context, destinationType); } - + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return baseConverter.ConvertFrom(context, culture, value); } - + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { return baseConverter.CreateInstance(context, dictionary); } - + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetCreateInstanceSupported(context); } - + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { return baseConverter.GetProperties(context, value, attributeVar); } - + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetPropertiesSupported(context); } - + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValues(context); } - + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesExclusive(context); } - + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesSupported(context); } - + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((baseType.BaseType == typeof(System.Enum))) { if ((value.GetType() == destinationType)) { return value; } - if ((((value == null) - && (context != null)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageJob.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageJob.cs index 5a101f1bfeb..2daa32f914e 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageJob.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_StorageJob.cs @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // 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_StorageJob public class StorageJob : 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_StorageJob"; - + // 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 StorageJob() { this.InitializeObject(null, null, null); } - + public StorageJob(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(StorageJob.ConstructPath(keyInstanceID)), null); } - + public StorageJob(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(StorageJob.ConstructPath(keyInstanceID)), null); } - + public StorageJob(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public StorageJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public StorageJob(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public StorageJob(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public StorageJob(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public StorageJob(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCancellableNull { @@ -234,7 +234,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates whether the job can be cancelled. The value of this property does not g" + @@ -248,7 +248,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["Cancellable"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -256,7 +256,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("On failure of the asynchronous operation, this property contains the file path to" + @@ -266,7 +266,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Child"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -279,7 +279,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -291,7 +291,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDeleteOnCompletionNull { @@ -304,7 +304,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -316,7 +316,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["DeleteOnCompletion"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -324,7 +324,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -337,7 +337,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -349,7 +349,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsElapsedTimeNull { @@ -362,7 +362,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -376,7 +376,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -384,7 +384,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsErrorCodeNull { @@ -397,7 +397,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -409,7 +409,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ErrorCode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorDescription { @@ -417,7 +417,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorDescription"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ErrorSummaryDescription { @@ -425,7 +425,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ErrorSummaryDescription"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -438,7 +438,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -450,7 +450,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -463,7 +463,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -477,7 +477,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -485,7 +485,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobCompletionStatusCodeNull { @@ -498,7 +498,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The HRESULT code that describes the completion status for the asynchronous operat" + @@ -512,7 +512,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["JobCompletionStatusCode"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobRunTimesNull { @@ -525,7 +525,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -537,7 +537,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["JobRunTimes"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobStateNull { @@ -550,7 +550,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -562,7 +562,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["JobState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string JobStatus { @@ -570,7 +570,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["JobStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsJobTypeNull { @@ -583,7 +583,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"The type of asynchronous operation being tracked by this instance of Msvm_StorageJob. @@ -607,7 +607,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((JobTypeValues)(System.Convert.ToInt32(curObj["JobType"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLocalOrUtcTimeNull { @@ -620,7 +620,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -632,7 +632,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((ushort)(curObj["LocalOrUtcTime"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -640,7 +640,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Notify { @@ -648,7 +648,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((string)(curObj["Notify"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -661,7 +661,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -673,7 +673,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -681,7 +681,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherRecoveryAction { @@ -689,7 +689,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((string)(curObj["OtherRecoveryAction"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Owner { @@ -697,7 +697,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((string)(curObj["Owner"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("On failure of the asynchronous operation, this property contains the file path to" + @@ -707,7 +707,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((string)(curObj["Parent"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentCompleteNull { @@ -720,7 +720,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -732,7 +732,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((ushort)(curObj["PercentComplete"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -745,7 +745,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -757,7 +757,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPriorityNull { @@ -770,7 +770,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -782,7 +782,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((uint)(curObj["Priority"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRecoveryActionNull { @@ -795,7 +795,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -807,7 +807,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((ushort)(curObj["RecoveryAction"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunDayNull { @@ -820,7 +820,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -832,7 +832,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((sbyte)(curObj["RunDay"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunDayOfWeekNull { @@ -845,7 +845,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -857,7 +857,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((sbyte)(curObj["RunDayOfWeek"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunMonthNull { @@ -870,7 +870,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -882,7 +882,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((byte)(curObj["RunMonth"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRunStartIntervalNull { @@ -895,7 +895,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -909,7 +909,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsScheduledStartTimeNull { @@ -922,7 +922,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -936,7 +936,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStartTimeNull { @@ -949,7 +949,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -963,7 +963,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -971,7 +971,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -979,7 +979,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeBeforeRemovalNull { @@ -992,7 +992,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1006,7 +1006,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -1019,7 +1019,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1033,7 +1033,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeSubmittedNull { @@ -1046,7 +1046,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1060,7 +1060,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsUntilTimeNull { @@ -1073,7 +1073,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1087,9 +1087,9 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1097,9 +1097,9 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1116,35 +1116,35 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } return false; } - + private bool ShouldSerializeCancellable() { if ((this.IsCancellableNull == false)) { return true; } return false; } - + private bool ShouldSerializeCommunicationStatus() { if ((this.IsCommunicationStatusNull == false)) { return true; } return false; } - + 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; @@ -1196,13 +1196,13 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1230,7 +1230,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1257,8 +1257,8 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1268,200 +1268,200 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] 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 ShouldSerializeJobCompletionStatusCode() { if ((this.IsJobCompletionStatusCodeNull == 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_StorageJob"; 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)) { @@ -1473,24 +1473,24 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static StorageJobCollection GetInstances() { return GetInstances(null, null, null); } - + public static StorageJobCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static StorageJobCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static StorageJobCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static StorageJobCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1511,15 +1511,15 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] } return new StorageJobCollection(clsObject.GetInstances(enumOptions)); } - + public static StorageJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static StorageJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static StorageJobCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1536,7 +1536,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] ObjectSearcher.Options = enumOptions; return new StorageJobCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static StorageJob CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1551,12 +1551,12 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new StorageJob(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint GetError(out string Error) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1569,7 +1569,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return System.Convert.ToUInt32(0); } } - + public uint GetErrorEx(out string[] Errors) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1582,7 +1582,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return System.Convert.ToUInt32(0); } } - + public uint KillJob(bool DeleteOnKill) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1595,7 +1595,7 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return System.Convert.ToUInt32(0); } } - + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1609,59 +1609,59 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] return System.Convert.ToUInt32(0); } } - + public enum JobTypeValues { - + Unknown0 = 0, - + VHD_Creation = 1, - + Floppy_Creation = 2, - + Compaction = 3, - + Expansion = 4, - + Merging = 5, - + Conversion = 6, - + Loopback_Mount = 7, - + Get_VHD_Info = 8, - + Validate_VHD_Image = 9, - + NULL_ENUM_VALUE = 10, } - + // Enumerator implementation for enumerating instances of the class. public class StorageJobCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public StorageJobCollection(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; @@ -1669,189 +1669,189 @@ Validate VHD Image: Validating a virtual hard disk image (VHD).")] array.SetValue(new StorageJob(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new StorageJobEnumerator(privColObj.GetEnumerator()); } - + public class StorageJobEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public StorageJobEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new StorageJob(((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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SummaryInformation.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SummaryInformation.cs index a9523b79851..b12d9c7eaad 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SummaryInformation.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SummaryInformation.cs @@ -23,102 +23,102 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. - // - // - // - // + // + // + // + // // If the embedded property is strongly typed then, to strongly type the property to the type of // the embedded object, you have to do the following things. // 1. Generate Managed class for the WMI class of the embedded property. This can be done with MgmtClassGen.exe tool or from Server Explorer. // 2. Include the namespace of the generated class. // 3. Change the property get/set functions so as return the instance of the Managed class. // Below is a sample code. - // + // // VB Code - // - // - // + // + // + // // Property name // Managed class name of Embedded Property - // - // - // - // - // - // + // + // + // + // + // + // // C# Code - // - // - // + // + // + // // Managed class name of Embedded property // Property name - // - // - // - // - // - // - // - // - // - // + // + // + // + // + // + // + // + // + // + // // An Early Bound class generated for the WMI class.Msvm_SummaryInformation public class SummaryInformation : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. private static string CreatedClassName = "Msvm_SummaryInformation"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public SummaryInformation() { this.InitializeObject(null, null, null); } - + public SummaryInformation(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public SummaryInformation(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public SummaryInformation(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public SummaryInformation(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public SummaryInformation(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public SummaryInformation(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -143,7 +143,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -152,7 +152,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -161,7 +161,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -170,7 +170,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -179,7 +179,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -207,7 +207,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -219,7 +219,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -240,7 +240,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -252,7 +252,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The identifier of the physical graphics processing unit (GPU) allocated to this v" + @@ -262,7 +262,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AllocatedGPU"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsApplicationHealthNull { @@ -275,7 +275,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"The current application health status for the virtual system. This property may be one of the following values: ""OK""; ""Application Critical""; ""Disabled"".For more information, see the documentation for the StatusDescriptions property of the Msvm_HeartbeatComponent class. This property is not valid for instances of Msvm_SummaryInformation representing a virtual system snapshot.")] @@ -288,7 +288,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ApplicationHealthValues)(System.Convert.ToInt32(curObj["ApplicationHealth"]))); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("An array of Msvm_ConcreteJob instances representing any asynchronous operations r" + @@ -300,7 +300,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((System.Management.ManagementBaseObject[])(curObj["AsynchronousTasks"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAvailableMemoryBufferNull { @@ -313,7 +313,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The available memory buffer percentage in the virtual system.")] @@ -326,7 +326,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((int)(curObj["AvailableMemoryBuffer"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCreationTimeNull { @@ -339,7 +339,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The time at which the virtual system or snapshot was created.")] @@ -354,7 +354,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The friendly name for the virtual system or snapshot.")] @@ -363,7 +363,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -376,7 +376,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The current state of the virtual system or snapshot.")] @@ -389,7 +389,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The name of the guest operating system, if available. If this information is not " + @@ -400,7 +400,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["GuestOperatingSystem"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -413,7 +413,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The current health state for the virtual system. This property is not valid for i" + @@ -427,7 +427,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHeartbeatNull { @@ -440,7 +440,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [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.")] @@ -453,7 +453,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["Heartbeat"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsIntegrationServicesVersionStateNull { @@ -466,7 +466,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Whether or not the integration services installed in the virtual machine are up t" + @@ -480,7 +480,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((IntegrationServicesVersionStateValues)(System.Convert.ToInt32(curObj["IntegrationServicesVersionState"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMemoryAvailableNull { @@ -493,7 +493,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The memory available percentage in the virtual system.")] @@ -506,7 +506,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((int)(curObj["MemoryAvailable"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMemorySpansPhysicalNumaNodesNull { @@ -519,7 +519,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates whether or not the memory of the one or more of the virtual non-uniform" + @@ -534,7 +534,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["MemorySpansPhysicalNumaNodes"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMemoryUsageNull { @@ -547,7 +547,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The current memory usage of the virtual system. This property is not valid for in" + @@ -561,7 +561,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["MemoryUsage"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The unique name for the virtual system or snapshot.")] @@ -570,7 +570,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The notes associated with the virtual system or snapshot.")] @@ -579,7 +579,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Notes"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNumberOfProcessorsNull { @@ -592,7 +592,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The total number of virtual processors allocated to the virtual system or snapsho" + @@ -606,7 +606,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["NumberOfProcessors"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The current status of the element.")] @@ -615,7 +615,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("A string that describes the enabled or disabled state of the element when the Ena" + @@ -626,7 +626,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsProcessorLoadNull { @@ -639,7 +639,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The current processor usage of the virtual system. This property is not valid for" + @@ -653,7 +653,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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" + @@ -664,7 +664,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["ProcessorLoadHistory"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReplicationHealthNull { @@ -677,7 +677,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Replication health for the virtual machine.")] @@ -690,7 +690,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ReplicationHealthValues)(System.Convert.ToInt32(curObj["ReplicationHealth"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReplicationModeNull { @@ -703,7 +703,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Identifies replication type for the virtual machine.")] @@ -716,7 +716,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ReplicationModeValues)(System.Convert.ToInt32(curObj["ReplicationMode"]))); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReplicationStateNull { @@ -729,7 +729,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Replication state for the virtual machine.")] @@ -742,7 +742,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ReplicationStateValues)(System.Convert.ToInt32(curObj["ReplicationState"]))); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("An array of Msvm_VirtualSystemSettingData instances representing the snapshots fo" + @@ -753,7 +753,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((System.Management.ManagementBaseObject[])(curObj["Snapshots"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Strings that describe the various OperationalStatus array values.")] @@ -762,7 +762,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsSwapFilesInUseNull { @@ -775,7 +775,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indecates if smart paging is active.")] @@ -788,7 +788,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["SwapFilesInUse"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Reference to the CIM_ComputerSystem instance representing the test replica virtua" + @@ -802,7 +802,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return null; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("An array containing a small, thumbnail-sized image of the desktop for the virtual" + @@ -812,7 +812,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((byte[])(curObj["ThumbnailImage"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsUpTimeNull { @@ -825,7 +825,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The amount of time since the virtual system was last booted. This property is not" + @@ -840,9 +840,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["UpTime"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -850,9 +850,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -869,21 +869,21 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeApplicationHealth() { if ((this.IsApplicationHealthNull == false)) { return true; } return false; } - + private bool ShouldSerializeAvailableMemoryBuffer() { if ((this.IsAvailableMemoryBufferNull == false)) { return true; } return false; } - + // Converts a given datetime in DMTF format to System.DateTime object. static System.DateTime ToDateTime(string dmtfDate) { System.DateTime initializer = System.DateTime.MinValue; @@ -935,13 +935,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -969,7 +969,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -996,8 +996,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1007,136 +1007,136 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { dmtfDateTime = string.Concat(dmtfDateTime, utcString); return dmtfDateTime; } - + private bool ShouldSerializeCreationTime() { if ((this.IsCreationTimeNull == false)) { return true; } return false; } - + private bool ShouldSerializeEnabledState() { if ((this.IsEnabledStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeHealthState() { if ((this.IsHealthStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeHeartbeat() { if ((this.IsHeartbeatNull == false)) { return true; } return false; } - + private bool ShouldSerializeIntegrationServicesVersionState() { if ((this.IsIntegrationServicesVersionStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeMemoryAvailable() { if ((this.IsMemoryAvailableNull == false)) { return true; } return false; } - + private bool ShouldSerializeMemorySpansPhysicalNumaNodes() { if ((this.IsMemorySpansPhysicalNumaNodesNull == false)) { return true; } return false; } - + private bool ShouldSerializeMemoryUsage() { if ((this.IsMemoryUsageNull == false)) { return true; } return false; } - + private bool ShouldSerializeNumberOfProcessors() { if ((this.IsNumberOfProcessorsNull == false)) { return true; } return false; } - + private bool ShouldSerializeProcessorLoad() { if ((this.IsProcessorLoadNull == false)) { return true; } return false; } - + private bool ShouldSerializeReplicationHealth() { if ((this.IsReplicationHealthNull == false)) { return true; } return false; } - + private bool ShouldSerializeReplicationMode() { if ((this.IsReplicationModeNull == false)) { return true; } return false; } - + private bool ShouldSerializeReplicationState() { if ((this.IsReplicationStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeSwapFilesInUse() { if ((this.IsSwapFilesInUseNull == false)) { return true; } return false; } - + private bool ShouldSerializeUpTime() { if ((this.IsUpTimeNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath() { string strPath = "ROOT\\virtualization\\v2:Msvm_SummaryInformation"; return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -1148,24 +1148,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1186,15 +1186,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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)) { @@ -1211,7 +1211,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new SummaryInformationCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static SummaryInformation CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1226,116 +1226,116 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new SummaryInformation(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public enum ApplicationHealthValues { - + OK = 2, - + Application_Critical = 32782, - + Disabled = 32896, - + NULL_ENUM_VALUE = 0, } - + public enum IntegrationServicesVersionStateValues { - + Unknown0 = 0, - + UpToDate = 1, - + Mismatch = 2, - + NULL_ENUM_VALUE = 3, } - + public enum ReplicationHealthValues { - + Not_applicable = 0, - + Ok = 1, - + Warning = 2, - + Critical = 3, - + NULL_ENUM_VALUE = 4, } - + public enum ReplicationModeValues { - + None = 0, - + Primary = 1, - + Recovery = 2, - + Test_Replica = 3, - + NULL_ENUM_VALUE = 4, } - + public enum ReplicationStateValues { - + Disabled = 0, - + Ready_for_replication = 1, - + Waiting_to_complete_initial_replication = 2, - + Replicating = 3, - + Synced_replication_complete = 4, - + Recovered = 5, - + Committed = 6, - + Suspended = 7, - + Critical = 8, - + Waiting_to_start_resynchronization = 9, - + Resynchronizing = 10, - + Resynchronization_suspended = 11, - + NULL_ENUM_VALUE = 12, } - + // Enumerator implementation for enumerating instances of the class. public class SummaryInformationCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public SummaryInformationCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -1343,189 +1343,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs index caa74fe5ac0..2e04d854141 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_SyntheticEthernetPortSettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // An Early Bound class generated for the WMI class.Msvm_SyntheticEthernetPortSettingData public class SyntheticEthernetPortSettingData : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_SyntheticEthernetPortSettingData"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public SyntheticEthernetPortSettingData() { this.InitializeObject(null, null, null); } - + public SyntheticEthernetPortSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(SyntheticEthernetPortSettingData.ConstructPath(keyInstanceID)), null); } - + public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(SyntheticEthernetPortSettingData.ConstructPath(keyInstanceID)), null); } - + public SyntheticEthernetPortSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public SyntheticEthernetPortSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public SyntheticEthernetPortSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public SyntheticEthernetPortSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public SyntheticEthernetPortSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Address { @@ -228,7 +228,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Address"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AddressOnParent { @@ -236,7 +236,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AddressOnParent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string AllocationUnits { @@ -244,7 +244,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["AllocationUnits"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticAllocationNull { @@ -257,7 +257,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -269,7 +269,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticAllocation"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticDeallocationNull { @@ -282,7 +282,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -294,7 +294,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["AutomaticDeallocation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -302,7 +302,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Connection { @@ -310,7 +310,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["Connection"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsConsumerVisibilityNull { @@ -323,7 +323,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -335,7 +335,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ConsumerVisibility"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -343,7 +343,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDesiredVLANEndpointModeNull { @@ -356,7 +356,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -368,7 +368,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DesiredVLANEndpointMode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -376,7 +376,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] HostResource { @@ -384,7 +384,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["HostResource"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -392,7 +392,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLimitNull { @@ -405,7 +405,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -417,7 +417,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Limit"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMappingBehaviorNull { @@ -430,7 +430,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -442,7 +442,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["MappingBehavior"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEndpointMode { @@ -450,7 +450,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEndpointMode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherResourceType { @@ -458,7 +458,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherResourceType"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Parent { @@ -466,7 +466,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Parent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PoolID { @@ -474,7 +474,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PoolID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsReservationNull { @@ -487,7 +487,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -499,7 +499,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["Reservation"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ResourceSubType { @@ -507,7 +507,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ResourceSubType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResourceTypeNull { @@ -520,7 +520,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -532,7 +532,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ResourceType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStaticMacAddressNull { @@ -545,7 +545,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates a static MAC address.\nThis is a read-only property, but it can be chang" + @@ -560,7 +560,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["StaticMacAddress"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualQuantityNull { @@ -573,7 +573,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -585,7 +585,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ulong)(curObj["VirtualQuantity"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string VirtualQuantityUnits { @@ -593,7 +593,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["VirtualQuantityUnits"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description(@"A free-form string array of identifiers of this resource presented to the virtual computer system's operating system. The indexes and values per index are defined on a per resource basis (that is, for each enumerated ResourceType value). This property is set to ""GUID"". @@ -603,7 +603,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string[])(curObj["VirtualSystemIdentifiers"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsWeightNull { @@ -616,7 +616,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -628,9 +628,9 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((uint)(curObj["Weight"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -638,9 +638,9 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -657,109 +657,109 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } return false; } - + private bool ShouldSerializeAutomaticAllocation() { if ((this.IsAutomaticAllocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeAutomaticDeallocation() { if ((this.IsAutomaticDeallocationNull == false)) { return true; } return false; } - + private bool ShouldSerializeConsumerVisibility() { if ((this.IsConsumerVisibilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeDesiredVLANEndpointMode() { if ((this.IsDesiredVLANEndpointModeNull == false)) { return true; } return false; } - + private bool ShouldSerializeLimit() { if ((this.IsLimitNull == false)) { return true; } return false; } - + private bool ShouldSerializeMappingBehavior() { if ((this.IsMappingBehaviorNull == false)) { return true; } return false; } - + private bool ShouldSerializeReservation() { if ((this.IsReservationNull == false)) { return true; } return false; } - + private bool ShouldSerializeResourceType() { if ((this.IsResourceTypeNull == false)) { return true; } return false; } - + private bool ShouldSerializeStaticMacAddress() { if ((this.IsStaticMacAddressNull == false)) { return true; } return false; } - + private bool ShouldSerializeVirtualQuantity() { if ((this.IsVirtualQuantityNull == false)) { return true; } return false; } - + private bool ShouldSerializeWeight() { if ((this.IsWeightNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyInstanceID) { string strPath = "ROOT\\virtualization\\v2:Msvm_SyntheticEthernetPortSettingData"; strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -771,24 +771,24 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste 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)) { @@ -809,15 +809,15 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } 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)) { @@ -834,7 +834,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste ObjectSearcher.Options = enumOptions; return new SyntheticEthernetPortSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static SyntheticEthernetPortSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -849,39 +849,39 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste 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; @@ -889,189 +889,189 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs index 1d54ea7be21..550494fe8fd 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitch.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. // An Early Bound class generated for the WMI class.Msvm_VirtualEthernetSwitch public class VirtualEthernetSwitch : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. public static string CreatedClassName = "Msvm_VirtualEthernetSwitch"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public VirtualEthernetSwitch() { this.InitializeObject(null, null, null); } - + public VirtualEthernetSwitch(string keyCreationClassName, string keyName) { this.InitializeObject(null, new System.Management.ManagementPath(VirtualEthernetSwitch.ConstructPath(keyCreationClassName, keyName)), null); } - + public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualEthernetSwitch.ConstructPath(keyCreationClassName, keyName)), null); } - + public VirtualEthernetSwitch(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public VirtualEthernetSwitch(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public VirtualEthernetSwitch(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public VirtualEthernetSwitch(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public VirtualEthernetSwitch(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -237,7 +237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -250,7 +250,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -262,7 +262,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] Dedicated { @@ -278,7 +278,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["Dedicated"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -286,7 +286,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -299,7 +299,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -311,7 +311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -319,7 +319,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -332,7 +332,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -344,7 +344,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -357,7 +357,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -369,7 +369,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -382,7 +382,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -394,7 +394,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] IdentifyingDescriptions { @@ -402,7 +402,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["IdentifyingDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -415,7 +415,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -429,7 +429,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -437,7 +437,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxIOVOffloadsNull { @@ -450,7 +450,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum number of SR-IOV Virtual Function offloads available on this switch.")] @@ -463,7 +463,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["MaxIOVOffloads"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxVMQOffloadsNull { @@ -476,7 +476,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum number of VMQ offloads allowed for a port on this switch.")] @@ -490,13 +490,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["MaxVMQOffloads"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -504,7 +504,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string NameFormat { @@ -512,7 +512,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["NameFormat"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -525,7 +525,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -537,7 +537,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -545,7 +545,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherDedicatedDescriptions { @@ -553,7 +553,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherDedicatedDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -561,7 +561,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] OtherIdentifyingInfo { @@ -569,7 +569,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["OtherIdentifyingInfo"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] PowerManagementCapabilities { @@ -577,7 +577,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["PowerManagementCapabilities"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerContact { @@ -585,7 +585,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerContact"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerName { @@ -593,7 +593,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -606,7 +606,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -618,7 +618,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -631,7 +631,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -643,7 +643,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsResetCapabilityNull { @@ -656,7 +656,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -668,7 +668,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["ResetCapability"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Roles { @@ -676,7 +676,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["Roles"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -684,7 +684,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -692,7 +692,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -705,7 +705,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -719,7 +719,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -732,7 +732,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -744,9 +744,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -754,9 +754,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -773,42 +773,42 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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; @@ -860,13 +860,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -894,7 +894,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -921,8 +921,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -932,104 +932,104 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { dmtfDateTime = string.Concat(dmtfDateTime, utcString); return dmtfDateTime; } - + private bool ShouldSerializeInstallDate() { if ((this.IsInstallDateNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxIOVOffloads() { if ((this.IsMaxIOVOffloadsNull == false)) { return true; } return false; } - + private bool ShouldSerializeMaxVMQOffloads() { if ((this.IsMaxVMQOffloadsNull == false)) { return true; } return false; } - + private void ResetMaxVMQOffloads() { curObj["MaxVMQOffloads"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeOperatingStatus() { if ((this.IsOperatingStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializePrimaryStatus() { if ((this.IsPrimaryStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeRequestedState() { if ((this.IsRequestedStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeResetCapability() { if ((this.IsResetCapabilityNull == false)) { return true; } return false; } - + private bool ShouldSerializeTimeOfLastStateChange() { if ((this.IsTimeOfLastStateChangeNull == false)) { return true; } return false; } - + private bool ShouldSerializeTransitioningToState() { if ((this.IsTransitioningToStateNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyCreationClassName, string keyName) { string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualEthernetSwitch"; strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); strPath = string.Concat(strPath, string.Concat(",Name=", string.Concat("\"", string.Concat(keyName, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -1041,24 +1041,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static VirtualEthernetSwitchCollection GetInstances() { return GetInstances(null, null, null); } - + public static VirtualEthernetSwitchCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static VirtualEthernetSwitchCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static VirtualEthernetSwitchCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1079,15 +1079,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new VirtualEthernetSwitchCollection(clsObject.GetInstances(enumOptions)); } - + public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static VirtualEthernetSwitchCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1104,7 +1104,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new VirtualEthernetSwitchCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static VirtualEthernetSwitch CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1119,12 +1119,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new VirtualEthernetSwitch(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint RequestStateChange(ushort RequestedState, System.DateTime TimeoutPeriod, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1143,7 +1143,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint SetPowerState(uint PowerState, System.DateTime Time) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1157,34 +1157,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + // Enumerator implementation for enumerating instances of the class. public class VirtualEthernetSwitchCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public VirtualEthernetSwitchCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -1192,189 +1192,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new VirtualEthernetSwitch(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new VirtualEthernetSwitchEnumerator(privColObj.GetEnumerator()); } - + public class VirtualEthernetSwitchEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public VirtualEthernetSwitchEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new VirtualEthernetSwitch(((System.Management.ManagementObject)(privObjEnum.Current))); } } - + public virtual bool MoveNext() { return privObjEnum.MoveNext(); } - + public virtual void Reset() { privObjEnum.Reset(); } } } - + // TypeConverter to handle null values for ValueType properties public class WMIValueTypeConverter : TypeConverter { - + private TypeConverter baseConverter; - + private System.Type baseType; - + public WMIValueTypeConverter(System.Type inBaseType) { baseConverter = TypeDescriptor.GetConverter(inBaseType); baseType = inBaseType; } - + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { return baseConverter.CanConvertFrom(context, srcType); } - + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return baseConverter.CanConvertTo(context, destinationType); } - + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return baseConverter.ConvertFrom(context, culture, value); } - + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { return baseConverter.CreateInstance(context, dictionary); } - + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetCreateInstanceSupported(context); } - + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { return baseConverter.GetProperties(context, value, attributeVar); } - + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetPropertiesSupported(context); } - + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValues(context); } - + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesExclusive(context); } - + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesSupported(context); } - + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((baseType.BaseType == typeof(System.Enum))) { if ((value.GetType() == destinationType)) { return value; } - if ((((value == null) - && (context != null)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs index 639e0070f52..89ac24ea755 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualEthernetSwitchManagementService.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // Datetime conversion functions ToDateTime and ToDmtfDateTime are added to the class to convert DMTF datetime to System.DateTime and vice-versa. // An Early Bound class generated for the WMI class.Msvm_VirtualEthernetSwitchManagementService public class VirtualEthernetSwitchManagementService : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. private static string CreatedClassName = "Msvm_VirtualEthernetSwitchManagementService"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public VirtualEthernetSwitchManagementService() { this.InitializeObject(null, null, null); } - + public VirtualEthernetSwitchManagementService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(null, new System.Management.ManagementPath(VirtualEthernetSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); } - + public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualEthernetSwitchManagementService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); } - + public VirtualEthernetSwitchManagementService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public VirtualEthernetSwitchManagementService(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public VirtualEthernetSwitchManagementService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public VirtualEthernetSwitchManagementService(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public VirtualEthernetSwitchManagementService(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -229,7 +229,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -237,7 +237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -250,7 +250,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -262,7 +262,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -270,7 +270,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -278,7 +278,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -291,7 +291,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -303,7 +303,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -311,7 +311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -324,7 +324,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -336,7 +336,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -349,7 +349,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -361,7 +361,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -374,7 +374,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -386,7 +386,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -399,7 +399,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -413,7 +413,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -421,7 +421,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -429,7 +429,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -442,7 +442,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -454,7 +454,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -462,7 +462,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -470,7 +470,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerContact { @@ -478,7 +478,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerContact"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerName { @@ -486,7 +486,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -499,7 +499,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -511,7 +511,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -524,7 +524,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -536,7 +536,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStartedNull { @@ -549,7 +549,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -561,7 +561,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["Started"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string StartMode { @@ -569,7 +569,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["StartMode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -577,7 +577,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -585,7 +585,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -593,7 +593,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -601,7 +601,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -614,7 +614,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -628,7 +628,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -641,7 +641,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -653,9 +653,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -663,9 +663,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -682,42 +682,42 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } 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; @@ -769,13 +769,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -803,7 +803,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -830,8 +830,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -841,75 +841,75 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { dmtfDateTime = string.Concat(dmtfDateTime, utcString); return dmtfDateTime; } - + private bool ShouldSerializeInstallDate() { if ((this.IsInstallDateNull == false)) { return true; } return false; } - + private bool ShouldSerializeOperatingStatus() { if ((this.IsOperatingStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializePrimaryStatus() { if ((this.IsPrimaryStatusNull == false)) { return true; } return false; } - + private bool ShouldSerializeRequestedState() { if ((this.IsRequestedStateNull == false)) { return true; } return false; } - + private bool ShouldSerializeStarted() { if ((this.IsStartedNull == false)) { return true; } return false; } - + private bool ShouldSerializeTimeOfLastStateChange() { if ((this.IsTimeOfLastStateChangeNull == false)) { return true; } return false; } - + private bool ShouldSerializeTransitioningToState() { if ((this.IsTransitioningToStateNull == false)) { return true; } return false; } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualEthernetSwitchManagementService"; strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); @@ -918,7 +918,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -930,24 +930,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static VirtualEthernetSwitchManagementServiceCollection GetInstances() { return GetInstances(null, null, null); } - + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -968,15 +968,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new VirtualEthernetSwitchManagementServiceCollection(clsObject.GetInstances(enumOptions)); } - + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static VirtualEthernetSwitchManagementServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -993,7 +993,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new VirtualEthernetSwitchManagementServiceCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static VirtualEthernetSwitchManagementService CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1008,12 +1008,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new VirtualEthernetSwitchManagementService(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint AddFeatureSettings(System.Management.ManagementPath AffectedConfiguration, string[] FeatureSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath[] ResultingFeatureSettings) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1042,7 +1042,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1071,7 +1071,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1096,7 +1096,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1114,7 +1114,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1142,7 +1142,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1170,7 +1170,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint ModifySystemSettings(string SystemSettings, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1188,7 +1188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1216,7 +1216,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1245,7 +1245,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1264,7 +1264,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint StartService() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1275,7 +1275,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint StopService() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1286,34 +1286,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + // Enumerator implementation for enumerating instances of the class. public class VirtualEthernetSwitchManagementServiceCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public VirtualEthernetSwitchManagementServiceCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -1321,189 +1321,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new VirtualEthernetSwitchManagementService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new VirtualEthernetSwitchManagementServiceEnumerator(privColObj.GetEnumerator()); } - + public class VirtualEthernetSwitchManagementServiceEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public VirtualEthernetSwitchManagementServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new VirtualEthernetSwitchManagementService(((System.Management.ManagementObject)(privObjEnum.Current))); } } - + public virtual bool MoveNext() { return privObjEnum.MoveNext(); } - + public virtual void Reset() { privObjEnum.Reset(); } } } - + // TypeConverter to handle null values for ValueType properties public class WMIValueTypeConverter : TypeConverter { - + private TypeConverter baseConverter; - + private System.Type baseType; - + public WMIValueTypeConverter(System.Type inBaseType) { baseConverter = TypeDescriptor.GetConverter(inBaseType); baseType = inBaseType; } - + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { return baseConverter.CanConvertFrom(context, srcType); } - + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return baseConverter.CanConvertTo(context, destinationType); } - + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return baseConverter.ConvertFrom(context, culture, value); } - + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { return baseConverter.CreateInstance(context, dictionary); } - + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetCreateInstanceSupported(context); } - + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { return baseConverter.GetProperties(context, value, attributeVar); } - + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetPropertiesSupported(context); } - + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValues(context); } - + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesExclusive(context); } - + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesSupported(context); } - + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((baseType.BaseType == typeof(System.Enum))) { if ((value.GetType() == destinationType)) { return value; } - if ((((value == null) - && (context != null)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs index 0a8aec37e58..95b711f6489 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualHardDiskSettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. // Every property added to the class for WMI property has attributes set to define its behavior in Visual Studio designer and also to define a TypeConverter to be used. // An Early Bound class generated for the WMI class.Msvm_VirtualHardDiskSettingData public class VirtualHardDiskSettingData : System.ComponentModel.Component { - + // Private property to hold the WMI namespace in which the class resides. private static string CreatedWmiNamespace = "ROOT\\virtualization\\v2"; - + // Private property to hold the name of WMI class which created this class. private static string CreatedClassName = "Msvm_VirtualHardDiskSettingData"; - + // Private member variable to hold the ManagementScope which is used by the various methods. private static System.Management.ManagementScope statMgmtScope = null; - + private ManagementSystemProperties PrivateSystemProperties; - + // Underlying lateBound WMI object. private System.Management.ManagementObject PrivateLateBoundObject; - + // Member variable to store the 'automatic commit' behavior for the class. private bool AutoCommitProp; - + // Private variable to hold the embedded property representing the instance. private System.Management.ManagementBaseObject embeddedObj; - + // The current WMI object used private System.Management.ManagementBaseObject curObj; - + // Flag to indicate if the instance is an embedded object. private bool isEmbedded; - + // Below are different overloads of constructors to initialize an instance of the class with a WMI object. public VirtualHardDiskSettingData() { this.InitializeObject(null, null, null); } - + public VirtualHardDiskSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(VirtualHardDiskSettingData.ConstructPath(keyInstanceID)), null); } - + public VirtualHardDiskSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualHardDiskSettingData.ConstructPath(keyInstanceID)), null); } - + public VirtualHardDiskSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public VirtualHardDiskSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public VirtualHardDiskSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public VirtualHardDiskSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public VirtualHardDiskSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public VirtualHardDiskSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsBlockSizeNull { @@ -233,7 +233,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The block size used by the virtual hard disk")] @@ -247,13 +247,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["BlockSize"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -262,13 +262,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["Caption"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -277,13 +277,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["Description"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -292,13 +292,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["ElementName"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFormatNull { @@ -311,7 +311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The format for the virtual hard disk.")] @@ -330,13 +330,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { else { curObj["Format"] = value; } - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -345,13 +345,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["InstanceID"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsLogicalSectorSizeNull { @@ -364,7 +364,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The logical sector size used by the virtual hard disk")] @@ -378,13 +378,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["LogicalSectorSize"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMaxInternalSizeNull { @@ -397,7 +397,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum size of the virtual hard disk as viewable by the virtual machine, in " + @@ -413,13 +413,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["MaxInternalSize"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The parent of the virtual hard disk. If the virtual hard disk does not have a par" + @@ -430,13 +430,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["ParentPath"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The path of the virtual hard disk.")] @@ -446,13 +446,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["Path"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPhysicalSectorSizeNull { @@ -465,7 +465,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The physical sector size used by the virtual hard disk")] @@ -479,13 +479,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["PhysicalSectorSize"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTypeNull { @@ -498,7 +498,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The type of virtual hard disk.")] @@ -517,15 +517,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { else { curObj["Type"] = value; } - if (((isEmbedded == false) + 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) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -533,9 +533,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -552,162 +552,162 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeBlockSize() { if ((this.IsBlockSizeNull == false)) { return true; } return false; } - + private void ResetBlockSize() { curObj["BlockSize"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetCaption() { curObj["Caption"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetDescription() { curObj["Description"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetElementName() { curObj["ElementName"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeFormat() { if ((this.IsFormatNull == false)) { return true; } return false; } - + private void ResetFormat() { curObj["Format"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeLogicalSectorSize() { if ((this.IsLogicalSectorSizeNull == false)) { return true; } return false; } - + private void ResetLogicalSectorSize() { curObj["LogicalSectorSize"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeMaxInternalSize() { if ((this.IsMaxInternalSizeNull == false)) { return true; } return false; } - + private void ResetMaxInternalSize() { curObj["MaxInternalSize"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetParentPath() { curObj["ParentPath"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetPath0() { curObj["Path"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializePhysicalSectorSize() { if ((this.IsPhysicalSectorSizeNull == false)) { return true; } return false; } - + private void ResetPhysicalSectorSize() { curObj["PhysicalSectorSize"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeType() { if ((this.IsTypeNull == false)) { return true; } return false; } - + private void ResetType() { curObj["Type"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject() { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(); } } - + [Browsable(true)] public void CommitObject(System.Management.PutOptions putOptions) { if ((isEmbedded == false)) { PrivateLateBoundObject.Put(putOptions); } } - + private void Initialize() { AutoCommitProp = true; isEmbedded = false; } - + private static string ConstructPath(string keyInstanceID) { string strPath = "ROOT\\virtualization\\v2:Msvm_VirtualHardDiskSettingData"; strPath = string.Concat(strPath, string.Concat(".InstanceID=", string.Concat("\"", string.Concat(keyInstanceID, "\"")))); return strPath; } - + private void InitializeObject(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { Initialize(); if ((path != null)) { @@ -719,24 +719,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static VirtualHardDiskSettingDataCollection GetInstances() { return GetInstances(null, null, null); } - + public static VirtualHardDiskSettingDataCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static VirtualHardDiskSettingDataCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static VirtualHardDiskSettingDataCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -757,15 +757,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new VirtualHardDiskSettingDataCollection(clsObject.GetInstances(enumOptions)); } - + public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static VirtualHardDiskSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -782,7 +782,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new VirtualHardDiskSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static VirtualHardDiskSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -797,59 +797,59 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new VirtualHardDiskSettingData(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public enum FormatValues { - + VHD = 2, - + VHDX = 3, - + NULL_ENUM_VALUE = 0, } - + public enum TypeValues { - + Fixed = 2, - + Dynamic = 3, - + Differencing = 4, - + NULL_ENUM_VALUE = 0, } - + // Enumerator implementation for enumerating instances of the class. public class VirtualHardDiskSettingDataCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public VirtualHardDiskSettingDataCollection(ManagementObjectCollection objCollection) { privColObj = objCollection; } - + public virtual int Count { get { return privColObj.Count; } } - + public virtual bool IsSynchronized { get { return privColObj.IsSynchronized; } } - + public virtual object SyncRoot { get { return this; } } - + public virtual void CopyTo(System.Array array, int index) { privColObj.CopyTo(array, index); int nCtr; @@ -857,189 +857,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new VirtualHardDiskSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new VirtualHardDiskSettingDataEnumerator(privColObj.GetEnumerator()); } - + public class VirtualHardDiskSettingDataEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public VirtualHardDiskSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new VirtualHardDiskSettingData(((System.Management.ManagementObject)(privObjEnum.Current))); } } - + public virtual bool MoveNext() { return privObjEnum.MoveNext(); } - + public virtual void Reset() { privObjEnum.Reset(); } } } - + // TypeConverter to handle null values for ValueType properties public class WMIValueTypeConverter : TypeConverter { - + private TypeConverter baseConverter; - + private System.Type baseType; - + public WMIValueTypeConverter(System.Type inBaseType) { baseConverter = TypeDescriptor.GetConverter(inBaseType); baseType = inBaseType; } - + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type srcType) { return baseConverter.CanConvertFrom(context, srcType); } - + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return baseConverter.CanConvertTo(context, destinationType); } - + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return baseConverter.ConvertFrom(context, culture, value); } - + public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary dictionary) { return baseConverter.CreateInstance(context, dictionary); } - + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetCreateInstanceSupported(context); } - + public override PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributeVar) { return baseConverter.GetProperties(context, value, attributeVar); } - + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetPropertiesSupported(context); } - + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValues(context); } - + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesExclusive(context); } - + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return baseConverter.GetStandardValuesSupported(context); } - + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((baseType.BaseType == typeof(System.Enum))) { if ((value.GetType() == destinationType)) { return value; } - if ((((value == null) - && (context != null)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementService.cs index ba014b1e322..b327d81bf94 100644 --- 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 @@ -24,8 +24,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -33,62 +33,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 // 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)) { @@ -100,7 +100,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + public VirtualSystemManagementService(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -113,7 +113,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -122,7 +122,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -131,7 +131,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -140,7 +140,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -149,7 +149,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -158,7 +158,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -177,7 +177,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // 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)] @@ -189,7 +189,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -210,7 +210,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -222,7 +222,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 statMgmtScope = value; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -230,7 +230,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -238,7 +238,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -251,7 +251,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -263,7 +263,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -271,7 +271,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -279,7 +279,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -292,7 +292,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -304,7 +304,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -312,7 +312,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -325,7 +325,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -337,7 +337,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -350,7 +350,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -362,7 +362,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -375,7 +375,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -387,7 +387,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -400,7 +400,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -414,7 +414,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -422,7 +422,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["InstanceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -430,7 +430,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -443,7 +443,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -455,7 +455,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -463,7 +463,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -471,7 +471,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerContact { @@ -479,7 +479,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["PrimaryOwnerContact"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerName { @@ -487,7 +487,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["PrimaryOwnerName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -500,7 +500,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -512,7 +512,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -525,7 +525,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -537,7 +537,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStartedNull { @@ -550,7 +550,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -562,7 +562,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((bool)(curObj["Started"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string StartMode { @@ -570,7 +570,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["StartMode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -578,7 +578,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -586,7 +586,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -594,7 +594,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -602,7 +602,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -615,7 +615,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -629,7 +629,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -642,7 +642,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -654,9 +654,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -664,9 +664,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -683,42 +683,42 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } 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; @@ -770,13 +770,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -804,7 +804,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -831,8 +831,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -842,75 +842,75 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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, "\"")))); @@ -919,7 +919,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) { @@ -931,24 +931,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) { @@ -969,15 +969,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } 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)) { @@ -994,7 +994,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 ObjectSearcher.Options = enumOptions; return new VirtualSystemManagementServiceCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static VirtualSystemManagementService CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1009,12 +1009,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1045,7 +1045,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint AddFibreChannelChap(string[] FcPortSettings, byte SecretEncoding, byte[] SharedSecret) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1060,7 +1060,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1080,7 +1080,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1111,7 +1111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint DefineSystem(string ReferenceConfigurationPath, string[] ResourceSettings, string SystemSettings, out System.Management.ManagementPath Job, out System.Management.ManagementPath ResultingSystem) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1138,7 +1138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1157,7 +1157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1179,7 +1179,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint FormatError(string[] Errors, out string ErrorMessage) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1194,7 +1194,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint GenerateWwpn(uint NumberOfWwpns, out string[] GeneratedWwpn) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1209,7 +1209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint GetCurrentWwpnFromGenerator(out string CurrentWwpn) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1222,7 +1222,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint GetDefinitionFileSummaryInformation(string[] DefinitionFiles, out System.Management.ManagementBaseObject[] SummaryInformation) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1237,7 +1237,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint GetSizeOfSystemFiles(System.Management.ManagementPath Vssd, out ulong Size) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1252,7 +1252,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1278,7 +1278,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1295,7 +1295,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1326,7 +1326,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1354,7 +1354,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint ModifyDiskMergeSettings(string SettingData, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1373,7 +1373,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1403,7 +1403,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1423,7 +1423,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1453,7 +1453,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint ModifyServiceSettings(string SettingData, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1472,7 +1472,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint ModifySystemSettings(string SystemSettings, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1491,7 +1491,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1515,7 +1515,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1544,7 +1544,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint RemoveFibreChannelChap(string[] FcPortSettings) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1557,7 +1557,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1577,7 +1577,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1606,7 +1606,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1626,7 +1626,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1646,7 +1646,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint StartService() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1657,7 +1657,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return System.Convert.ToUInt32(0); } } - + public uint StopService() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1668,7 +1668,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1687,34 +1687,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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; @@ -1722,189 +1722,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs index 390140f2b5e..c11e5cc27d6 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemManagementServiceSettingData.cs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 +namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System; using System.ComponentModel; @@ -24,70 +24,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset 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)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + public VirtualSystemManagementServiceSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 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. @@ -231,7 +231,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["BiosLockString"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -239,7 +239,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The WorldWideNodeName address for dynamically generated WorldWideName addresses u" + @@ -251,7 +251,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["CurrentWWNNAddress"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The default external data root. By default, \"root\\ProgramData\\Microsoft\\Windows\\V" + @@ -262,7 +262,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["DefaultExternalDataRoot"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The default virtual hard disk path. By default, \"root\\Users\\Public\\Documents\\Virt" + @@ -273,7 +273,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["DefaultVirtualHardDiskPath"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -281,7 +281,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -289,7 +289,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHbaLunTimeoutNull { @@ -302,7 +302,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti } } } - + [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. @@ -316,7 +316,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((uint)(curObj["HbaLunTimeout"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -324,7 +324,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["InstanceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum MAC address for dynamically generated MAC addresses.\nThis is a read-o" + @@ -335,7 +335,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["MaximumMacAddress"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The maximum WorldWidePortName address for dynamically generated WorldWideName add" + @@ -347,7 +347,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["MaximumWWPNAddress"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The minimum MAC address for dynamically generated MAC addresses.\nThis is a read-o" + @@ -358,7 +358,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["MinimumMacAddress"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The minimum WorldWidePortName address for dynamically generated WorldWideName add" + @@ -370,7 +370,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["MinimumWWPNAddress"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsNumaSpanningEnabledNull { @@ -383,7 +383,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Reserved for future use.")] @@ -396,7 +396,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((bool)(curObj["NumaSpanningEnabled"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Controls memory allocation for the VMs on non-uniform memory access (NUMA) system" + @@ -407,7 +407,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti 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. @@ -417,9 +417,9 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return ((string)(curObj["PrimaryOwnerName"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -427,9 +427,9 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -446,46 +446,46 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti } 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)) { @@ -497,24 +497,24 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti 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)) { @@ -535,15 +535,15 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti } 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)) { @@ -560,7 +560,7 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti ObjectSearcher.Options = enumOptions; return new VirtualSystemManagementServiceSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static VirtualSystemManagementServiceSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -575,39 +575,39 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti 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; @@ -615,189 +615,189 @@ This is a read-only property, but it can be changed using the ModifyServiceSetti 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemMigrationService.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemMigrationService.cs index 89592b1b900..4a00d23513c 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemMigrationService.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemMigrationService.cs @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // 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_VirtualSystemMigrationService public class VirtualSystemMigrationService : 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_VirtualSystemMigrationService"; - + // 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 VirtualSystemMigrationService() { this.InitializeObject(null, null, null); } - + public VirtualSystemMigrationService(string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemMigrationService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); } - + public VirtualSystemMigrationService(System.Management.ManagementScope mgmtScope, string keyCreationClassName, string keyName, string keySystemCreationClassName, string keySystemName) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemMigrationService.ConstructPath(keyCreationClassName, keyName, keySystemCreationClassName, keySystemName)), null); } - + public VirtualSystemMigrationService(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public VirtualSystemMigrationService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public VirtualSystemMigrationService(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public VirtualSystemMigrationService(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public VirtualSystemMigrationService(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public VirtualSystemMigrationService(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsActiveStorageMigrationCountNull { @@ -234,7 +234,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The number of currently in-flight storage migrations.")] @@ -247,7 +247,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["ActiveStorageMigrationCount"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsActiveVirtualSystemMigrationCountNull { @@ -260,7 +260,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The number of currently in-flight virtual system migrations.")] @@ -273,7 +273,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((uint)(curObj["ActiveVirtualSystemMigrationCount"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] AvailableRequestedStates { @@ -281,7 +281,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["AvailableRequestedStates"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -289,7 +289,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCommunicationStatusNull { @@ -302,7 +302,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -314,7 +314,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["CommunicationStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string CreationClassName { @@ -322,7 +322,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["CreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -330,7 +330,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDetailedStatusNull { @@ -343,7 +343,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -355,7 +355,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["DetailedStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -363,7 +363,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledDefaultNull { @@ -376,7 +376,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -388,7 +388,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledDefault"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsEnabledStateNull { @@ -401,7 +401,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -413,7 +413,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["EnabledState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsHealthStateNull { @@ -426,7 +426,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -438,7 +438,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["HealthState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInstallDateNull { @@ -451,7 +451,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -465,7 +465,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -473,7 +473,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["InstanceID"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The list of IP addresses of the host, which can be used for virtual system migra" + @@ -483,7 +483,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["MigrationServiceListenerIPAddressList"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { @@ -491,7 +491,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsOperatingStatusNull { @@ -504,7 +504,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -516,7 +516,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["OperatingStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public ushort[] OperationalStatus { @@ -524,7 +524,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort[])(curObj["OperationalStatus"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherEnabledState { @@ -532,7 +532,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["OtherEnabledState"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerContact { @@ -540,7 +540,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerContact"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string PrimaryOwnerName { @@ -548,7 +548,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["PrimaryOwnerName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPrimaryStatusNull { @@ -561,7 +561,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -573,7 +573,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["PrimaryStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRequestedStateNull { @@ -586,7 +586,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -598,7 +598,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["RequestedState"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsStartedNull { @@ -611,7 +611,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -623,7 +623,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((bool)(curObj["Started"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string StartMode { @@ -631,7 +631,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["StartMode"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Status { @@ -639,7 +639,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Status"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] StatusDescriptions { @@ -647,7 +647,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string[])(curObj["StatusDescriptions"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemCreationClassName { @@ -655,7 +655,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemCreationClassName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SystemName { @@ -663,7 +663,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["SystemName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimeOfLastStateChangeNull { @@ -676,7 +676,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -690,7 +690,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransitioningToStateNull { @@ -703,7 +703,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -715,9 +715,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["TransitioningToState"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -725,9 +725,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -744,56 +744,56 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return false; } - + private bool ShouldSerializeActiveStorageMigrationCount() { if ((this.IsActiveStorageMigrationCountNull == false)) { return true; } return false; } - + private bool ShouldSerializeActiveVirtualSystemMigrationCount() { if ((this.IsActiveVirtualSystemMigrationCountNull == 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 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; @@ -845,13 +845,13 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -879,7 +879,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -906,8 +906,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -917,75 +917,75 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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_VirtualSystemMigrationService"; strPath = string.Concat(strPath, string.Concat(".CreationClassName=", string.Concat("\"", string.Concat(keyCreationClassName, "\"")))); @@ -994,7 +994,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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)) { @@ -1006,24 +1006,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static VirtualSystemMigrationServiceCollection GetInstances() { return GetInstances(null, null, null); } - + public static VirtualSystemMigrationServiceCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static VirtualSystemMigrationServiceCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static VirtualSystemMigrationServiceCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static VirtualSystemMigrationServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1044,15 +1044,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } return new VirtualSystemMigrationServiceCollection(clsObject.GetInstances(enumOptions)); } - + public static VirtualSystemMigrationServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static VirtualSystemMigrationServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static VirtualSystemMigrationServiceCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -1069,7 +1069,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { ObjectSearcher.Options = enumOptions; return new VirtualSystemMigrationServiceCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static VirtualSystemMigrationService CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1084,12 +1084,12 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new VirtualSystemMigrationService(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public uint AddNetworkSettings(string[] NetworkSettings, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1107,7 +1107,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint CheckSystemCompatibilityInfo(byte[] CompatibilityInfo, out string[] Reasons) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1122,7 +1122,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint CheckVirtualSystemIsMigratable(System.Management.ManagementPath ComputerSystem, string DestinationHost, string MigrationSettingData, string[] NewResourceSettingData, string NewSystemSettingData, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1144,7 +1144,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint CheckVirtualSystemIsMigratableToHost(System.Management.ManagementPath ComputerSystem, string DestinationHost, string MigrationSettingData, string[] NewResourceSettingData, string NewSystemSettingData, out bool IsMigratable) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1163,7 +1163,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint CheckVirtualSystemIsMigratableToSystem(System.Management.ManagementPath ComputerSystem, System.Management.ManagementPath DestinationSystem, string MigrationSettingData, string[] NewResourceSettingData, string NewSystemSettingData, out bool IsMigratable) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1182,7 +1182,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint GetSystemCompatibilityInfo(System.Management.ManagementPath ComputerSystem, out byte[] CompatibilityInfo) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1197,7 +1197,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint MigrateVirtualSystemToHost(System.Management.ManagementPath ComputerSystem, string DestinationHost, string MigrationSettingData, string[] NewResourceSettingData, string NewSystemSettingData, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1220,7 +1220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint MigrateVirtualSystemToSystem(System.Management.ManagementPath ComputerSystem, System.Management.ManagementPath DestinationSystem, string MigrationSettingData, string[] NewResourceSettingData, string NewSystemSettingData, out System.Management.ManagementPath Job, out System.Management.ManagementPath NewComputerSystem) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1247,7 +1247,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint ModifyNetworkSettings(string[] NetworkSettings, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1265,7 +1265,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint ModifyServiceSettings(string ServiceSettingData, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1283,7 +1283,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint RemoveNetworkSettings(System.Management.ManagementPath[] NetworkSettings, out System.Management.ManagementPath Job) { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1311,7 +1311,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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; @@ -1330,7 +1330,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint StartService() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1341,7 +1341,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + public uint StopService() { if ((isEmbedded == false)) { System.Management.ManagementBaseObject inParams = null; @@ -1352,34 +1352,34 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return System.Convert.ToUInt32(0); } } - + // Enumerator implementation for enumerating instances of the class. public class VirtualSystemMigrationServiceCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public VirtualSystemMigrationServiceCollection(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; @@ -1387,189 +1387,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { array.SetValue(new VirtualSystemMigrationService(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new VirtualSystemMigrationServiceEnumerator(privColObj.GetEnumerator()); } - + public class VirtualSystemMigrationServiceEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public VirtualSystemMigrationServiceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new VirtualSystemMigrationService(((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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemMigrationSettingData.cs b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemMigrationSettingData.cs index f7642dffa28..55e3cab6c2a 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemMigrationSettingData.cs +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/WmiWrappers/ROOT.virtualization.v2.Msvm_VirtualSystemMigrationSettingData.cs @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset 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_VirtualSystemMigrationSettingData public class VirtualSystemMigrationSettingData : 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_VirtualSystemMigrationSettingData"; - + // 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 VirtualSystemMigrationSettingData() { this.InitializeObject(null, null, null); } - + public VirtualSystemMigrationSettingData(string keyInstanceID) { this.InitializeObject(null, new System.Management.ManagementPath(VirtualSystemMigrationSettingData.ConstructPath(keyInstanceID)), null); } - + public VirtualSystemMigrationSettingData(System.Management.ManagementScope mgmtScope, string keyInstanceID) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(VirtualSystemMigrationSettingData.ConstructPath(keyInstanceID)), null); } - + public VirtualSystemMigrationSettingData(System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(null, path, getOptions); } - + public VirtualSystemMigrationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path) { this.InitializeObject(mgmtScope, path, null); } - + public VirtualSystemMigrationSettingData(System.Management.ManagementPath path) { this.InitializeObject(null, path, null); } - + public VirtualSystemMigrationSettingData(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions getOptions) { this.InitializeObject(mgmtScope, path, getOptions); } - + public VirtualSystemMigrationSettingData(System.Management.ManagementObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public VirtualSystemMigrationSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsBandwidthNull { @@ -233,7 +233,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -245,7 +245,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((ushort)(curObj["Bandwidth"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string BandwidthUnit { @@ -253,7 +253,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["BandwidthUnit"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -261,7 +261,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Caption"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -269,7 +269,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("For storage migration it will be NULL. For virtual system \nmigration, client can " + @@ -280,19 +280,19 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } set { curObj["DestinationIPAddressList"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - [Description(@"If we have a planned computer system at migration destination then DestinationPlannedVirtualSystemId could be set to -the GUID of the destination Planned VM where the VM needs to -migrate. This is useful for cases where user has created a -planned VM at the destination along with resource fixup, and + [Description(@"If we have a planned computer system at migration destination then DestinationPlannedVirtualSystemId could be set to +the GUID of the destination Planned VM where the VM needs to +migrate. This is useful for cases where user has created a +planned VM at the destination along with resource fixup, and wants a VM from source to migrate into this planned VM.")] public string DestinationPlannedVirtualSystemId { get { @@ -300,13 +300,13 @@ wants a VM from source to migrate into this planned VM.")] } set { curObj["DestinationPlannedVirtualSystemId"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -314,7 +314,7 @@ wants a VM from source to migrate into this planned VM.")] return ((string)(curObj["ElementName"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -322,7 +322,7 @@ wants a VM from source to migrate into this planned VM.")] return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsMigrationTypeNull { @@ -335,7 +335,7 @@ wants a VM from source to migrate into this planned VM.")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("MigrationType describes the type of migration operation to \nbe performed.\n")] @@ -354,13 +354,13 @@ wants a VM from source to migrate into this planned VM.")] else { curObj["MigrationType"] = value; } - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string OtherTransportType { @@ -368,7 +368,7 @@ wants a VM from source to migrate into this planned VM.")] return ((string)(curObj["OtherTransportType"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPriorityNull { @@ -381,7 +381,7 @@ wants a VM from source to migrate into this planned VM.")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -393,7 +393,7 @@ wants a VM from source to migrate into this planned VM.")] return ((ushort)(curObj["Priority"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsRetainVhdCopiesOnSourceNull { @@ -406,7 +406,7 @@ wants a VM from source to migrate into this planned VM.")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("For storage migration, this could be set to TRUE or FALSE\nto determine wheither, " + @@ -422,13 +422,13 @@ wants a VM from source to migrate into this planned VM.")] } set { curObj["RetainVhdCopiesOnSource"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTransportTypeNull { @@ -441,7 +441,7 @@ wants a VM from source to migrate into this planned VM.")] } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -453,9 +453,9 @@ wants a VM from source to migrate into this planned VM.")] return ((ushort)(curObj["TransportType"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -463,9 +463,9 @@ wants a VM from source to migrate into this planned VM.")] return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -482,99 +482,99 @@ wants a VM from source to migrate into this planned VM.")] } return false; } - + private bool ShouldSerializeBandwidth() { if ((this.IsBandwidthNull == false)) { return true; } return false; } - + private void ResetDestinationIPAddressList() { curObj["DestinationIPAddressList"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetDestinationPlannedVirtualSystemId() { curObj["DestinationPlannedVirtualSystemId"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeMigrationType() { if ((this.IsMigrationTypeNull == false)) { return true; } return false; } - + private void ResetMigrationType() { curObj["MigrationType"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializePriority() { if ((this.IsPriorityNull == false)) { return true; } return false; } - + private bool ShouldSerializeRetainVhdCopiesOnSource() { if ((this.IsRetainVhdCopiesOnSourceNull == false)) { return true; } return false; } - + private void ResetRetainVhdCopiesOnSource() { curObj["RetainVhdCopiesOnSource"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private bool ShouldSerializeTransportType() { if ((this.IsTransportTypeNull == 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_VirtualSystemMigrationSettingData"; 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)) { @@ -586,24 +586,24 @@ wants a VM from source to migrate into this planned VM.")] PrivateSystemProperties = new ManagementSystemProperties(PrivateLateBoundObject); curObj = PrivateLateBoundObject; } - + // Different overloads of GetInstances() help in enumerating instances of the WMI class. public static VirtualSystemMigrationSettingDataCollection GetInstances() { return GetInstances(null, null, null); } - + public static VirtualSystemMigrationSettingDataCollection GetInstances(string condition) { return GetInstances(null, condition, null); } - + public static VirtualSystemMigrationSettingDataCollection GetInstances(string[] selectedProperties) { return GetInstances(null, null, selectedProperties); } - + public static VirtualSystemMigrationSettingDataCollection GetInstances(string condition, string[] selectedProperties) { return GetInstances(null, condition, selectedProperties); } - + public static VirtualSystemMigrationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, System.Management.EnumerationOptions enumOptions) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -624,15 +624,15 @@ wants a VM from source to migrate into this planned VM.")] } return new VirtualSystemMigrationSettingDataCollection(clsObject.GetInstances(enumOptions)); } - + public static VirtualSystemMigrationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition) { return GetInstances(mgmtScope, condition, null); } - + public static VirtualSystemMigrationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string[] selectedProperties) { return GetInstances(mgmtScope, null, selectedProperties); } - + public static VirtualSystemMigrationSettingDataCollection GetInstances(System.Management.ManagementScope mgmtScope, string condition, string[] selectedProperties) { if ((mgmtScope == null)) { if ((statMgmtScope == null)) { @@ -649,7 +649,7 @@ wants a VM from source to migrate into this planned VM.")] ObjectSearcher.Options = enumOptions; return new VirtualSystemMigrationSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static VirtualSystemMigrationSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -664,56 +664,56 @@ wants a VM from source to migrate into this planned VM.")] System.Management.ManagementClass tmpMgmtClass = new System.Management.ManagementClass(mgmtScope, mgmtPath, null); return new VirtualSystemMigrationSettingData(tmpMgmtClass.CreateInstance()); } - + [Browsable(true)] public void Delete() { PrivateLateBoundObject.Delete(); } - + public enum MigrationTypeValues { - + Unknown0 = 0, - + VirtualSystem = 32768, - + Storage = 32769, - + Staged = 32770, - + VirtualSystemAndStorage = 32771, - + StorageDeepCheck = 32772, - + NULL_ENUM_VALUE = 32773, } - + // Enumerator implementation for enumerating instances of the class. public class VirtualSystemMigrationSettingDataCollection : object, ICollection { - + private ManagementObjectCollection privColObj; - + public VirtualSystemMigrationSettingDataCollection(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; @@ -721,189 +721,189 @@ wants a VM from source to migrate into this planned VM.")] array.SetValue(new VirtualSystemMigrationSettingData(((System.Management.ManagementObject)(array.GetValue(nCtr)))), nCtr); } } - + public virtual System.Collections.IEnumerator GetEnumerator() { return new VirtualSystemMigrationSettingDataEnumerator(privColObj.GetEnumerator()); } - + public class VirtualSystemMigrationSettingDataEnumerator : object, System.Collections.IEnumerator { - + private ManagementObjectCollection.ManagementObjectEnumerator privObjEnum; - + public VirtualSystemMigrationSettingDataEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum) { privObjEnum = objEnum; } - + public virtual object Current { get { return new VirtualSystemMigrationSettingData(((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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { 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 index 4877957ad6b..bc1e1fd3618 100644 --- 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 @@ -23,8 +23,8 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset are added for Nullable Read/Write properties. These functions are used by VS designer in property browser to set a property to NULL. @@ -32,62 +32,62 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { // 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)) { @@ -99,7 +99,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + public VirtualSystemSettingData(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -112,7 +112,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -121,7 +121,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return "ROOT\\virtualization\\v2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -130,7 +130,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -139,7 +139,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -148,7 +148,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -157,7 +157,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -176,7 +176,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // 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)] @@ -188,7 +188,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -209,7 +209,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -221,7 +221,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.VIRTUALIZATION.V2 { 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. @@ -232,13 +232,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["AdditionalRecoveryInformation"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAllowFullSCSICommandSetNull { @@ -251,7 +251,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [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. @@ -267,13 +267,13 @@ Windows Server 2008: The AllowFullSCSICommandSet property is not supported.")] } set { curObj["AllowFullSCSICommandSet"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAllowReducedFcRedundancyNull { @@ -286,11 +286,11 @@ Windows Server 2008: The AllowFullSCSICommandSet property is not supported.")] } } } - + [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. + [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 { @@ -302,13 +302,13 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } set { curObj["AllowReducedFcRedundancy"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticRecoveryActionNull { @@ -321,7 +321,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -333,7 +333,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live return ((ushort)(curObj["AutomaticRecoveryAction"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticShutdownActionNull { @@ -346,7 +346,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -358,7 +358,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live return ((ushort)(curObj["AutomaticShutdownAction"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticStartupActionNull { @@ -371,7 +371,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -383,7 +383,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live return ((ushort)(curObj["AutomaticStartupAction"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticStartupActionDelayNull { @@ -396,7 +396,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -410,7 +410,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAutomaticStartupActionSequenceNumberNull { @@ -423,7 +423,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -435,7 +435,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live 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" + @@ -447,13 +447,13 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } set { curObj["BaseBoardSerialNumber"] = value; - if (((isEmbedded == false) + 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 " + @@ -465,13 +465,13 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } set { curObj["BIOSGUID"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsBIOSNumLockNull { @@ -484,7 +484,7 @@ The default value of this property is FALSE. If set to TRUE, the VM can be live } } } - + [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. @@ -499,13 +499,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["BIOSNumLock"] = value; - if (((isEmbedded == false) + 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" + @@ -517,13 +517,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["BIOSSerialNumber"] = value; - if (((isEmbedded == false) + 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]. @@ -541,13 +541,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["BootOrder"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Caption { @@ -555,7 +555,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste 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" + @@ -567,13 +567,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["ChassisAssetTag"] = value; - if (((isEmbedded == false) + 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-" + @@ -585,13 +585,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["ChassisSerialNumber"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ConfigurationDataRoot { @@ -599,7 +599,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["ConfigurationDataRoot"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ConfigurationFile { @@ -607,7 +607,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["ConfigurationFile"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ConfigurationID { @@ -615,7 +615,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["ConfigurationID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsCreationTimeNull { @@ -628,7 +628,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -642,7 +642,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDebugChannelIdNull { @@ -655,7 +655,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The channel identifier used to debug the virtual system using the VUD unified deb" + @@ -670,13 +670,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["DebugChannelId"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDebugPortNull { @@ -689,7 +689,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The tcpip port used to debug the virtual system using synthetic debugging.")] @@ -703,13 +703,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["DebugPort"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDebugPortEnabledNull { @@ -722,7 +722,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Whether the virtual system is using synthetic debugging.")] @@ -741,13 +741,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste else { curObj["DebugPortEnabled"] = value; } - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Description { @@ -755,7 +755,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["Description"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ElementName { @@ -763,7 +763,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["ElementName"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsIncrementalBackupEnabledNull { @@ -776,7 +776,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Indicates whether the Hyper-V VSS writer supports taking incremental backup of th" + @@ -791,13 +791,13 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } set { curObj["IncrementalBackupEnabled"] = value; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string InstanceID { @@ -805,7 +805,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste return ((string)(curObj["InstanceID"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsIsSavedNull { @@ -818,7 +818,7 @@ This is a read-only property, but it can be changed using the ModifyVirtualSyste } } } - + [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. @@ -832,7 +832,7 @@ This is a read-only property, it cannot be changed.")] return ((bool)(curObj["IsSaved"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string LogDataRoot { @@ -840,7 +840,7 @@ This is a read-only property, it cannot be changed.")] return ((string)(curObj["LogDataRoot"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string[] Notes { @@ -848,7 +848,7 @@ This is a read-only property, it cannot be changed.")] return ((string[])(curObj["Notes"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("The object path for the snapshot Msvm_VirtualSystemSettingData from which this ob" + @@ -859,7 +859,7 @@ This is a read-only property, it cannot be changed.")] return ((string)(curObj["Parent"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string RecoveryFile { @@ -867,7 +867,7 @@ This is a read-only property, it cannot be changed.")] return ((string)(curObj["RecoveryFile"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SnapshotDataRoot { @@ -875,7 +875,7 @@ This is a read-only property, it cannot be changed.")] return ((string)(curObj["SnapshotDataRoot"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SuspendDataRoot { @@ -883,7 +883,7 @@ This is a read-only property, it cannot be changed.")] return ((string)(curObj["SuspendDataRoot"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string SwapFileDataRoot { @@ -891,7 +891,7 @@ This is a read-only property, it cannot be changed.")] 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\"" + @@ -901,7 +901,7 @@ This is a read-only property, it cannot be changed.")] return ((string)(curObj["Version"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsVirtualNumaEnabledNull { @@ -914,7 +914,7 @@ This is a read-only property, it cannot be changed.")] } } } - + [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. @@ -929,13 +929,13 @@ This is a read-only property, it cannot be changed.")] } set { curObj["VirtualNumaEnabled"] = value; - if (((isEmbedded == false) + 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")] @@ -944,7 +944,7 @@ This is a read-only property, it cannot be changed.")] return ((string)(curObj["VirtualSystemIdentifier"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string VirtualSystemType { @@ -952,9 +952,9 @@ This is a read-only property, it cannot be changed.")] return ((string)(curObj["VirtualSystemType"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -962,9 +962,9 @@ This is a read-only property, it cannot be changed.")] return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -981,66 +981,66 @@ This is a read-only property, it cannot be changed.")] } return false; } - + private void ResetAdditionalRecoveryInformation() { curObj["AdditionalRecoveryInformation"] = null; - if (((isEmbedded == false) + 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) + 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) + 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; @@ -1092,13 +1092,13 @@ This is a read-only property, it cannot be changed.")] 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)) + if (((((((((year < 0) + || (month < 0)) + || (day < 0)) + || (hour < 0)) + || (minute < 0)) + || (minute < 0)) + || (second < 0)) || (ticks < 0))) { throw new System.ArgumentOutOfRangeException(); } @@ -1126,7 +1126,7 @@ This is a read-only property, it cannot be changed.")] } return datetime; } - + // Converts a given System.DateTime object to DMTF datetime format. static string ToDmtfDateTime(System.DateTime date) { string utcString = string.Empty; @@ -1153,8 +1153,8 @@ This is a read-only property, it cannot be changed.")] 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) + long microsec = ((long)((((date.Ticks - dtTemp.Ticks) + * 1000) / System.TimeSpan.TicksPerMillisecond))); string strMicrosec = ((long)(microsec)).ToString(); if ((strMicrosec.Length > 6)) { @@ -1164,198 +1164,198 @@ This is a read-only property, it cannot be changed.")] 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) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetBIOSGUID() { curObj["BIOSGUID"] = null; - if (((isEmbedded == false) + 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) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetBIOSSerialNumber() { curObj["BIOSSerialNumber"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetBootOrder() { curObj["BootOrder"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetChassisAssetTag() { curObj["ChassisAssetTag"] = null; - if (((isEmbedded == false) + if (((isEmbedded == false) && (AutoCommitProp == true))) { PrivateLateBoundObject.Put(); } } - + private void ResetChassisSerialNumber() { curObj["ChassisSerialNumber"] = null; - if (((isEmbedded == false) + 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) + 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) + 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) + 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) + 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) + 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)) { @@ -1367,24 +1367,24 @@ This is a read-only property, it cannot be changed.")] 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)) { @@ -1405,15 +1405,15 @@ This is a read-only property, it cannot be changed.")] } 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)) { @@ -1430,7 +1430,7 @@ This is a read-only property, it cannot be changed.")] ObjectSearcher.Options = enumOptions; return new VirtualSystemSettingDataCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static VirtualSystemSettingData CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1445,50 +1445,50 @@ This is a read-only property, it cannot be changed.")] 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; @@ -1496,189 +1496,189 @@ This is a read-only property, it cannot be changed.")] 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { 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 index 0cf3735712e..4d7ffc9cb3f 100644 --- 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 @@ -23,70 +23,70 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { using System.Globalization; using System.ComponentModel.Design.Serialization; using System.Reflection; - - + + // Functions ShouldSerialize 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 IsNull 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 IsNull() are used to check if a property is NULL. // Functions Reset 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)) { @@ -98,7 +98,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { throw new System.ArgumentException("Class name does not match."); } } - + public PerfFormattedData_Counters_ProcessorInformation(System.Management.ManagementBaseObject theObject) { Initialize(); if ((CheckIfProperClass(theObject) == true)) { @@ -111,7 +111,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { throw new System.ArgumentException("Class name does not match."); } } - + // Property returns the namespace of the WMI class. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -120,7 +120,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return "root\\CIMV2"; } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string ManagementClassName { @@ -129,7 +129,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { if ((curObj != null)) { if ((curObj.ClassPath != null)) { strRet = ((string)(curObj["__CLASS"])); - if (((strRet == null) + if (((strRet == null) || (strRet == string.Empty))) { strRet = CreatedClassName; } @@ -138,7 +138,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return strRet; } } - + // Property pointing to an embedded object to get System properties of the WMI object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -147,7 +147,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return PrivateSystemProperties; } } - + // Property returning the underlying lateBound object. [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -156,7 +156,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return curObj; } } - + // ManagementScope of the object. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -175,7 +175,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + // 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)] @@ -187,7 +187,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { AutoCommitProp = value; } } - + // The ManagementPath of the underlying WMI object. [Browsable(true)] public System.Management.ManagementPath Path { @@ -208,7 +208,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + // Public static scope property which is used by the various methods. [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -220,7 +220,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { statMgmtScope = value; } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsAverageIdleTimeNull { @@ -233,7 +233,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Average Idle Time is the average idle duration in 100ns units observed between th" + @@ -247,7 +247,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["AverageIdleTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsC1TransitionsPersecNull { @@ -260,7 +260,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -273,7 +273,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["C1TransitionsPersec"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsC2TransitionsPersecNull { @@ -286,7 +286,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -299,7 +299,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["C2TransitionsPersec"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsC3TransitionsPersecNull { @@ -312,7 +312,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -325,7 +325,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["C3TransitionsPersec"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("A short textual description (one-line string) for the statistic or metric.")] @@ -334,7 +334,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((string)(curObj["Caption"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsClockInterruptsPersecNull { @@ -347,7 +347,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -360,7 +360,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["ClockInterruptsPersec"])); } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("A textual description of the statistic or metric.")] @@ -369,7 +369,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((string)(curObj["Description"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDPCRateNull { @@ -382,7 +382,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -395,7 +395,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["DPCRate"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsDPCsQueuedPersecNull { @@ -408,7 +408,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -421,7 +421,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["DPCsQueuedPersec"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFrequency_ObjectNull { @@ -434,7 +434,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -446,7 +446,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["Frequency_Object"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFrequency_PerfTimeNull { @@ -459,7 +459,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -471,7 +471,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["Frequency_PerfTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsFrequency_Sys100NSNull { @@ -484,7 +484,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -496,7 +496,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["Frequency_Sys100NS"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsIdleBreakEventsPersecNull { @@ -509,7 +509,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Idle Break Events/sec is the average rate, in incidents per second, at which the " + @@ -525,7 +525,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["IdleBreakEventsPersec"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsInterruptsPersecNull { @@ -538,7 +538,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -551,7 +551,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { 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" + @@ -561,7 +561,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((string)(curObj["Name"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsParkingStatusNull { @@ -574,7 +574,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Parking Status represents whether a processor is parked or not.")] @@ -587,7 +587,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["ParkingStatus"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentC1TimeNull { @@ -600,7 +600,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -613,7 +613,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentC1Time"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentC2TimeNull { @@ -626,7 +626,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -639,7 +639,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentC2Time"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentC3TimeNull { @@ -652,7 +652,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -665,7 +665,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentC3Time"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentDPCTimeNull { @@ -678,7 +678,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -691,7 +691,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentDPCTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentIdleTimeNull { @@ -704,7 +704,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("% Idle Time is the percentage of time the processor is idle during the sample int" + @@ -718,7 +718,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentIdleTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentInterruptTimeNull { @@ -731,7 +731,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -744,7 +744,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentInterruptTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentofMaximumFrequencyNull { @@ -757,7 +757,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("% of Maximum Frequency is the percentage of the current processor\'s maximum frequ" + @@ -771,7 +771,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["PercentofMaximumFrequency"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentPerformanceLimitNull { @@ -784,7 +784,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -797,7 +797,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["PercentPerformanceLimit"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentPriorityTimeNull { @@ -810,7 +810,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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 inaccurately as timers are signaled just after the sample is taken.")] @@ -823,7 +823,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentPriorityTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentPrivilegedTimeNull { @@ -836,7 +836,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -849,7 +849,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentPrivilegedTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentPrivilegedUtilityNull { @@ -862,7 +862,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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%.")] @@ -875,7 +875,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentPrivilegedUtility"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentProcessorPerformanceNull { @@ -888,7 +888,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Processor Performance is the average performance of the processor while it is exe" + @@ -903,7 +903,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentProcessorPerformance"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentProcessorTimeNull { @@ -916,7 +916,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -929,7 +929,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentProcessorTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentProcessorUtilityNull { @@ -942,7 +942,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Processor Utility is the amount of work a processor is completing, as a percentag" + @@ -958,7 +958,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentProcessorUtility"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPercentUserTimeNull { @@ -971,7 +971,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [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.")] @@ -984,7 +984,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["PercentUserTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsPerformanceLimitFlagsNull { @@ -997,7 +997,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Performance Limit Flags indicate reasons why the processor performance was limite" + @@ -1011,7 +1011,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["PerformanceLimitFlags"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsProcessorFrequencyNull { @@ -1024,7 +1024,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Processor Frequency is the frequency of the current processor in megahertz.")] @@ -1037,7 +1037,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["ProcessorFrequency"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsProcessorStateFlagsNull { @@ -1050,7 +1050,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [Description("Processor State Flags")] @@ -1063,7 +1063,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((uint)(curObj["ProcessorStateFlags"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimestamp_ObjectNull { @@ -1076,7 +1076,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1088,7 +1088,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["Timestamp_Object"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimestamp_PerfTimeNull { @@ -1101,7 +1101,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1113,7 +1113,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["Timestamp_PerfTime"])); } } - + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool IsTimestamp_Sys100NSNull { @@ -1126,7 +1126,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } } } - + [Browsable(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] [TypeConverter(typeof(WMIValueTypeConverter))] @@ -1138,9 +1138,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return ((ulong)(curObj["Timestamp_Sys100NS"])); } } - + private bool CheckIfProperClass(System.Management.ManagementScope mgmtScope, System.Management.ManagementPath path, System.Management.ObjectGetOptions OptionsParam) { - if (((path != null) + if (((path != null) && (string.Compare(path.ClassName, this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1148,9 +1148,9 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { return CheckIfProperClass(new System.Management.ManagementObject(mgmtScope, path, OptionsParam)); } } - + private bool CheckIfProperClass(System.Management.ManagementBaseObject theObj) { - if (((theObj != null) + if (((theObj != null) && (string.Compare(((string)(theObj["__CLASS"])), this.ManagementClassName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))) { return true; } @@ -1167,270 +1167,270 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } 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)) { @@ -1442,24 +1442,24 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { 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)) { @@ -1480,15 +1480,15 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { } 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)) { @@ -1505,7 +1505,7 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { ObjectSearcher.Options = enumOptions; return new PerfFormattedData_Counters_ProcessorInformationCollection(ObjectSearcher.Get()); } - + [Browsable(true)] public static PerfFormattedData_Counters_ProcessorInformation CreateInstance() { System.Management.ManagementScope mgmtScope = null; @@ -1520,39 +1520,39 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { 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; @@ -1560,189 +1560,189 @@ namespace CloudStack.Plugin.WmiWrappers.ROOT.CIMV2 { 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)) + 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)) + if (((baseType == typeof(bool)) && (baseType.BaseType == typeof(System.ValueType)))) { - if ((((value == null) - && (context != null)) + if ((((value == null) + && (context != null)) && (context.PropertyDescriptor.ShouldSerializeValue(context.Instance) == false))) { return ""; } return baseConverter.ConvertTo(context, culture, value, destinationType); } - if (((context != null) + 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 { diff --git a/plugins/hypervisors/hyperv/pom.xml b/plugins/hypervisors/hyperv/pom.xml index 56b2b6d1503..76026b31845 100644 --- a/plugins/hypervisors/hyperv/pom.xml +++ b/plugins/hypervisors/hyperv/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml index f1eb4ea8c4f..08ad50ce2cb 100644 --- a/plugins/hypervisors/kvm/pom.xml +++ b/plugins/hypervisors/kvm/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.20.0.0-SNAPSHOT + 4.21.0.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index abd6e24a532..ca3395be5dc 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -381,6 +381,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv protected static final String DEFAULT_TUNGSTEN_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.VRouterVifDriver"; private final static long HYPERVISOR_LIBVIRT_VERSION_SUPPORTS_IO_URING = 6003000; private final static long HYPERVISOR_QEMU_VERSION_SUPPORTS_IO_URING = 5000000; + private final static long HYPERVISOR_QEMU_VERSION_IDE_DISCARD_FIXED = 7000000; protected HypervisorType hypervisorType; protected String hypervisorURI; @@ -1030,7 +1031,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv hostHealthCheckScriptPath = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.HEALTH_CHECK_SCRIPT_PATH); if (StringUtils.isNotBlank(hostHealthCheckScriptPath) && !new File(hostHealthCheckScriptPath).exists()) { - logger.info(String.format("Unable to find the host health check script at: %s, " + + LOGGER.info(String.format("Unable to find the host health check script at: %s, " + "discarding it", hostHealthCheckScriptPath)); } @@ -2795,11 +2796,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (hostCpuMaxCapacity > 0) { int updatedCpuShares = (int) Math.ceil((requestedCpuShares * CGROUP_V2_UPPER_LIMIT) / (double) hostCpuMaxCapacity); - logger.debug(String.format("This host utilizes cgroupv2 (as the max shares value is [%s]), thus, the VM requested shares of [%s] will be converted to " + + LOGGER.debug(String.format("This host utilizes cgroupv2 (as the max shares value is [%s]), thus, the VM requested shares of [%s] will be converted to " + "consider the host limits; the new CPU shares value is [%s].", hostCpuMaxCapacity, requestedCpuShares, updatedCpuShares)); return updatedCpuShares; } - logger.debug(String.format("This host does not have a maximum CPU shares set; therefore, this host utilizes cgroupv1 and the VM requested CPU shares [%s] will not be " + + LOGGER.debug(String.format("This host does not have a maximum CPU shares set; therefore, this host utilizes cgroupv1 and the VM requested CPU shares [%s] will not be " + "converted.", requestedCpuShares)); return requestedCpuShares; } @@ -2930,7 +2931,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv LOGGER.warn(String.format("Setting System VM's [%s] current memory as max memory [%s].", vmTO.toString(), maxRam)); } else { long minRam = ByteScaleUtils.bytesToKibibytes(vmTO.getMinRam()); - logger.debug(String.format("Setting VM's [%s] current memory as min memory [%s] due to memory ballooning is enabled.", vmTO.toString(), minRam)); + LOGGER.debug(String.format("Setting VM's [%s] current memory as min memory [%s] due to memory ballooning is enabled.", vmTO.toString(), minRam)); retVal = minRam; } return retVal; @@ -2999,6 +3000,18 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return dataPath; } + public static boolean useBLOCKDiskType(KVMPhysicalDisk physicalDisk) { + return physicalDisk != null && + physicalDisk.getPool() != null && + StoragePoolType.Linstor.equals(physicalDisk.getPool().getType()) && + physicalDisk.getFormat() != null && + PhysicalDiskFormat.RAW.equals(physicalDisk.getFormat()); + } + + public static DiskDef.DiskType getDiskType(KVMPhysicalDisk physicalDisk) { + return useBLOCKDiskType(physicalDisk) ? DiskDef.DiskType.BLOCK : DiskDef.DiskType.FILE; + } + public void createVbd(final Connect conn, final VirtualMachineTO vmSpec, final String vmName, final LibvirtVMDef vm) throws InternalErrorException, LibvirtException, URISyntaxException { final Map details = vmSpec.getDetails(); final List disks = Arrays.asList(vmSpec.getDisks()); @@ -3044,13 +3057,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv physicalDisk = getPhysicalDiskFromNfsStore(dataStoreUrl, data); } else if (primaryDataStoreTO.getPoolType().equals(StoragePoolType.SharedMountPoint) || primaryDataStoreTO.getPoolType().equals(StoragePoolType.Filesystem) || - primaryDataStoreTO.getPoolType().equals(StoragePoolType.StorPool)) { + primaryDataStoreTO.getPoolType().equals(StoragePoolType.StorPool) || + primaryDataStoreTO.getPoolType().equals(StoragePoolType.Linstor)) { physicalDisk = getPhysicalDiskPrimaryStore(primaryDataStoreTO, data); } } } else if (volume.getType() != Volume.Type.ISO) { final PrimaryDataStoreTO store = (PrimaryDataStoreTO)data.getDataStore(); - physicalDisk = storagePoolManager.getPhysicalDisk(store.getPoolType(), store.getUuid(), data.getPath()); + physicalDisk = getStoragePoolMgr().getPhysicalDisk(store.getPoolType(), store.getUuid(), data.getPath()); pool = physicalDisk.getPool(); } @@ -3094,8 +3108,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv final DiskDef disk = new DiskDef(); int devId = volume.getDiskSeq().intValue(); if (volume.getType() == Volume.Type.ISO) { - - disk.defISODisk(volPath, devId, isUefiEnabled); + final DiskDef.DiskType diskType = getDiskType(physicalDisk); + disk.defISODisk(volPath, devId, isUefiEnabled, diskType); if (guestCpuArch != null && guestCpuArch.equals("aarch64")) { disk.setBusType(DiskDef.DiskBus.SCSI); @@ -3152,6 +3166,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv else { disk.defBlockBasedDisk(physicalDisk.getPath(), devId, diskBusType); } + if (pool.getType() == StoragePoolType.Linstor && isQemuDiscardBugFree(diskBusType)) { + disk.setDiscard(DiscardType.UNMAP); + } } else { if (volume.getType() == Volume.Type.DATADISK && !(isWindowsTemplate && isUefiEnabled)) { disk.defFileBasedDisk(physicalDisk.getPath(), devId, diskBusTypeData, DiskDef.DiskFmtType.QCOW2); @@ -3191,7 +3208,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (vmSpec.getType() != VirtualMachine.Type.User) { final DiskDef iso = new DiskDef(); - iso.defISODisk(sysvmISOPath); + iso.defISODisk(sysvmISOPath, DiskDef.DiskType.FILE); if (guestCpuArch != null && guestCpuArch.equals("aarch64")) { iso.setBusType(DiskDef.DiskBus.SCSI); } @@ -3267,7 +3284,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv * (ii) Libvirt >= 6.3.0 */ public void setDiskIoDriver(DiskDef disk, IoDriverPolicy ioDriver) { - logger.debug(String.format("Disk IO driver policy [%s]. The host supports the io_uring policy [%s]", ioDriver, enableIoUring)); + LOGGER.debug(String.format("Disk IO driver policy [%s]. The host supports the io_uring policy [%s]", ioDriver, enableIoUring)); if (ioDriver != null) { if (IoDriverPolicy.IO_URING != ioDriver) { disk.setIoDriver(ioDriver); @@ -3296,6 +3313,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return isUbuntuHost() || isIoUringSupportedByQemu(); } + /** + * Qemu has a bug with discard enabled on IDE bus devices if qemu version < 7.0. + * redhat bug entry + * @param diskBus used for the disk + * @return true if it is safe to enable discard, otherwise false. + */ + public boolean isQemuDiscardBugFree(DiskDef.DiskBus diskBus) { + return diskBus != DiskDef.DiskBus.IDE || getHypervisorQemuVersion() >= HYPERVISOR_QEMU_VERSION_IDE_DISCARD_FIXED; + } + public boolean isUbuntuHost() { Map versionString = getVersionStrings(); String hostKey = "Host.OS"; @@ -3394,19 +3421,21 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv List disks = getDisks(conn, vmName); DiskDef configdrive = null; for (DiskDef disk : disks) { - if (disk.getDeviceType() == DiskDef.DeviceType.CDROM && disk.getDiskLabel() == CONFIG_DRIVE_ISO_DISK_LABEL) { + if (disk.getDeviceType() == DiskDef.DeviceType.CDROM && CONFIG_DRIVE_ISO_DISK_LABEL.equals(disk.getDiskLabel())) { configdrive = disk; } } if (configdrive != null) { try { + LOGGER.debug(String.format("Detaching ConfigDrive ISO of the VM %s, at path %s", vmName, configdrive.getDiskPath())); String result = attachOrDetachISO(conn, vmName, configdrive.getDiskPath(), false, CONFIG_DRIVE_ISO_DEVICE_ID); if (result != null) { - LOGGER.warn("Detach ConfigDrive ISO with result: " + result); + LOGGER.warn("Detach ConfigDrive ISO of the VM {}, at path {} with result: {}", vmName, configdrive.getDiskPath(), result); } + LOGGER.debug(String.format("Attaching ConfigDrive ISO of the VM %s, at path %s", vmName, configdrive.getDiskPath())); result = attachOrDetachISO(conn, vmName, configdrive.getDiskPath(), true, CONFIG_DRIVE_ISO_DEVICE_ID); if (result != null) { - LOGGER.warn("Attach ConfigDrive ISO with result: " + result); + LOGGER.warn("Attach ConfigDrive ISO of the VM {}, at path {} with result: {}", vmName, configdrive.getDiskPath(), result); } } catch (final LibvirtException | InternalErrorException | URISyntaxException e) { final String msg = "Detach and attach ConfigDrive ISO failed due to " + e.toString(); @@ -3418,17 +3447,22 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv public synchronized String attachOrDetachISO(final Connect conn, final String vmName, String isoPath, final boolean isAttach, final Integer diskSeq) throws LibvirtException, URISyntaxException, InternalErrorException { final DiskDef iso = new DiskDef(); - if (isoPath != null && isAttach) { - final int index = isoPath.lastIndexOf("/"); - final String path = isoPath.substring(0, index); - final String name = isoPath.substring(index + 1); - final KVMStoragePool secondaryPool = storagePoolManager.getStoragePoolByURI(path); - final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name); - isoPath = isoVol.getPath(); + if (isAttach && StringUtils.isNotBlank(isoPath) && isoPath.lastIndexOf("/") > 0) { + if (isoPath.startsWith(getConfigPath() + "/" + ConfigDrive.CONFIGDRIVEDIR) && isoPath.contains(vmName)) { + iso.defISODisk(isoPath, diskSeq, DiskDef.DiskType.FILE); + } else { + final int index = isoPath.lastIndexOf("/"); + final String path = isoPath.substring(0, index); + final String name = isoPath.substring(index + 1); + final KVMStoragePool storagePool = storagePoolManager.getStoragePoolByURI(path); + final KVMPhysicalDisk isoVol = storagePool.getPhysicalDisk(name); + final DiskDef.DiskType diskType = getDiskType(isoVol); + isoPath = isoVol.getPath(); - iso.defISODisk(isoPath, diskSeq); + iso.defISODisk(isoPath, diskSeq, diskType); + } } else { - iso.defISODisk(null, diskSeq); + iso.defISODisk(null, diskSeq, DiskDef.DiskType.FILE); } final String result = attachOrDetachDevice(conn, true, vmName, iso.toString()); @@ -3436,7 +3470,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv final List disks = getDisks(conn, vmName); for (final DiskDef disk : disks) { if (disk.getDeviceType() == DiskDef.DeviceType.CDROM - && (diskSeq == null || disk.getDiskLabel() == iso.getDiskLabel())) { + && (diskSeq == null || disk.getDiskLabel().equals(iso.getDiskLabel()))) { cleanupDisk(disk); } } @@ -3498,6 +3532,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, busT, DiskDef.DiskFmtType.QCOW2); } else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) { diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, busT); + if (attachingPool.getType() == StoragePoolType.Linstor) { + diskdef.setDiscard(DiscardType.UNMAP); + } } if (bytesReadRate != null && bytesReadRate > 0) { diskdef.setBytesReadRate(bytesReadRate); @@ -3610,19 +3647,19 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv */ private HealthCheckResult getHostHealthCheckResult() { if (StringUtils.isBlank(hostHealthCheckScriptPath)) { - logger.debug("Host health check script path is not specified"); + LOGGER.debug("Host health check script path is not specified"); return HealthCheckResult.IGNORE; } File script = new File(hostHealthCheckScriptPath); if (!script.exists() || !script.isFile() || !script.canExecute()) { - logger.warn(String.format("The host health check script file set at: %s cannot be executed, " + + LOGGER.warn(String.format("The host health check script file set at: %s cannot be executed, " + "reason: %s", hostHealthCheckScriptPath, !script.exists() ? "file does not exist" : "please check file permissions to execute this file")); return HealthCheckResult.IGNORE; } int exitCode = executeBashScriptAndRetrieveExitValue(hostHealthCheckScriptPath); - if (logger.isDebugEnabled()) { - logger.debug(String.format("Host health check script exit code: %s", exitCode)); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(String.format("Host health check script exit code: %s", exitCode)); } return retrieveHealthCheckResultFromExitCode(exitCode); } @@ -3731,17 +3768,17 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv */ protected void calculateHostCpuMaxCapacity(int cpuCores, Long cpuSpeed) { String output = Script.runSimpleBashScript(COMMAND_GET_CGROUP_HOST_VERSION); - logger.info(String.format("Host uses control group [%s].", output)); + LOGGER.info(String.format("Host uses control group [%s].", output)); if (!CGROUP_V2.equals(output)) { - logger.info(String.format("Setting host CPU max capacity to 0, as it uses cgroup v1.", getHostCpuMaxCapacity())); + LOGGER.info(String.format("Setting host CPU max capacity to 0, as it uses cgroup v1.", getHostCpuMaxCapacity())); setHostCpuMaxCapacity(0); return; } - logger.info(String.format("Calculating the max shares of the host.")); + LOGGER.info(String.format("Calculating the max shares of the host.")); setHostCpuMaxCapacity(cpuCores * cpuSpeed.intValue()); - logger.info(String.format("The max shares of the host is [%d].", getHostCpuMaxCapacity())); + LOGGER.info(String.format("The max shares of the host is [%d].", getHostCpuMaxCapacity())); } private StartupStorageCommand createLocalStoragePool(String localStoragePath, String localStorageUUID, StartupRoutingCommand cmd) { @@ -3804,7 +3841,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv String sourcePath = null; try { String mountResult = Script.runSimpleBashScript("mount | grep \"" + diskPath + "\""); - logger.debug("Got mount result for " + diskPath + "\n\n" + mountResult); + LOGGER.debug("Got mount result for " + diskPath + "\n\n" + mountResult); if (StringUtils.isNotEmpty(mountResult)) { String[] res = mountResult.strip().split(" "); if (res[0].contains(":")) { @@ -3821,7 +3858,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return new Pair<>(sourceHostIp, sourcePath); } } catch (Exception ex) { - logger.warn("Failed to list source host and IP for " + diskPath + ex.toString()); + LOGGER.warn("Failed to list source host and IP for " + diskPath + ex.toString()); } return null; } @@ -3834,14 +3871,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv domainNames.add(names[i]); } } catch (final LibvirtException e) { - logger.warn("Failed to list defined domains", e); + LOGGER.warn("Failed to list defined domains", e); } int[] ids = null; try { ids = conn.listDomains(); } catch (final LibvirtException e) { - logger.warn("Failed to list domains", e); + LOGGER.warn("Failed to list domains", e); return domainNames; } @@ -4029,7 +4066,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return stopVMInternal(conn, vmName, true); } String ret = stopVMInternal(conn, vmName, false); - if (ret == Script.ERR_TIMEOUT) { + if (Script.ERR_TIMEOUT.equals(ret)) { ret = stopVMInternal(conn, vmName, true); } else if (ret != null) { /* @@ -4929,7 +4966,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv public boolean setupTungstenVRouter(final String oper, final String inf, final String subnet, final String route, final String vrf) { - final Script cmd = new Script(setupTungstenVrouterPath, timeout, logger); + final Script cmd = new Script(setupTungstenVrouterPath, timeout, LOGGER); cmd.add(oper); cmd.add(inf); cmd.add(subnet); @@ -4942,7 +4979,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv public boolean updateTungstenLoadbalancerStats(final String lbUuid, final String lbStatsPort, final String lbStatsUri, final String lbStatsAuth) { - final Script cmd = new Script(updateTungstenLoadbalancerStatsPath, timeout, logger); + final Script cmd = new Script(updateTungstenLoadbalancerStatsPath, timeout, LOGGER); cmd.add(lbUuid); cmd.add(lbStatsPort); cmd.add(lbStatsUri); @@ -4954,7 +4991,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv public boolean updateTungstenLoadbalancerSsl(final String lbUuid, final String sslCertName, final String certificateKey, final String privateKey, final String privateIp, final String port) { - final Script cmd = new Script(updateTungstenLoadbalancerSslPath, timeout, logger); + final Script cmd = new Script(updateTungstenLoadbalancerSslPath, timeout, LOGGER); cmd.add(lbUuid); cmd.add(sslCertName); cmd.add(certificateKey); @@ -4967,7 +5004,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } public boolean setupTfRoute(final String privateIpAddress, final String fromNetwork, final String toNetwork) { - final Script setupTfRouteScript = new Script(routerProxyPath, timeout, logger); + final Script setupTfRouteScript = new Script(routerProxyPath, timeout, LOGGER); setupTfRouteScript.add("setup_tf_route.py"); setupTfRouteScript.add(privateIpAddress); setupTfRouteScript.add(fromNetwork); @@ -4976,7 +5013,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv final OutputInterpreter.OneLineParser setupTfRouteParser = new OutputInterpreter.OneLineParser(); final String result = setupTfRouteScript.execute(setupTfRouteParser); if (result != null) { - logger.debug("Failed to execute setup TF Route:" + result); + LOGGER.debug("Failed to execute setup TF Route:" + result); return false; } return true; @@ -5495,7 +5532,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv interfaceDef.setMultiQueueNumber(nicMultiqueueNumberInteger); } } catch (NumberFormatException ex) { - logger.warn(String.format("VM details %s is not a valid integer value %s", VmDetailConstants.NIC_MULTIQUEUE_NUMBER, nicMultiqueueNumber)); + LOGGER.warn(String.format("VM details %s is not a valid integer value %s", VmDetailConstants.NIC_MULTIQUEUE_NUMBER, nicMultiqueueNumber)); } } String nicPackedEnabled = details.get(VmDetailConstants.NIC_PACKED_VIRTQUEUES_ENABLED); @@ -5503,7 +5540,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv try { interfaceDef.setPackedVirtQueues(Boolean.valueOf(nicPackedEnabled)); } catch (NumberFormatException ex) { - logger.warn(String.format("VM details %s is not a valid Boolean value %s", VmDetailConstants.NIC_PACKED_VIRTQUEUES_ENABLED, nicPackedEnabled)); + LOGGER.warn(String.format("VM details %s is not a valid Boolean value %s", VmDetailConstants.NIC_PACKED_VIRTQUEUES_ENABLED, nicPackedEnabled)); } } } @@ -5518,11 +5555,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv command.append(remoteFile); command.append(" " + tmpPath); command.append(outputFile); - logger.debug(String.format("Converting remote disk file: %s, output file: %s%s (timeout: %d secs)", remoteFile, tmpPath, outputFile, timeoutInSecs)); + LOGGER.debug(String.format("Converting remote disk file: %s, output file: %s%s (timeout: %d secs)", remoteFile, tmpPath, outputFile, timeoutInSecs)); SshHelper.sshExecute(srcIp, 22, username, null, password, command.toString(), timeoutInSecs * 1000); - logger.debug("Copying converted remote disk file " + outputFile + " to: " + localDir); + LOGGER.debug("Copying converted remote disk file " + outputFile + " to: " + localDir); SshHelper.scpFrom(srcIp, 22, username, null, password, localDir, tmpPath + outputFile); - logger.debug("Successfully copied converted remote disk file to: " + localDir + "/" + outputFile); + LOGGER.debug("Successfully copied converted remote disk file to: " + localDir + "/" + outputFile); return outputFile; } catch (Exception e) { try { diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java index 46620e77fda..c4d5ac48f6f 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java @@ -127,11 +127,10 @@ public class LibvirtDomainXMLParser { } def.defFileBasedDisk(diskFile, diskLabel, DiskDef.DiskBus.valueOf(bus.toUpperCase()), fmt); } else if (device.equalsIgnoreCase("cdrom")) { - def.defISODisk(diskFile, i+1, diskLabel); + def.defISODisk(diskFile, i+1, diskLabel, DiskDef.DiskType.FILE); } } else if (type.equalsIgnoreCase("block")) { - def.defBlockBasedDisk(diskDev, diskLabel, - DiskDef.DiskBus.valueOf(bus.toUpperCase())); + parseDiskBlock(def, device, diskDev, diskLabel, bus, diskFile, i); } if (StringUtils.isNotBlank(diskCacheMode)) { def.setCacheMode(DiskDef.DiskCacheMode.valueOf(diskCacheMode.toUpperCase())); @@ -450,6 +449,25 @@ public class LibvirtDomainXMLParser { return node.getAttribute(attr); } + /** + * Parse the disk block part of the libvirt XML. + * @param def + * @param device + * @param diskDev + * @param diskLabel + * @param bus + * @param diskFile + * @param curDiskIndex + */ + private void parseDiskBlock(DiskDef def, String device, String diskDev, String diskLabel, String bus, + String diskFile, int curDiskIndex) { + if (device.equalsIgnoreCase("disk")) { + def.defBlockBasedDisk(diskDev, diskLabel, DiskDef.DiskBus.valueOf(bus.toUpperCase())); + } else if (device.equalsIgnoreCase("cdrom")) { + def.defISODisk(diskFile, curDiskIndex+1, diskLabel, DiskDef.DiskType.BLOCK); + } + } + public Integer getVncPort() { return vncPort; } diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java index 09ee45d5908..4f8b2843ec2 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.CollectionUtils; public class LibvirtStoragePoolDef { public enum PoolType { - ISCSI("iscsi"), NETFS("netfs"), loggerICAL("logical"), DIR("dir"), RBD("rbd"), GLUSTERFS("glusterfs"), POWERFLEX("powerflex"); + ISCSI("iscsi"), NETFS("netfs"), LOGICAL("logical"), DIR("dir"), RBD("rbd"), GLUSTERFS("glusterfs"), POWERFLEX("powerflex"); String _poolType; PoolType(String poolType) { diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index 0f11c12f101..a67294ecadb 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -894,8 +894,8 @@ public class LibvirtVMDef { } } - public void defISODisk(String volPath) { - _diskType = DiskType.FILE; + public void defISODisk(String volPath, DiskType diskType) { + _diskType = diskType; _deviceType = DeviceType.CDROM; _sourcePath = volPath; _diskLabel = getDevLabel(3, DiskBus.IDE, true); @@ -904,8 +904,8 @@ public class LibvirtVMDef { _bus = DiskBus.IDE; } - public void defISODisk(String volPath, boolean isUefiEnabled) { - _diskType = DiskType.FILE; + public void defISODisk(String volPath, boolean isUefiEnabled, DiskType diskType) { + _diskType = diskType; _deviceType = DeviceType.CDROM; _sourcePath = volPath; _bus = isUefiEnabled ? DiskBus.SATA : DiskBus.IDE; @@ -914,18 +914,18 @@ public class LibvirtVMDef { _diskCacheMode = DiskCacheMode.NONE; } - public void defISODisk(String volPath, Integer devId) { - defISODisk(volPath, devId, null); + public void defISODisk(String volPath, Integer devId, DiskType diskType) { + defISODisk(volPath, devId, null, diskType); } - public void defISODisk(String volPath, Integer devId, String diskLabel) { + public void defISODisk(String volPath, Integer devId, String diskLabel, DiskType diskType) { if (devId == null && StringUtils.isBlank(diskLabel)) { LOGGER.debug(String.format("No ID or label informed for volume [%s].", volPath)); - defISODisk(volPath); + defISODisk(volPath, diskType); return; } - _diskType = DiskType.FILE; + _diskType = diskType; _deviceType = DeviceType.CDROM; _sourcePath = volPath; @@ -942,11 +942,11 @@ public class LibvirtVMDef { _bus = DiskBus.IDE; } - public void defISODisk(String volPath, Integer devId,boolean isSecure) { + public void defISODisk(String volPath, Integer devId, boolean isSecure, DiskType diskType) { if (!isSecure) { - defISODisk(volPath, devId); + defISODisk(volPath, devId, diskType); } else { - _diskType = DiskType.FILE; + _diskType = diskType; _deviceType = DeviceType.CDROM; _sourcePath = volPath; _diskLabel = getDevLabel(devId, DiskBus.SATA, true); diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java index ae8d06a1986..8f027e01ca4 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/MigrateKVMAsync.java @@ -123,8 +123,10 @@ public class MigrateKVMAsync implements Callable { if (migrateNonSharedInc) { flags |= VIR_MIGRATE_PERSIST_DEST; flags |= VIR_MIGRATE_NON_SHARED_INC; + logger.debug("Setting VIR_MIGRATE_NON_SHARED_INC for linked clone migration."); } else { flags |= VIR_MIGRATE_NON_SHARED_DISK; + logger.debug("Setting VIR_MIGRATE_NON_SHARED_DISK for full clone migration."); } } diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java index cc955e86d8a..3ba1bc11975 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java @@ -130,34 +130,25 @@ public class LibvirtConvertInstanceCommandWrapper extends CommandWrapper temporaryDisks = xmlParser == null ? - getTemporaryDisksWithPrefixFromTemporaryPool(temporaryStoragePool, temporaryConvertPath, temporaryConvertUuid) : - getTemporaryDisksFromParsedXml(temporaryStoragePool, xmlParser, convertedBasePath); - - List destinationDisks = moveTemporaryDisksToDestination(temporaryDisks, - destinationStoragePools, storagePoolMgr); - - cleanupDisksAndDomainFromTemporaryLocation(temporaryDisks, temporaryStoragePool, temporaryConvertUuid); - - UnmanagedInstanceTO convertedInstanceTO = getConvertedUnmanagedInstance(temporaryConvertUuid, - destinationDisks, xmlParser); - return new ConvertInstanceAnswer(cmd, convertedInstanceTO); + return new ConvertInstanceAnswer(cmd, temporaryConvertUuid); } catch (Exception e) { String error = String.format("Error converting instance %s from %s, due to: %s", sourceInstanceName, sourceHypervisorType, e.getMessage()); logger.error(error, e); + cleanupSecondaryStorage = true; return new ConvertInstanceAnswer(cmd, false, error); } finally { if (ovfExported && StringUtils.isNotBlank(ovfTemplateDirOnConversionLocation)) { @@ -165,7 +156,7 @@ public class LibvirtConvertInstanceCommandWrapper extends CommandWrapper commands = new ArrayList<>(); diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtImportConvertedInstanceCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtImportConvertedInstanceCommandWrapper.java new file mode 100644 index 00000000000..0eec15cf733 --- /dev/null +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtImportConvertedInstanceCommandWrapper.java @@ -0,0 +1,299 @@ +// +// 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.kvm.resource.wrapper; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; +import org.apache.cloudstack.vm.UnmanagedInstanceTO; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.ImportConvertedInstanceAnswer; +import com.cloud.agent.api.ImportConvertedInstanceCommand; +import com.cloud.agent.api.to.DataStoreTO; +import com.cloud.agent.api.to.NfsTO; +import com.cloud.agent.api.to.RemoteInstanceTO; +import com.cloud.hypervisor.Hypervisor; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtDomainXMLParser; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.resource.CommandWrapper; +import com.cloud.resource.ResourceWrapper; +import com.cloud.storage.Storage; +import com.cloud.utils.FileUtil; +import com.cloud.utils.Pair; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; + +@ResourceWrapper(handles = ImportConvertedInstanceCommand.class) +public class LibvirtImportConvertedInstanceCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(ImportConvertedInstanceCommand cmd, LibvirtComputingResource serverResource) { + RemoteInstanceTO sourceInstance = cmd.getSourceInstance(); + Hypervisor.HypervisorType sourceHypervisorType = sourceInstance.getHypervisorType(); + String sourceInstanceName = sourceInstance.getInstanceName(); + List destinationStoragePools = cmd.getDestinationStoragePools(); + DataStoreTO conversionTemporaryLocation = cmd.getConversionTemporaryLocation(); + final String temporaryConvertUuid = cmd.getTemporaryConvertUuid(); + + final KVMStoragePoolManager storagePoolMgr = serverResource.getStoragePoolMgr(); + KVMStoragePool temporaryStoragePool = getTemporaryStoragePool(conversionTemporaryLocation, storagePoolMgr); + final String temporaryConvertPath = temporaryStoragePool.getLocalPath(); + + try { + String convertedBasePath = String.format("%s/%s", temporaryConvertPath, temporaryConvertUuid); + LibvirtDomainXMLParser xmlParser = parseMigratedVMXmlDomain(convertedBasePath); + + List temporaryDisks = xmlParser == null ? + getTemporaryDisksWithPrefixFromTemporaryPool(temporaryStoragePool, temporaryConvertPath, temporaryConvertUuid) : + getTemporaryDisksFromParsedXml(temporaryStoragePool, xmlParser, convertedBasePath); + + List destinationDisks = moveTemporaryDisksToDestination(temporaryDisks, + destinationStoragePools, storagePoolMgr); + + cleanupDisksAndDomainFromTemporaryLocation(temporaryDisks, temporaryStoragePool, temporaryConvertUuid); + + UnmanagedInstanceTO convertedInstanceTO = getConvertedUnmanagedInstance(temporaryConvertUuid, + destinationDisks, xmlParser); + return new ImportConvertedInstanceAnswer(cmd, convertedInstanceTO); + } catch (Exception e) { + String error = String.format("Error converting instance %s from %s, due to: %s", + sourceInstanceName, sourceHypervisorType, e.getMessage()); + logger.error(error, e); + return new ImportConvertedInstanceAnswer(cmd, false, error); + } finally { + if (conversionTemporaryLocation instanceof NfsTO) { + logger.debug("Cleaning up secondary storage temporary location"); + storagePoolMgr.deleteStoragePool(temporaryStoragePool.getType(), temporaryStoragePool.getUuid()); + } + } + } + + protected KVMStoragePool getTemporaryStoragePool(DataStoreTO conversionTemporaryLocation, KVMStoragePoolManager storagePoolMgr) { + if (conversionTemporaryLocation instanceof NfsTO) { + NfsTO nfsTO = (NfsTO) conversionTemporaryLocation; + return storagePoolMgr.getStoragePoolByURI(nfsTO.getUrl()); + } else { + PrimaryDataStoreTO primaryDataStoreTO = (PrimaryDataStoreTO) conversionTemporaryLocation; + return storagePoolMgr.getStoragePool(primaryDataStoreTO.getPoolType(), primaryDataStoreTO.getUuid()); + } + } + + protected List getTemporaryDisksFromParsedXml(KVMStoragePool pool, LibvirtDomainXMLParser xmlParser, String convertedBasePath) { + List disksDefs = xmlParser.getDisks(); + disksDefs = disksDefs.stream().filter(x -> x.getDiskType() == LibvirtVMDef.DiskDef.DiskType.FILE && + x.getDeviceType() == LibvirtVMDef.DiskDef.DeviceType.DISK).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(disksDefs)) { + String err = String.format("Cannot find any disk defined on the converted XML domain %s.xml", convertedBasePath); + logger.error(err); + throw new CloudRuntimeException(err); + } + sanitizeDisksPath(disksDefs); + return getPhysicalDisksFromDefPaths(disksDefs, pool); + } + + private List getPhysicalDisksFromDefPaths(List disksDefs, KVMStoragePool pool) { + List disks = new ArrayList<>(); + for (LibvirtVMDef.DiskDef diskDef : disksDefs) { + KVMPhysicalDisk physicalDisk = pool.getPhysicalDisk(diskDef.getDiskPath()); + disks.add(physicalDisk); + } + return disks; + } + + protected List getTemporaryDisksWithPrefixFromTemporaryPool(KVMStoragePool pool, String path, String prefix) { + String msg = String.format("Could not parse correctly the converted XML domain, checking for disks on %s with prefix %s", path, prefix); + logger.info(msg); + pool.refresh(); + List disksWithPrefix = pool.listPhysicalDisks() + .stream() + .filter(x -> x.getName().startsWith(prefix) && !x.getName().endsWith(".xml")) + .collect(Collectors.toList()); + if (CollectionUtils.isEmpty(disksWithPrefix)) { + msg = String.format("Could not find any converted disk with prefix %s on temporary location %s", prefix, path); + logger.error(msg); + throw new CloudRuntimeException(msg); + } + return disksWithPrefix; + } + + private void cleanupDisksAndDomainFromTemporaryLocation(List disks, + KVMStoragePool temporaryStoragePool, + String temporaryConvertUuid) { + for (KVMPhysicalDisk disk : disks) { + logger.info(String.format("Cleaning up temporary disk %s after conversion from temporary location", disk.getName())); + temporaryStoragePool.deletePhysicalDisk(disk.getName(), Storage.ImageFormat.QCOW2); + } + logger.info(String.format("Cleaning up temporary domain %s after conversion from temporary location", temporaryConvertUuid)); + FileUtil.deleteFiles(temporaryStoragePool.getLocalPath(), temporaryConvertUuid, ".xml"); + } + + protected void sanitizeDisksPath(List disks) { + for (LibvirtVMDef.DiskDef disk : disks) { + String[] diskPathParts = disk.getDiskPath().split("/"); + String relativePath = diskPathParts[diskPathParts.length - 1]; + disk.setDiskPath(relativePath); + } + } + + protected List moveTemporaryDisksToDestination(List temporaryDisks, + List destinationStoragePools, + KVMStoragePoolManager storagePoolMgr) { + List targetDisks = new ArrayList<>(); + if (temporaryDisks.size() != destinationStoragePools.size()) { + String warn = String.format("Discrepancy between the converted instance disks (%s) " + + "and the expected number of disks (%s)", temporaryDisks.size(), destinationStoragePools.size()); + logger.warn(warn); + } + for (int i = 0; i < temporaryDisks.size(); i++) { + String poolPath = destinationStoragePools.get(i); + KVMStoragePool destinationPool = storagePoolMgr.getStoragePool(Storage.StoragePoolType.NetworkFilesystem, poolPath); + if (destinationPool == null) { + String err = String.format("Could not find a storage pool by URI: %s", poolPath); + logger.error(err); + continue; + } + if (destinationPool.getType() != Storage.StoragePoolType.NetworkFilesystem) { + String err = String.format("Storage pool by URI: %s is not an NFS storage", poolPath); + logger.error(err); + continue; + } + KVMPhysicalDisk sourceDisk = temporaryDisks.get(i); + if (logger.isDebugEnabled()) { + String msg = String.format("Trying to copy converted instance disk number %s from the temporary location %s" + + " to destination storage pool %s", i, sourceDisk.getPool().getLocalPath(), destinationPool.getUuid()); + logger.debug(msg); + } + + String destinationName = UUID.randomUUID().toString(); + + KVMPhysicalDisk destinationDisk = storagePoolMgr.copyPhysicalDisk(sourceDisk, destinationName, destinationPool, 7200 * 1000); + targetDisks.add(destinationDisk); + } + return targetDisks; + } + + private UnmanagedInstanceTO getConvertedUnmanagedInstance(String baseName, + List vmDisks, + LibvirtDomainXMLParser xmlParser) { + UnmanagedInstanceTO instanceTO = new UnmanagedInstanceTO(); + instanceTO.setName(baseName); + instanceTO.setDisks(getUnmanagedInstanceDisks(vmDisks, xmlParser)); + instanceTO.setNics(getUnmanagedInstanceNics(xmlParser)); + return instanceTO; + } + + private List getUnmanagedInstanceNics(LibvirtDomainXMLParser xmlParser) { + List nics = new ArrayList<>(); + if (xmlParser != null) { + List interfaces = xmlParser.getInterfaces(); + for (LibvirtVMDef.InterfaceDef interfaceDef : interfaces) { + UnmanagedInstanceTO.Nic nic = new UnmanagedInstanceTO.Nic(); + nic.setMacAddress(interfaceDef.getMacAddress()); + nic.setNicId(interfaceDef.getBrName()); + nic.setAdapterType(interfaceDef.getModel().toString()); + nics.add(nic); + } + } + return nics; + } + + protected List getUnmanagedInstanceDisks(List vmDisks, LibvirtDomainXMLParser xmlParser) { + List instanceDisks = new ArrayList<>(); + List diskDefs = xmlParser != null ? xmlParser.getDisks() : null; + for (int i = 0; i< vmDisks.size(); i++) { + KVMPhysicalDisk physicalDisk = vmDisks.get(i); + KVMStoragePool storagePool = physicalDisk.getPool(); + UnmanagedInstanceTO.Disk disk = new UnmanagedInstanceTO.Disk(); + disk.setPosition(i); + Pair storagePoolHostAndPath = getNfsStoragePoolHostAndPath(storagePool); + disk.setDatastoreHost(storagePoolHostAndPath.first()); + disk.setDatastorePath(storagePoolHostAndPath.second()); + disk.setDatastoreName(storagePool.getUuid()); + disk.setDatastoreType(storagePool.getType().name()); + disk.setCapacity(physicalDisk.getVirtualSize()); + disk.setFileBaseName(physicalDisk.getName()); + if (CollectionUtils.isNotEmpty(diskDefs)) { + LibvirtVMDef.DiskDef diskDef = diskDefs.get(i); + disk.setController(diskDef.getBusType() != null ? diskDef.getBusType().toString() : LibvirtVMDef.DiskDef.DiskBus.VIRTIO.toString()); + } else { + // If the job is finished but we cannot parse the XML, the guest VM can use the virtio driver + disk.setController(LibvirtVMDef.DiskDef.DiskBus.VIRTIO.toString()); + } + instanceDisks.add(disk); + } + return instanceDisks; + } + + protected Pair getNfsStoragePoolHostAndPath(KVMStoragePool storagePool) { + String sourceHostIp = null; + String sourcePath = null; + List commands = new ArrayList<>(); + commands.add(new String[]{Script.getExecutableAbsolutePath("mount")}); + commands.add(new String[]{Script.getExecutableAbsolutePath("grep"), storagePool.getLocalPath()}); + String storagePoolMountPoint = Script.executePipedCommands(commands, 0).second(); + logger.debug(String.format("NFS Storage pool: %s - local path: %s, mount point: %s", storagePool.getUuid(), storagePool.getLocalPath(), storagePoolMountPoint)); + if (StringUtils.isNotEmpty(storagePoolMountPoint)) { + String[] res = storagePoolMountPoint.strip().split(" "); + res = res[0].split(":"); + if (res.length > 1) { + sourceHostIp = res[0].strip(); + sourcePath = res[1].strip(); + } + } + return new Pair<>(sourceHostIp, sourcePath); + } + + protected LibvirtDomainXMLParser parseMigratedVMXmlDomain(String installPath) throws IOException { + String xmlPath = String.format("%s.xml", installPath); + if (!new File(xmlPath).exists()) { + String err = String.format("Conversion failed. Unable to find the converted XML domain, expected %s", xmlPath); + logger.error(err); + throw new CloudRuntimeException(err); + } + InputStream is = new BufferedInputStream(new FileInputStream(xmlPath)); + String xml = IOUtils.toString(is, Charset.defaultCharset()); + final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); + try { + parser.parseDomainXML(xml); + return parser; + } catch (RuntimeException e) { + String err = String.format("Error parsing the converted instance XML domain at %s: %s", xmlPath, e.getMessage()); + logger.error(err, e); + logger.debug(xml); + return null; + } + } +} diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java index 923c44f4828..9ecdfddc2ad 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtOvsFetchInterfaceCommandWrapper.java @@ -89,7 +89,7 @@ public final class LibvirtOvsFetchInterfaceCommandWrapper extends CommandWrapper @Override public Answer execute(final OvsFetchInterfaceCommand command, final LibvirtComputingResource libvirtComputingResource) { - final String label = "'" + command.getLabel() + "'"; + final String label = command.getLabel(); logger.debug("Will look for network with name-label:" + label); try { diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java index 53549487704..8d7ee14dc13 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java @@ -118,7 +118,7 @@ public final class LibvirtPrepareForMigrationCommandWrapper extends CommandWrapp skipDisconnect = true; - if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) { + if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm, true)) { return new PrepareForMigrationAnswer(command, "failed to connect physical disks to host"); } diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSetupDirectDownloadCertificateCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSetupDirectDownloadCertificateCommandWrapper.java index fcca16ba618..62cca7eb209 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSetupDirectDownloadCertificateCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSetupDirectDownloadCertificateCommandWrapper.java @@ -36,6 +36,7 @@ import com.cloud.resource.ResourceWrapper; import com.cloud.utils.FileUtil; import com.cloud.utils.PropertiesUtil; import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.net.NetUtils; import com.cloud.utils.script.Script; @ResourceWrapper(handles = SetupDirectDownloadCertificateCommand.class) @@ -131,6 +132,9 @@ public class LibvirtSetupDirectDownloadCertificateCommandWrapper extends Command public Answer execute(SetupDirectDownloadCertificateCommand cmd, LibvirtComputingResource serverResource) { String certificate = cmd.getCertificate(); String certificateName = cmd.getCertificateName(); + if (!NetUtils.verifyDomainNameLabel(certificateName, false)) { + return new Answer(cmd, false, "The provided certificate name is invalid"); + } try { File agentFile = getAgentPropertiesFile(); diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java index e0c41acea12..a174c9a6f14 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java @@ -75,7 +75,7 @@ public final class LibvirtStartCommandWrapper extends CommandWrapper MapStorageUuidToStoragePool = new HashMap<>(); @Override - public KVMStoragePool createStoragePool(String uuid, String host, int port, String path, String userInfo, StoragePoolType storagePoolType, Map details) { + public KVMStoragePool createStoragePool(String uuid, String host, int port, String path, String userInfo, StoragePoolType storagePoolType, Map details, boolean isPrimaryStorage) { IscsiAdmStoragePool storagePool = new IscsiAdmStoragePool(uuid, host, port, storagePoolType, this); MapStorageUuidToStoragePool.put(uuid, storagePool); @@ -84,7 +84,7 @@ public class IscsiAdmStorageAdaptor implements StorageAdaptor { } @Override - public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map details) { + public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map details, boolean isVMMigrate) { // ex. sudo iscsiadm -m node -T iqn.2012-03.com.test:volume1 -p 192.168.233.10:3260 -o new Script iScsiAdmCmd = new Script(true, "iscsiadm", 0, logger); diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/IscsiAdmStoragePool.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/IscsiAdmStoragePool.java index a89650f6eb6..f5bfd898a4f 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/IscsiAdmStoragePool.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/IscsiAdmStoragePool.java @@ -106,7 +106,7 @@ public class IscsiAdmStoragePool implements KVMStoragePool { @Override public boolean connectPhysicalDisk(String name, Map details) { - return this._storageAdaptor.connectPhysicalDisk(name, this, details); + return this._storageAdaptor.connectPhysicalDisk(name, this, details, false); } @Override diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java index 3c8026c7ffd..e27547acbb2 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java @@ -161,10 +161,10 @@ public class KVMStoragePoolManager { StorageAdaptor adaptor = getStorageAdaptor(type); KVMStoragePool pool = adaptor.getStoragePool(poolUuid); - return adaptor.connectPhysicalDisk(volPath, pool, details); + return adaptor.connectPhysicalDisk(volPath, pool, details, false); } - public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec) { + public boolean connectPhysicalDisksViaVmSpec(VirtualMachineTO vmSpec, boolean isVMMigrate) { boolean result = false; final String vmName = vmSpec.getName(); @@ -187,7 +187,7 @@ public class KVMStoragePoolManager { KVMStoragePool pool = getStoragePool(store.getPoolType(), store.getUuid()); StorageAdaptor adaptor = getStorageAdaptor(pool.getType()); - result = adaptor.connectPhysicalDisk(vol.getPath(), pool, disk.getDetails()); + result = adaptor.connectPhysicalDisk(vol.getPath(), pool, disk.getDetails(), isVMMigrate); if (!result) { logger.error("Failed to connect disks via vm spec for vm: " + vmName + " volume:" + vol.toString()); @@ -315,6 +315,7 @@ public class KVMStoragePoolManager { URI storageUri = null; try { + logger.debug("Get storage pool by uri: " + uri); storageUri = new URI(uri); } catch (URISyntaxException e) { throw new CloudRuntimeException(e.toString()); @@ -324,7 +325,7 @@ public class KVMStoragePoolManager { String uuid = null; String sourceHost = ""; StoragePoolType protocol = null; - final String scheme = storageUri.getScheme().toLowerCase(); + final String scheme = (storageUri.getScheme() != null) ? storageUri.getScheme().toLowerCase() : ""; List acceptedSchemes = List.of("nfs", "networkfilesystem", "filesystem"); if (acceptedSchemes.contains(scheme)) { sourcePath = storageUri.getPath(); @@ -389,7 +390,7 @@ public class KVMStoragePoolManager { //Note: due to bug CLOUDSTACK-4459, createStoragepool can be called in parallel, so need to be synced. private synchronized KVMStoragePool createStoragePool(String name, String host, int port, String path, String userInfo, StoragePoolType type, Map details, boolean primaryStorage) { StorageAdaptor adaptor = getStorageAdaptor(type); - KVMStoragePool pool = adaptor.createStoragePool(name, host, port, path, userInfo, type, details); + KVMStoragePool pool = adaptor.createStoragePool(name, host, port, path, userInfo, type, details, primaryStorage); // LibvirtStorageAdaptor-specific statement if (pool.isPoolSupportHA() && primaryStorage) { diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java index 04662604382..fe6be10f9b8 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java @@ -26,9 +26,11 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; @@ -63,15 +65,19 @@ import org.apache.cloudstack.storage.command.ResignatureCommand; import org.apache.cloudstack.storage.command.SnapshotAndCopyAnswer; import org.apache.cloudstack.storage.command.SnapshotAndCopyCommand; import org.apache.cloudstack.storage.command.SyncVolumePathCommand; +import org.apache.cloudstack.storage.formatinspector.Qcow2Inspector; import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; import org.apache.cloudstack.storage.to.SnapshotObjectTO; import org.apache.cloudstack.storage.to.TemplateObjectTO; import org.apache.cloudstack.storage.to.VolumeObjectTO; +import org.apache.cloudstack.utils.cryptsetup.KeyFile; +import org.apache.cloudstack.utils.qemu.QemuImageOptions; import org.apache.cloudstack.utils.qemu.QemuImg; import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; import org.apache.cloudstack.utils.qemu.QemuImgException; import org.apache.cloudstack.utils.qemu.QemuImgFile; import org.apache.cloudstack.utils.qemu.QemuObject; +import org.apache.cloudstack.utils.qemu.QemuObject.EncryptFormat; import org.apache.commons.collections.MapUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.BooleanUtils; @@ -80,6 +86,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; + import org.libvirt.Connect; import org.libvirt.Domain; import org.libvirt.DomainInfo; @@ -134,10 +141,7 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; import com.cloud.utils.storage.S3.S3Utils; import com.cloud.vm.VmDetailConstants; -import org.apache.cloudstack.utils.cryptsetup.KeyFile; -import org.apache.cloudstack.utils.qemu.QemuImageOptions; -import org.apache.cloudstack.utils.qemu.QemuObject.EncryptFormat; -import java.util.ArrayList; + public class KVMStorageProcessor implements StorageProcessor { protected Logger logger = LogManager.getLogger(getClass()); @@ -1115,11 +1119,12 @@ public class KVMStorageProcessor implements StorageProcessor { storagePool = storagePoolMgr.getStoragePoolByURI(path); } final KVMPhysicalDisk isoVol = storagePool.getPhysicalDisk(name); + final DiskDef.DiskType isoDiskType = LibvirtComputingResource.getDiskType(isoVol); isoPath = isoVol.getPath(); - iso.defISODisk(isoPath, isUefiEnabled); + iso.defISODisk(isoPath, isUefiEnabled, isoDiskType); } else { - iso.defISODisk(null, isUefiEnabled); + iso.defISODisk(null, isUefiEnabled, DiskDef.DiskType.FILE); } final List disks = resource.getDisks(conn, vmName); @@ -1447,6 +1452,9 @@ public class KVMStorageProcessor implements StorageProcessor { diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, busT, DiskDef.DiskFmtType.QCOW2); } else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) { diskdef.defBlockBasedDisk(attachingDisk.getPath(), devId, busT); + if (attachingPool.getType() == StoragePoolType.Linstor && resource.isQemuDiscardBugFree(busT)) { + diskdef.setDiscard(DiscardType.UNMAP); + } } if (encryptDetails != null) { @@ -2449,6 +2457,22 @@ public class KVMStorageProcessor implements StorageProcessor { template = storagePoolMgr.createPhysicalDiskFromDirectDownloadTemplate(tempFilePath, destTemplatePath, destPool, cmd.getFormat(), cmd.getWaitInMillSeconds()); + String templatePath = template.getPath(); + if (templatePath != null) { + try { + Qcow2Inspector.validateQcow2File(templatePath); + } catch (RuntimeException e) { + try { + Files.deleteIfExists(Path.of(templatePath)); + } catch (IOException ioException) { + logger.warn("Unable to remove file [{}]; consider removing it manually.", templatePath, ioException); + } + + logger.error("The downloaded file [{}] is not a valid QCOW2.", templatePath, e); + return new DirectDownloadAnswer(false, "The downloaded file is not a valid QCOW2. Ask the administrator to check the logs for more details.", true); + } + } + if (!storagePoolMgr.disconnectPhysicalDisk(pool.getPoolType(), pool.getUuid(), destTemplatePath)) { logger.warn("Unable to disconnect physical disk at path: " + destTemplatePath + ", in storage pool id: " + pool.getUuid()); } diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java index 45a65037340..a9dfd29a4bf 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java @@ -73,6 +73,7 @@ import static com.cloud.utils.NumbersUtil.toHumanReadableSize; import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -81,6 +82,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { private StorageLayer _storageLayer; private String _mountPoint = "/mnt"; private String _manageSnapshotPath; + private static final ConcurrentHashMap storagePoolRefCounts = new ConcurrentHashMap<>(); private String rbdTemplateSnapName = "cloudstack-base-snap"; private static final int RBD_FEATURE_LAYERING = 1; @@ -171,7 +173,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { * Checks if downloaded template is extractable * @return true if it should be extracted, false if not */ - private boolean isTemplateExtractable(String templatePath) { + public static boolean isTemplateExtractable(String templatePath) { String type = Script.runSimpleBashScript("file " + templatePath + " | awk -F' ' '{print $2}'"); return type.equalsIgnoreCase("bzip2") || type.equalsIgnoreCase("gzip") || type.equalsIgnoreCase("zip"); } @@ -181,7 +183,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { * @param downloadedTemplateFile * @param templateUuid */ - private String getExtractCommandForDownloadedFile(String downloadedTemplateFile, String templateUuid) { + public static String getExtractCommandForDownloadedFile(String downloadedTemplateFile, String templateUuid) { if (downloadedTemplateFile.endsWith(".zip")) { return "unzip -p " + downloadedTemplateFile + " | cat > " + templateUuid; } else if (downloadedTemplateFile.endsWith(".bz2")) { @@ -196,7 +198,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { /** * Extract downloaded template into installPath, remove compressed file */ - private void extractDownloadedTemplate(String downloadedTemplateFile, KVMStoragePool destPool, String destinationFile) { + public static void extractDownloadedTemplate(String downloadedTemplateFile, KVMStoragePool destPool, String destinationFile) { String extractCommand = getExtractCommandForDownloadedFile(downloadedTemplateFile, destinationFile); Script.runSimpleBashScript(extractCommand); Script.runSimpleBashScript("rm -f " + downloadedTemplateFile); @@ -350,7 +352,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { String volgroupName = path; volgroupName = volgroupName.replaceFirst("/", ""); - LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(PoolType.loggerICAL, volgroupName, uuid, host, volgroupPath, volgroupPath); + LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(PoolType.LOGICAL, volgroupName, uuid, host, volgroupPath, volgroupPath); StoragePool sp = null; try { logger.debug(spd.toString()); @@ -542,7 +544,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { type = StoragePoolType.Filesystem; } else if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.RBD) { type = StoragePoolType.RBD; - } else if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.loggerICAL) { + } else if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.LOGICAL) { type = StoragePoolType.CLVM; } else if (spd.getPoolType() == LibvirtStoragePoolDef.PoolType.GLUSTERFS) { type = StoragePoolType.Gluster; @@ -644,8 +646,44 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } } + /** + * adjust refcount + */ + private int adjustStoragePoolRefCount(String uuid, int adjustment) { + final String mutexKey = storagePoolRefCounts.keySet().stream() + .filter(k -> k.equals(uuid)) + .findFirst() + .orElse(uuid); + synchronized (mutexKey) { + // some access on the storagePoolRefCounts.key(mutexKey) element + int refCount = storagePoolRefCounts.computeIfAbsent(mutexKey, k -> 0); + refCount += adjustment; + if (refCount < 1) { + storagePoolRefCounts.remove(mutexKey); + } else { + storagePoolRefCounts.put(mutexKey, refCount); + } + return refCount; + } + } + /** + * Thread-safe increment storage pool usage refcount + * @param uuid UUID of the storage pool to increment the count + */ + private void incStoragePoolRefCount(String uuid) { + adjustStoragePoolRefCount(uuid, 1); + } + /** + * Thread-safe decrement storage pool usage refcount for the given uuid and return if storage pool still in use. + * @param uuid UUID of the storage pool to decrement the count + * @return true if the storage pool is still used, else false. + */ + private boolean decStoragePoolRefCount(String uuid) { + return adjustStoragePoolRefCount(uuid, -1) > 0; + } + @Override - public KVMStoragePool createStoragePool(String name, String host, int port, String path, String userInfo, StoragePoolType type, Map details) { + public KVMStoragePool createStoragePool(String name, String host, int port, String path, String userInfo, StoragePoolType type, Map details, boolean isPrimaryStorage) { logger.info("Attempting to create storage pool " + name + " (" + type.toString() + ") in libvirt"); StoragePool sp = null; @@ -751,6 +789,12 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } try { + if (!isPrimaryStorage) { + // only ref count storage pools for secondary storage, as primary storage is assumed + // to be always mounted, as long the primary storage isn't fully deleted. + incStoragePoolRefCount(name); + } + if (sp.isActive() == 0) { logger.debug("Attempting to activate pool " + name); sp.create(0); @@ -762,6 +806,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { return getStoragePool(name); } catch (LibvirtException e) { + decStoragePoolRefCount(name); String error = e.toString(); if (error.contains("Storage source conflict")) { throw new CloudRuntimeException("A pool matching this location already exists in libvirt, " + @@ -812,6 +857,13 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { @Override public boolean deleteStoragePool(String uuid) { logger.info("Attempting to remove storage pool " + uuid + " from libvirt"); + + // decrement and check if storage pool still in use + if (decStoragePoolRefCount(uuid)) { + logger.info(String.format("deleteStoragePool: Storage pool %s still in use", uuid)); + return true; + } + Connect conn = null; try { conn = LibvirtConnection.getConnection(); @@ -966,7 +1018,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } @Override - public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map details) { + public boolean connectPhysicalDisk(String name, KVMStoragePool pool, Map details, boolean isVMMigrate) { // this is for managed storage that needs to prep disks prior to use return true; } diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ManagedNfsStorageAdaptor.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ManagedNfsStorageAdaptor.java index 8ec56b885f2..3353738fd09 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ManagedNfsStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ManagedNfsStorageAdaptor.java @@ -56,7 +56,7 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { } @Override - public KVMStoragePool createStoragePool(String uuid, String host, int port, String path, String userInfo, StoragePoolType storagePoolType, Map details) { + public KVMStoragePool createStoragePool(String uuid, String host, int port, String path, String userInfo, StoragePoolType storagePoolType, Map details, boolean isPrimaryStorage) { LibvirtStoragePool storagePool = new LibvirtStoragePool(uuid, path, StoragePoolType.ManagedNFS, this, null); storagePool.setSourceHost(host); @@ -97,7 +97,7 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { * creates a nfs storage pool using libvirt */ @Override - public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map details) { + public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map details, boolean isVMMigrate) { StoragePool sp = null; Connect conn = null; diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIAdapterBase.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIAdapterBase.java index 03acfcc89ad..19d8378eb78 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIAdapterBase.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIAdapterBase.java @@ -169,7 +169,7 @@ public abstract class MultipathSCSIAdapterBase implements StorageAdaptor { } @Override - public KVMStoragePool createStoragePool(String uuid, String host, int port, String path, String userInfo, Storage.StoragePoolType type, Map details) { + public KVMStoragePool createStoragePool(String uuid, String host, int port, String path, String userInfo, Storage.StoragePoolType type, Map details, boolean isPrimaryStorage) { LOGGER.info(String.format("createStoragePool(uuid,host,port,path,type) called with args (%s, %s, %s, %s, %s)", uuid, host, ""+port, path, type)); MultipathSCSIPool storagePool = new MultipathSCSIPool(uuid, host, port, path, type, details, this); MapStorageUuidToStoragePool.put(uuid, storagePool); @@ -182,7 +182,7 @@ public abstract class MultipathSCSIAdapterBase implements StorageAdaptor { } @Override - public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map details) { + public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map details, boolean isVMMigrate) { LOGGER.info("connectPhysicalDisk called for [" + volumePath + "]"); if (StringUtils.isEmpty(volumePath)) { diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIPool.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIPool.java index bc2f072f719..229481b1f79 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIPool.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIPool.java @@ -78,7 +78,7 @@ public class MultipathSCSIPool implements KVMStoragePool { @Override public boolean connectPhysicalDisk(String volumeUuid, Map details) { - return storageAdaptor.connectPhysicalDisk(volumeUuid, this, details); + return storageAdaptor.connectPhysicalDisk(volumeUuid, this, details, false); } @Override diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java index b33f49404ad..335ea0d03d2 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java @@ -146,7 +146,7 @@ public class ScaleIOStorageAdaptor implements StorageAdaptor { } @Override - public KVMStoragePool createStoragePool(String uuid, String host, int port, String path, String userInfo, Storage.StoragePoolType type, Map details) { + public KVMStoragePool createStoragePool(String uuid, String host, int port, String path, String userInfo, Storage.StoragePoolType type, Map details, boolean isPrimaryStorage) { ScaleIOStoragePool storagePool = new ScaleIOStoragePool(uuid, host, port, path, type, details, this); MapStorageUuidToStoragePool.put(uuid, storagePool); return storagePool; @@ -181,7 +181,7 @@ public class ScaleIOStorageAdaptor implements StorageAdaptor { return null; } - if(!connectPhysicalDisk(name, pool, null)) { + if(!connectPhysicalDisk(name, pool, null, false)) { throw new CloudRuntimeException(String.format("Failed to ensure disk %s was present", name)); } @@ -224,7 +224,7 @@ public class ScaleIOStorageAdaptor implements StorageAdaptor { } @Override - public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map details) { + public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map details, boolean isMigration) { if (StringUtils.isEmpty(volumePath) || pool == null) { logger.error("Unable to connect physical disk due to insufficient data"); throw new CloudRuntimeException("Unable to connect physical disk due to insufficient data"); diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStoragePool.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStoragePool.java index 77f21910da6..e8243c3f7cf 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStoragePool.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStoragePool.java @@ -89,7 +89,7 @@ public class ScaleIOStoragePool implements KVMStoragePool { @Override public boolean connectPhysicalDisk(String volumeUuid, Map details) { - return storageAdaptor.connectPhysicalDisk(volumeUuid, this, details); + return storageAdaptor.connectPhysicalDisk(volumeUuid, this, details, false); } @Override diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java index 9a27d44ff92..8439a50073e 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java @@ -40,7 +40,7 @@ public interface StorageAdaptor { // it with info from local disk, and return it public KVMPhysicalDisk getPhysicalDisk(String volumeUuid, KVMStoragePool pool); - public KVMStoragePool createStoragePool(String name, String host, int port, String path, String userInfo, StoragePoolType type, Map details); + public KVMStoragePool createStoragePool(String name, String host, int port, String path, String userInfo, StoragePoolType type, Map details, boolean isPrimaryStorage); public boolean deleteStoragePool(String uuid); @@ -52,8 +52,15 @@ public interface StorageAdaptor { public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, PhysicalDiskFormat format, Storage.ProvisioningType provisioningType, long size, byte[] passphrase); - // given disk path (per database) and pool, prepare disk on host - public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map details); + /** + * given disk path (per database) and pool, prepare disk on host + * @param volumePath volume path + * @param pool storage pool the disk is part of + * @param details disk details map + * @param isVMMigrate Indicates if request is while VM is migration + * @return true if connect was a success + */ + public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map details, boolean isVMMigrate); // given disk path (per database) and pool, clean up disk on host public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool pool); diff --git a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index 30d0b2ab163..961537a534e 100644 --- a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -58,9 +58,12 @@ import javax.xml.xpath.XPathFactory; import com.cloud.utils.net.NetUtils; +import com.cloud.vm.VmDetailConstants; import org.apache.cloudstack.api.ApiConstants.IoDriverPolicy; import org.apache.cloudstack.storage.command.AttachAnswer; import org.apache.cloudstack.storage.command.AttachCommand; +import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; +import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.utils.bytescale.ByteScaleUtils; import org.apache.cloudstack.utils.linux.CPUStat; import org.apache.cloudstack.utils.linux.MemStat; @@ -1474,7 +1477,7 @@ public class LibvirtComputingResourceTest { when(libvirtComputingResourceMock.getVifDriver(nicTO.getType(), nicTO.getName())).thenReturn(vifDriver); when(libvirtComputingResourceMock.getStoragePoolMgr()).thenReturn(storagePoolManager); - when(storagePoolManager.connectPhysicalDisksViaVmSpec(vm)).thenReturn(true); + when(storagePoolManager.connectPhysicalDisksViaVmSpec(vm, true)).thenReturn(true); final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); @@ -5020,7 +5023,7 @@ public class LibvirtComputingResourceTest { fail(e.getMessage()); } - when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)).thenReturn(false); + when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec, false)).thenReturn(false); final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); @@ -5221,7 +5224,7 @@ public class LibvirtComputingResourceTest { fail(e.getMessage()); } - when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)).thenReturn(true); + when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec, false)).thenReturn(true); try { doNothing().when(libvirtComputingResourceMock).createVifs(vmSpec, vmDef); @@ -5300,7 +5303,7 @@ public class LibvirtComputingResourceTest { fail(e.getMessage()); } - when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)).thenReturn(true); + when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec, false)).thenReturn(true); try { doNothing().when(libvirtComputingResourceMock).createVifs(vmSpec, vmDef); @@ -5377,7 +5380,7 @@ public class LibvirtComputingResourceTest { fail(e.getMessage()); } - when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)).thenReturn(true); + when(storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec, false)).thenReturn(true); final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance(); assertNotNull(wrapper); @@ -6415,4 +6418,114 @@ public class LibvirtComputingResourceTest { Assert.assertEquals(newStats.getDiskReadKBs() - oldStats.getDiskReadKBs(), metrics.getDiskReadKBs(), 0); Assert.assertEquals(newStats.getDiskWriteKBs() - oldStats.getDiskWriteKBs(), metrics.getDiskWriteKBs(), 0); } + + @Test + public void createLinstorVdb() throws LibvirtException, InternalErrorException, URISyntaxException { + final Connect connect = Mockito.mock(Connect.class); + + final int id = random.nextInt(65534); + final String name = "test-instance-1"; + + final int cpus = 2; + final int speed = 1024; + final int minRam = 256 * 1024; + final int maxRam = 512 * 1024; + final String os = "Ubuntu"; + final String vncPassword = "mySuperSecretPassword"; + + final VirtualMachineTO to = new VirtualMachineTO(id, name, VirtualMachine.Type.User, cpus, speed, minRam, + maxRam, BootloaderType.HVM, os, false, false, vncPassword); + to.setVncAddr(""); + to.setArch("x86_64"); + to.setUuid("b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9"); + to.setVcpuMaxLimit(cpus + 1); + final HashMap vmToDetails = new HashMap<>(); + to.setDetails(vmToDetails); + + String diskLinPath = "9ebe53c1-3d35-46e5-b7aa-6fc223ba0fcf"; + final DiskTO diskTO = new DiskTO(); + diskTO.setDiskSeq(1L); + diskTO.setType(Volume.Type.ROOT); + diskTO.setDetails(new HashMap<>()); + diskTO.setPath(diskLinPath); + + final PrimaryDataStoreTO primaryDataStoreTO = Mockito.mock(PrimaryDataStoreTO.class); + String pDSTOUUID = "9ebe53c1-3d35-46e5-b7aa-6fc223ac4fcf"; + when(primaryDataStoreTO.getPoolType()).thenReturn(StoragePoolType.Linstor); + when(primaryDataStoreTO.getUuid()).thenReturn(pDSTOUUID); + + VolumeObjectTO dataTO = new VolumeObjectTO(); + + dataTO.setUuid("12be53c1-3d35-46e5-b7aa-6fc223ba0f34"); + dataTO.setPath(diskTO.getPath()); + dataTO.setDataStore(primaryDataStoreTO); + diskTO.setData(dataTO); + to.setDisks(new DiskTO[]{diskTO}); + + String path = "/dev/drbd1020"; + final KVMStoragePoolManager storagePoolMgr = Mockito.mock(KVMStoragePoolManager.class); + final KVMStoragePool storagePool = Mockito.mock(KVMStoragePool.class); + final KVMPhysicalDisk vol = Mockito.mock(KVMPhysicalDisk.class); + + when(libvirtComputingResourceSpy.getStoragePoolMgr()).thenReturn(storagePoolMgr); + when(storagePool.getType()).thenReturn(StoragePoolType.Linstor); + when(storagePoolMgr.getPhysicalDisk(StoragePoolType.Linstor, pDSTOUUID, diskLinPath)).thenReturn(vol); + when(vol.getPath()).thenReturn(path); + when(vol.getPool()).thenReturn(storagePool); + when(vol.getFormat()).thenReturn(PhysicalDiskFormat.RAW); + + // 1. test Bus: IDE and broken qemu version -> NO discard + when(libvirtComputingResourceSpy.getHypervisorQemuVersion()).thenReturn(6000000L); + vmToDetails.put(VmDetailConstants.ROOT_DISK_CONTROLLER, DiskDef.DiskBus.IDE.name()); + { + LibvirtVMDef vm = new LibvirtVMDef(); + vm.addComp(new DevicesDef()); + libvirtComputingResourceSpy.createVbd(connect, to, name, vm); + + DiskDef rootDisk = vm.getDevices().getDisks().get(0); + assertEquals(DiskDef.DiskType.BLOCK, rootDisk.getDiskType()); + assertEquals(DiskDef.DiskBus.IDE, rootDisk.getBusType()); + assertEquals(DiskDef.DiscardType.IGNORE, rootDisk.getDiscard()); + } + + // 2. test Bus: VIRTIO and broken qemu version -> discard unmap + vmToDetails.put(VmDetailConstants.ROOT_DISK_CONTROLLER, DiskDef.DiskBus.VIRTIO.name()); + { + LibvirtVMDef vm = new LibvirtVMDef(); + vm.addComp(new DevicesDef()); + libvirtComputingResourceSpy.createVbd(connect, to, name, vm); + + DiskDef rootDisk = vm.getDevices().getDisks().get(0); + assertEquals(DiskDef.DiskType.BLOCK, rootDisk.getDiskType()); + assertEquals(DiskDef.DiskBus.VIRTIO, rootDisk.getBusType()); + assertEquals(DiskDef.DiscardType.UNMAP, rootDisk.getDiscard()); + } + + // 3. test Bus; IDE and "good" qemu version -> discard unmap + vmToDetails.put(VmDetailConstants.ROOT_DISK_CONTROLLER, DiskDef.DiskBus.IDE.name()); + when(libvirtComputingResourceSpy.getHypervisorQemuVersion()).thenReturn(7000000L); + { + LibvirtVMDef vm = new LibvirtVMDef(); + vm.addComp(new DevicesDef()); + libvirtComputingResourceSpy.createVbd(connect, to, name, vm); + + DiskDef rootDisk = vm.getDevices().getDisks().get(0); + assertEquals(DiskDef.DiskType.BLOCK, rootDisk.getDiskType()); + assertEquals(DiskDef.DiskBus.IDE, rootDisk.getBusType()); + assertEquals(DiskDef.DiscardType.UNMAP, rootDisk.getDiscard()); + } + + // 4. test Bus: VIRTIO and "good" qemu version -> discard unmap + vmToDetails.put(VmDetailConstants.ROOT_DISK_CONTROLLER, DiskDef.DiskBus.VIRTIO.name()); + { + LibvirtVMDef vm = new LibvirtVMDef(); + vm.addComp(new DevicesDef()); + libvirtComputingResourceSpy.createVbd(connect, to, name, vm); + + DiskDef rootDisk = vm.getDevices().getDisks().get(0); + assertEquals(DiskDef.DiskType.BLOCK, rootDisk.getDiskType()); + assertEquals(DiskDef.DiskBus.VIRTIO, rootDisk.getBusType()); + assertEquals(DiskDef.DiscardType.UNMAP, rootDisk.getDiscard()); + } + } } diff --git a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapperTest.java b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapperTest.java index f0e94e59485..9537469145f 100644 --- a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapperTest.java +++ b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapperTest.java @@ -18,7 +18,6 @@ // package com.cloud.hypervisor.kvm.resource.wrapper; -import java.util.Arrays; import java.util.List; import java.util.UUID; @@ -80,7 +79,6 @@ public class LibvirtConvertInstanceCommandWrapperTest { Mockito.when(storagePoolManager.getStoragePoolByURI(secondaryPoolUrl)).thenReturn(temporaryPool); KVMPhysicalDisk physicalDisk1 = Mockito.mock(KVMPhysicalDisk.class); KVMPhysicalDisk physicalDisk2 = Mockito.mock(KVMPhysicalDisk.class); - Mockito.when(temporaryPool.listPhysicalDisks()).thenReturn(Arrays.asList(physicalDisk1, physicalDisk2)); } @Test @@ -107,51 +105,6 @@ public class LibvirtConvertInstanceCommandWrapperTest { Assert.assertNotNull(temporaryStoragePool); } - @Test - public void testGetTemporaryDisksWithPrefixFromTemporaryPool() { - String convertPath = "/xyz"; - String convertPrefix = UUID.randomUUID().toString(); - KVMPhysicalDisk physicalDisk1 = Mockito.mock(KVMPhysicalDisk.class); - Mockito.when(physicalDisk1.getName()).thenReturn("disk1"); - KVMPhysicalDisk physicalDisk2 = Mockito.mock(KVMPhysicalDisk.class); - Mockito.when(physicalDisk2.getName()).thenReturn("disk2"); - - KVMPhysicalDisk convertedDisk1 = Mockito.mock(KVMPhysicalDisk.class); - Mockito.when(convertedDisk1.getName()).thenReturn(String.format("%s-sda", convertPrefix)); - KVMPhysicalDisk convertedDisk2 = Mockito.mock(KVMPhysicalDisk.class); - Mockito.when(convertedDisk2.getName()).thenReturn(String.format("%s-sdb", convertPrefix)); - KVMPhysicalDisk convertedXml = Mockito.mock(KVMPhysicalDisk.class); - Mockito.when(convertedXml.getName()).thenReturn(String.format("%s.xml", convertPrefix)); - Mockito.when(temporaryPool.listPhysicalDisks()).thenReturn(Arrays.asList(physicalDisk1, physicalDisk2, - convertedDisk1, convertedDisk2, convertedXml)); - - List convertedDisks = convertInstanceCommandWrapper.getTemporaryDisksWithPrefixFromTemporaryPool(temporaryPool, convertPath, convertPrefix); - Assert.assertEquals(2, convertedDisks.size()); - } - - @Test - public void testGetTemporaryDisksFromParsedXml() { - String relativePath = UUID.randomUUID().toString(); - String fullPath = String.format("/mnt/xyz/%s", relativePath); - - LibvirtVMDef.DiskDef diskDef = new LibvirtVMDef.DiskDef(); - LibvirtVMDef.DiskDef.DiskBus bus = LibvirtVMDef.DiskDef.DiskBus.VIRTIO; - LibvirtVMDef.DiskDef.DiskFmtType type = LibvirtVMDef.DiskDef.DiskFmtType.QCOW2; - diskDef.defFileBasedDisk(fullPath, "test", bus, type); - - LibvirtDomainXMLParser parser = Mockito.mock(LibvirtDomainXMLParser.class); - Mockito.when(parser.getDisks()).thenReturn(List.of(diskDef)); - - KVMPhysicalDisk convertedDisk1 = Mockito.mock(KVMPhysicalDisk.class); - Mockito.when(convertedDisk1.getName()).thenReturn("disk1"); - Mockito.when(temporaryPool.getPhysicalDisk(relativePath)).thenReturn(convertedDisk1); - - List disks = convertInstanceCommandWrapper.getTemporaryDisksFromParsedXml(temporaryPool, parser, ""); - Mockito.verify(convertInstanceCommandWrapper).sanitizeDisksPath(List.of(diskDef)); - Assert.assertEquals(1, disks.size()); - Assert.assertEquals("disk1", disks.get(0).getName()); - } - @Test public void testSanitizeDisksPath() { String relativePath = UUID.randomUUID().toString(); diff --git a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtImportConvertedInstanceCommandWrapperTest.java b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtImportConvertedInstanceCommandWrapperTest.java new file mode 100644 index 00000000000..343a15b367d --- /dev/null +++ b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtImportConvertedInstanceCommandWrapperTest.java @@ -0,0 +1,245 @@ +// +// 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.kvm.resource.wrapper; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.ImportConvertedInstanceCommand; +import com.cloud.agent.api.to.NfsTO; +import com.cloud.agent.api.to.RemoteInstanceTO; +import com.cloud.hypervisor.Hypervisor; +import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource; +import com.cloud.hypervisor.kvm.resource.LibvirtDomainXMLParser; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef; +import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; +import com.cloud.hypervisor.kvm.storage.KVMStoragePool; +import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; +import com.cloud.storage.Storage; +import com.cloud.utils.Pair; +import com.cloud.utils.script.Script; +import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; +import org.apache.cloudstack.vm.UnmanagedInstanceTO; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +@RunWith(MockitoJUnitRunner.class) +public class LibvirtImportConvertedInstanceCommandWrapperTest { + + @Spy + private LibvirtImportConvertedInstanceCommandWrapper importInstanceCommandWrapper = + Mockito.spy(LibvirtImportConvertedInstanceCommandWrapper.class); + + @Mock + private LibvirtComputingResource libvirtComputingResourceMock; + + @Mock + private KVMStoragePool temporaryPool; + @Mock + private KVMStoragePool destinationPool; + @Mock + private PrimaryDataStoreTO primaryDataStore; + @Mock + private NfsTO secondaryDataStore; + @Mock + private KVMStoragePoolManager storagePoolManager; + + private static final String secondaryPoolUrl = "nfs://192.168.1.1/secondary"; + private static final String vmName = "VmToImport"; + + @Before + public void setUp() { + Mockito.when(secondaryDataStore.getUrl()).thenReturn(secondaryPoolUrl); + Mockito.when(libvirtComputingResourceMock.getStoragePoolMgr()).thenReturn(storagePoolManager); + Mockito.when(storagePoolManager.getStoragePoolByURI(secondaryPoolUrl)).thenReturn(temporaryPool); + KVMPhysicalDisk physicalDisk1 = Mockito.mock(KVMPhysicalDisk.class); + KVMPhysicalDisk physicalDisk2 = Mockito.mock(KVMPhysicalDisk.class); + Mockito.when(temporaryPool.listPhysicalDisks()).thenReturn(Arrays.asList(physicalDisk1, physicalDisk2)); + } + + @Test + public void testGetTemporaryStoragePool() { + KVMStoragePool temporaryStoragePool = importInstanceCommandWrapper.getTemporaryStoragePool(secondaryDataStore, libvirtComputingResourceMock.getStoragePoolMgr()); + Assert.assertNotNull(temporaryStoragePool); + } + + @Test + public void testGetTemporaryDisksWithPrefixFromTemporaryPool() { + String convertPath = "/xyz"; + String convertPrefix = UUID.randomUUID().toString(); + KVMPhysicalDisk physicalDisk1 = Mockito.mock(KVMPhysicalDisk.class); + Mockito.when(physicalDisk1.getName()).thenReturn("disk1"); + KVMPhysicalDisk physicalDisk2 = Mockito.mock(KVMPhysicalDisk.class); + Mockito.when(physicalDisk2.getName()).thenReturn("disk2"); + + KVMPhysicalDisk convertedDisk1 = Mockito.mock(KVMPhysicalDisk.class); + Mockito.when(convertedDisk1.getName()).thenReturn(String.format("%s-sda", convertPrefix)); + KVMPhysicalDisk convertedDisk2 = Mockito.mock(KVMPhysicalDisk.class); + Mockito.when(convertedDisk2.getName()).thenReturn(String.format("%s-sdb", convertPrefix)); + KVMPhysicalDisk convertedXml = Mockito.mock(KVMPhysicalDisk.class); + Mockito.when(convertedXml.getName()).thenReturn(String.format("%s.xml", convertPrefix)); + Mockito.when(temporaryPool.listPhysicalDisks()).thenReturn(Arrays.asList(physicalDisk1, physicalDisk2, + convertedDisk1, convertedDisk2, convertedXml)); + + List convertedDisks = importInstanceCommandWrapper.getTemporaryDisksWithPrefixFromTemporaryPool(temporaryPool, convertPath, convertPrefix); + Assert.assertEquals(2, convertedDisks.size()); + } + + @Test + public void testGetTemporaryDisksFromParsedXml() { + String relativePath = UUID.randomUUID().toString(); + String fullPath = String.format("/mnt/xyz/%s", relativePath); + + LibvirtVMDef.DiskDef diskDef = new LibvirtVMDef.DiskDef(); + LibvirtVMDef.DiskDef.DiskBus bus = LibvirtVMDef.DiskDef.DiskBus.VIRTIO; + LibvirtVMDef.DiskDef.DiskFmtType type = LibvirtVMDef.DiskDef.DiskFmtType.QCOW2; + diskDef.defFileBasedDisk(fullPath, "test", bus, type); + + LibvirtDomainXMLParser parser = Mockito.mock(LibvirtDomainXMLParser.class); + Mockito.when(parser.getDisks()).thenReturn(List.of(diskDef)); + + KVMPhysicalDisk convertedDisk1 = Mockito.mock(KVMPhysicalDisk.class); + Mockito.when(convertedDisk1.getName()).thenReturn("disk1"); + Mockito.when(temporaryPool.getPhysicalDisk(relativePath)).thenReturn(convertedDisk1); + + List disks = importInstanceCommandWrapper.getTemporaryDisksFromParsedXml(temporaryPool, parser, ""); + Mockito.verify(importInstanceCommandWrapper).sanitizeDisksPath(List.of(diskDef)); + Assert.assertEquals(1, disks.size()); + Assert.assertEquals("disk1", disks.get(0).getName()); + } + + @Test + public void testSanitizeDisksPath() { + String relativePath = UUID.randomUUID().toString(); + String fullPath = String.format("/mnt/xyz/%s", relativePath); + LibvirtVMDef.DiskDef diskDef = new LibvirtVMDef.DiskDef(); + LibvirtVMDef.DiskDef.DiskBus bus = LibvirtVMDef.DiskDef.DiskBus.VIRTIO; + LibvirtVMDef.DiskDef.DiskFmtType type = LibvirtVMDef.DiskDef.DiskFmtType.QCOW2; + diskDef.defFileBasedDisk(fullPath, "test", bus, type); + + importInstanceCommandWrapper.sanitizeDisksPath(List.of(diskDef)); + Assert.assertEquals(relativePath, diskDef.getDiskPath()); + } + + @Test + public void testMoveTemporaryDisksToDestination() { + KVMPhysicalDisk sourceDisk = Mockito.mock(KVMPhysicalDisk.class); + Mockito.lenient().when(sourceDisk.getPool()).thenReturn(temporaryPool); + List disks = List.of(sourceDisk); + String destinationPoolUuid = UUID.randomUUID().toString(); + List destinationPools = List.of(destinationPoolUuid); + + KVMPhysicalDisk destDisk = Mockito.mock(KVMPhysicalDisk.class); + Mockito.when(destDisk.getPath()).thenReturn("xyz"); + Mockito.when(storagePoolManager.getStoragePool(Storage.StoragePoolType.NetworkFilesystem, destinationPoolUuid)) + .thenReturn(destinationPool); + Mockito.when(destinationPool.getType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); + Mockito.when(storagePoolManager.copyPhysicalDisk(Mockito.eq(sourceDisk), Mockito.anyString(), Mockito.eq(destinationPool), Mockito.anyInt())) + .thenReturn(destDisk); + + List movedDisks = importInstanceCommandWrapper.moveTemporaryDisksToDestination(disks, destinationPools, storagePoolManager); + Assert.assertEquals(1, movedDisks.size()); + Assert.assertEquals("xyz", movedDisks.get(0).getPath()); + } + + @Test + public void testGetUnmanagedInstanceDisks() { + try (MockedStatic + diff --git a/ui/src/views/iam/EditUser.vue b/ui/src/views/iam/EditUser.vue index e082fd17a06..18f22b6f1e8 100644 --- a/ui/src/views/iam/EditUser.vue +++ b/ui/src/views/iam/EditUser.vue @@ -81,6 +81,16 @@ + + + + Enabled + Inherit + Disabled + +
{{ $t('label.cancel') }} {{ $t('label.ok') }} @@ -128,6 +138,11 @@ export default { this.initForm() this.fetchData() }, + computed: { + isRootAdmin () { + return this.$store.getters.userInfo?.roletype === 'Admin' + } + }, methods: { initForm () { this.formRef = ref() @@ -187,7 +202,8 @@ export default { username: values.username, email: values.email, firstname: values.firstname, - lastname: values.lastname + lastname: values.lastname, + apikeyaccess: values.apikeyaccess } if (this.isValidValueForKey(values, 'timezone') && values.timezone.length > 0) { params.timezone = values.timezone diff --git a/ui/src/views/image/UpdateTemplateIsoPermissions.vue b/ui/src/views/image/UpdateTemplateIsoPermissions.vue index c7b0f9e5cf1..557574156b1 100644 --- a/ui/src/views/image/UpdateTemplateIsoPermissions.vue +++ b/ui/src/views/image/UpdateTemplateIsoPermissions.vue @@ -25,7 +25,7 @@

{{ $t('label.operation') }}

- {{ $t('label.add') }} - {{ $t('label.remove') }} - {{ $t('label.reset') }} + {{ $t('label.add') }} + {{ $t('label.remove') }} + {{ $t('label.reset') }}
-